// JavaScript Document


var Checksfm = new Array();
function SendForm(){
				
		var txtName = $F('stru_n')  // returns the value of the field with id 'myinput'
		var txtEmail = $F('stru_e') 
		var txtTel = $F('stru_t') 
		var txtEnq = $F('stru_en') 
		
		if (!txtName == ''){
		
		} else{
	
		new Effect.Shake('stru_n');
		new Effect.Highlight('stru_n');
		$('submit').value='Send';
		$('submit').enable();
		
		}
		
		if (!txtTel==''){
		
		}else{
		
		new Effect.Shake('stru_t');
		new Effect.Highlight('stru_t');
		$('submit').value='Send';
		$('submit').enable();
		
		}
		
		if (NC_EmailValid(txtEmail)){
		
		}else{
	
		new Effect.Shake('stru_e');
		new Effect.Highlight('stru_e');
		$('submit').value='Send';
		$('submit').enable();
		
		}
		
		if (!txtEnq == ''){
		
		} else{
		
		new Effect.Shake('stru_en');
		new Effect.Highlight('stru_en');
		$('submit').value='Send';
		$('submit').enable();
		
		}
		
	if ((Checksfm['txtName']) && (Checksfm['txtTel']) && (Checksfm['txtEmail'])){
	

		$('submit').value='Wait...';
		$('submit').disable(); 
		$('loadinggfx').show();
		
		var url = '/scripts/sendemail.asp';
	    var pars = 'strName=' + encodeURIComponent(txtName) + '&strTel=' +encodeURIComponent(txtTel) + '&strEmail=' +encodeURIComponent(txtEmail)+ '&strEnq=' + encodeURIComponent(txtEnq) + '&ajax=1';
	    var myAjax = new Ajax.Request( url, {method: 'post', parameters: pars, onComplete: emailResponse} );
		
		}
}
		
		
		

function Checkfields(){
	var txtName = $('stru_n');
	var txtTel = $('stru_t');
	var txtEmail = $('stru_e');
	var txtEnq = $('stru_en');
	
	if (txtName.value.length>0){
		$('NameGood').show();
	
		Checksfm['txtName'] = true;
		} else{
	
		$('NameGood').hide();
		Checksfm['txtName'] = false;
		
		}
		
	if (txtTel.value.length>=6){
		$('TelGood').show();
		
		Checksfm['txtTel'] = true;
		} else{
	
		$('TelGood').hide();
		Checksfm['txtTel'] = false;
		
		}
		
	if (NC_EmailValid(txtEmail.value)){
		
			$('EmailGood').show();
		
			Checksfm['txtEmail'] = true;
		} else{
		$
		$('EmailGood').hide();
			Checksfm['txtEmail'] = false;
		
		}
	if (txtEnq.value.length>=6){
		$('EnqGood').show();
	
		Checksfm['txtEnq'] = true;
		} else{
	
		$('EnqGood').hide();
		Checksfm['txtEnq'] = false;
		
		}
	
}

function NC_EmailValid(src) {
 
     var emailReg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
     var regex = new RegExp(emailReg);
     return regex.test(src);
	}
	
function emailResponse(response){


$('emailSuccess').show();
$('emailSuccess').innerHTML=response.responseText;
$('submit').hide();
$('loadinggfx').hide();
$('fmContact').hide();

}
window.onload = function() {
$('stru_n').onkeyup = Checkfields;
$('stru_e').onkeyup = Checkfields;
$('stru_t').onkeyup = Checkfields;
$('stru_en').onkeyup = Checkfields;
$('submit').onclick= function(){
	SendForm();
	return false;
}
$('stru_n').focus();



}

