﻿// JScript File
function getCompany(companyselect)
{
    var selectedvalue = document.frmcompany.ddl_company.value;
    document.frmcompany.searchval.value = selectedvalue;
    if(selectedvalue != "0")
    {
	    document.frmcompany.submit();
    }
}

function getLine(lineselect)
{
    var selectedvalue = document.frmline.ddl_lines.value;
    document.frmline.searchval.value = selectedvalue;
    if(selectedvalue != "0")
    {
	    document.frmline.submit();
    }
}

function getHours(HoursSelect)
{
    var selectedvalue = document.frmhours.ddl_hours.value;
    document.frmhours.searchval.value = selectedvalue;
    if(selectedvalue != "0")
    {
	    document.frmhours.submit();
    }
}

function EmailSubscripton()
{
    var selectedvalue = document.emailsubscribe.email.value;
    if(selectedvalue == "" || selectedvalue.length == 0)
    {
        alert('please enter a valid email address');
        return false;
    }
    return true;
}


function ContactCaballero()
{
    var uname = document.frmcontact.GuestName.value;
    var ucompany = document.frmcontact.GuestCompany.value;
    var uaddress = document.frmcontact.GuestAddress.value;
    var ucity = document.frmcontact.GuestCity.value;
    var ustate = document.frmcontact.GuestState.value;
    var uzip = document.frmcontact.GuestZip.value;
    var ucountry = document.frmcontact.GuestCountry.value;
    var uphone = document.frmcontact.GuestPhone.value;
    var uemail = document.frmcontact.GuestEmail.value;
    var umessage = document.frmcontact.GuestMessage.value;
    
    var badChar = "!@#$%^&;*()-=+[]{}\\|;:'\",./<>_`~?"
    var badNum = "345678"
    var badNum2 = "12345678"
    
    if (uname.length < 1) {
        alert("You must supply your Name!")
        return false
    }
    
    if (ucompany.length < 1) {
        alert("You must supply your Company Name!")
        return false
    }


     if (uaddress.length < 1) {
        alert("You must supply your Address!")
        return false
    }

     if (ucity.length < 1) {
        alert("You must supply your City!")
        return false
    }

     if (uzip.length < 1) {
        alert("You must supply your Zip Code!")
        return false
    }   
    

     if (ucountry.length < 1) {
        alert("You must supply your Country!")
        return false
    } 
    
    if(ucountry == "United States" & ustate.length < 1)
    {
        alert("US Address must supply State!")
        return false        
    }

     if (uphone.length < 1) {
        alert("You must supply your Phone!")
        return false
    } 
    
    
     if (uemail.length < 1) {
        alert("You must supply your email!")
        return false
    }               
    
    

	for(var j = 0; j <= badChar.length - 1; j++) {
    	if (uname.charAt(0) == badChar.charAt(j)){
    	 	alert("you have invalid characters in your name")
    	 	return false
		}
	}
	

    if (uzip.length!=5 & uzip.length!=10 & ucountry == "United States") {
        alert("Please enter your 5 digit or 5 digit+4 zip code.");
        return false;
    }
    

    var em_val=/^(.+)@\w+(\.\w+?)/
    if(em_val.test(uemail)==false) {
        alert(uemail +" is invalid email address")
        return false
    }
        
    return true;
    	
}

function CustomerCaballero()
{
    var uname = document.frmcustomer.ContactName.value;
    var upass = document.frmcustomer.ContactPass.value;
    var uconpass = document.frmcustomer.ContactConfirmPass.value;
    var uconphone = document.frmcustomer.ContactPhone.value;
    var uemail = document.frmcustomer.ContactEmail.value;
    
    var ucompany = document.frmcustomer.ContactCompany.value;
    var uaddress = document.frmcustomer.ContactAddress.value;
    var ucity = document.frmcustomer.ContactCity.value;
    var ustate = document.frmcustomer.ContactState.value;
    var uzip = document.frmcustomer.ContactZip.value;
    var ucountry = document.frmcustomer.ContactCountry.value;
    var uphone = document.frmcustomer.CompanyPhone.value;

    var badChar = "!@#$%^&*()-=+[]{}\\|;:'\",./<>_`~?"
    var badNum = "345678"
    var badNum2 = "12345678"
    var em_val=/^(.+)@\w+(\.\w+?)/
    
    if (uname.length < 1) {
        alert("You must supply your Name!")
        return false
    }
    
    if (upass.length < 5) {
        alert("password must be longer then 5 charecters!")
        return false
    }
        
    if (upass != uconpass) {
        alert("passwords do not match")
        return false
    }
      
     if (uconphone.length < 1) {
        alert("You must supply your Phone!")
        return false
    } 
    
    if(em_val.test(uemail)==false) {
        alert(uemail +" is invalid email address")
        return false
    }
              
            
    if (ucompany.length < 1) {
        alert("You must supply your Company Name!")
        return false
    }


     if (uaddress.length < 1) {
        alert("You must supply your Address!")
        return false
    }

     if (ucity.length < 1) {
        alert("You must supply your City!")
        return false
    }

     if (uzip.length < 1) {
        alert("You must supply your Zip Code!")
        return false
    }   
    

     if (ucountry.length < 1) {
        alert("You must supply your Country!")
        return false
    } 
    
    if(ucountry == "United States" & ustate.length < 1)
    {
        alert("US Address must supply State!")
        return false        
    }

     if (uphone.length < 1) {
        alert("You must supply your Phone!")
        return false
    } 
    
    
     if (uemail.length < 1) {
        alert("You must supply your email!")
        return false
    }               
    
    

	for(var j = 0; j <= badChar.length - 1; j++) {
    	if (uname.charAt(0) == badChar.charAt(j)){
    	 	alert("you have invalid characters in your name")
    	 	return false
		}
	}
	

    if (uzip.length!=5 & uzip.length!=10 & ucountry == "United States") {
        alert("Please enter your 5 digit or 5 digit+4 zip code.");
        return false;
    }
    
    return true;    
}
