
var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;

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 launchvideo() {
	 	window.open('../news/launchvideo.cfm','helix13','scrollbars=no,resizable=yes,width=320,height=320');
	}
function specials(hb)
{        
         window.open('http://helix13.com/'+hb+'/specials.php','Helix_Specials','height=300,width=400,toolbar=no,titlebar=no,menubar=no,menu=no,resizable=yes,scrollbars=auto,resize=yes');
}
function launchvideo2() {
	 	window.open('../news/launchvideo2.cfm','helix13','scrollbars=no,resizable=yes,width=320,height=320');
	}
    
function launchimage(url, w, h) {
	window.open(url,'','status=no,menubar=no,scrollbars=no,resizable=yes,width='+w+',height='+h+'');
    return false;
}
    
function copyinfo()
    {
         document.checkoutform.billfname.value = document.checkoutform.shipfname.value;
         document.checkoutform.billlname.value = document.checkoutform.shiplname.value;
         document.checkoutform.billcompany.value = document.checkoutform.shipcompany.value;
         document.checkoutform.billaddress1.value = document.checkoutform.shipaddress1.value;
         document.checkoutform.billaddress2.value = document.checkoutform.shipaddress2.value;
         document.checkoutform.billaddress3.value = document.checkoutform.shipaddress3.value;
         document.checkoutform.billcity.value = document.checkoutform.shipcity.value;
         document.checkoutform.billstate.value = document.checkoutform.shipstate.value;
         document.checkoutform.billcountry.value = document.checkoutform.shipcountry.value;
         document.checkoutform.billzip.value = document.checkoutform.shipzip.value;
         document.checkoutform.billphone.value = document.checkoutform.shipphone.value;
         document.checkoutform.billemail.value = document.checkoutform.shipemail.value;
         return false;
    }
    
function checkNotNull(thisform, fname)
{
    var ret = true;

    if("" == thisform.value)
    {
        alert("Please enter a value for " + fname);
        ret = false;
    }
    return ret;
}

function checkNumeric(thisval, fname)
{
    var ret = true;

    if(isNaN(thisval))
    {
        alert("Please enter a numeric value for " + fname);
        ret = false;
    }
    return ret;
}
 

function verifyFields()
{
    var ret=false;

    if(
        checkNotNull(document.checkoutform.shipfname, 'Shipping First Name') &&
        checkNotNull(document.checkoutform.shiplname, 'Shipping Last Name') &&
        checkNotNull(document.checkoutform.shipaddress1, 'Shipping Address') &&
        checkNotNull(document.checkoutform.shipcity, 'Shipping City') &&
        checkNotNull(document.checkoutform.shipstate, 'Shipping State or Province') &&
        checkNotNull(document.checkoutform.shipzip, 'Shipping Zip') &&
        
        checkNotNull(document.checkoutform.billfname, ' Billing First Name') &&
        checkNotNull(document.checkoutform.billlname, 'Billing Last Name') &&
        checkNotNull(document.checkoutform.billaddress1, 'Billing Address') &&
        checkNotNull(document.checkoutform.billcity, 'Billing City') &&
        checkNotNull(document.checkoutform.billstate, 'Billing State or Province') &&
        checkNotNull(document.checkoutform.billzip, 'Billing Zip') &&
        checkNotNull(document.checkoutform.billphone, 'Billing Phone Number') &&
        checkNotNull(document.checkoutform.billemail, 'Billing Email') &&
        
        checkNotNull(document.checkoutform.ccnum, 'Credit Card Number') &&
        checkNumeric(document.checkoutform.ccnum.value, 'Credit Card Number') &&
        checkNotNull(document.checkoutform.cccvv2, 'CVV2 Security Code') &&
        checkNumeric(document.checkoutform.cccvv2.value, 'CVV2 Security Code') &&
        checkNotNull(document.checkoutform.ccexpmo, 'Credit Card Expiration Month') &&
        checkNumeric(document.checkoutform.ccexpmo.value, 'Credit Card Expiration Month') &&
        checkNotNull(document.checkoutform.ccexpyr, 'Credit Card Expiration Year') &&
        checkNumeric(document.checkoutform.ccexpyr.value, 'Credit Card Expiration Year') &&
        checkCCType(document.checkoutform.cctype) 
       )
    {
        ret = true;
    }
    return ret;
}

