// Validation rounites for Advansys eCommerce with CMS

function CheckSearch(form){
	if (form.search.value.length <=1){alert('Please enter one or more keywords'); return false;}
}

function CheckCustomerLogin(form){
	if (form.email.value=='') {alert('Please enter your email address');form.email.focus(); return false;}
	if (!CheckEmail(form.email.value)) {alert('Please enter a valid email address');form.email.focus(); return false;}
	if (form.password.value=='') {alert('Please enter your password'); form.password.focus(); return false;}
}

function CheckCustomerData(form){
	if (form.title.value=='') {alert('Please select a title'); form.title.focus(); return false;}
	if (form.firstname.value=='') {alert('Please enter your first name'); form.firstname.focus(); return false;}
	if (form.lastname.value=='') {alert('Please enter your last name'); form.lastname.focus(); return false;}
	if (form.address1.value=='') {alert('Please enter your address'); form.address1.focus(); return false;}
	if (form.city.value=='') {alert('Please enter your town or city'); form.city.focus(); return false;}
	if (form.county.value=='') {alert('Please enter your county'); form.county.focus(); return false;}
	if (form.postcode.value=='') {alert('Please enter your postcode'); form.postcode.focus(); return false;}
	if (form.country.value=='') {alert('Please select your country of residence'); form.country.focus(); return false;}
	if (form.firstname.value=='') {alert('Please enter your first name'); form.firstname.focus(); return false;}
	if (form.telephone.value=='') {alert('Please enter a contact telephone number'); form.telephone.focus(); return false;}
	if (form.email.value=='') {alert('Please enter your email address');form.email.focus(); return false;}
	if (!CheckEmail(form.email.value)) {alert('Please enter a valid email address');form.email.focus(); return false;}
	if (form.password.value=='') {alert('Please enter a password');form.password.focus(); return false;}
}

function CheckCardData(form){

	if (form.VPBillingHouseNumber.value=='') {alert('Please enter your house number name'); form.VPBillingHouseNumber.focus(); return false;}
	if (form.VPBillingStreet.value=='') {alert('Please enter your street'); form.VPBillingStreet.focus(); return false;}
	if (form.VPBillingCity.value=='') {alert('Please enter your town or city'); form.VPBillingCity.focus(); return false;}
	if (form.VPBillingState.value=='') {alert('Please enter your state'); form.VPBillingState.focus(); return false;}
	if (form.VPBillingPostCode.value=='') {alert('Please enter your postcode'); form.VPBillingPostCode.focus(); return false;}
	if (form.VPBillingPhoneNumber.value=='') {alert('Please enter a contact telephone number'); form.VPBillingPhoneNumber.focus(); return false;}
	if (form.VPBillingEmail.value=='') {alert('Please enter your email address');form.VPBillingEmail.focus(); return false;}
	if (form.VPCardNumber.value==''){alert('Please specify the Card Number');form.VPCardNumber.focus();  return false;}
	if (form.VPCardName.value==''){alert('Please specify the Card Name'); form.VPCardName.focus(); return false;}
	if (form.VPStartDateMM.value==''){alert('Please specify the Start Date');form.VPStartDateMM.focus();  return false;}
	if (form.VPStartDateMM.value==''){alert('Please specify the Start Date');form.VPStartDateMM.focus();  return false;}
	if (form.VPExpiryDateMM.value==''){alert('Please specify the Expiry Date');form.VPExpiryDateMM.focus();  return false;}
	if (form.VPExpiryDateYY.value==''){alert('Please specify the Expiry Date'); form.VPExpiryDateYY.focus(); return false;}
	if (form.VPCV2.value==''){alert('Please specify the CVV (last 3 digits on the reverse of you card)');form.VPCV2.focus();  return false;}
	return true;
}

function CheckDeliveryData(form){
	if (form.delname.value==''){alert('Please specify the Delivery Name'); return false;}
	if (form.deladdress1.value==''){alert('Please specify the Delivery Address'); return false;}
	if (form.delcity.value==''){alert('Please specify the Delivery City'); return false;}
	if (form.delcountrycode.value==''){alert('Please specify the Delivery Country'); return false;}
	return true;
}

