var popupLinkConfig = new Array;

// popupLinkConfig["classname"] = new Array ( "targetname", "width=550,height=350,scrollbars=yes,resizable=yes,status=yes,toolbar=yes,location=yes,menubar=yes");
popupLinkConfig["helppage"]    = new Array ( "helppage", "width=370,height=425,scrollbars=yes,resizable=yes,status=no,toolbar=no,location=no,menubar=no");
popupLinkConfig["uploadimage"]    = new Array ( "uploadimage", "width=400,height=600,scrollbars=yes,resizable=no,status=no,toolbar=no,location=no,menubar=no");
popupLinkConfig["viewimage"]    = new Array ( "viewimage", "width=200,height=200,scrollbars=no,resizable=no,status=no,toolbar=no,location=no,menubar=no");
popupLinkConfig["basket"] = new Array ( "basket", "width=500,height=500,scrollbars=no,resizable=no,status=no,toolbar=no,location=no,menubar=no");
popupLinkConfig["definitions"] = new Array ( "definitions", "width=425,height=475,scrollbars=yes,resizable=no,status=no,toolbar=no,location=no,menubar=no");

// ==========================================================================
window.onload = initPage;  
// Note: Make sure that no other javscripts assign a fuction to window.onload
// There can be only one function tied to window.onload at a time.

function initPage() {
  initPopupLinks();
  // place here any other code you wish to run when the page loads.
}

function initPopupLinks()
{
  if (!document.getElementsByTagName) return true;
  var pageLinks = document.getElementsByTagName("a");
  for (var i = 0; i < pageLinks.length; i++) 
  {
    if (((pageLinks[i].className != null) && 
         (pageLinks[i].className != "")) ||
        ((pageLinks[i].parentNode.className != null) && 
         (pageLinks[i].parentNode.className != "")))
    {
      var linkClass = " " + pageLinks[i].className + " ";
      if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
      {
        linkClass = " " + pageLinks[i].parentNode.className + " ";
      }
      for (var theKey in popupLinkConfig) 
      {
        if (linkClass.indexOf(" " + theKey + " ") > -1)
        {
          if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
          {
            pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
          }
          pageLinks[i].settings = popupLinkConfig[theKey][1];
          pageLinks[i].onclick = popUp;
        }
      }
    }
  }
  return true;
}

function popUp()
{
  newWin = window.open(this.href, this.target, this.settings);
  newWin.focus();
  return false;
}
/*************************************/
/* NEW FUNCTIONALITY

/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: JTricks.com :: http://www.jtricks.com/ */

function move_box(an, box) {
	/*var cleft = 0;
	var ctop = 0;
	var obj = an;
	while (obj.offsetParent) {
		cleft += obj.offsetLeft;
		ctop += obj.offsetTop;
		obj = obj.offsetParent;
	}
		box.style.left = cleft + 'px';
		ctop += an.offsetHeight + 8;
	if (document.body.currentStyle &&
		document.body.currentStyle['marginTop']) {
		ctop += parseInt(
		document.body.currentStyle['marginTop']);
	}

	box.style.top = ctop + 'px';*/
	
	box.style.left = '190px';
	box.style.top = '250px';
	}

function show_hide_box(an, photo_id) {

	try{
		
	var href = an.href
	href = href.replace('.asp', '2.asp');
	//'more-information2.asp'//an.href;
	var innerdiv;
	var boxid = 'info_'+photo_id; // id for main div
	var innerid = 'inner_'+photo_id; // id for inner div
	var boxdiv = document.getElementById(boxid);
	var width = 430;
	var height = 500;
	var borderStyle = '#7E1F16 4px ridge';
	
	var closeurl = '<a style="text-align: right;" href="#"  title="close the information window" onclick="closeDiv(\''+boxid+'\'); return false;"><img src="/images/close-info.gif" alt="close the information window" height="13" width="170" border="0" hspace="3" /></a>';
	
	// check if already exists - if so, hide
	if (boxdiv != null) {
	if (boxdiv.style.display=='none') {
		move_box(an, boxdiv);
		boxdiv.style.display='block';
	} else
		closeDiv(boxdiv.id)
		return false; // no need to do anything else
	}
	
	// create main div
	boxdiv = document.createElement('div');
	boxdiv.setAttribute('id', boxid);
	boxdiv.setAttribute('class', 'infobox');
	boxdiv.style.display = 'block';
	boxdiv.style.position = 'absolute';
	boxdiv.style.overflow = 'hidden'; 
	boxdiv.style.zIndex = 100; 
	boxdiv.style.width = width + 'px';
	boxdiv.style.height = height + 'px';
	boxdiv.style.border = borderStyle;
	boxdiv.style.backgroundColor = '#eee';
	
	boxdiv.style.backgroundImage = 'url(/images/loading-message.gif)';
	boxdiv.style.backgroundAttachment = 'fixed';
	boxdiv.style.backgroundPosition = 'left center';
	boxdiv.style.backgroundRepeat = 'no-repeat';
	
	// create inner div (contains iframe)
	innerdiv = document.createElement('div');
	innerdiv.setAttribute('id', innerid);
	innerdiv.style.display = 'block';
	innerdiv.style.float = 'clear'; 
	innerdiv.style.position = 'absolute';
	innerdiv.style.overflow = 'auto'; 
	innerdiv.style.width = (width - 3) + 'px';
	innerdiv.style.height = (height - 15) + 'px';
	
	// create the close link - closes the main div
	var closelink = document.createElement('span');
	closelink.style.display = 'block';
	closelink.style.width = '100%';
	closelink.style.textAlign = 'right';
	closelink.innerHTML = closeurl;
	
	// create the iframe content	
	var contents = document.createElement('iframe');
	contents.scrolling = 'no';
	contents.frameBorder = '0';
	contents.style.width = (width - 20) + 'px';
	contents.style.height = (height + 130) + 'px';
	contents.src = href;

	// append objects to main div
	boxdiv.appendChild(closelink);
	boxdiv.appendChild(innerdiv);
	innerdiv.appendChild(contents);

	// append main div to page
	document.body.appendChild(boxdiv);
	// position main div
	move_box(an, boxdiv);


	} catch(e) {
		
	}

	// prevent #link being followed
	return false;
}

// from: http://www.harrymaugans.com/2007/03/05/how-to-create-a-collapsible-div-with-javascript-and-css/
function closeDiv(divid){

	try {
	//alert(document.getElementById(divid).id);
	if(document.getElementById(divid).style.display == 'none'){
		document.getElementById(divid).style.display = 'block';
	}else{
		document.getElementById(divid).style.display = 'none';
		// added: remove object from dom: http://www.javascriptkit.com/domref/elementmethods.shtml
		document.body.removeChild(document.getElementById(divid));

	}
	
	} catch(e) {}
}
