////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

/* 
 * More info at: http://kevin.vanzonneveld.net/techblog/article/phpjs_licensing/
 * 
 * This is version: 1.46
 * php.js is copyright 2008 Kevin van Zonneveld.

 */ 


// {{{ substr
function substr( f_string, f_start, f_length ) {
    // Return part of a string
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_substr/
    // +       version: 809.522
    // +     original by: Martijn Wieringa
    // +     bugfixed by: T.Wild
    // *       example 1: substr('abcdef', 0, -1);
    // *       returns 1: 'abcde'
    // *       example 2: substr(2, 0, -6);
    // *       returns 2: ''

    f_string = f_string+'';
    
    if(f_start < 0) {
        f_start += f_string.length;
    }

    if(f_length == undefined) {
        f_length = f_string.length;
    } else if(f_length < 0){
        f_length += f_string.length;
    } else {
        f_length += f_start;
    }

    if(f_length < f_start) {
        f_length = f_start;
    }

    return f_string.substring(f_start, f_length);
}// }}}

// {{{ strstr
function strstr( haystack, needle, bool ) {
    // Find first occurrence of a string
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_strstr/
    // +       version: 809.522
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: strstr('Kevin van Zonneveld', 'van');
    // *     returns 1: 'van Zonneveld'
    // *     example 2: strstr('Kevin van Zonneveld', 'van', true);
    // *     returns 2: 'Kevin '

    var pos = 0;

    pos = haystack.indexOf( needle );
    if( pos == -1 ){
        return false;
    } else{
        if( bool ){
            return haystack.substr( 0, pos );
        } else{
            return haystack.slice( pos );
        }
    }
}// }}}

// {{{ empty
function empty( mixed_var ) {
    // Determine whether a variable is empty
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_empty/
    // +       version: 809.1713
    // +   original by: Philippe Baumann
    // +      input by: Onno Marsman
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: LH
    // *     example 1: empty(null);
    // *     returns 1: true
    // *     example 2: empty(undefined);
    // *     returns 2: true
    // *     example 3: empty([]);
    // *     returns 3: true
    
    if (mixed_var === "" 
        || mixed_var === 0   
        || mixed_var === "0"
        || mixed_var === null  
        || mixed_var === false
        || mixed_var === undefined    
        || ((typeof mixed_var == 'array' || typeof mixed_var == 'object') && mixed_var.length === 0) ){
        return true;
    }
    
    return false;
}// }}}

// {{{ is_int
function is_int( mixed_var ) {
    // Find whether the type of a variable is integer
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_is_int/
    // +       version: 809.522
    // +   original by: Alex
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: is_int(186.31);
    // *     returns 1: false
    // *     example 2: is_int(12);
    // *     returns 2: true

    var y = parseInt(mixed_var * 1);
    
    if (isNaN(y)) {
        return false;
    }
    
    return mixed_var == y && mixed_var.toString() == y.toString(); 
}// }}}

// {{{ trim
function trim( str, charlist ) {
    // Strip whitespace (or other characters) from the beginning and end of a string
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_trim/
    // +       version: 809.522
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: mdsjack (http://www.mdsjack.bo.it)
    // +   improved by: Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev)
    // +      input by: Erkekjetter
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: DxGx
    // +   improved by: Steven Levithan (http://blog.stevenlevithan.com)
    // +   improved by: Jack
    // *     example 1: trim('    Kevin van Zonneveld    ');
    // *     returns 1: 'Kevin van Zonneveld'
    // *     example 2: trim('Hello World', 'Hdle');
    // *     returns 2: 'o Wor'

    var whitespace, l = 0;
    
    if (!charlist) {
        whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000';
    } else {
        whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
    }
    
    l = str.length;
    for (var i = 0; i < l; i++) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(i);
            break;
        }
    }
    
    l = str.length;
    for (i = l - 1; i >= 0; i--) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(0, i + 1);
            break;
        }
    }
    
    return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}// }}}

