function EnlargeImage(iCode,iPID,nImg){
  window.open("/EnlargeImage.asp?ProdID="+ iPID + "&Code=" + iCode + "&Img=" + nImg,"","toolbar=no,menubar=0,resizable=0,scrollbars=no,width=200,height=200"); 
}

function Size(swImg){
var i = new Image();
i.src=swImg;
window.resizeTo(i.width + 30,i.height + 160);
}

function OpenParent(cadena){

  var Open = opener.window.parent.closed;
  if (Open == false) {
    opener.window.location.href = cadena;
  }else
  {
  	//window.open(cadena,'','width=' + screen.width + ',height=' + screen.height);
  	window.open(cadena);
  }
  window.close();
}


function AddProduct(){
  document.frmProduct.Target.value="ADD";
  document.frmProduct.submit();
}

function AddFProduct(iCode){
  document.all("frmProduct" + iCode).Target.value="ADD";
  document.all("frmProduct" + iCode).submit();
}

function DetailSet(iCode){
  var sw = document.all("TD"+iCode).style.display;
  if (sw == "") {
     document.all("TD"+iCode).style.display = "none";
     document.all("ID"+iCode).style.display = "";
     document.all("IH"+iCode).style.display = "none";
  }else{
     document.all("TD"+iCode).style.display = "";
     document.all("ID"+iCode).style.display = "none";
     document.all("IH"+iCode).style.display = "";
  }
}

function DeleteItem(iCode){
  document.frmOrder.Target.value= "DELETE";
  document.frmOrder.DItem.value = iCode;
  document.frmOrder.submit();
}

function Recalculate(iCode){
  var sw = true;
  for (i=1; i<=iCode; i++){
    if (!isNumber(document.all("Qty"+i).value)) sw = false;
    if (document.all("Qty"+i).value == "0") sw = false;
  }
  if (sw) {
  document.frmOrder.Target.value= "CALC";
  document.frmOrder.DItem.value = iCode;
  document.frmOrder.submit();
  }else{
    alert("Please enter valid values for the quantity items!.");
  }
}


function isNumber(value) {
	for (var i=0; i < value.length; i++) {
		a = parseInt(value.charAt(i));
		if (isNaN(a)) {
			return false;			
			break;
		}
	}
	return true;
}

function ApplyCoupon(){
  if (document.frmCoupon.CouponCode.value == ""){
    alert("You must fill the Coupon Code fields!");
  }else{
    document.frmCoupon.Target.value = "ADDCOUPON";
    document.frmCoupon.submit();
  }
}

function DeleteCoupon(){
  document.frmOrder.Target.value= "DELETECOUPON";
  document.frmOrder.DItem.value = 0;
  document.frmOrder.submit();
}

function CheckOut(sCad){
  document.frmOrder.Target.value="";
  if (sCad == "")  document.frmOrder.action = "secure/Customer.asp";
  else{document.frmOrder.action = sCad + "/Customer.asp"; }
  
  document.frmOrder.method = "post"
  document.frmOrder.submit();
}

function RetrievePassword(){
  window.open("Password.asp","","toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=352,height=202");
}

function CreateAccount(){
  window.location.href="Customer.asp?Target=new";
}

function SameON(){
  document.all("SInfo").disabled = true;
  document.frmCustomer.csFName.disabled = true;
  document.frmCustomer.csMI.disabled = true;
  document.frmCustomer.csLName.disabled = true;
  document.frmCustomer.csCompany.disabled = true;
  document.frmCustomer.csAddr1.disabled = true;
  document.frmCustomer.csAddr2.disabled = true;
  document.frmCustomer.csCity.disabled = true;
  document.frmCustomer.csZip.disabled = true;
  document.frmCustomer.csPhone.disabled = true;
  document.frmCustomer.csFax.disabled = true;
  document.frmCustomer.csEmail.disabled = true;
  document.frmCustomer.csState.disabled = true;
  document.frmCustomer.csCountry.disabled = true;
          
}


function SameOFF(){
  document.all("SInfo").disabled = false;
  document.frmCustomer.csFName.disabled = false;
  document.frmCustomer.csMI.disabled = false;
  document.frmCustomer.csLName.disabled = false;
  document.frmCustomer.csCompany.disabled = false;
  document.frmCustomer.csAddr1.disabled = false;
  document.frmCustomer.csAddr2.disabled = false;
  document.frmCustomer.csCity.disabled = false;
  document.frmCustomer.csZip.disabled = false;
  document.frmCustomer.csPhone.disabled = false;
  document.frmCustomer.csFax.disabled = false;
  document.frmCustomer.csEmail.disabled = false;
  document.frmCustomer.csState.disabled = false;
  document.frmCustomer.csCountry.disabled = false;
  
}


