/* This is our current popup function - parts of the site still use it, so I need to keep it */

function acpopup(strURL,strType,strWidth,strHeight) {
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
window.open(strURL, '', strOptions);
}

function newpicwindow(imageSrc,pageTitle)//,styleSheet) 
{
	WinTop = 0;  
	WinLeft = 0;
	winFeatures = 'toolbar=0,location=0,directories=0,status=0';
	winFeatures += ',menubar=0,scrollbars=0,resizable=0';
	winFeatures += ',screenX='+WinLeft+',screenY='+WinTop;
	winFeatures += ',left='+WinLeft+',top='+WinTop;
	winFeatures += ',height=320,width=270';
	PopUpWindow=window.open('','PopUpWindow',winFeatures);
	PopUpWindow.document.writeln('<html>');
	PopUpWindow.document.writeln('<head>');
//original line, just in case	PopUpWindow.document.writeln('<title>Product Image</title>');
	PopUpWindow.document.writeln('<title>'+pageTitle+'</title>');
	//PopUpWindow.document.writeln('<link rel="stylesheet" type="text/css" href="'+styleSheet+'" />');
	PopUpWindow.document.writeln('<style type="text/css">body{margin: 10px; text-align: center; font: normal 80% arial,sans-serif;} img{border: 1px solid #000000;}</style>');
	PopUpWindow.document.writeln('</head>');
	if (navigator.appName == "Microsoft Internet Explorer")
		PopUpWindow.document.writeln('<body onload="window.resizeTo(document.images[0].width+35,document.images[0].height+125)">');
	else
		PopUpWindow.document.writeln('<body onload="window.resizeTo(document.images[0].width+30,document.images[0].height+115)">');
	PopUpWindow.document.writeln('<img src="'+imageSrc+'" alt="'+pageTitle+'" />');
	PopUpWindow.document.writeln('<br/>'+pageTitle);
	//PopUpWindow.document.writeln('<br/><form id="form1" name="form1" style="text-align: center;"><input type="button" onclick="self.close();" value="Close Window" id="button1" name="button1"/></form>');
	PopUpWindow.document.writeln('</body>');
	PopUpWindow.document.writeln('</html>');
	PopUpWindow.document.close();
	PopUpWindow.focus();
}

/* new accessible, unobtrusive popup code */

function windowLinks() {                      // create a new function called windowLink(); 
    if(!document.getElementsByTagName) {      // Only run the function on browsers that
         return;                              // understand 'getElementsByTagName' - new browsers
    }
	
    var anchors = document.getElementsByTagName("a"); // grab all links and pop them in an array called 'anchors'
    for (var i = 0; i < anchors.length; i++) {        // start a loop to work our way through 
         var anchor = anchors[i];                     // grab the next link & copy it to 'anchor' for working
         var relIndex = anchor.rel;                   // get the value of it's 'REL' attribute
		 if (relIndex){                               // does it have a value for REL?...
		 var relSplit = relIndex.split("|");          
		 /* if it does, look for '|' to use to split the value into an 
		 array - relSplit[0], relSplit[1], relSplit[2], etc . If it doesn't 
		 find any '|', the whole value gets transferred to relSplit[0] */

		 var imgs = anchor.getElementsByTagName("img");
		 if(imgs.length > 0)
			{hasImage = true;}
		else
			{hasImage = false;}
		 
/* XHTML compliant target attribute */

		 if (relSplit[0] == "external") {       // If the relSplit[0] is 'external'...
            anchor.target = "_blank";           // then set it's 'target' attribute to '_blank'
			if (!hasImage)
			{anchor.className = "external";      // then attach a CSS class to it 
			}
			anchor.title = "Load in new window: "+ anchor.href;  
			// And give it a new title attribute to warn users a new window is launching
			
/* Elegantly degrading window code */

   			} else if (relSplit[0] == "popup") {      // else if relSplit[0] is 'popup'...
			if (!hasImage)
			{anchor.className = "popup";               // attach a CSS class to it 
			}
			anchor.title = "Loads in a Popup Window"; // Give it a helpful title attribute
			anchor.popupWidth = relSplit[1];          // set the popup's width
			anchor.popupHeight = relSplit[2];          // set the popup's height
	        anchor.onclick = function() {acpopup(this.href,'console',this.popupWidth,this.popupHeight);return false;};
			// plug all this information into our origainl window launch function (acpopup) 
			}
			else if(relSplit[0] == "picwin")
			//{anchor.onclick=function(){newpicwindow(this.href,this.title,'../css/nsl.css');return false;};}
			{anchor.onclick=function(){newpicwindow(this.href,this.title);return false;};}
		}
	  }
}

addLoadEvent(function() {
	windowLinks();	// run our new function as soon as the page loads. 
	//otherFunctions();
	//goHere();
});