/*
' Copyright (c) 2007 Affno (Pvt) Ltd, . All rights reserved.
'
' This software is the confidential and proprietary information of        
' Affno  ("Confidential Information").  You shall not disclose such 
' Confidential Information and shall use it only in accordance with
' the terms of the license agreement you entered into with Affno.
'
'Module Name	: AFFWEB3
' File Name		: contact_us.js
' Description	: This is the page where we validatethe form.
' Created By	: NISHAN SHANAKA
' Created Date	: 
' Modified By	: 
' Modified Date	: 
' Version		: 1.00.000
*/

function checkForm(){
//Enquiry
	if (document.getElementById('Enquiry').selectedIndex == 0 )
    {
        alert ( "Please choose your Enquiry type" );
		document.ContactUs.Enquiry.focus();
        valid = false;
		return false;
    }
//Name
	strName = document.ContactUs.Name.value		
	if (isEmpty(strName)) 
	{
		alert(msgError_emptyName);
		document.ContactUs.Name.focus();
		return false;
	}
	else if (!isName(strName))
	{
		alert(msgError_validName);
		document.ContactUs.Name.focus();
		return false;
	}
	else if (isSpace(strName))
	{
		alert(msgError_spaceName);
		document.ContactUs.Name.value="";
		document.ContactUs.Name.focus();
		return false;
	}
	
//Company
	strCompany = document.ContactUs.Company.value		
	if (isEmpty(strCompany)) 
	{
		alert(msgError_emptyCompany);
		document.ContactUs.Company.focus();
		return false;
	}	
	else if (isSpace(strCompany))
	{
		alert(msgError_spaceCompany);
		document.ContactUs.Company.value="";
		document.ContactUs.Company.focus();
		return false;
	}

//Address
strAddress = document.ContactUs.Address.value
	if (isSpace(strAddress)||(isEmpty(strAddress))) 
	{
		alert(msgError_emptyAddress)
		document.ContactUs.Address.value = "";
		document.ContactUs.Address.focus();
		return false;
	}

//State
	strState = document.ContactUs.State.value
	if (!isEmpty(strState)) {
		if (!isCity(strState)) {
		alert(msgError_validState);
		document.ContactUs.State.focus();
		return false;
		}
	}
	if (isSpace(strState)) {
		alert(msgError_spaceState);
		document.ContactUs.State.focus();
		document.ContactUs.State.value=""
		return false;
	}
	
//Zip
	strZip = document.ContactUs.Zip.value
	if (!isEmpty(strZip)) {
		if (!isAlphaNu(strZip)) {
		alert(msgError_validZip);
		document.ContactUs.Zip.focus();
		return false;
		}
	}
	if (isSpace(strZip)) {
		alert(msgError_spaceZip);
		document.ContactUs.Zip.focus();
		document.ContactUs.Zip.value=""
		return false;
		}
	
//Telephone
    strTelephone = document.ContactUs.Telephone.value		
	if (isEmpty(strTelephone)){
		alert(msgError_emptyTelephone);
		document.ContactUs.Telephone.focus();
		return false;
		}
	else if (!isTelephone(strTelephone)){
		alert(msgError_validTelephone);
		document.ContactUs.Telephone.focus();
		return false;
		}
	else if (isSpace(strTelephone)){
		alert(msgError_spaceTelephone);
		document.ContactUs.Telephone.value="";
		document.ContactUs.Telephone.focus();
		return false;
		}

//Email
strEmail = document.ContactUs.Email.value
	if (isEmpty(strEmail)){
		alert(msgError_emptyEmail);
		document.ContactUs.Email.focus();
		return false;
		}

	else if (!isEmail(strEmail))
	{
		alert(msgError_validEmail);
		document.ContactUs.Email.focus();
		return false;
	}
	else if (isSpace(strEmail))
	{
		alert(msgError_spaceEmail);
		document.ContactUs.Email.value="";
		document.ContactUs.Email.focus();
		return false;
	}
//Comment
strComment = document.ContactUs.Comment.value
if (isEmpty(strComment)) 
	{
		alert(msgError_emptyComment);
		document.ContactUs.Comment.focus();
		return false;
	}
	else if (isSpace(strComment))
	{
		alert(msgError_spaceComment);
		document.ContactUs.Comment.value="";
		document.ContactUs.Comment.focus();
		return false;
	}
	else if(strComment.length>1000)
	{
		alert(msgError_lengthOfComment);
		document.contactus_form.Comments.focus();
		return false;
	}
//	return false;
}