function Login(){
  var sw = true;
  if (document.frmLogin.User.value == "") sw = false;
  if (document.frmLogin.Password.value == "") sw = false;
  if (!sw) {
    alert("You must fill all fields to continue.");
   } else {
     document.frmLogin.Target.value = "LOGIN";
     document.frmLogin.submit();
   }
}

function SetShipping(){
  var iIndex = -1;
  for (var i=0; i<=document.frmShipping.nItems.value; i++){
    //alert("entro" + i);
    if (document.frmShipping.nItems.value != 0){
    	if (document.frmShipping.sShipMethod[i].checked) {
     		//alert(document.all("smethod"+i).checked + " - " + document.all("smethod"+i).value);
     		iIndex = i;
    	}
    }else{
        //alert("volvio" + i);
    	iIndex = i;
    }
  }
  if (iIndex == -1){
    alert("Please select a shipping method to continue.");
  }else{
    document.frmShipping.ShipIndex.value = iIndex;
    document.frmShipping.Target.value="SAVE";
    document.frmShipping.submit();
  }
}

function RemoveOASRP(){
  if (confirm("Do you want to remove this O.A.S.R.P. Value?")){
    window.location.href= "Payments.asp?SetExtra=DEL";
  }
}

function PayOption(){
  var index = document.frmPayments.sPayMethod.selectedIndex;
  var index2 = document.frmPayments.sPayMethod.options[index].text;
  if (index2=="PayPal") {
    document.all("Pay01").style.display = "none";
    document.all("Pay02").style.display = "none";
    document.all("Pay03").style.display = "";
    document.all("Pay04").style.display = "none";
    document.all("Pay05").style.display = "none";
  }
  if (index2=="Credit Card") {
    document.all("Pay01").style.display = "";
    document.all("Pay02").style.display = "none";
    document.all("Pay03").style.display = "none";
    document.all("Pay04").style.display = "none";
    document.all("Pay05").style.display = "none";
  }
  if (index2=="Phone/Fax") {
    document.all("Pay01").style.display = "none";
    document.all("Pay02").style.display = "";
    document.all("Pay03").style.display = "none";
    document.all("Pay04").style.display = "none";
    document.all("Pay05").style.display = "none";
  }
  if (index2=="Value Partner") {
    document.all("Pay01").style.display = "none";
    document.all("Pay02").style.display = "none";
    document.all("Pay03").style.display = "none";
    document.all("Pay04").style.display = "none";
    document.all("Pay05").style.display = "";
  }
  if (index2=="eCheck") {
    document.all("Pay01").style.display = "none";
    document.all("Pay02").style.display = "none";
    document.all("Pay03").style.display = "none";
    document.all("Pay04").style.display = "";
    document.all("Pay05").style.display = "none";
  }
}

function OpenWindowCC(){

 window.open("/CCard.html","","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=550,height=600");

}

function SetOASRP(){
  var iH = document.all("OASRP").value;
  if (!isNumber(iH)){
    document.all("OASRP").value = "";
    alert("Please insert a valid value.");
  }else{
    window.location.href= "Payments.asp?SetExtra=SET&iEXTRA=" + iH;
  } 
  //alert("AQY");
}