// {{{ explode
function explode( delimiter, string, limit ) {
    // Split a string by string
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_explode/
    // +       version: 809.522
    // +     original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: kenneth
    // +     improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: d3x
    // +     bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: explode(' ', 'Kevin van Zonneveld');
    // *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
    // *     example 2: explode('=', 'a=bc=d', 2);
    // *     returns 2: ['a', 'bc=d']
 
    var emptyArray = { 0: '' };
    
    // third argument is not required
    if ( arguments.length < 2
        || typeof arguments[0] == 'undefined'
        || typeof arguments[1] == 'undefined' )
    {
        return null;
    }
 
    if ( delimiter === ''
        || delimiter === false
        || delimiter === null )
    {
        return false;
    }
 
    if ( typeof delimiter == 'function'
        || typeof delimiter == 'object'
        || typeof string == 'function'
        || typeof string == 'object' )
    {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
    
    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }
}// }}}

// {{{ str_replace
function str_replace(search, replace, subject) {
    // Replace all occurrences of the search string with the replacement string
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_str_replace/
    // +       version: 809.522
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // -    depends on: is_array
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'    
    
    var f = search, r = replace, s = subject;
    var ra = is_array(r), sa = is_array(s), f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;

    while (j = 0, i--) {
        while (s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
    };
     
    return sa ? s : s[0];
}// }}}

// {{{ is_array
function is_array( mixed_var ) {
    // Finds whether a variable is an array
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_is_array/
    // +       version: 809.522
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Legaev Andrey
    // +   bugfixed by: Cord
    // *     example 1: is_array(['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: true
    // *     example 2: is_array('Kevin van Zonneveld');
    // *     returns 2: false

    return ( mixed_var instanceof Array );
}// }}}

// {{{ in_array
function in_array(needle, haystack, strict) {
    // Checks if a value exists in an array
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_in_array/
    // +       version: 809.522
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: true

    var found = false, key, strict = !!strict;

    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
    }

    return found;
}// }}}


