function ValidateEmail(email, formName){
		var atCharPresent = false;
		var dotPresent = false;
		
		for ( var Idx = 0; Idx < email.value.length; Idx++ ){
			if ( email.value.charAt ( Idx ) == '@' )
				atCharPresent = true;
			if ( email.value.charAt ( Idx ) == '.' )
				dotPresent = true;
		}
		if ( !atCharPresent || !dotPresent ){
			alert( formName + "Please provide a valid email address !");
			email.focus();
			return false;
			}
	return true;
}
function isNumbers(stryear){
	var validdate = "1234567890-";
	var strlength = stryear.length;
	for(var i=0; i<=strlength; i++){
		var unitstr = stryear.substr(i,1);
		if (validdate.indexOf(unitstr)==-1){
			return false;
		}
	}
	return true;
}

/*************/


function validateForm(){
	check = document.conForm;
	flag=false;
	
	if(check.fname.value.replace(/\s/g, "") == ""){
		alert("Please enter first name !");
		check.fname.focus();
		flag=false;
		return false;
	} else { flag=true; }
	
	if(check.lname.value.replace(/\s/g, "") == ""){
		alert("Please enter last name !");
		check.lname.focus();
		flag=false;
		return false;
	} else { flag=true; }
	
	if(check.email.value.replace(/\s/g, "") == ""){
		alert("Please provide a valid email address !");
		check.email.focus();
		flag=false;
		return false;
	} else { flag=true; }
	
	if(! ValidateEmail(check.email, '')){
		return false;
		flag=false;
	} else { flag=true; }
	
	if(check.address.value.replace(/\s/g, "") == ""){
		alert("Please enter address !");
		check.address.focus();
		flag=false;
		return false;
	} else { flag=true; }

	if(check.state.value.replace(/\s/g, "") == ""){
		alert("Please enter state !");
		check.state.focus();
		flag=false;
		return false;
	} else { flag=true; }

	if(check.country.value.replace(/\s/g, "") == ""){
		alert("Please enter country !");
		check.country.focus();
		flag=false;
		return false;
	} else { flag=true; }

	
	if(check.phone.value.replace(/\s/g, "") != ""){
		if (!isNumbers(check.phone.value.replace(/\s/g, ""))){
			alert("Please fill only number values for phone number!");
			check.phone.focus();
			flag=false;
			return false;
		} else { flag=true; }
	}else {
			alert("Please fill phone number !");
			check.phone.focus();
			flag=false;
			return false;
	}
	
	if((check.quiry.value.replace(/\s/g, "") == "")||(check.quiry.value.replace(/\s/g, "") == "Comments/Query")){
		alert("Please fill in your Query/Comments !");
		check.quiry.focus();
		flag=false;
		return false;
	} else { flag=true; }

/*if((check.fname.value.replace(/\s/g, "") != "") && (check.lname.value.replace(/\s/g, "") != "") && (check.email.value.replace(/\s/g, "") != "") && ValidateEmail(check.email, '') && (check.phone.value.replace(/\s/g, "") != "") && (check.phone.value.replace(/\s/g, "") != "Phone") && (check.country.value.replace(/\s/g, "") != "") && (check.country.value.replace(/\s/g, "") != "Country") && (check.enquiry.value.replace(/\s/g, "") != "") && (check.enquiry.value.replace(/\s/g, "") != "Comments/Query"))
{
	flag=true;
	}
*/	
	if(flag==true) {
		
		document.getElementById('sButton').style.display='block';
		document.getElementById('fButton').style.display='none';
		
		fname=encodeURI(document.getElementById('fname').value);
		lname=encodeURI(document.getElementById('lname').value);
		email=encodeURI(document.getElementById('email').value);
		address=encodeURI(document.getElementById('address').value);
		state=encodeURI(document.getElementById('state').value);
		country=encodeURI(document.getElementById('country').value);
		postcode=encodeURI(document.getElementById('postcode').value);
		phone=encodeURI(document.getElementById('phone').value);
		fax=encodeURI(document.getElementById('fax').value);
		quiry=encodeURI(document.getElementById('quiry').value);
		
linkvalue = 'captcha.php?height=280&amp;width=430&fname='+fname+'&lname='+lname+'&email='+email+'&address='+address+'&state='+state+'&country='+country+'&postcode='+postcode+'&phone='+phone+'&fax='+fax+'&quiry='+quiry;

		anchors = document.getElementById('sButton').getElementsByTagName('a');
		anchors[0].setAttribute('href', linkvalue);

	}else { 
		document.getElementById('sButton').style.display='none';
		document.getElementById('fButton').style.display='block';
	}
	
	return true;
}

function changeButton()
{
	check = document.conForm;
	flag=false;
//	if(( (( ((check.enquiry.value.replace(/\s/g, "") != "")||(check.enquiry.value.replace(/\s/g, "") != "Comments/Query"))) {

if((check.fname.value.replace(/\s/g, "") != "") && (check.lname.value.replace(/\s/g, "") != "") && (check.email.value.replace(/\s/g, "") != "") && ValidateEmail(check.email, '') && (check.address.value.replace(/\s/g, "") != "") && (check.state.value.replace(/\s/g, "") != "") && (check.country.value.replace(/\s/g, "") != "") && (check.phone.value.replace(/\s/g, "") != "") && (check.quiry.value.replace(/\s/g, "") != ""))
{
	flag=true;
	}
	
	if(flag==true) {
	
		document.getElementById('sButton').style.display='block';
		document.getElementById('fButton').style.display='none';

		fname=encodeURI(document.getElementById('fname').value);
		lname=encodeURI(document.getElementById('lname').value);
		email=encodeURI(document.getElementById('email').value);
		address=encodeURI(document.getElementById('address').value);
		state=encodeURI(document.getElementById('state').value);
		country=encodeURI(document.getElementById('country').value);
		postcode=encodeURI(document.getElementById('postcode').value);
		phone=encodeURI(document.getElementById('phone').value);
		fax=encodeURI(document.getElementById('fax').value);
		quiry=encodeURI(document.getElementById('quiry').value);
		
linkvalue = 'captcha.php?height=280&amp;width=430&fname='+fname+'&lname='+lname+'&email='+email+'&address='+address+'&state='+state+'&country='+country+'&postcode='+postcode+'&phone='+phone+'&fax='+fax+'&quiry='+quiry;
		
		anchors = document.getElementById('sButton').getElementsByTagName('a');
		anchors[0].setAttribute('href', linkvalue);
	}else { 
		document.getElementById('sButton').style.display='none';
		document.getElementById('fButton').style.display='block';
	}
}