function PlaceOrder(){
  var index = document.frmPayments.sPayMethod.selectedIndex;
  var index2 = document.frmPayments.sPayMethod.options[index].text;
  var CadError = "";
  if ((index2=="Credit Card")) {
    if (isCardNumValid(document.frmPayments.sCardNumber.value)) {
       CadError = "Credit Card invalid!";
       document.frmPayments.sCardNumber.value = "";
    }else{
       if (document.frmPayments.sCardNumber.value=="") CadError += "\nCard Number";
       if (document.frmPayments.sCardName.value=="") CadError += "\nCard Name Holder";
       if (document.frmPayments.sCardType.selectedIndex == 0) CadError += "\nCard Type";
       if (document.frmPayments.sCardMonth.selectedIndex == 0) CadError += "\nCard Month Expitarion";
       if (document.frmPayments.sCardYear.selectedIndex == 0) CadError += "\nCard Year Expitarion";
       if (document.frmPayments.sCardCode.value=="") CadError += "\nCard Code";
       //if (document.frmPayments.Terms.status!=true) CadError += "\nAccept the terms and conditions";
    }
  }
  if (index2== "PhoneFax"){
    var c = false;
    var iII = 0;
    for (var i=0; i<document.frmPayments.elements.length;i++)
    {
    var e = document.frmPayments.elements[i];
    if (e.type == 'radio'){
      iII++;
      if (e.checked){
        c = true;
      }
    }
    }
    if (!c) {
      if (iII != 0) {
        CadError += "\nPayment Method";
      }
    }
  }
  
  if (index2 == "eCheck"){ 
    if (document.frmPayments.sBankName.value == "") CadError += "\nBank Name";
    if (document.frmPayments.sAccountNumber.value == "") CadError += "\nAccount Number";
    if (document.frmPayments.sRoutingNumber.value == "") CadError += "\nRouting Number";
    if (document.frmPayments.sCheckNumber.value == "") CadError += "\nCheck Number";
  }

  if (index2 == "Value Partner") {
     if (document.frmPayments.sPartnerLogin.value == "") CadError += "\nPartner Login";
     if (document.frmPayments.sPartnerPassword.value == "") CadError += "\nPartner Password";
   }
  

  if (CadError == "") {
     document.frmPayments.Target.value = "PLACE";
     document.frmPayments.submit();
  }else{
    if (CadError  == "Credit Card invalid!") {
       alert(CadError);
    }else{
       var sError = "";
       sError += "SORRY\nWe cannot process this form. You must fill in the follow fields first:\n";
       sError += "---------------------------------------------------------------------------------\n";
       alert(sError + CadError);
    }
  }
  
}

function isCardNumValid(num) {
	var num1, num2, tempNum;
	if (!isNumber(num)) {
		return true;
	}
	num1 = ""
	if (!(num.length%2==0)) {
		for(var j=0; j < num.length; j++) {
			if ((j+1)%2==0){
				tempNum = 2 * num.charAt(j);
			}
			else {
				tempNum = 1 * num.charAt(j);
			}
			num1 = num1 + tempNum.toString();
		}
	}else{
		for(var j=0; j < num.length; j++){
			if ((j+1)%2==0){
				tempNum = 1 * num.charAt(j);
			}
			else{
				tempNum = 2 * num.charAt(j);
			}
			num1 = num1 + tempNum.toString();
		}
	}
	num2 = 0;
	for (var j = 0; j < num1.length; j++) {
		num2 = num2 + parseInt(num1.charAt(j));
	}
	if (num2%10==0) {
		return false;
	}
	else {
		return true;
	}
}

function CreatePhoneFaxForm(iOrderID){
  var sURL = "orderprint.asp?OrderID=" + iOrderID + "&Target=Form";
  window.open(sURL,"","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=600");
}



function PrintFriendly(iOrderID){
  var sURL = "orderprint.asp?OrderID=" + iOrderID;
  window.open(sURL,"","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=600");
}

function Category(){
  if (document.frmResults.sCate.selectedIndex == 0){
  }else{
    var Resp = document.frmResults.sCate.value;
    var sS = document.frmResults.Cate.options[document.frmResults.Cate.selectedIndex].value;
    if (Resp == ""){
      sOut = "catid=" + sS;
    }else{
      sOut = Resp + "&catid=" + sS
    }
    sRedir = "/results.asp?" + sOut;
    window.location = sRedir;
    
  }
   
}

function Sort(){
  if (document.frmResults.PSort.selectedIndex == 0){
  }else{
    var Resp = document.frmResults.SSort.value;
    var sS = document.frmResults.PSort.options[document.frmResults.PSort.selectedIndex].value;
    var sOut = "";
    if (Resp == ""){
      sOut = "orderby=" + sS;
    }else{
      sOut = Resp + "&orderby=" + sS;
    }
    sRedir = "/results.asp?" + sOut
    window.location = sRedir;
   
  }
}

function Page(iPage){
  var Resp = document.frmResults.SPage.value;
  var sOut = "";
  if (Resp==""){
    sOut = "page=" + iPage;
  }else{
    sOut = Resp + "&page=" + iPage;
  }
  sRedir = "/results.asp?" + sOut;
  window.location = sRedir;
}

function SubMit(){
  document.frmAgain.submit();
}

