function valid_contactus(first_no,second_no)
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = document.frmCont.txt_email.value.match(emailPat);
	if(document.frmCont.txt_firstname.value == "")
	{
		alert("Please enter the first name.");
		document.frmCont.txt_firstname.focus();
		return false;
	}
	if(document.frmCont.txt_postcode.value == "")
	{
		alert("Please enter the post/zip code.");
		document.frmCont.txt_postcode.focus();
		return false;
	}
	if(document.frmCont.txt_email.value=="")
	{
		alert("Please enter the email address");
		document.frmCont.txt_email.focus();
		return false;
	}
	else
	{
		if (matchArray == null)
		{
			alert ("Please enter your valid email address.");
			document.frmCont.txt_email.focus();
			return false;
		}
	}
	/*if(document.frmCont.txt_comment.value=="")
	{
		alert("Please enter the comment");	
		document.frmCont.txt_comment.focus();
		return false;
	}*/
	if(document.frmCont.txt_secu_code.value == "")
	{
		alert("Please enter the addition of "+first_no+" + "+second_no);
		document.frmCont.txt_secu_code.focus();
		return false;
	}
}
function valid_brochure(first_no,second_no)
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = document.frmCont.txt_email.value.match(emailPat);
	if(document.frmCont.txt_firstname.value == "")
	{
		alert("Please enter your name.");
		document.frmCont.txt_firstname.focus();
		return false;
	}
	
	if(document.frmCont.txt_email.value=="")
	{
		alert("Please enter the email address");
		document.frmCont.txt_email.focus();
		return false;
	}
	else
	{
		if (matchArray == null)
		{
			alert ("Please enter your valid email address.");
			document.frmCont.txt_email.focus();
			return false;
		}
	}
	
	if(document.frmCont.txt_address.value == "")
	{
		alert("Please enter your address.");
		document.frmCont.txt_address.focus();
		return false;
	}
	
	/*if(document.frmCont.txt_comment.value=="")
	{
		alert("Please enter the comment");	
		document.frmCont.txt_comment.focus();
		return false;
	}*/
	if(document.frmCont.txt_secu_code.value == "")
	{
		alert("Please enter the addition of "+first_no+" + "+second_no);
		document.frmCont.txt_secu_code.focus();
		return false;
	}
}
function valid_online_form(first_no,second_no)
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = document.frmCont.txt_email.value.match(emailPat);
	if(document.frmCont.txt_firstname.value == "")
	{
		alert("Please enter your name.");
		document.frmCont.txt_firstname.focus();
		return false;
	}
	
	if(document.frmCont.txt_email.value=="")
	{
		alert("Please enter the email address");
		document.frmCont.txt_email.focus();
		return false;
	}
	else
	{
		if (matchArray == null)
		{
			alert ("Please enter your valid email address.");
			document.frmCont.txt_email.focus();
			return false;
		}
	}
	
	
	if(document.frmCont.txt_secu_code.value == "")
	{
		alert("Please enter the addition of "+first_no+" + "+second_no);
		document.frmCont.txt_secu_code.focus();
		return false;
	}
}

function valid_quote_me_now(first_no,second_no)
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = document.frmCont.txt_email.value.match(emailPat);
	if(document.frmCont.txt_plant_type.value == "")
	{
		alert("Please select plant type.");
		document.frmCont.txt_plant_type.focus();
		return false;
	}
	if(document.frmCont.txt_hire_duration.value == "")
	{
		alert("Please enter hire duration.");
		document.frmCont.txt_hire_duration.focus();
		return false;
	}
	if(document.frmCont.txt_site_location.value == "")
	{
		alert("Please enter site location.");
		document.frmCont.txt_site_location.focus();
		return false;
	}
	if(document.frmCont.txt_firstname.value == "")
	{
		alert("Please enter contact name.");
		document.frmCont.txt_firstname.focus();
		return false;
	}
	if(document.frmCont.txt_email.value=="")
	{
		alert("Please enter the email address");
		document.frmCont.txt_email.focus();
		return false;
	}
	else
	{
		if (matchArray == null)
		{
			alert ("Please enter your valid email address.");
			document.frmCont.txt_email.focus();
			return false;
		}
	}
	
	
	if(document.frmCont.txt_secu_code.value == "")
	{
		alert("Please enter the addition of "+first_no+" + "+second_no);
		document.frmCont.txt_secu_code.focus();
		return false;
	}
}

