function openwindow() {
  window.open('templates/helmet_sizing_pop.html','','width=800,height=400,scrollbars,resizable');
}

/* popup for checkout page */
function cvv2_pop() {
  window.open('templates/cvv2_pop.html','','width=350,height=350');
  return false; 
}  

var newWindow = null;

function popUpWin(url, type, strWidth, strHeight){
	
	//closeWin();
	
	if (type == "fullScreen") {
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=no,location=no,scrollbars=yes,menubar=no,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();

}

function checkform() {
		
  if (isEmpty(document.EnterInfo.Shipping_First_Name.value) || isEmpty(document.EnterInfo.Shipping_Last_Name.value) || isEmpty(document.EnterInfo.Shipping_Address.value) || isEmpty(document.EnterInfo.Shipping_City.value) || isEmpty(document.EnterInfo.Shipping_State.value) || isEmpty(document.EnterInfo.Shipping_Zip_Code.value)) {
    alert('Please enter the required shipping information \n as indicated by the asterisks (*).');
    document.EnterInfo.Shipping_First_Name.focus();
    return false;   
  }
  else if (document.EnterInfo.Same_As_Shipping.checked == 0 && (isEmpty(document.EnterInfo.Billing_First_Name.value) || isEmpty(document.EnterInfo.Billing_Last_Name.value) || isEmpty(document.EnterInfo.Billing_Address.value) || isEmpty(document.EnterInfo.Billing_City.value) || isEmpty(document.EnterInfo.Billing_State.value) || isEmpty(document.EnterInfo.Billing_Zip_Code.value))) {
    alert('Please enter the required billing information as indicated by the asterisks (*) \n or if your shipping information is the same as your billing information, \n select the checkbox.');
    document.EnterInfo.Same_As_Shipping.focus();
    return false;   
  }				
  else if (isEmpty(document.EnterInfo.Phone_1.value) || isEmpty(document.EnterInfo.Email_Address.value)) {
    alert('Please enter the required contact information \n as indicated by the asterisks (*).');
    document.EnterInfo.Phone_1.focus();
    return false;   
  }
  else if ( document.EnterInfo.Email_Address.value.length <= 6 || document.EnterInfo.Email_Address.value.indexOf ('@', 0) == -1 || document.EnterInfo.Email_Address.value.indexOf ('.', 0) == -1){
    alert("'' " + document.EnterInfo.Email_Address.value + " '', is not valid e-mail Address.");
	  document.EnterInfo.Email_Address.focus();
    return false;
  }
  else if (isEmpty(document.EnterInfo.Credit_Card_Number.value)) {
    alert('Please enter a credit card number.');
    document.EnterInfo.Credit_Card_Number.focus();
    return false;
  }
  else if (isEmpty(document.EnterInfo.CVV2.value)) {
    alert('Please enter a CVV2 code.');
    document.EnterInfo.CVV2.focus();
    return false;
  }
  else if (document.EnterInfo.Credit_Card_Type.options[document.EnterInfo.Credit_Card_Type.selectedIndex].value == '') {
    alert('Please enter the credit card type.');
    document.EnterInfo.Credit_Card_Type.focus();
    return false;
  }
  else if (document.EnterInfo.Expiration_Month.options[document.EnterInfo.Expiration_Month.selectedIndex].value == '')  {
    alert('Please enter the expiration month.');
    document.EnterInfo.Expiration_Month.focus();
    return false;
  }
  else if (document.EnterInfo.Expiration_Year.options[document.EnterInfo.Expiration_Year.selectedIndex].value == '') {
    alert('Please enter the expiration year.');
    document.EnterInfo.Expiration_Month.focus();
    return false;
  }
  else { document.EnterInfo.submit();}
}

function isEmpty(s) {
   return ((s == null) || (s.length == 0));
}

/* hide status data */
function hidestatus() {
  var statusmsg = "";
  window.status = statusmsg;
  return true;
}
