﻿function gototext(txtgotopage,totpage)
 {
     //alert(txtgotopage.value);
     if (emptyField(txtgotopage)) {
        alert('Please Enter Page No.');
        txtgotopage.focus();
        return false;
    }

    if (txtgotopage.value < 1) {
        alert('Page No. Must Be Greater Then Zero.');
        txtgotopage.focus();
        return false;
    }

    if (!isInt(txtgotopage.value)) {
        alert('Please Enter Integer Value.');
        txtgotopage.focus();
        return false;
    }
    if (parseInt(totpage) < parseInt(txtgotopage.value))
     {
        alert('Enter Value Less Then Total Page No.');
        txtgotopage.focus();
        return false;
    }

}

//*************Add to cart for msg popup inquiry***********************//
function valid_inquiry(txtEmailId, txtyouremail, txtmessage) {
    if (emptyField(txtEmailId)) {
        alert('Please enter Recipient EmailId');
        txtEmailId.focus();
        return false;
    }
    else {
       	if (!validEmailId(txtEmailId.value)){       
            alert('Please enter valid Recipient EmailId');
            txtEmailId.focus();
            txtEmailId.select();
            return false;
        }
    }

    if (emptyField(txtyouremail)) {
        alert('Please enter your EmailId');
        txtyouremail.focus();
        return false;
    }
    else {
        if (!validEmailId(txtyouremail.value)) {
            alert('Please enter your valid EmailId');
            txtyouremail.focus();
            txtyouremail.select();
            return false;
        }
    }
    if (emptyField(txtmessage)) {
        alert('Please enter Message');
        txtmessage.focus();
        return false;
    }

}


function viewtable(chksend, txtEmail, txtcomment) {
    if (chksend.checked == true) {
        txtEmail.disabled = false;
        txtcomment.disabled = false;
    }
    else {
        txtEmail.value = '';
        txtcomment.value = '';
        txtEmail.disabled = true;
        txtcomment.disabled = true;

    }
}

function valid_giftvoucher(chksend, txtEmail, txtcomment) {
    if (chksend.checked == true) {
        if (emptyField(txtEmail)) {
            alert('Please enter the email of the person to whom you want to send this gift voucher.');
            txtEmail.focus();
            return false;
        }
        if (!validEmailId(txtEmail.value)) {
            alert('Please enter your valid email.');
            txtEmail.focus();
            return false;
        }
        if (emptyField(txtcomment)) {
            alert('Please enter your message');
            txtcomment.focus();
            return false;
        }
    }
}





function validQuantity() {
    var objDataList = document.getElementById("_ctl0_ContentPlaceHolder1_DataGrid1");
    var inputcount = objDataList.getElementsByTagName("input").length;
    for (var i = 0; i < inputcount; i++) {
        var input = objDataList.getElementsByTagName("input")[i];
        if (input.getAttribute("type") == "text") {
            if (emptyField(input)) {
                alert('Please Enter Quantity');
                input.focus();
                return false;
            }
            if (!isInt(input.value)) {
                alert('Please Enter Integer Value.');
                input.focus();
                return false;
            }
            if (parseInt(input.value) == 0) {
                alert('Quantity Must Be Greater Then Zero.');
                input.focus();
                return false;
            }
        }
    }
}



//******Billing Shipping info**************************////////