////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
function checkNumeric(objName,minval, maxval,comma,period,hyphen)
{
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen)
{
// only allow 0-9 be entered, plus any values passed
// (can be in any order, and don't have to be comma, period, or hyphen)
// if all numbers allow commas, periods, hyphens or whatever,
// just hard code it here and take out the passed parameters
var checkOK = "0123456789" + comma + period + hyphen;
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";

for (i = 0;  i < checkStr.value.length;  i++)
{
ch = checkStr.value.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{	
//alertsay = "Please enter only these values \""
//alertsay = alertsay + checkOK + "\" in the \"" + checkStr.name + "\" field."
alertsay = "Please enter a valid 5 digit zipcode"
alert(alertsay);
return (false);
}

// set the minimum and maximum
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
{
//alertsay = "Please enter a value greater than or "
//alertsay = alertsay + "equal to \"" + minval + "\" and less than or "
//alertsay = alertsay + "equal to \"" + maxval + "\" in the \"" + checkStr.name + "\" field."
alertsay = "Please enter a valid 5 digit zipcode"
alert(alertsay);
return (false);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
/*	confirm. 8/19/2008	*/

function confirmation(message) {
	var answer = confirm(message);
	if (answer)
		return true ;
	else
		return false ;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
/*	this function belongs to the new showHideFunction. 8/19/2008	*/

	function showContent(vThis)
	{
		// alert(vSibling.className + " " + vDef_Key);
		vParent = vThis.parentNode;
		vSibling = vParent.nextSibling;
		while (vSibling.nodeType==3) { // Fix for Mozilla/FireFox Empty Space becomes a TextNode or Something
		vSibling = vSibling.nextSibling;
		};
		if(vSibling.style.display == "none")
		{
		vSibling.style.display = "block";
		} else {
		vSibling.style.display = "none";
		}
		return;
	}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
/*	this function belongs to showHideFunction.	*/

var max = 6;
var headerheight = 60;
var start = 480;
var heights = new Array(230,1100,550,1700,1700,1300);
var shown = new Array();
var safe = headerheight*max;
safe += start;
var test = 0;
for (i=0;i<max;i++)
{
	safe += heights[i];
	if (heights[i] > test) test = heights[i];
	shown[i+1] = false;
}

safe -= test;

var stylie = "<STYLE TYPE='text/css'><!--";
var endstylie = "--></STYLE>";

if (document.getElementById || document.all)
{
	document.write(stylie);
	document.write('.para {display: none}');
	document.write(endstylie);
}
 else if (document.layers)
{
	document.write(stylie);
	document.write(".para {position: absolute; visibility: hide; top: " + safe + "}");
	document.write(".head {position: absolute;}");
	document.write(endstylie);
}


/*	this function belongs to showHideFunction.	*/
function blocking(nr)
{
	if (document.getElementById)
	{
		current = (document.getElementById(nr).style.display == 'block') ? 'none' : 'block';
		document.getElementById(nr).style.display = current;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'block') ? 'none' : 'block'
		document.all[nr].style.display = current;
	}
	else if (document.layers)
	{
		var i = parseInt(nr.substr(nr.length-1,1));
		var replacing = heights[i-1];
		if (shown[i])
		{
			shown[i] = false;
			replacing = -replacing;
			document.layers[nr].visibility = 'hide';
			document.layers[nr].top = safe;
		}
		else
		{
			shown[i] = true;
			document.layers[nr].visibility = 'show';
			var tempname = 'header' + i;
			document.layers[nr].top = document.layers[tempname].top + headerheight;
		}
		for (j=(i+1);j<=max;j++)
		{
			name1 = 'header' + j;
			document.layers[name1].top += replacing;
			if (shown[j])
			{
				name2 = 'number' + j;
				document.layers[name2].top += replacing;
			}
		}
	}
	else alert ('This link does not work in your browser.');
}

/*	this function belongs to showHideFunction.	*/
function NN4()
{
	if (document.layers)
	{
		pos = start;
		for (i=1;i<=max;i++)
		{
			eval("document.layers['header" + i + "'].top = " + pos);
			eval("document.layers['header" + i + "'].visibility = 'show'");
			pos += headerheight;
		}
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
/* http://code.jenseng.com/google/
Disable yellow background added by google toolbar. works only in IE
*/

 if(window.attachEvent)
    window.attachEvent("onload",setListeners);
  
  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "" && event.srcElement.style.backgroundColor != "#a0d0ff"){
      event.srcElement.style.backgroundColor = "#a0d0ff"; /* color of choice for AutoFill */
      document.all['googleblurb'].style.display = "block";
    }
  }
  
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: David Leppek :: https://www.azcode.com/Mod10

Basically, the alorithum takes each digit, from right to left and muliplies each second
digit by two. If the multiple is two-digits long (i.e.: 6 * 2 = 12) the two digits of
the multiple are then added together for a new number (1 + 2 = 3). You then add up the 
string of numbers, both unaltered and new values and get a total sum. This sum is then
divided by 10 and the remainder should be zero if it is a valid credit card. Hense the
name Mod 10 or Modulus 10. */
function Mod10(ccNumb) {  // v2.0
var valid = "0123456789"  // Valid digits in a credit card number
var len = ccNumb.length;  // The length of the submitted cc number
var iCCN = parseInt(ccNumb);  // integer of ccNumb
var sCCN = ccNumb.toString();  // string of ccNumb
sCCN = sCCN.replace (/^\s+|\s+$/g,'');  // strip spaces
var iTotal = 0;  // integer total set at zero
var bNum = true;  // by default assume it is a number
var bResult = false;  // by default assume it is NOT a valid cc
var temp;  // temp variable for parsing string
var calc;  // used for calculation of each digit

// Determine if the ccNumb is in fact all numbers
for (var j=0; j<len; j++) {
  temp = "" + sCCN.substring(j, j+1);
  if (valid.indexOf(temp) == "-1"){bNum = false;}
}

// if it is NOT a number, you can either alert to the fact, or just pass a failure
if(!bNum){
  /*alert("Not a Number");*/bResult = false;
}

// Determine if it is the proper length 
if((len == 0)&&(bResult)){  // nothing, field is blank AND passed above # check
  bResult = false;
} else{  // ccNumb is a number and the proper length - let's see if it is a valid card number
  if(len >= 15){  // 15 or 16 for Amex or V/MC
    for(var i=len;i>0;i--){  // LOOP throught the digits of the card
      calc = parseInt(iCCN) % 10;  // right most digit
      calc = parseInt(calc);  // assure it is an integer
      iTotal += calc;  // running total of the card number as we loop - Do Nothing to first digit
      i--;  // decrement the count - move to the next digit in the card
      iCCN = iCCN / 10;                               // subtracts right most digit from ccNumb
      calc = parseInt(iCCN) % 10 ;    // NEXT right most digit
      calc = calc *2;                                 // multiply the digit by two
      // Instead of some screwy method of converting 16 to a string and then parsing 1 and 6 and then adding them to make 7,
      // I use a simple switch statement to change the value of calc2 to 7 if 16 is the multiple.
      switch(calc){
        case 10: calc = 1; break;       //5*2=10 & 1+0 = 1
        case 12: calc = 3; break;       //6*2=12 & 1+2 = 3
        case 14: calc = 5; break;       //7*2=14 & 1+4 = 5
        case 16: calc = 7; break;       //8*2=16 & 1+6 = 7
        case 18: calc = 9; break;       //9*2=18 & 1+8 = 9
        default: calc = calc;           //4*2= 8 &   8 = 8  -same for all lower numbers
      }                                               
    iCCN = iCCN / 10;  // subtracts right most digit from ccNum
    iTotal += calc;  // running total of the card number as we loop
  }  // END OF LOOP
  if ((iTotal%10)==0){  // check to see if the sum Mod 10 is zero
    bResult = true;  // This IS (or could be) a valid credit card number.
  } else {
    bResult = false;  // This could NOT be a valid credit card number
    }
  }
}
// change alert to on-page display or other indication as needed.
if(bResult) {
  //alert("This IS a valid Credit Card Number!");
}
if(!bResult){
  alert("This is NOT a valid Credit Card Number!");
}
  return bResult; // Return the results
}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
/*	Checks to see if tems and conditions has been checked in cart/checkout.php.	*/ 

function checkPolicy(){
	if(document.policyform.policy.checked == false){
		alert('Please read our terms and conditions. Then check the box.');
		return false;
	}

	/*
	if(document.policyform.policy2.checked == false){
		alert('Please check the box confirming you understand that your credit card will be billed by ALPHA TIME PRODUCTS. Thank you very much');
		return false;
	}
	*/

	var errormsg = "";
	if (document.merchant_form.cc_type.value == "") { var errormsg = errormsg + "Please Enter Your Credit Card Type.\n\r"; }
	if (document.merchant_form.cc_number.value == "") { var errormsg = errormsg + "Please Enter Your Credit Card Number.\n\r"; }
	if (document.merchant_form.cc_month.value == "") { var errormsg = errormsg + "Please Enter Your Credit Card Expiration Month.\n\r"; }
	if (document.merchant_form.cc_year.value == "") { var errormsg = errormsg + "Please Enter Your Credit Card Expiration Year.\n\r"; }
	if (document.merchant_form.cc_security_code.value == "") { var errormsg = errormsg + "Please Enter a Credit Card CVV Number.\n\r"; }
	if (errormsg != "") { alert(errormsg); return false; }

}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
/***********************************************
* image rollover 
* 1/8/2008
***********************************************/
function lightup(imgName)
 {
   if (document.images)
	{
	  imgOn=eval(imgName + "on.src");
	  document[imgName].src= imgOn;
	}
 }

function turnoff(imgName)
 {
   if (document.images)
	{
	  imgOff=eval(imgName + "off.src");
	  document[imgName].src= imgOff;
	}
 }
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
* 1/8/2008
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

function submitform(a)
{
	if (a=='login_form')
	{
		document.login_form.submit();
	}else if (a=='newsletter_form')
	{
		document.newsletter_form.submit();
	}else if (a=='search_form')
	{
		document.search_form.submit();
	}
}
function submitform2()
{
  document.myform.submit();
}
function checkboxChange()
{
	document.this_form.ship_to_billing.checked = false;
}
function checkboxSwap()
{
	if(document.this_form.ship_to_billing.checked)
	{
		if(document.this_form.b_address.value != null)
		{
			document.this_form.s_address.value = document.this_form.b_address.value;			
		}
		if(document.this_form.b_address2.value != null)
		{
			document.this_form.s_address2.value = document.this_form.b_address2.value;
		}
		if(document.this_form.b_city.value != null)
		{
			document.this_form.s_city.value = document.this_form.b_city.value;
		}
			
		document.this_form.s_state.selectedIndex = document.this_form.b_state.selectedIndex;
		document.this_form.s_country.selectedIndex = document.this_form.b_country.selectedIndex;
		
		if(document.this_form.b_zip.value != null)
		{
			document.this_form.s_zip.value = document.this_form.b_zip.value;
		}
	}
	else
	{
		document.this_form.s_address.value = "";
		document.this_form.s_address2.value = "";
		document.this_form.s_city.value = "";
		document.this_form.s_state.selectedIndex = 0;
		document.this_form.s_country.selectedIndex = 0;
		document.this_form.s_zip.value = "";
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

function checkboxSwap()
{ 
	if(document.this_form.ship_to_billing.checked)
	{
		if(document.this_form.b_address.value != null)
		{
			document.this_form.s_address.value = document.this_form.b_address.value;			
		}
		if(document.this_form.b_address2.value != null)
		{
			document.this_form.s_address2.value = document.this_form.b_address2.value;
		}
		if(document.this_form.b_city.value != null)
		{
			document.this_form.s_city.value = document.this_form.b_city.value;
		}
			
		document.this_form.s_state.selectedIndex = document.this_form.b_state.selectedIndex;
		document.this_form.s_country.selectedIndex = document.this_form.b_country.selectedIndex;
		
		if(document.this_form.b_zip.value != null)
		{
			document.this_form.s_zip.value = document.this_form.b_zip.value;
		}
	}
	else
	{
		document.this_form.s_address.value = "";
		document.this_form.s_address2.value = "";
		document.this_form.s_city.value = "";
		document.this_form.s_state.selectedIndex = 0;
		document.this_form.s_country.selectedIndex = 0;
		document.this_form.s_zip.value = "";
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////


var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {browserType= "gecko"}

function hideExpressInstall(){
	
	if (browserType == "gecko" ){
		document.poppedLayer = eval('document.getElementById(\'expressInstall\')');
	}else if (browserType == "ie"){
		document.poppedLayer = eval('document.all[\'expressInstall\']');
	}else{
		document.poppedLayer = eval('document.layers[\'`expressInstall\']');
	}	
	
	document.poppedLayer.style.visibility = "hidden";
	
}

function openAndCenterWindow(the_url,the_window,the_settings)
{
    //if ((parseInt(navigator.appVersion) > 3) && (navigator.appName == "Netscape"))
    //{
        var the_window =  
            window.open(the_url,the_window,the_settings);
        var screen_height = window.screen.availHeight;
        var screen_width = window.screen.availWidth;
        var left_point = parseInt(screen_width / 2) - 100;
        var top_point = parseInt(screen_height/2) - 100;
        the_window.moveTo(left_point, top_point);
   // }
}

function showPic(folder, image){

		//alert(folder);
		pic = new Image();
		pic.src = "../../images/product/" + folder + "/" + image +"a.jpg"; 
		//alert(pic.src);
		document.all.pictureDiv.src = pic.src;  // imgSlide = main large slide	"parent.slideIframe."
}

function stopError() {
		 return true;
	   }
	   window.onerror = stopError;

function checksearch(form)
{
	if (form.SearchFor.value == "") {
		alert( "You must enter a search term" );
		return false ; }
		
	return true ;
}

function checkform (form)
{    
	if (form.attribute_id.value == "") {
		alert( "Please Make a Selection for this product." );
		return false ; }
		
	return true ;
}

function popUp(URL, name) { 
	window.open(URL, '', "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=425,height=550");
}

function popUp_original(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=420,height=550');");
}

function launchCenter(url, name, height, width){
	
	var str = "height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
    var ah = screen.availHeight;
    var aw = screen.availWidth;

    var xc = (aw - width);
    var yc = (ah - height);

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
	window.open(url, name, str);
	//window.open('http://www.google.com', 'k')
}

function launchCenter2(url, name, height, width){
	
	var str = "height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
	window.open(url, name, str);
	//window.open('http://www.google.com', 'k')
}

function newWindowPopup(URL){
	var new_window = window.open(URL);
	new_window.focus();
	}

function showimages(){
	var new_window = window.open();
	new_window.focus();
	}



	/*
function reloadSession(){
	if (x != null){
window.location.reload();
x = x +1;
	}
}

 var x = 0;
 while (x < 1){
 
 x++;
	}
}
*/

function checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass,URL,altURL) 
{ 
	var cmediaType = getCookie('mediaType');
	var cday = getCookie('day');
	var cbandw = getCookie('bandw');
	
	if (cmediaType == "rmp")
	{
	URL = cday + cbandw + cmediaType + ".htm";
	altURL = cday + 'ns_' + cmediaType + ".htm";
	}
	if (cmediaType == "WMP")
	{
	URL = cday + cbandw + cmediaType + ".htm";
	altURL = cday + 'ns_' + cmediaType + ".htm";
	}

var newURL='', verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);

	if (app.indexOf('Netscape') != -1)
		{
	  	if (version >= NSvers) 
			{
			if (NSpass>0) newURL=(NSpass==1)?URL:altURL;
			}
	    else 
			{
			if (NSnoPass>0) newURL=(NSnoPass==1)?URL:altURL;
			}
		} 
	else if (app.indexOf('Microsoft') != -1) 
		{
		if (version >= IEvers || verStr.indexOf(IEvers) != -1)
			{
			if (IEpass>0) newURL=(IEpass==1)?URL:altURL;
			}
	    else
			{
			if (IEnoPass>0) newURL=(IEnoPass==1)?URL:altURL;
			}
		}
	else if (OBpass>0) newURL=(OBpass==1)?URL:altURL;
	if (newURL) 
		{
		window.location=unescape(newURL); document.MM_returnValue=false; 
		}
}

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments

//setCookie('counter', 4);
//x = getCookie('counter');

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function check(){
	if (getCookie('trackingNum') == null){
		alert('You must enter a tracking number');
		//window.document.thisForm.charge.value = '';
		setCookie('trackingNum', null);
	}
}

function alertme(){
	window.open('http://www.google.com', 'k')
	alert('420');
}

function unavailable(){
	alert("This watch is currently out of stock, please check back soon.");

}





/*
<!--  

if ($_SERVER['REQUEST_METHOD'] == 'POST'  && !empty($_POST['tracknum']))
{
    //sql code to submit data to database.

    unset($_POST['tracknum']; //clear variables after data has been posted

    //here you can  redirect to another page upon successful posting
}

echo"<form method='POST' action='form.php'>"; //notice how form references itself

echo"<input type='textfield' name='tracknum'>";

echo"</form>";

 -->

 <!--  onLoad="window.focus('

<?php 

$test = $_GET['tracknum']; 

$xtracknum = $_GET['tracknum'];
  

if (empty($xtracknum))
{
    //sql code to submit data to database.

    unset($xtracknum); //clear variables after data has been posted

    //here you can  redirect to another page upon successful posting
}

?>

')" -->


<!--onLoad="fedExTracking()"  -->

<!-- <SCRIPT FOR=window EVENT=onload LANGUAGE="JScript">
   "fedExTracking()";
</SCRIPT> -->*/
