// JavaScript Document
//open links in a new window validly
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";
 }
}
window.onload = externalLinks;
//image preloaders
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function copyAddress() {
	var mailingAddress = document.getElementById('p_address');
	var mailingCity = document.getElementById('p_city');
	var mailingState = document.getElementById('p_state');
	var mailingZip = document.getElementById('p_zip');
    var billingAddress = document.getElementById('p_billing_address');
	var billingCity = document.getElementById('p_billing_city');
	var billingState = document.getElementById('p_billing_state');
	var billingZip = document.getElementById('p_billing_zip');
	
	var billingSame = document.getElementById('p_billing_same');
	
	if (billingSame.checked == true) {
	  billingAddress.value = mailingAddress.value;	
	  billingCity.value = mailingCity.value;
	  billingZip.value = mailingZip.value;
	  billingState.value = mailingState.value;
	}  else {
	  billingAddress.value = "";	
	  billingCity.value = "";
	  billingState.value = "1";
	  billingZip.value = "";	  
	}
}
function showSub() {
  var chkSubscribe = document.getElementById('p_subscribe');
  var subOtherLbl = document.getElementById('sub_other_lbl');
  var txtSubOthers = document.getElementById('p_sub_others');
  var subOtherLbl2 = document.getElementById('sub_other_lbl2');
  
  if (chkSubscribe.checked == true){
	  subOtherLbl.style.display = "inline";
	  txtSubOthers.style.display = "inline";
	  subOtherLbl2.style.display = "inline";	  
  } else {
	  subOtherLbl.style.display = "none";
	  txtSubOthers.style.display = "none";
	  subOtherLbl2.style.display = "none";	  
	  txtSubOthers.value = "";
  }
}
function copyApp(whichID) {
  var appName = document.getElementById('p_applicant_name').value;
  var appEmail = document.getElementById('p_applicant_email').value;
  
  switch(whichID) {
	case 'p_principal_applicant':
	  document.getElementById('p_principal_owner').value = appName;
	  document.getElementById('p_principal_email').value = appEmail;
	break;
	
	case 'p_sales_applicant':
	  document.getElementById('p_sales_contact').value = appName;
	  document.getElementById('p_sales_email').value = appEmail;	
	break;
	
	case 'p_purchasing_applicant':
	  document.getElementById('p_purchasing_agent').value = appName;
	  document.getElementById('p_purchasing_email').value = appEmail;
	break;
	
	case 'p_accts_applicant':
	  document.getElementById('p_accounts_payable').value = appName;
	  document.getElementById('p_accounts_email').value = appEmail;
	break;
	
	case 'p_mktg_applicant':
	  document.getElementById('p_mktg_contact').value = appName;
	  document.getElementById('p_mktg_email').value = appEmail;
	break;	
  }
}
function openFlashZC(prodID){
  var disclaimer = confirm("DISCLAIMER: \n\nCalculations are provided using industry recognized software and are provided for estimation purposes only. Input data for data.  However, actual lighting levels will vary depending on field conditions such as room characteristics, temperature, the calculations corresponds to the information provided to Orion.  Assumptions may be made for information that is not provided.  It is the responsibility of those using this service to verify that our input data is consistent with actual field conditions.  Results of the lighting calculations accurately reflect the input voltage and lamp/ballast output and other factors.  Calculations are subject to limitations of the software. Due to the above considerations, Orion will not guarantee that actual light levels measured in the field will match the initial calculations.\n\n No objects considered in calculations unless otherwise noted on the print.\n\nBy clicking OK you are agreeing to the terms herein.  If you do not agree, click cancel.");
  
  if (disclaimer) {
	var popurl = "photometrics.php?id="+prodID+"";
	winpops=window.open(popurl,"Photometrics","width=650,height=500,status=no,resizable=yes,menubar=no,toobar=no,location=no,directories=no");
 } 
}