﻿
function  restvalues()
{
    //MasterForm.reset();
}

function checkEmail(emailAddr)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailAddr.value))
	{
		return (true)
	}
	alert("Invalid E-mail Address! Please re-enter.")
	emailAddr.focus();
	emailAddr.select();
	return false;
}
	
function ValidateContactUsForm1()
{
alert("test1");
}

function ValidateContactUsForm(name, email, state, otherstate, country)
{      
    if(name.value=="")
    {
        alert("Please enter name");
        name.focus();
        name.select();
        return false;
    }
    if(email.value=="")
    {
         alert("Please enter valid email address");
        email.focus();
        email.select();
        return false;
    }
    else
    {
        if(!checkEmail(email))
        {
            return false;
        }
    }    
    if(state.options[state.selectedIndex].value=="" && otherstate.value=="")
    {
        alert("Please select/enter city name");
        otherstate.value="";
        return false;
    }
    
    if(state.options[state.selectedIndex].value!="" && otherstate.value!="")
    {
        alert("Not necessary to put both state name and other state, please spciffy one");
        otherstate.value="";
        return false;
    }
    if(country.options[country.selectedIndex].value=="")
    {
        alert("Please select country");
        country.focus();
        return false;
    }
    return true;
}

function resetContactUsForm(name, email, company, address1, address2, phone, city, state, otherstate, country, zip, comment)
{
    name.value="";
    email.value="";
    company.value="";
    address1.value="";
    address2.value="";
    phone.value="";
    city.value="";
    state.value="";
    otherstate.value="";
    country.value="";
    zip.value="";
    comment.value="";
    return false;
}


function ValidateEmailAddressForForgetPassword(email)
{
    if(email.value=="")
    {
        alert("Please enter a valid email address");
        email.select();
        email.focus();
        return false;
    }
    else if(checkEmail(email)==false)
    {
        email.value="";
        email.select();
        email.focus();
        return false;
    }
    return true;    
}

function validateCheckoutCustomer(title, fname, email, pass, cpass)
{   
    if(title.options[title.selectedIndex].value=="")
    {
        alert("Please select name title");
        title.focus();
        return false;
    }
    if(fname.value=="")
    {
        alert("Please enter First Name");
        fname.select();
        fname.focus();
        return false;
    }
    if(email.value=="")
    {
        alert("Please enter a valid email address");
        email.select();
        email.focus();
        return false;
    }
     else if(checkEmail(email)==false)
    {
        email.value="";
        email.select();
        email.focus();
        return false;
    }
    if(pass.value=="")
    {
        alert("Please enter password");
        pass.select();
        pass.focus();
        return false;
    }
    if(cpass.value=="")
    {
        alert("Please enter confirm password");
        cpass.select();
        cpass.focus();
        return false;
    }
     if(pass.value!=cpass.value)
    {
        alert("Password mismatch, please re-enter confirm password");
        cpass.select();
        cpass.focus();
        return false;
    }
    return true;
}


function validateCheckoutLogin(email, pass)
{
    if(email.value=="")
    {
        alert("Please enter a valid email address");
        email.select();
        email.focus();
        return false;
    }
     else if(checkEmail(email)==false)
    {
        email.value="";
        email.select();
        email.focus();
        return false;
    }
     if(pass.value=="")
    {
        alert("Please enter your password");
        pass.select();
        pass.focus();
        return false;
    }
    return true;
}

function selectShipAddress(rdo, chk, sfn, sln, sadd1, sadd2, scity, sstate, sothercity, szip, scountry, cmbShipAddress )
{
    if(rdo.checked)
    {
        cmbShipAddress.disabled=false;
        chk.checked=false;
        sfn.value="";
        sln.value="";
        //sphone.value="";
        sadd1.value="";
        sadd2.value="";
        scity.value="";
        sstate.selectedIndex=0;
        sothercity.value="";
        szip.value="";        
        scountry.selectedIndex=0;
    }
}