function CheckOrder(form){
	if (!form.termsagreed.checked){ alert('You must agree to the terms and conditions before placing an order'); return false;}
	return true;
}
	
function CheckEmail(address) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(address)){
	return (true)
	}
	return (false)
}

function CheckIntegerNow(Event) {
		  if   ((Event.keyCode > 7 && Event.keyCode < 10) || (Event.keyCode > 27 && Event.keyCode < 30) || Event.keyCode > 47 && Event.keyCode < 58)
			{
				Event.returnValue = Event.keyCode ;
			}
			else
			{
				Event.cancelBubble = true ;
				Event.returnValue = false ;
			}
}


function ValidateCallback(form){
if (form.name.value=='') {alert('Please fill in your name'); form.name.focus(); return false}
if (form.phone.value=='') {alert('Please fill in your contact telephone number'); form.phone.focus(); return false}
if (form.email.value=='') {alert('Please fill in your email address'); form.email.focus(); return false}
if (!CheckEmail(form.email.value)) {alert('Invalid email address'); form.email.focus(); return false}
if (form.subject.value=='') {alert('Please enter a subject'); form.subject.focus(); return false}
if (form.enquiry.value=='') {alert('Please enter enquiry details'); form.enquiry.focus(); return false}
if (form.captcha.value=='') {alert('Please enter the security code'); form.captcha.focus(); return false}
}


//Added by srini.
function acceptOnlyNumbers()
{  
	var isNS4 = (navigator.appName=="Netscape")?1:0;
	if(!isNS4){if(window.event.keyCode < 45 || window.event.keyCode > 57) event.returnValue = false;}else{if(event.which < 45 || event.which > 57) return false;}
}


function ShowQuoteUploadform(option)
{
    if(option.value == 'LABELS') 
    {
        document.getElementById('frmLabels').style.display="block";
        document.getElementById('frmTags').style.display="none";
    }
    else if(option.value == 'TAGS')
    {
       document.getElementById('frmLabels').style.display="none";
       document.getElementById('frmTags').style.display="block";       
    }
    else
    {
      document.getElementById('frmLabels').style.display="none";
      document.getElementById('frmTags').style.display="none";
    }
}

function Quote_Supplied_on(option)
{
    if(option.value=='Rolls')
    {
        document.getElementById('rolls').style.display = "block"
        document.getElementById('sheets').style.display = "none"
    }
    else if(option.value=='Sheets')
    {    
        document.getElementById('sheets').style.display = "block"
        document.getElementById('rolls').style.display = "none"
    }
    else
    {
        document.getElementById('sheets').style.display = "none" 
        document.getElementById('rolls').style.display = "none"
    }       
}

