window.onload = initialize;

function initialize(){
	prepareLinks();
	externalLinks();
	
}


function toggleLayer(whichLayer){
	
	if (document.getElementById){
	// this is the way the standards work
		
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all){
	// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers){
	// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}


function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function popUp(winURL) {
  window.open(winURL,'pop','width=310,height=450');
}

function popCredit(winURL){
	  window.open(winURL,'pop','width=380,height=360');
}


function printDoc(){
	var links = document.getElementsByTagName("a");
	for(var i=0; i<links.length; i++){
		if(links[i].className == "print"){
			 links[i].onclick = function() {
			 	window.print();
        		 return false;
    	  }
		}
	}
}


function prepareLinks() {
if (!document.getElementsByTagName) return false;
  var links = document.getElementsByTagName("a");
    for (var i=0; i<links.length; i++) {
	//if ((links[i].getAttribute("className") == "popup") || (links[i].getAttribute("class") == "popup")) {
    if (links[i].className == "popup") {
      links[i].onclick = function() {
        popUp(this.href);
        return false;
      }
    }
	else if(links[i].className =="credit"){
		links[i].onclick = function() {
			 popCredit(this.href);
       			 return false;
		}
	}
	else if(links[i].className == "back"){
			links[i].onclick = function(){
				history.back(0);
				return false;	
			}
	}//end of back
	else if(links[i].className == "int"){
			links[i].onclick = function(){
				var targetUrl = this.href;
				window.open(targetUrl,'popup','width=800,height=600,resizable=1,scrollbars=1,toolbar=0');
				return false;	
			}
		}//end of internal
  }
}

function toggleBio(){
if (!document.getElementsByTagName) return false;
var list = document.getElementById("staffList");
var links = list.getElementsByTagName("a");
	for(var i=0; i<links.length; i++){
		links[i].onclick = function(){
			var divName = this.href;
			for(j=0; j<divName.length; j++){
				var pound = divName.charAt(j);
				if(pound == "#"){
					divName = divName.slice(j+1,divName.length);
				}
			}
			toggleLayer(divName);
			return false;
		}
	}
}

function PopulateAddress() {
	document.getElementById('Template_Content_ShipToAddress1').value =  document.getElementById('Template_Content_BillToAddress1').value;
	document.getElementById('Template_Content_ShipToAddress2').value =  document.getElementById('Template_Content_BillToAddress2').value;
	document.getElementById('Template_Content_ShipToCity').value =  document.getElementById('Template_Content_BillToCity').value;
	document.getElementById('Template_Content_ShipToState').selectedIndex =  document.getElementById('Template_Content_BillToState').selectedIndex;
	document.getElementById('Template_Content_ShipToPostalCode').value =  document.getElementById('Template_Content_BillToPostalCode').value;
	document.getElementById('Template_Content_ShipToCountry').selectedIndex =  document.getElementById('Template_Content_BillToCountry').selectedIndex;
}



  