function verifyCheckoutFields()
{
    var ret=false;

    if(
        
        checkNotNull(document.checkoutform.billfname, ' Billing First Name') &&
        checkNotNull(document.checkoutform.billlname, 'Billing Last Name') &&
        checkNotNull(document.checkoutform.billaddress1, 'Billing Address') &&
        checkNotNull(document.checkoutform.billcity, 'Billing City') &&
        checkNotNull(document.checkoutform.billstate, 'Billing State or Province') &&
        checkNotNull(document.checkoutform.billzip, 'Billing Zip') &&
        checkNotNull(document.checkoutform.billphone, 'Billing Phone Number') &&
        checkNotNull(document.checkoutform.billemail, 'Billing Email') &&
        
        checkNotNull(document.checkoutform.ccnum, 'Credit Card Number') &&
        checkNumeric(document.checkoutform.ccnum.value, 'Credit Card Number') &&
        checkNotNull(document.checkoutform.cccvv2, 'CVV2 Security Code') &&
        checkNumeric(document.checkoutform.cccvv2.value, 'CVV2 Security Code') &&
        checkNotNull(document.checkoutform.ccexpmo, 'Credit Card Expiration Month') &&
        checkNumeric(document.checkoutform.ccexpmo.value, 'Credit Card Expiration Month') &&
        checkNotNull(document.checkoutform.ccexpyr, 'Credit Card Expiration Year') &&
        checkNumeric(document.checkoutform.ccexpyr.value, 'Credit Card Expiration Year') &&
        checkCCType(document.checkoutform.cctype) 
       )
    {
        ret = true;
    }
    return ret;
}

function verifydsFields()
{
    var ret=false;
	if(document.checkoutform.dropship.checked==true)
    {
    	if( 
        	checkNotNull(document.checkoutform.dsname, 'Shipping Name') &&
	        checkNotNull(document.checkoutform.dsaddress1, 'Shipping Address') &&
    	    checkNotNull(document.checkoutform.dscity, 'Shipping City') &&
        	checkNotNull(document.checkoutform.dsstate, 'Shipping State or Province') &&
	        checkNotNull(document.checkoutform.dszip, 'Shipping Zip') &&
    	    checkNotNull(document.checkoutform.dsphone, 'Shipping Phone') &&
        	checkNotNull(document.checkoutform.dsemail, 'Shipping Email')
	       )
	    {
    	    ret = true;
	    }
    }
    else
    {
    	ret=true;
    }
    return ret;
}


function verifytap()
{
    var ret=false;

    if(document.finalize.tapagree.checked==0)
    {
    	alert("Please read and agree to our Terms and Policies");
        ret=false;
    }
    else
    {
        ret = true;
    }
    return ret;
}

function checkShipToZip()
{
 var ret=false;
 if( checkNotNull(document.calcshipform.shipzip, 'Ship To Zip') && checkNumeric(document.calcshipform.shipzip.value, 'Ship To Zip'))
 {
  ret = true;
 }
 return ret;
}

function checkShipToZipAndState()
{
 var ret=false;
 if( checkNotNull(document.calcshipform.shipzip, 'Ship To Zip') && checkNotNull(document.calcshipform.shipstate, 'Ship To State') && checkNumeric(document.calcshipform.shipzip.value, 'Ship To Zip'))
 {
  ret = true;
 }
 return ret;
}

function checkCCType(val)
{
  var ret=true;
  if( "0"==val.value )
  {
      alert("Please choose your Credit Card Type.");
      ret = false;
  } 
  return ret;
}

function upTax()
{
  document.checkoutform.salestax.value="0.00";
  if ("1"==document.checkoutform.pares.value)
     document.checkoutform.salestax.value= kekFormat(parseFloat(document.checkoutform.subtotal.value)*.07,2);
  
  document.checkoutform.total.value=kekFormat(parseFloat(document.checkoutform.subtotal.value) + parseFloat(document.checkoutform.salestax.value), 2);
  
  return false;

}


function kekFormat(total,decimals)
{
   if ( decimals==undefined )
      decimals = 2;

   decimals *= 1;

   var suffix = ""
   for ( var i=0; i<decimals; i++ )
      suffix += "0";

   var num = "" + parseFloat(total);
   if ( num == "NaN" )
      return num = "0" + ((decimals>0) ? "."+suffix : "");

   if ( num.indexOf(".") == -1 )
      return num += (decimals>0) ? "."+suffix : "";

   num += suffix;
   var tp = num.indexOf(".")+decimals;
   var rnd = Math.round(num.substring(tp,tp+1)+"."+num.substring(tp+1));

   return num.substring(0,tp)+rnd;
}

function mail(domain,user) {
	locationstring = 'mailto:' + user + '@' + domain;
	window.location = locationstring;
	}
    
var prodbuttoncolor;

function hmouseover(myid, overcolor){
	prodbuttoncolor = document.getElementById(myid).style.backgroundColor;
    document.getElementById(myid).style.backgroundColor=overcolor;
	
}

function hmouseout(myid){	
	document.getElementById(myid).style.backgroundColor=prodbuttoncolor;
    
}

function setCookie(c_name,value,expiredays)
{var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}