function enableDisableControl(cmbPayment, giftCert, cmbCartType, cartNo, securityNo, expMonth, expYear)
{
    var isGift=false;
    if(cmbPayment.options[cmbPayment.selectedIndex].value=="10")
    {
        isGift=true;
    }
    
    giftCert.value="";
    cartNo.value="";
    securityNo.value="";    
    
    giftCert.disabled = !isGift;
    cmbCartType.disabled=isGift;
    cartNo.disabled=isGift;
    securityNo.disabled=isGift;
    expMonth.disabled=isGift;
    expYear.disabled=isGift;
        
    if(isGift==false)
    {
        cmbCartType.focus();
    }
    else
    {
        giftCert.select();
        giftCert.focus();
    }
}



function ValidateTellAFriend(fromName, fromEmail, toEmail)
{      
    if(fromName.value=="")
    {
        alert("Please enter from name");
        fromName.focus();
        fromName.select();
        return false;
    }
    if(fromEmail.value=="")
    {
        alert("Please enter your valid fromemail address");
        fromEmail.focus();
        fromEmail.select();
        return false;
    }
    else
    {
        if(!checkEmail(fromEmail))
        {
            return false;
        }
    }    
    if(toEmail.value=="")
    {
        alert("Please enter your valid toemail address");
        toEmail.focus();
        toEmail.select();
        return false;
    }
    else
    {
        if(!checkEmail(toEmail))
        {
            return false;
        }
    }    

    return true;
}