function valid_enquiry_submit(first_no,second_no)
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = document.enquiry.txt_email.value.match(emailPat);
	if(document.enquiry.txt_firstname.value == '')
	{
		alert("Please enter the first name.");
		document.enquiry.txt_firstname.focus();
		return false;
	}
	
	if(document.enquiry.txt_email.value=="")
	{
		alert("Please enter the email address");
		document.enquiry.txt_email.focus();
		return false;
	}
	else
	{
		if (matchArray == null)
		{
			alert ("Please enter your valid email address.");
			document.enquiry.txt_email.focus();
			return false;
		}
	}
	if(document.enquiry.txt_comment.value == '')
	{
		alert("Please enter the comment / enquiry.");
		document.enquiry.txt_comment.focus();
		return false;
	}
	if(document.enquiry.txt_secu_code.value == "")
	{
		alert("Please enter the addition of "+first_no+" + "+second_no);
		document.enquiry.txt_secu_code.focus();
		return false;
	}
}

function valid_appoint_submit(first_no,second_no)
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = appoint.txt_email.value.match(emailPat);
	if(document.appoint.txt_yourname.value == '')
	{
		alert("Please enter your name.");
		document.appoint.txt_yourname.focus();
		return false;
	}
	
	if(document.appoint.txt_email.value=="")
	{
		alert("Please enter email address");
		document.appoint.txt_email.focus();
		return false;
	}
	else
	{
		if (matchArray == null)
		{
			alert ("Please enter your valid email address.");
			document.appoint.txt_email.focus();
			return false;
		}
	}
	if(document.appoint.txt_comment.value == '')
	{
		alert("Please enter comment / enquiry.");
		document.appoint.txt_comment.focus();
		return false;
	}
	if(document.appoint.txt_secu_code.value == "")
	{
		alert("Please enter addition of "+first_no+" + "+second_no);
		document.appoint.txt_secu_code.focus();
		return false;
	}
}
function getXmlHttpObject()
{
	try
	{    // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();  
		return xmlHttp;  
	}
	catch (e)
	{    // Internet Explorer    
		try
		{      
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
			return xmlHttp;    
		}
		catch (e)
		{      
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				return xmlHttp;
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!"+e.message);
				return false;
			}
		}
	}
}
function fill_dropdown(tmp_cat_id)
{
	fill_model(tmp_cat_id,'');	
	fill_weight(tmp_cat_id,'');	
}
function fill_model(tmp_cat_id,by)
{
	//alert(document.getElementById('hid_tonnage').value);
	//if(document.getElementById('mod_id').value == '' || document.getElementById('tonnage').value != document.getElementById('hid_tonnage').value)
	//{
		tmp_cat_id			= document.getElementById('cat_id').value;
		var weight = '';
		if(by == 'tonnage')
		{
			
			weight	= escape(document.getElementById('tonnage').value);
		}
		
		var xmlHttp;
		var data;
		xmlHttp=getXmlHttpObject(); //class template in common.js
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{	
				data		= xmlHttp.responseText;
				dataarr		= data.split('=rahul=');
				totrec		= dataarr.length;
				if(totrec>0)
				{
					document.getElementById('mod_id').options.length	= 0;
					 opt			= document.createElement('OPTION');
					opt.text		= 'Select Model';
					opt.value		= '0';
					document.getElementById('mod_id').options.add(opt);	
					for(i=0;i<totrec;i++)
					{
						option	= dataarr[i];
						if(option != '')
						{
							optionstr		= option.split('=-=');
							var opt			= document.createElement('OPTION');
							opt.text		= optionstr[1];
							opt.value		= optionstr[0];
							document.getElementById('mod_id').options.add(opt);
						}
					}
				}
				/*
				document.getElementById('tonnage').options.length	= 0;
				opt			= document.createElement('OPTION');
				opt.text		= 'Select Tonnage';
				opt.value		= '';
				document.getElementById('tonnage').options.add(opt);	
				*/
			}
		}
		
		xmlHttp.open("GET","fill_model.php?cat_id="+tmp_cat_id+"&by="+by+"&weight="+weight,true);
		xmlHttp.send(null);
	//}
}
function fill_weight(tmp_cat_id,by)
{
	
	//if(document.getElementById('tonnage').value == '' || document.getElementById('mod_id').value != document.getElementById('hid_mod_id').value)
	//{
		tmp_cat_id			= document.getElementById('cat_id').value;	
		var mod_id = '';
		if(by == 'model')
		{
			mod_id	= document.getElementById('mod_id').value;
		}
		var xmlHttp;
		xmlHttp=getXmlHttpObject(); //class template in common.js
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{	
				data		= xmlHttp.responseText;
				dataarr		= data.split('=rahul=');
				totrec		= dataarr.length;
				if(totrec>0)
				{
					document.getElementById('tonnage').options.length	= 0;
					if(by == '' || mod_id == 0)
					{
						opt			= document.createElement('OPTION');
						opt.text		= 'Select Tonnage';
						opt.value		= '0';
						document.getElementById('tonnage').options.add(opt);	
					}
					for(i=0;i<totrec;i++)
					{
						option	= dataarr[i];
						if(option != '')
						{
							optionstr		= option.split('=-=');
							var opt			= document.createElement('OPTION');
							opt.text		= optionstr[1];
							opt.value		= optionstr[0];
							document.getElementById('tonnage').options.add(opt);
						}
					}
				}
			}
		}
		
		xmlHttp.open("GET","fill_tonnage.php?cat_id="+tmp_cat_id+"&by="+by+"&mod_id="+mod_id,true);
		xmlHttp.send(null);
	//}
}
function valid_search()
{
	if(document.getElementById('cat_id').value == '')
	{
		alert("Please choose machine");
		return false;
	}
	if(document.getElementById('mod_id').value == '0' && document.getElementById('tonnage').value == '0')
	{
		alert("Please select model/tonnage");
		return false;
	}
	/*
	if(document.getElementById('tonnage').value == '')
	{
		alert("Please select tonnage");
		return false;
	}
	*/
}