function HidePass(){
	if (document.getElementById("Password").style.display == "")
		document.getElementById("Password").style.display = "none";
	else
		document.getElementById("Password").style.display = "";
		//document.getElementById("Tracking").style.display = "none";
	if (document.getElementById("Password1").style.display == "")
		document.getElementById("Password1").style.display = "none";
	else
		document.getElementById("Password1").style.display = "";
   }

function HideTrack(){
	if (document.getElementById("Tracking").style.display == "")
		document.getElementById("Tracking").style.display = "none";
	else
		document.getElementById("Tracking").style.display = "";
		document.getElementById("Password").style.display = "none";
	if (document.getElementById("Tracking1").style.display == "")
		document.getElementById("Tracking1").style.display = "none";
	else
		document.getElementById("Tracking1").style.display = "";	
   }   
   
   function VerifiPass(){
   		clave1 = document.FPass.NewPass.value 
   		clave2 = document.FPass.ConPass.value
		if ((clave1 == "") || (clave2 == ""))
			alert("Insert Password");
		else {
    	if (clave1 == clave2) 
       		document.FPass.submit();
    	else 
			alert("Password incorrect\nPlease verifies");
		}
   }
function ShowSetOS(iREL){
     var sw = document.getElementById("T"+iREL).style.display;
     if (sw == ""){
        document.getElementById("T"+iREL).style.display = "none";
        document.getElementById("ON"+iREL).style.display = "";
        document.getElementById("OFF"+iREL).style.display = "none";
     }else{
        document.getElementById("T"+iREL).style.display = "";
        document.getElementById("ON"+iREL).style.display = "none";
        document.getElementById("OFF"+iREL).style.display = "";
     }
   }

