

function emptyvalidation(entered, alertbox)
{
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
} 




function emailvalidation(entered, alertbox)
{
with (entered)
{
apos=value.indexOf("@"); 
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
} 


 //Created / Generates the captcha function    
    function DrawCaptcha()
    {
        var a = Math.ceil(Math.random() * 10)+ '';
        var b = Math.ceil(Math.random() * 10)+ '';       
        var c = Math.ceil(Math.random() * 10)+ '';  
        var d = Math.ceil(Math.random() * 10)+ '';  
        var e = Math.ceil(Math.random() * 10)+ '';  
        var f = Math.ceil(Math.random() * 10)+ '';  
        var g = Math.ceil(Math.random() * 10)+ '';  
        var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' '+ f + ' ' + g;
        document.getElementById("txtCaptcha").value = code
    }

    // Validate the Entered input aganist the generated security code function   
    function ValidCaptcha(){
        
        
    }

    // Remove the spaces from the entered and generated code
    function removeSpaces(string)
    {
        return string.split(' ').join('');
    }
    
	
	
	
	

function formvalidation(thisform)
{
with (thisform)
{
	var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
        var str2 = removeSpaces(document.getElementById('txtInput').value);
if (emptyvalidation(name,"Error ! You must type your Full Name !")==false) {name.focus(); return false;}
if (emptyvalidation(phone,"Error ! You must type your Phone !")==false) {phone.focus(); return false;}
//if (emptyvalidation(company_name,"Error ! You must type your company name !")==false) {company_name.focus(); return false;}
if (emailvalidation(email,"Error ! Please provide with your valid Email Address !")==false) {email.focus(); return false;}

//if (emptyvalidation(booking,"Error ! You must type Booking date !")==false) {booking.focus(); return false;}
if (emptyvalidation(enquiry,"Error ! You must type your Comments !")==false) {enquiry.focus(); return false;}
//if (emailvalidation(sub_email,"Error ! Please provide with your valid Email Address !")==false) {sub_email.focus(); return false;}
//if (emptyvalidation(number,"Error ! You must type the code shown on the image !")==false) {number.focus(); return false;}
//if (emailvalidation(email,"Error ! Please provide with your valid Email Address !")==false) {email.focus(); return false;}


        if (str1 != str2) //return false;        
        {
			alert('Please enter captcha to avoid spams.');
		return false;
		}
		
else
{
	document.thisform.mail_sent();
}

}
} 