function set_shippingInfo(chkShip, txtBillFname, txtBillLname, txtBillAddr1, txtBillAddr2, txtBillCity, txtBillState, ddlBillCountry, txtBillPost, txtBillPhone, txtShipFname, txtShipLname, txtShipAddr1, txtShipAddr2, txtShipCity, txtShipState, ddlShipCountry, txtShipPost, txtShipPhone) {
    if (chkShip.checked == true) {
        txtShipFname.value = txtBillFname.value;
        txtShipLname.value = txtBillLname.value;
        txtShipAddr1.value = txtBillAddr1.value;
        txtShipAddr2.value = txtBillAddr2.value;
        txtShipCity.value = txtBillCity.value;
        txtShipState.value = txtBillState.value;
        ddlShipCountry.value = ddlBillCountry.value;
        txtShipPost.value = txtBillPost.value;
        txtShipPhone.value = txtBillPhone.value;
        
    }
    else if (chkShip.checked == false) {
        txtShipFname.value = "";
        txtShipLname.value = "";
        txtShipAddr1.value = "";
        txtShipAddr2.value = "";
        txtShipCity.value = "";
        txtShipState.value = "";
        ddlShipCountry.value = "0";
        txtShipPost.value = "";
        txtShipPhone.value = "";            
        
    }
}
function check_billingInfo(chkShip, txtBillFname, txtBillLname, txtBillAddr1, txtBillAddr2, txtBillCity, txtBillState, ddlBillCountry, txtBillPost, txtBillPhone, txtShipFname, txtShipLname, txtShipAddr1, txtShipAddr2, txtShipCity, txtShipState, ddlShipCountry, txtShipPost, txtShipPhone) {
    var arg;
    var flag;
    // check billing info fields
    if (emptyField(txtBillFname)) {
        alert("Enter your First Name");
        txtBillFname.focus();
        return false;
    }
    if (emptyField(txtBillLname)) {
        alert("Enter your Last Name");
        txtBillLname.focus();
        return false;
    }
    if (emptyField(txtBillAddr1)) {
        alert("Enter your Address Line 1");
        txtBillAddr1.focus();
        return false;
    }
    if (emptyField(txtBillCity)) {
        alert("Enter your Town/City");
        txtBillCity.focus();
        return false;
    }
    if (emptyField(txtBillState)) {
        alert("Enter your County / State");
        txtBillState.focus();
        return false;
    }
   
    if (ddlBillCountry.value == "0") {
        alert('Select Your Country.');
        ddlBillCountry.focus();
        return false;
    }

    if (emptyField(txtBillPost)) {
        alert('Enter your Post Code/Zip');
        txtBillPost.focus();
        return false;
    }
    
    if (emptyField(txtBillPhone)) {
        alert('Enter your Telephone.');
        txtBillPhone.focus();
        return false;
    }
   
   
   
    
    // check shipping info fields
    if (emptyField(txtShipFname)) {
        alert("Enter your First Name");
        txtShipFname.focus();
        return false;
    }
    if (emptyField(txtShipLname)) {
        alert("Enter your Last Name");
        txtShipLname.focus();
        return false;
    }

    if (emptyField(txtShipAddr1)) {
        alert("Enter your Address Line 1");
        txtShipAddr1.focus();
        return false;
    }
    if (emptyField(txtShipCity)) {
        alert("Enter your Town/City");
        txtShipCity.focus();
        return false;
    }
    if (emptyField(txtShipState)) {
        alert("Enter your County / State");
        txtShipState.focus();
        return false;
    }
    if (ddlShipCountry.value == "0") {
        alert('Select Your Country.');
        ddlShipCountry.focus();
        return false;
    }
    
    
    if (emptyField(txtShipPost)) {
        alert('Enter Your Post Code/Zip');
        txtShipPost.focus();
        return false;
    }
    if (emptyField(txtShipPhone)) {
        alert('Enter your Telephone.');
        txtShipPhone.focus();
        return false;
    }
  
}



//*****Credit card validation**********//

function cc_fields(ddlcard, txtccno, txtcvvno, ddlvalidfrom, ddlvalidyr, ddlmonth, ddlyear) {
    if (ddlcard.value == "0") {
        alert('Please Select Credit Card Type');
        ddlcard.focus();
        return false;
    }


    if (emptyField(txtccno)) {
        alert('Please Enter Credit Card number');
        txtccno.focus();
        return false;
    }
    if (!isNum(txtccno.value)) {
        alert('Please Enter Credit Card Number In Numeric Value.');
        txtccno.focus();
        return false;
    }
    if (emptyField(txtcvvno)) {
        alert('Please Enter Credit Card Validation Code ');
        txtcvvno.focus();
        return false;
    }
    if (!isNum(txtcvvno.value)) {
        alert('Please Enter Card Validation Code In Numeric Value.');
        txtcvvno.focus();
        return false;
    }

    var mydate = new Date()
    var year = mydate.getYear()
    if (year < 1000) year += 1900
    var day = mydate.getDay()
    var month = mydate.getMonth() + 1
    var daym = mydate.getDate()
    // ddlvalidfrom, ddlvalidyr, ddlmonth, ddlyear
    if (ddlvalidfrom.value > month && ddlvalidyr.value == year) {
        alert('Credit Card Valid Month should be less than current month');
        ddlvalidfrom.focus();
        return false;
    }
    if (ddlmonth.value < month && ddlyear.value == year) {
        alert('Credit Card Expiration Month should not be less than current month');
        ddlmonth.focus();
        return false;
    }
}