function OpenOS(URL,Altura){
window.open(URL,'Dashboard', 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=538,height= '+ Altura);
}


function EmailFriend(iPID){
  window.open("/EmailFriend.asp?ProdID="+ iPID,"","toolbar=no,menubar=0,resizable=0,scrollbars=no,width=662,height=404"); 
}

function isInteger(iNumber, iSW){
  var isOK = true;
  var iMinus = 0;
  if ((iNumber == null) ||(iNumber == "")){
    isOK = false;
    return isOK; 
  }
  for (j=0; j<iNumber.length; j++) {
    if ((iNumber.substring(j,j+1) != "0") &&
        (iNumber.substring(j,j+1) != "1") &&
        (iNumber.substring(j,j+1) != "2") &&
        (iNumber.substring(j,j+1) != "3") &&
        (iNumber.substring(j,j+1) != "4") &&
        (iNumber.substring(j,j+1) != "5") && 
        (iNumber.substring(j,j+1) != "6") &&
        (iNumber.substring(j,j+1) != "7") &&
        (iNumber.substring(j,j+1) != "8") &&
        (iNumber.substring(j,j+1) != "9") &&
        (iNumber.substring(j,j+1) != "-")) {
       isOK = false
     }
     if (iNumber.substring(j,j+1) == "-" ) iMinus += 1;
  }
  //if (iNumber.substring(0,1) == "0") isOK = false
  if (iMinus>1) { 
      isOK = false;   
  }else{
    if (iMinus == 1) {
       if (iNumber.substring(0,1) != "-") { 
            isOK = false;
       }else{
         if (!iSW) isOK = false;
       }
    }
  } 
  return isOK;
}



function DoNothing(){

}

function SaveZipCode(){
  var xZip = document.frmZipCode.ZipCode.value;
  if (isInteger(xZip,false) && (xZip!="")&&(xZip.length==5)){
    document.frmZipCode.Target.value="ZIPCode";
    document.frmZipCode.submit();
  }else{
    alert("Please enter a valid 5-Digit Zip Code");
  }
}

function CaptureEnter3(e){
  var keynum
  if(window.event) // IE 
  {
     keynum = e.keyCode
  }
  else if(e.which) // Netscape/Firefox/Opera
  {
    keynum = e.which
  }
  if (keynum==13){
      SaveZipCode();
      return false;
  }
  else
      return true;
}


function ChangeZipCode(){
  window.open("/ChangeZipCode.asp","","toolbar=no,menubar=0,resizable=0,scrollbars=no,width=300,height=150");
}

function CZipCode(){
  var xZip = document.frmZip.ZipCode.value;
  if (isInteger(xZip,false) && (xZip!="")&&(xZip.length==5)){
    document.frmZip.Target.value="ZIPCode";
    document.frmZip.submit();
  }else{
    alert("Please enter a valid 5-Digit Zip Code");
  }
}

function CaptureEnter2(e){
  var keynum
  if(window.event) // IE 
  {
     keynum = e.keyCode
  }
  else if(e.which) // Netscape/Firefox/Opera
  {
    keynum = e.which
  }
  if (keynum==13){
      CZipCode();
      return false;
  }
  else
      return true;
}

function ChangeZipFromPID(iCode){
  var xZip = document.all("ZipCode_" + iCode).value;
  if (isInteger(xZip,false) && (xZip!="")&&(xZip.length==5)){
    window.open("/ChangeZipCode.asp?Target=RECORDZIP&ZipCode=" + xZip +"&PID=" + iCode,"","toolbar=no,menubar=0,resizable=0,scrollbars=no,width=300,height=150");
  }else{
    alert("Please enter a valid 5-Digit Zip Code");
  }
}

function CaptureEnter(e){
  var keynum
  if(window.event) // IE 
  {
     keynum = e.keyCode
  }
  else if(e.which) // Netscape/Firefox/Opera
  {
    keynum = e.which
  }
  if (keynum==13){
      ChangeZipFromPID('ALL');
      return false;
  }
  else
      return true;
}


function ChangeSameAddress(){
  if (confirm("Are you sure to change shipping information?")){
    window.location.href = "Customer.asp?Target=UPDATEADDRESS&ZipCode=" + document.frmCustomer.cZip.value;
  }else{
    document.frmCustomer.cShippSame[1].checked = true;
    return false;
  }
}

function ChangeState(){
  if(document.frmCustomer.M_State.value != ""){
    var xCode = document.frmCustomer.cState.selectedIndex;
    xST = document.frmCustomer.cState.options[xCode].value;
    if (xST != document.frmCustomer.M_State.value){
      
      
      document.all("SInfo").disabled = false 
      document.frmCustomer.csFName.disabled = false;
      document.frmCustomer.csMI.disabled = false;
      document.frmCustomer.csLName.disabled = false;
      document.frmCustomer.csCompany.disabled = false;
      document.frmCustomer.csAddr1.disabled = false;
      document.frmCustomer.csAddr2.disabled = false;
  document.frmCustomer.csCity.disabled = false;
  document.frmCustomer.csZip.disabled = false;
  document.frmCustomer.csPhone.disabled = false;
  document.frmCustomer.csFax.disabled = false;
  document.frmCustomer.csEmail.disabled = false;
  document.frmCustomer.csState.disabled = false;
  document.frmCustomer.csCountry.disabled = false;
     document.frmCustomer.cShippSame[0].checked = false;
      document.frmCustomer.cShippSame[0].disabled = true;
     document.frmCustomer.cShippSame[1].checked = true;
    }
  }
}

function SendDealForm(){
  var xU = "";
  if (!isFloat(document.frmDeal.Price.value)){
    alert("Please enter a valid value for your offer.");
  }else{
    sOutB = ""
    if (document.frmDeal.cFName.value == "") sOutB += "\t\t- First Name\n";
    if (document.frmDeal.cLName.value == "") sOutB += "\t\t- Last Name\n";
    if (document.frmDeal.cAddr1.value == "") sOutB += "\t\t- Address\n";
    if (document.frmDeal.cCity.value == "") sOutB += "\t\t- City\n";
    if (document.frmDeal.cState.selectedIndex == 0) sOutB += "\t\t- State\n";
    if (document.frmDeal.cCountry.selectedIndex == 0) sOutB += "\t\t- Country\n";
    if (document.frmDeal.cZip.value == "") sOutB += "\t\t- Zip Code\n";
    if (document.frmDeal.cPhone.value == "") sOutB += "\t\t- Phone Number\n";
    if (document.frmDeal.cEmail.value == "") sOutB += "\t\t- Email Address\n";
    if (sOutB == ""){
      document.frmDeal.Target.value = "SAVEOFFER";
      document.frmDeal.submit();
    }else{
      sError = "";
      sError += "SORRY\nWe cannot process this form. You must fill in the follow fields first:\n";
      sError += "---------------------------------------------------------------------------------\n" + sOutB;
      alert(sError);
    }
  }
}

function SubmitOffer(iCode){
  window.location.href="/DealWithTheManager.asp?PID=" + iCode + "&Offer=" + document.all("Offer_" + iCode).value;
}

function Upgrades(iCode){
  var xx = document.all("TN_" + iCode).style.display;
  if (xx == ""){
    document.all("TN_" + iCode).style.display = "none";
    document.all("UPG_ON_" + iCode).style.display = "";
    document.all("UPG_OFF_" + iCode).style.display = "none";
  }else{
    document.all("TN_" + iCode).style.display = "";
    document.all("UPG_ON_" + iCode).style.display = "none";
    document.all("UPG_OFF_" + iCode).style.display = "";

  }
}

function VerifiTrack(){
	if (document.FTrack.TrackNum.value == "")
	{
	alert("Insert a Track Number");
	return;
	}
	else
	{
	document.FTrack.submit();
	}
}

function SaveShipment(){
var sOutB = "";
var sOutS = "";
var sOutP = "";


if (document.frmCustomer.csFName.value == "") sOutS += "\t\t- First Name\n";
if (document.frmCustomer.csLName.value == "") sOutS += "\t\t- Last Name\n";
if (document.frmCustomer.csAddr1.value == "") sOutS += "\t\t- Address\n";
if (document.frmCustomer.csCity.value == "") sOutS += "\t\t- City\n";
if (document.frmCustomer.csState.selectedIndex == 0) sOutS += "\t\t- State\n";
if (document.frmCustomer.csCountry.selectedIndex == 0) sOutS += "\t\t- Country\n";
if (document.frmCustomer.csZip.value == "") sOutS += "\t\t- Zip Code\n";
if (document.frmCustomer.csPhone.value == "") sOutS += "\t\t- Phone Number\n";
if (document.frmCustomer.csEmail.value == "") sOutS += "\t\t- Email Address\n";


//if (document.frmCustomer.cPass1.value != document.frmCustomer.cPass2.value) sOutP += "\tYour password confirmation is wrong."

if ((sOutB == "") && (sOutS == "") && (sOutP == "")) {
  document.frmCustomer.Target.value="SAVESHIP";
  document.frmCustomer.submit();
}else{
  var sError = "";
  sError += "SORRY\nWe cannot process this form. You must fill in the follow fields first:\n";
  sError += "---------------------------------------------------------------------------------\n";
  if (sOutB != "") sError += "Billing Information:\n" + sOutB;
  if (sOutS != "") sError += "Shipping Information:\n" + sOutS;
  if (sOutP != "") sError += "Returning Information:\n" + sOutP;
  alert(sError);
}
 
}


   function ShowTrans(iRel){
     if (document.all("TR"+iRel).style.display == ""){
       document.all("TR"+iRel).style.display = "none";
     }else{
       document.all("TR"+iRel).style.display = "";
     }
   
   }
   
   function ShowTrk(x){
   if (document.getElementById("tblTrk_"+x).style.display = "")
   {
	   document.getElementById("tblTrk_"+x).style.display = "none";
	   document.getElementById("linkShow").style.display = ""
	}	   
   else
   {
	   document.getElementById("tblTrk_"+x).style.display = "";
	   document.getElementById("linkShow").style.display = "none"	   
	}   
  }



function PlaceOrder1(){
  var CadError = "";
  if ((document.frmPayments.sPayMethod.value)!="") {
    if (isCardNumValid(document.frmPayments.sCardNumber.value)) {
       CadError = "Credit Card invalid!";
       document.frmPayments.sCardNumber.value = "";
    }else{
       if (document.frmPayments.sCardNumber.value=="") CadError += "\nCard Number";
       if (document.frmPayments.sCardName.value=="") CadError += "\nCard Name Holder";
       if (document.frmPayments.sCardType.selectedIndex == 0) CadError += "\nCard Type";
       if (document.frmPayments.sCardMonth.selectedIndex == 0) CadError += "\nCard Month Expitarion";
       if (document.frmPayments.sCardYear.selectedIndex == 0) CadError += "\nCard Year Expitarion";
       if (document.frmPayments.sCardCode.value=="") CadError += "\nCard Code";
       //if (document.frmPayments.Terms.status!=true) CadError += "\nAccept the terms and conditions";
    }
  } 

  if (CadError == "") {
     document.frmPayments.Target.value = "PLACE";
     document.frmPayments.submit();
  }else{
    if (CadError  == "Credit Card invalid!") {
       alert(CadError);
    }else{
       var sError = "";
       sError += "SORRY\nWe cannot process this form. You must fill in the follow fields first:\n";
       sError += "---------------------------------------------------------------------------------\n";
       alert(sError + CadError);
    } 
  }
}  

function PlaceOrder12() {
	//alert("holaa2");
	//alert(document.frmCustomer.sPayMethod.value);
		var sOutB = "";
		var sOutS = "";
		var sOutP = "";
	    var CadError = "";
		
		if (document.frmCustomer.cFName.value == "") sOutB += "\n First Name";
		if (document.frmCustomer.cLName.value == "") sOutB += "\n Last Name";
		if (document.frmCustomer.cAddr1.value == "") sOutB += "\n Address";
		if (document.frmCustomer.cCity.value == "") sOutB += "\n City";
		if (document.frmCustomer.cState.selectedIndex == 0) sOutB += "\n State";
		if (document.frmCustomer.cCountry.selectedIndex == 0) sOutB += "\n Country";
		if (document.frmCustomer.cZip.value == "") sOutB += "\n- Zip Code";
		if (document.frmCustomer.cPhone.value == "") sOutB += "\n Phone Number";
		if (document.frmCustomer.cEmail.value == "") sOutB += "\n Email Address";
		  if ((document.frmCustomer.sPayMethod.value)!="") {
		    if (isCardNumValid(document.frmCustomer.sCardNumber.value)) {
		       CadError = "Credit Card invalid!";
		       document.frmCustomer.sCardNumber.value = "";
		    }else{
		       if (document.frmCustomer.sCardNumber.value=="") sOutS += "\nCard Number";
		       if (document.frmCustomer.sCardName.value=="") sOutS += "\nCard Name Holder";
		       if (document.frmCustomer.sCardType.selectedIndex == 0) sOutS += "\nCard Type";
		       if (document.frmCustomer.sCardMonth.selectedIndex == 0) sOutS += "\nCard Month Expitarion";
		       if (document.frmCustomer.sCardYear.selectedIndex == 0) sOutS += "\nCard Year Expitarion";
		       if (document.frmCustomer.sCardCode.value=="") sOutS += "\nCard Code";
		       //if (document.frmCustomer.Terms.status!=true) CadError += "\nAccept the terms and conditions";
		    }
		  } 
		
		if ((sOutB == "") && (sOutS == "") && (sOutP == "") && (CadError == "")) {
		  document.frmCustomer.Target.value="PLACE";
		  document.frmCustomer.submit();
		  //alert("entro");
		}else{
		  var sError = "";
		      if (CadError  == "Credit Card invalid!") {
		       alert(CadError);
			    }else{
		  sError += "SORRY\nWe cannot process this form. You must fill in the follow fields first:\n";
		  sError += "---------------------------------------------------------------------------------\n";
		  if (sOutB != "") sError += "\nBilling Information:\n" + sOutB;
		  if (sOutS != "") sError += "\nPayment Information:\n" + sOutS;
		  if (sOutP != "") sError += "\nReturning Information:\n" + sOutP;
		  alert(sError);
		  		}
		}
	
	
} 	
	
function SaveCustomer(){
var sOutB = "";
var sOutS = "";
var sOutP = "";

if (document.frmCustomer.cFName.value == "") sOutB += "\t\t- First Name\n";
if (document.frmCustomer.cLName.value == "") sOutB += "\t\t- Last Name\n";
if (document.frmCustomer.cAddr1.value == "") sOutB += "\t\t- Address\n";
if (document.frmCustomer.cCity.value == "") sOutB += "\t\t- City\n";
if (document.frmCustomer.cState.selectedIndex == 0) sOutB += "\t\t- State\n";
//if (document.frmCustomer.cState){alert("SI")}else{alert("NO")}
//if (document.frmCustomer.cState.value == "") sOutB += "\t\t- State\n";
//alert (document.frmCustomer.cState.selectedIndex)
if (document.frmCustomer.cCountry.selectedIndex == 0) sOutB += "\t\t- Country\n";
if (document.frmCustomer.cZip.value == "") sOutB += "\t\t- Zip Code\n";
if (document.frmCustomer.cPhone.value == "") sOutB += "\t\t- Phone Number\n";
if (document.frmCustomer.cEmail.value == "") sOutB += "\t\t- Email Address\n";

if ((sOutB == "") && (sOutS == "") && (sOutP == "")) {
  document.frmCustomer.Target.value="SAVE";
  document.frmCustomer.submit();
}else{
  var sError = "";
  sError += "SORRY\nWe cannot process this form. You must fill in the follow fields first:\n";
  sError += "---------------------------------------------------------------------------------\n";
  if (sOutB != "") sError += "Billing Information:\n" + sOutB;
  if (sOutS != "") sError += "Shipping Information:\n" + sOutS;
  if (sOutP != "") sError += "Returning Information:\n" + sOutP;
  alert(sError);
}
 
}

function SaveToCompare()
{
	  document.frmSaveCompare.Target.value="SAVECOMPARE";
	  document.frmSaveCompare.submit();	
}

function AddProduct2(xVal){
//alert(xVal);
  document.all("frmProduct_" + xVal).Target.value="ADD";
  document.all("frmProduct_" + xVal).submit();
}

function ChangeZipCodeCenter(){
  var xZip = document.frmZipCodeCenter.Zip_Code.value;
  if (isInteger(xZip,false) && (xZip!="")&&(xZip.length==5)){
    document.frmZipCodeCenter.submit();
  }else{
    alert("Please enter a valid 5-Digit Zip Code");
  }

}

function CaptureEnterCenter(e){
  var keynum
  if(window.event) // IE 
  {
     keynum = e.keyCode
  }
  else if(e.which) // Netscape/Firefox/Opera
  {
    keynum = e.which
  }
  if (keynum==13){
      ChangeZipCodeCenter();
      return false;
  }
  else
      return true;

}

//function that validate if a value is an double number
function isFloat(iNumber){
  var isOK = true;
  var iMinus = 0;
  var iComma = 0;
  if ((iNumber == null) ||(iNumber == "")){
    isOK = false;
    return isOK; 
  }
  for (j=0; j<iNumber.length; j++) {
    if ((iNumber.substring(j,j+1) != "0") &&
        (iNumber.substring(j,j+1) != "1") &&
        (iNumber.substring(j,j+1) != "2") &&
        (iNumber.substring(j,j+1) != "3") &&
        (iNumber.substring(j,j+1) != "4") &&
        (iNumber.substring(j,j+1) != "5") && 
        (iNumber.substring(j,j+1) != "6") &&
        (iNumber.substring(j,j+1) != "7") &&
        (iNumber.substring(j,j+1) != "8") &&
        (iNumber.substring(j,j+1) != "9") &&
        (iNumber.substring(j,j+1) != ".") &&
        (iNumber.substring(j,j+1) != "-")) {
       isOK = false
     }
     if (iNumber.substring(j,j+1) == "-" ) iMinus += 1;
     if (iNumber.substring(j,j+1) == "." ) iComma += 1;
  }
  if (iMinus>1) isOK = false;
  if (iComma>1) isOK = false;
  return isOK;
}

//function that validate if a value is a valid email address
function isEmail(sValue){
  var isOK = true;
  var iLength = sValue.length;
  var iArr = 0;
  var iDot = 0;
  if (iLength < 6){
     isOK = false;
     return isOK;
  }
  for (j=0; j<iLength; j++){
    if((sValue.substring(j,j+1) == "'") ||
       (sValue.substring(j,j+1) == "*") ||
       (sValue.substring(j,j+1) == "%") ||
       (sValue.substring(j,j+1) == ",") ||
       (sValue.substring(j,j+1) == "&") ||
       (sValue.substring(j,j+1) == "/") ||
       (sValue.substring(j,j+1) == "$") ||
       (sValue.substring(j,j+1) == "=") ||
       (sValue.substring(j,j+1) == "#") ||
       (sValue.substring(j,j+1) == "?") ||
       (sValue.substring(j,j+1) == "¿") ||
       (sValue.substring(j,j+1) == "<") ||
       (sValue.substring(j,j+1) == ">") ||
       (sValue.substring(j,j+1) == "\"")) {
      isOK = false;
     }
     if (sValue.substring(j,j+1) == "@") iArr += 1;
     if (sValue.substring(j,j+1) == ".") iDot += 1;
  }
  if (iArr != 1) isOK = false;
  if (iDot < 1) isOK = false;
  return isOK;
}

function CheckPriceAlert(){
  var dd="";
  if (!isEmail(document.frmPriceAlert.Email.value)) dd += "\nEmail Address";
  if (!isFloat(document.frmPriceAlert.Price.value)) dd += "\nPrice";
  if (dd == ""){
    document.frmPriceAlert.submit();
  }else{
    alert("Please fill the following fields to continue:\n" + dd);
  }
}