function validateOrderForm()
{
    var txtBFName = document.getElementById("ctl00_ContentPlaceHolder1_txtBFName");
    if(txtBFName.value=="")
    {
        alert("Please enter Billing First Name");
        txtBFName.focus();
        txtBFName.select();
        return false;
    }
     var txtBLName = document.getElementById("ctl00_ContentPlaceHolder1_txtBLName");
    if(txtBLName.value=="")
    {
        alert("Please enter Billing Last Name");
        txtBLName.focus();
        txtBLName.select();
        return false;
    }
    var txtBEmail = document.getElementById("ctl00_ContentPlaceHolder1_txtBEmail");
    if(txtBEmail.value=="")
    {
        alert("Please enter Billing Email address");
        txtBEmail.focus();
        txtBEmail.select();
        return false;
    }
    else
    {
        if(!checkEmail(txtBEmail))
        {
            return false;
        }
    }
    var txtBPhone = document.getElementById("ctl00_ContentPlaceHolder1_txtBPhone");
    if(txtBPhone.value=="")
    {
        alert("Please enter Billing Phone");
        txtBPhone.focus();
        txtBPhone.select();
        return false;
    }
    var txtBAddress1 = document.getElementById("ctl00_ContentPlaceHolder1_txtBAddress1");
    if(txtBAddress1.value=="")
    {
        alert("Please enter Billing Address1");
        txtBAddress1.focus();
        txtBAddress1.select();
        return false;
    }
    var txtBCity = document.getElementById("ctl00_ContentPlaceHolder1_txtBCity");
    if(txtBCity.value=="")
    {
        alert("Please select Billing City");
        txtBCity.focus();
        txtBCity.select();
        return false;
    }
   var cmbBCountry = document.getElementById("ctl00_ContentPlaceHolder1_cmbBCountry");
    if(cmbBCountry.options[cmbBCountry.selectedIndex].value=="")
    {
        alert("Please select Billing Country");
        cmbBCountry.focus();
        return false;
    }
    var cmbBState = document.getElementById("ctl00_ContentPlaceHolder1_cmbBState");
    if(cmbBCountry.options[cmbBCountry.selectedIndex].text =="UNITED STATES" && cmbBState.options[cmbBState.selectedIndex].value =="")
    {
        alert("Please select Billing State Code");
        cmbBState.focus();
        return false;
    }
    var txtBZip = document.getElementById("ctl00_ContentPlaceHolder1_txtBZip");
    if(txtBZip.value=="")
    {
        alert("Please enter Billing Zip Code");
        txtBZip.focus();
        txtBZip.select();
        return false;
    }

    var txtSFName = document.getElementById("ctl00_ContentPlaceHolder1_txtSFName");
    if(txtSFName.value=="")
    {
        alert("Please enter Shipping First name");
        txtSFName.focus();
        txtSFName.select();
        return false;
    }   
    var txtSLName = document.getElementById("ctl00_ContentPlaceHolder1_txtSLName");
    if(txtSLName.value=="")
    {
        alert("Please enter Shipping Last name");
        txtSLName.focus();
        txtSLName.select();
        return false;
    }   
    var txtSAddressl = document.getElementById("ctl00_ContentPlaceHolder1_txtSAddressl");
    if(txtSAddressl.value=="")
    {
        alert("Please enter Shipping Addressl");
        txtSAddressl.focus();
        txtSAddressl.select();
        return false;
    }  
    var txtSCity = document.getElementById("ctl00_ContentPlaceHolder1_txtSCity");
    if(txtSCity.value=="")
    {
        alert("Please enter Shipping City");
        txtSCity.focus();
        txtSCity.select();
        return false;
    } 
       
     var cmbSCountry = document.getElementById("ctl00_ContentPlaceHolder1_cmbSCountry");
    if(cmbSCountry.options[cmbSCountry.selectedIndex].value=="")
    {
        alert("Please select Shipping country name");
        cmbSCountry.focus();
        return false;
    }
    var cmbSState = document.getElementById("ctl00_ContentPlaceHolder1_cmbSState");
    if(cmbSCountry.options[cmbSCountry.selectedIndex].text=="UNITED STATES" && cmbSState.options[cmbSState.selectedIndex].value =="")
    {
        alert("Please select Shipping state name");
        cmbSState.focus();
        return false;
    } 
     var txtSZip = document.getElementById("ctl00_ContentPlaceHolder1_txtSZip");
    if(txtSZip.value=="")
    {
        alert("Please enter Shipping Zip");
        txtSZip.focus();
        txtSZip.select();
        return false;
    } 


    var cmdShippingMethod = document.getElementById("ctl00_ContentPlaceHolder1_cmdShippingMethod");
    if(cmdShippingMethod.options[cmdShippingMethod.selectedIndex].value=="0")
    {
        alert("Please select Shipping method");
        cmdShippingMethod.focus();
        return false;
    }
    
    var cmbPaymentType = document.getElementById("ctl00_ContentPlaceHolder1_cmbPaymentType");
    if(cmbPaymentType.options[cmbPaymentType.selectedIndex].value=="10")
    {
        var txtGiftCertificateNo = document.getElementById("ctl00_ContentPlaceHolder1_txtGiftCertificateNo");
        if(txtGiftCertificateNo.value=="")
        {
            alert("Please enter Gift Certificate");
            txtGiftCertificateNo.focus();
            txtGiftCertificateNo.select();
            return false;
        }
    }    
    var cmbPaymentType = document.getElementById("ctl00_ContentPlaceHolder1_cmbPaymentType");
    if(cmbPaymentType.options[cmbPaymentType.selectedIndex].value=="1")
    {
        var cmbCardType = document.getElementById("ctl00_ContentPlaceHolder1_cmbCardType");
        if(cmbCardType.options[cmbCardType.selectedIndex].value=="" || cmbCardType.options[cmbCardType.selectedIndex].value=="Select One")
        {
            alert("Please enter card type");
            cmbCardType.focus();
            return false;
        }
        var txtCardNumber = document.getElementById("ctl00_ContentPlaceHolder1_txtCardNumber");
        if(txtCardNumber.value=="")
        {
            alert("Please enter card number");
            txtCardNumber.focus();
            txtCardNumber.select();
            return false;
        }
         if(checknumber(txtCardNumber)==false)
        {
            return false;
        }
        var txtSecurityNo = document.getElementById("ctl00_ContentPlaceHolder1_txtSecurityNo");
        if(txtSecurityNo.value=="")
        {
            alert("Please enter card security number number");
            txtSecurityNo.focus();
            txtSecurityNo.select();
            return false;
        }
        if(checknumber(txtSecurityNo)==false)
        {
            return false;
        }
    }
    return true;
}

