// JavaScript Document

// This script pops product images up in a sized to fit window.
function PopWindow(url,name,scroll,width,height,top,left,resizable,toolbar,location)
{
	settings="directories=no,status=no,menubar=no,scrollbars="+scroll+",resizable="+resizable+",width="+width+",height="+height+",top="+top+",left="+left+",toolbar="+toolbar+",location="+location;
	MyNewWindow=window.open(url,name,settings);
}

// This script pops up all external links in a new window.
function popLinks(){
  var serverone = document.location.hostname;
  // Enter an additional domain that you DON'T want in new windows here 
  var servertwo = "percival-scientific.com";
  
  if (!document.getElementsByTagName) return null;
  var anchors = document.getElementsByTagName("a");
  for(var i=0; i < anchors.length; i++){
    var a = anchors[i];
    var href = a.href;
    if ((href.indexOf("http") != -1) && (href.indexOf(serverone) == -1) && (href.indexOf(servertwo) == -1)) { 
	  a.setAttribute("title","This link will open in a new window.");  
	  
	  // Change the width/height of the popup window below, if you wish
	  a.onclick = function() { popWin = window.open(this.getAttribute('href'), "popUp", "toolbar,location,resizable,scrollbars,width=500,height=400"); return false; }
    }
  }
}


// This script pops up all .pdf files and any href with class="new_win" in a new window.
function newWin(){
  var serverone = document.location.hostname;
  // Enter an additional domain that you DON'T want in new windows here 
  var servertwo = "percival-scientific.com";
  
  if (!document.getElementsByTagName) return null;
  var anchors = document.getElementsByTagName("a");
  for(var i=0; i < anchors.length; i++){
    var a = anchors[i];
    var href = a.href;
	var thisClass = a.className;
    if ((thisClass.indexOf("new_win") != -1) || (href.indexOf(".pdf") != -1) && (href.indexOf(servertwo) == -1))  { 
	  a.setAttribute("title","This link will open in a new window.");  
	  
	  // Change the width/height of the popup window below, if you wish
	  a.onclick = function() { popWin = window.open(this.getAttribute('href'), "popUp", "toolbar,location,resizable,scrollbars,width=500,height=400"); return false; }
    }
  }
  var areas = document.getElementsByTagName("area");
  for(var i=0; i < areas.length; i++){
    var a = areas[i];
    var href = a.href;
	var thisClass = a.className;
    if ((thisClass.indexOf("new_win") != -1) || (href.indexOf(".pdf") != -1))  { 
	  a.setAttribute("title","This link will open in a new window.");  
	  
	  // Change the width/height of the popup window below, if you wish
	  a.onclick = function() { popWin = window.open(this.getAttribute('href'), "popUp", "toolbar,location,resizable,scrollbars,width=500,height=400"); return false; }
    }
  }

}


// Function to allow multiple onload functions to be called
function multipleOnload()
{
// Add multiple Onload functions to the list below
popLinks();
newWin();
}
window.onload = multipleOnload;
// end function