/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_ovr'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_ovr'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

function startList() 
{
	navRoot = document.getElementById("nav");
	for( i=0; i < navRoot.childNodes.length; ++i ) 
	{
		node = navRoot.childNodes[i];
		if( node.nodeName == "LI" ) 
		{
			node.onmouseover = function() 
			{
				this.className += "over";
 		 	}
  			node.onmouseout = function() 
  			{
  				this.className = this.className.replace( "over", "" );
   			}
   		}
  	}
}

//DZ
function ImageEnlarge(filename, uniquename, htmltitle, height, width)
{
	if(screen.height > height)
	{
		fromtop = (screen.height - height) / 2;
		aheight = height;
		scrolls = "no";
	}
	else
	{
		fromtop = 0;
		aheight = screen.height-80;
		scrolls = "yes";
	}
	if(screen.width > width)
	{
		fromleft = (screen.width-width)/2;
		if(scrolls != "yes"){
		awidth = width;}
		else{
		awidth = (width * 1)+18;}
	}
	else
	{
		fromleft = 0;
		awidth = screen.width;
		scrolls = "yes";
	}
	message = "left="+fromleft+",top="+fromtop+",width="+awidth+",height="+aheight+",resizable=yes,scrollbars="+scrolls;
    window.open("enlarge.php?show="+filename+"&title="+htmltitle,uniquename,message);
}

function sameAsBilling()
{
	if( document.checkoutform.samebilling.checked )
	{ 
	  	disabled = true; 
		document.checkoutform.shipname.value = '';
		document.checkoutform.shipaddress.value = '';
		document.checkoutform.shipcity.value = '';
		document.checkoutform.shipstate.value = '';			
		document.checkoutform.shipzip.value = '';
		document.checkoutform.shipphone.value = '';
	}
	else{ disabled = false; }	

	document.checkoutform.shipname.disabled = disabled;
	document.checkoutform.shipaddress.disabled = disabled;
	document.checkoutform.shipcity.disabled = disabled;	
	document.checkoutform.shipstate.disabled = disabled;			
	document.checkoutform.shipzip.disabled = disabled;
	document.checkoutform.shipphone.disabled = disabled;
}

function ValidateInput()
{
	    		 	
	if( document.checkoutform.firstname.value.length < 2 ||	
		document.checkoutform.lastname.value.length < 2 ||		
		document.checkoutform.address.value.length < 3 ||
		document.checkoutform.city.value.length < 2 ||			
		document.checkoutform.state.value.length != 2 ||			
		document.checkoutform.zip.value.length != 5
	){
		alert('Please, fill out all required CREDIT CARD BILLING INFORMATION fields in order to proceed with the checkout. Thank you.');
		return;
	}

	if( ! checkMail( document.checkoutform.email.value ) )
	{
	  	alert('Please enter a valid email address. Thank you.'); return;
	}	
	
 	if( ! document.checkoutform.samebilling.checked )
	{
 	 	 if( document.checkoutform.shipname.value.length < 3 ||		
		 	 document.checkoutform.shipaddress.value.length < 3 ||
			 document.checkoutform.shipcity.value.length < 2 ||		
			 document.checkoutform.shipstate.value.length != 2 ||				
			 document.checkoutform.shipzip.value.length != 5
	 	){
			alert('Please, fill out all required SHIPPING INFORMATION fields in order to proceed with the checkout. Thank you.');
			return;
		}
	}

  	if(	document.checkoutform.cc.value.length != 16 ){ alert('Credit Card number must be 16 digits long. Thank you.'); return; }
   	if(	document.checkoutform.ccexp.value.length != 4 ){ alert('Credit Card expiration date must be 4 digits long. Thank you.'); return; }
  	if(	document.checkoutform.ccvc.value.length != 3 ){ alert('Credit Card CCVC number must be 3 digits long. Thank you.'); return; }
  	
  	if( document.checkoutform.cc.value.charAt(0) != 4 && document.checkoutform.cc.value.charAt(0) != 5 ){ alert('Only VISA and MasterCard cards are accepted. Thank you.'); return; }
	
	//terms & conditions
	if(	! document.checkoutform.termsbox.checked  )
	{
			alert('Please, acknowledge that you have read, understood, and accept the terms and conditions. Thank you.');
			return;
	}
		
	document.checkoutform.submit();
}

function checkMail( email )
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email)) return true;
	else return false;
}


function CERT_DETAILS_FUNCTION()
{

var IE4 = navigator.userAgent.toLowerCase().indexOf("msie 4.");
var withChars = window.location.href;
var charIndex = withChars.indexOf("?");

var HSDSDYWERYUS;

if(charIndex != -1 ){
    HSDSDYWERYUS = withChars.substring(0, charIndex);
}else{
    HSDSDYWERYUS = withChars
}

var KJSDHKJSHDKDFJHF = 'https://seal.godaddy.com/verifySeal?sealID=124632432101360912812711d4c84747117f5100581685220898037338';
var JGMT_OFFSET = (new Date()).getTimezoneOffset();
var newwindow = '';

    if (!newwindow.closed && newwindow.location){
            newwindow.location.href = KJSDHKJSHDKDFJHF;
        } else {
            newwindow=window.open(KJSDHKJSHDKDFJHF,'QWIWQUUWOIUOIU','height=450,width=550,scrollbars=yes,status=1');
            if (!newwindow.opener) newwindow.opener = self;
        }

    if (window.focus){
        if(IE4 == -1){
            newwindow.focus()
        }
    }
    return false;
}

var imageon0, imageon1, imageon2, x, z;
function load_rotation()
{ 
imageon0 = new Image(); 
imageon0.src = "/images/prehome_bkgd.jpg";

imageon1 = new Image(); 
imageon1.src = "/images/prehome_discount.jpg";

imageon2 = new Image();
imageon2.src = "/images/prehome_discount_40_OFF.jpg";

	x = 1;
	z = 0;
	setTimeout('rotate()', 2000);
}

function rotate()
{   
    document.getElementById('pages').className = 'homepage' + x;
    setTimeout( 'rotate()', z == 0 ? (4000 + x * 1000) : 8000 );
    if( ++x == 3 ){ x = 0; ++z; }
}