function formValidation(form,nextpanel){
	var errorcount = 0;
	
	if(form == 1){
		errorcount += checkField('userForename','Please enter your firstname');
		errorcount += checkField('userSurname','Please enter your surname');
		//errorcount += checkField('userCompany','Please enter your company name');
		//errorcount += checkField('userTel','Please enter your surname');
		//errorcount += checkField('userJobTitle','Please enter your job title');
		//errorcount += checkField('userURL','Please enter your website address');
	}
	if(form == 2){
		errorcount += checkField('message','Please select or enter a message');
		errorcount += checkField('subjectEdit','Please enter a subject');
		
	}
	//alert(errorcount)
	if(errorcount == 0){
		setPanels(nextpanel)
		makeTxt('form'+form+'_Error', '');	
	} else {
		makeTxt('form'+form+'_Error', 'Please make sure you have completed all the required information<br />');	
	}
}

function checkField(id,msg){
	
	if(document.getElementById(id).value!=''){
		//OK - Input Found
		makeTxt(id+'_Error','');
		//Return count for error
		return 0;
	} 
	
	if(id == 'message'){
		if(tinyMCE.get(id).getContent()!=''){
		//OK - Input Found
		makeTxt(id+'_Error','');
		//Return count for error
		return 0;
		}
	} 
	
	//ERROR - No Input
	makeTxt(id+'_Error','<br />'+msg);	
	//Return count for error
	return 1;	
	
}

function validateURL(obj,supressBlock){
	lengthValue = document.getElementById(obj).value;
	lengthValue = lengthValue.length;
	if(lengthValue != 0){
	var j = new RegExp();
	j.compile("^[A-Za-z]+://[A-Za-z0-9-]+\.[A-Za-z0-9]+");
	lengthValue = document.getElementById(obj).value;
		if (!j.test(lengthValue)){
		if(!supressBlock){
		alertBlock('<span style="font-size: 14px;">Please Enter A Valid Full URL</span><br /><span style="font-size: 12px;">eg: <em>http://www.yourdomain.com</em></span>');
		}
		document.getElementById(obj).focus();
		return false;
		}
	}
}