function fill_model_bkp(tmp_cat_id,url)
{
	var xmlHttp;
	var data;
	xmlHttp=getXmlHttpObject(); //class template in common.js
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{	
			dropdata	= xmlHttp.responseText;
			dropdataarr	= dropdata.split('=joshi=');
			ddtotrec	= dropdataarr.length;
						
			dataarr		= dropdataarr[0].split('=rahul=');
			totrec		= dataarr.length;
			document.getElementById('mod_id').options.length	= 0;
			document.getElementById('tonnage').options.length	= 0;
			if(totrec>0)
			{
				
				opt				= document.createElement('OPTION');
				opt.text		= 'Select Model';
				opt.value		= '';
				document.getElementById('mod_id').options.add(opt);	
				for(i=0;i<totrec;i++)
				{
					option	= dataarr[i];
					if(option != '')
					{
						optionstr		= option.split('=-=');
						var opt			= document.createElement('OPTION');
						opt.text		= optionstr[1];
						opt.value		= optionstr[0];
						document.getElementById('mod_id').options.add(opt);
					}
				}
			}
			
			dataarr		= dropdataarr[1].split('=luhar=');
			totrec		= dataarr.length;
			if(totrec>0)
			{
				document.getElementById('tonnage').options.length	= 0;
				 opt			= document.createElement('OPTION');
				opt.text		= 'Select Tonnage';
				opt.value		= '';
				document.getElementById('tonnage').options.add(opt);	
				for(i=0;i<totrec;i++)
				{
					option	= dataarr[i];
					if(option != '')
					{
						optionstr		= option.split('=-=');
						var opt			= document.createElement('OPTION');
						opt.text		= optionstr[1];
						opt.value		= optionstr[0];
						document.getElementById('tonnage').options.add(opt);
					}
				}
			}
			
			
			//document.getElementById('mod_id').innerHTML=xmlHttp.responseText;
			
			opt			= document.createElement('OPTION');
			opt.text		= 'Select Tonnage';
			opt.value		= '';
			document.getElementById('tonnage').options.add(opt);	
		}
	}
	
	xmlHttp.open("GET","fill_model.php?cat_id="+tmp_cat_id,true);
	xmlHttp.send(null);
}
