function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
		{
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1)
		 {
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		 {
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1)
		 {
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(" ")!=-1)
		 {
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true
}

function validate_form1() {
		if (document.contactform.Last_Name.value == "")
		{
			alert(" Please Enter Last Name");
			document.contactform.Last_Name.focus();
			return false;
		}
		if (document.contactform.Company_Address.value == "")
		{
			alert(" Please Enter Address1");
			document.contactform.Company_Address.focus();
			return false;
		}

		if (document.contactform.postcode.value == "")
		{
			alert(" Please Enter Postcode");
			document.contactform.postcode.focus();
			return false;
		}
		if (document.contactform.Telephone_Number.value == "")
		{
			alert(" Please Enter Telephone Number");
			document.contactform.Telephone_Number.focus();
			return false;
		}

		if ((document.contactform.Email_Address.value==null)||(document.contactform.Email_Address.value==""))
		{
			alert("Please Enter your Email ID")
			document.contactform.Email_Address.focus()
			return false;
		}
		if (echeck(document.contactform.Email_Address.value)==false)
		{
				document.contactform.Email_Address.value=""
				document.contactform.Email_Address.focus()
				return false
		}

		//validation for extra field

		if (document.contactform.Electricity.checked == true)
		{
			if (document.contactform.elec_extra.value == "")
				{
					alert("Please Enter Value in field")
					document.contactform.elec_extra.focus()
					return false
				}
		}
		else
		{
		document.contactform.elec_extra.value=""
		document.contactform.elec_extra.disabled=true
		//var s1 = document.contactform.elec_extra.value;
		//alert (s1)
		}

		if (document.contactform.Insurance.checked == true)
		{
			if (document.contactform.insurance_extra.value == "")
				{
					alert("Please Enter Value in field")
					document.contactform.insurance_extra.focus()
					return false
				}
		}
		else
		{
		document.contactform.insurance_extra.value=""
		document.contactform.insurance_extra.disabled=true
		//var s2= document.contactform.insurance_extra.value;
		//alert (s2)

		}

		//validation for extra field

	return true;
}

function checkNum() {
var carCode = event.keyCode;
if ((carCode < 48) || (carCode > 57))
		{
			alert('Please enter only numbers.');
			event.cancelBubble = true
			event.returnValue = false;
		}
}

function showNews(opt) {
	if (opt == 'cng') {
		$('#cng-news').show();
		$('#industry-news').hide();
		$('#cng-news-link').addClass('selected');
		$('#industry-news-link').removeClass('selected');
	}
	else {
		$('#cng-news').hide();
		$('#industry-news').show();
		$('#cng-news-link').removeClass('selected');
		$('#industry-news-link').addClass('selected');
	}
}