function CheckFormLabels(form)
{
    if (form.description_title.value=='') {alert('Please fill in Description / Title'); form.description_title.focus(); return false}
    if (form.label_size.value=='') {alert('Please fill in Label Size'); form.label_size.focus(); return false}
    if (form.face_material.value=='') {alert('Please select Face Material'); form.face_material.focus(); return false}
    if (form.face_material.value=='Other')
    {
        if (form.Other_Face_Material.value=='') {alert('Please fill in Face Material'); form.Other_Face_Material.focus(); return false}
    }
    if (form.adhesive.value=='') {alert('Please select adhesive'); form.adhesive.focus(); return false}
    if (form.adhesive.value=='Other')
    {
        if (form.Other_Adhesive.value=='') {alert('Please fill in adhesive'); form.Other_Adhesive.focus(); return false}
    }
    //if (form.unsure_label.value=='') {alert('Please fill in Description / Title'); form.unsure_label.focus(); return false}
    if (form.supplied_on.value=='') {alert('Please select Supplied on'); form.supplied_on.focus(); return false}
    if (form.is_overprinted.value=='') {alert('Please select Overprinted option'); form.is_overprinted.focus(); return false}
    if (form.is_overprinted.value=='Yes')
    {
        if(form.is_overprinted_yes.value=='') {alert('Please select Overprinted option'); form.is_overprinted_yes.focus(); return false}
    }
    if (form.no_of_colours_on_face.value=='') {alert('Please fill in No of colours on face'); form.no_of_colours_on_face.focus(); return false}
    if (form.no_of_colours_on_reverse.value=='') {alert('Please fill in No of colours on reverse'); form.no_of_colours_on_reverse.focus(); return false}
    if (form.finishing.value=='') {alert('Please select finishing option'); form.finishing.focus(); return false}
    if (form.finishing.value=='Other')
    {
        if(form.Other_Finishing.value=='') {alert('Please fill in finihing'); form.Other_Finishing.focus(); return false}
    }
    if (form.special_features.value=='') {alert('Please select special features'); form.special_features.focus(); return false}
    if (form.How_many_sorts_are_there.value=='') {alert('Please fill in How many sorts are there '); form.How_many_sorts_are_there.focus(); return false}
    if (form.Quantity_required_per_sort.value=='') {alert('Please fill in Quantity required per sort '); form.Quantity_required_per_sort.focus(); return false}
    if (form.Any_additional_information.value=='') {alert('Please fill in Any additional information'); form.Any_additional_information.focus(); return false}
    if (form.Name.value=='') {alert('Please fill in Name'); form.Name.focus(); return false}
    if (form.mail.value=='') {alert('Please fill in mail address'); form.mail.focus(); return false}
    if (!CheckEmail(form.mail.value)) {alert('Invalid email address'); form.mail.focus(); return false}
    if (form.Phone.value=='') {alert('Please fill in Phone Number'); form.Phone.focus(); return false}
}

                                   
function CheckFormTags(form)
{
    if (form.description_title.value=='') {alert('Please fill in Description / Title'); form.description_title.focus(); return false}
    if (form.tag_size.value=='') {alert('Please fill in Tag Size'); form.tag_size.focus(); return false}
    if (form.shape.value=='') {alert('Please select shape'); form.shape.focus(); return false}
    if (form.material.value=='') {alert('Please select material'); form.material.focus(); return false}
    if (form.material.value=='Other')
    {
        if (form.Other_Face_Material.value=='') {alert('Please fill in Material'); form.Other_Face_Material.focus(); return false}
    }
    //if (form.unsure_label.value=='') {alert('Please fill in Description / Title'); form.unsure_label.focus(); return false}
    if (form.how_many_colours_to_face.value=='') {alert('Please fill in how many colours to face'); form.how_many_colours_to_face.focus(); return false}
    if (form.how_many_colours_on_reverse.value=='') {alert('Please fill in how many colours on reverse'); form.how_many_colours_on_reverse.focus(); return false}
    if (form.punched_hole.value=='') {alert('Please select punched hole'); form.punched_hole.focus(); return false}
    if (form.strung.value=='') {alert('Please select strung'); form.strung.focus(); return false}
    if (form.strung.value=='Yes')
    {
        if (form.yes_strung.value=='') {alert('Please select strung option'); form.yes_strung.focus(); return false}
        else if(form.yes_strung.value=='Other')
        {
            if(form.yes_other_strung.value=='')
            {
                alert('Please fill in strung '); form.yes_other_strung.focus(); return false
            }   
        }
    }
    if (form.length_of_string_approx.value=='') {alert('Please fill in Length of string approx'); form.length_of_string_approx.focus(); return false}
    if (form.eyeleted.value=='') {alert('Please select Eyeleted'); form.eyeleted.focus(); return false}
    
    if (form.How_many_sorts_are_there.value=='') {alert('Please fill in How many sorts are there '); form.How_many_sorts_are_there.focus(); return false}
    if (form.Quantity_required_per_sort.value=='') {alert('Please fill in Quantity required per sort '); form.Quantity_required_per_sort.focus(); return false}
    if (form.Any_additional_information.value=='') {alert('Please fill in Any additional information'); form.Any_additional_information.focus(); return false}
    
    if (form.Name.value=='') {alert('Please fill in Name'); form.Name.focus(); return false}
    if (form.mail.value=='') {alert('Please fill in mail address'); form.mail.focus(); return false}
    if (!CheckEmail(form.mail.value)) {alert('Invalid email address'); form.mail.focus(); return false}
    if (form.Phone.value=='') {alert('Please fill in Phone Number'); form.Phone.focus(); return false}
}                                   


