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