// JavaScript Document
// Start Swap Image Script

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// End Swap Image Script
function validate(form)
{
		if(trim(document.quote.product.value)=="")
		{
		alert("Please select your Product");	 
		document.quote.product.focus();
		return false;
		}
		if(trim(document.quote.Quantity.value)=="")
		{
		alert("Please select your Quantity");
		document.quote.Quantity.focus();
		return false;
		}
		//if(trim(document.getElementById("Title").value)=="")
//		{
//		alert("Please enter your Title");
//		document.getElementById("Title").focus();
//		return false;
//		}
		if(trim(document.quote.Name.value)=="")
		{
		alert("Please enter your Name");
		document.quote.Name.focus();
		return false;
		}
		if(trim(document.quote.email.value)=="")
		{
		alert("Please enter your Email");
		document.quote.email.focus();
		return false;
		}
		if(emailCheck(document.quote.email.value)=="")
		{
		alert("Enter the email in a valid format 'ex:abc@bca.com'");
		document.quote.email.focus();
		return false;
		}
	//	if(trim(document.getElementById("Organisation").value)=="")
//		{
//		alert("Please enter your Organisation");
//		document.getElementById("Organisation").focus();
//		return false;
//		}
//		if(trim(document.quote.TelNo.value)=="")
//		{
//		alert("Please enter your TelNo");
//		document.quote.TelNo.focus();
//		return false;
//		}
//		if(isNaN(document.quote.TelNo.value)||document.quote.TelNo.value.length>15||document.quote.TelNo.value.length<8)
//		{
//		alert("Please enter your Valid TelNo");
//		document.quote.TelNo.focus();
//		return false;
//		}
		//if(trim(document.getElementById("Mobile").value)=="")
//		{
//		alert("Please enter your Mobile");
//		document.getElementById("Mobile").focus();
//		return false;
//		}
//		if(trim(document.getElementById("Address1").value)=="")
//		{
//		alert("Please enter your Address");
//		document.getElementById("Address1").focus();
//		return false;
//		}		
//	 
//		if(trim(document.getElementById("Postcode").value)=="")
//		{
//		alert("Please enter your Postcode");
//		document.getElementById("Postcode").focus();
//		return false;
//		}
//		if(trim(document.getElementById("Faxno").value)=="")
//		{
//		alert("Please enter your Faxno");
//		document.getElementById("Faxno").focus();
//		return false;
//		}
//		if(trim(document.getElementById("Country").value)=="")
//		{
//		alert("Please enter your Country");
//		document.getElementById("Country").focus();
//		return false;
//		}
		
		
}

function validate1() {
	var form=document.quote1;
	if(trim(form.Name.value)=="")
	{
		alert("Please enter your Name");
		form.Name.focus();
		return false;
	}
	if(trim(form.product.value)=="")
	{
		alert("Please select your Product");
		form.product.focus();
		return false;
	}
	if(trim(form.Quantity.value)=="")
	{
		alert("Please select your Quantity");
		form.Quantity.focus();
		return false;
	}


	if(trim(document.quote1.email.value)=="")
	{
		alert("Please enter your Email");
		document.quote1.email.focus();
		return false;
	}
	if(emailCheck(document.quote1.email.value)=="")
	{
		alert("Enter the email in a valid format 'ex:abc@bca.com'");
		document.quote1.email.focus();
		return false;
	}
//	if(isNaN(document.quote1.TelNo.value)||document.quote1.TelNo.value.length>15||document.quote1.TelNo.value.length<8)
	//{
		//alert("Please enter your Valid TelNo");
		//document.quote1.TelNo.focus();
		//return false;
//	}

	document.quote1.submit();

}

function emailCheck(email)
{	   
		var validCharRegExp = /^\w(\.?[-\w])*@\w(\.?[-\w])*\.([a-z]{3}(\.[a-z]{2})?|[a-z]{2}(\.[a-z]{2})?)$/i;
		var isValid = (validCharRegExp.test(email)); 
		return isValid;
} 
function trim(str)
{
  	    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}