////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
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> -->*/
