// $Id$
// $HeadURL$
function set()
{


	if (document.dataform.S_name.value.length == 0)
	 {
		alert ("Kindly enter your name.");
		document.dataform.S_name.focus();
		return false;
	}
	if (document.dataform.S_country.selectedIndex == "")  {
		alert ("Kindly select your country name.");
		document.dataform.S_country.focus();
		return false;
	}
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.dataform.S_email.value))) {
			alert("Invalid Email ID. Kindly enter the correct ID.");
			document.dataform.S_email.focus();
			return (false);
	}
	if (document.dataform.company.value.length == 0)
	 {
		alert ("Kindly enter your Company.");
		document.dataform.company.focus();
		return false;
	}
	if (document.dataform.company_is[0].checked == false && document.dataform.company_is[1].checked == false && document.dataform.company_is[2].checked == false)
	{
		alert('Kindly Fill the Company is.');
		document.dataform.company_is[0].focus();
		return false;
	}

	//if (document.dataform.company_formation_date.selectedIndex == 0 || document.dataform.company_formation_month.selectedIndex == 0 || document.dataform.company_formation_year.selectedIndex == 0)
	//{
	//	alert('Kindly Fill the Correct Date of Company formation.');
	//	if (document.dataform.company_formation_date.selectedIndex == 0)
	//	{
	//		document.dataform.company_formation_date.focus();
	//	}
	//	if (document.dataform.company_formation_month.selectedIndex == 0)
	//	{
	//		document.dataform.company_formation_month.focus();
	//	}
	//	if (document.dataform.company_formation_year.selectedIndex == 0)
	//	{
	//		document.dataform.company_formation_year.focus();
	//	}
	//	return false;
	//}
	if (document.dataform.location_country.value.length == 0)  {
		alert ("Kindly enter Location of the Company.");
		document.dataform.location_country.focus();
		return false;
	}
	if (document.dataform.location_state.value.length == 0)  {
		alert ("Kindly enter Location of the Company.");
		document.dataform.location_state.focus();
		return false;
	}
	if (document.dataform.location_city.value.length == 0)  {
		alert ("Kindly enter Location of the Company.");
		document.dataform.location_city.focus();
		return false;
	}
	if (document.dataform.name_managing_1.value.length == 0 && document.dataform.name_managing_2.value.length == 0 && document.dataform.name_managing_3.value.length == 0 && document.dataform.name_managing_notapplicable.value.length == 0)  {
		alert ("Kindly enter Name/s of the Managing Director/Owner/Proprietor/Partners.");
		document.dataform.name_managing_1.focus();
		return false;
	}

	if (document.dataform.nature_business.value.length == 0)  {
		alert ("Kindly enter the nature/line of business.");
		document.dataform.nature_business.focus();
		return false;
	}
	if (document.dataform.product_category.value.length == 0)  {
		alert ("Kindly enter the product category.");
		document.dataform.product_category.focus();
		return false;
	}
	if (document.dataform.company_focus.value.length == 0)  {
		alert ("Kindly describe the Company.");
		document.dataform.company_focus.focus();
		return false;
	}






newCookie = document.dataform.S_name.value;
	newCookie +="|"+document.dataform.S_email.value;
	newCookie +="|"+document.dataform.S_phone.value;
	newCookie +="|"+document.dataform.S_country.selectedIndex;
	newCookie +="|"+document.dataform.S_ccode.value;
	newCookie +="|"+document.dataform.S_acode.value;
	setCookie("newImeshID",newCookie);
	return true;
}

function setCookie(name, value)
{
	expires = new Date();
	expires.setTime (expires.getTime() + 24 * 60 * 60 * 150 * 1000);

	if (value.length > 0)
 	document.cookie = name + "=" + escape(value)+ ";"+"path=/;"+"expires=" + expires.toGMTString()+";"
}

function getCookie(Name)
{
	var search = Name + "="
	if (document.cookie.length > 0)
	{ // if there are any cookies
		offset = document.cookie.indexOf(search)
		if (offset != -1)
		{ // if cookie exists
			offset += search.length
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset)
			// set index of end of cookie value
			if (end == -1) end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		}
	}

	return "";
}
function get_ccode()
{
	document.dataform.S_ccode_fax.value = document.dataform.S_ccode.value;
}

function get_acode()
{
	document.dataform.S_acode_fax.value = document.dataform.S_acode.value;
}

function  get()
{
	if( (cookie = getCookie("newImeshID")) > "")
	{
		Values = cookie.split("|");
		if (Values.length >= 7)
		{
			if (Values[0]) document.dataform.S_name.value  = Values[0];
			if (Values[1]) document.dataform.S_email.value = Values[1];
			if (Values[2]) document.dataform.S_phone.value = Values[2];
			if (Values[6]) document.dataform.S_country.options[Values[6]].selected=true;
			if (Values[7]) document.dataform.S_ccode.value = Values[7];
			if (Values[8]) document.dataform.S_acode.value = Values[8];
		}
	}
}
