// $Id: query-pcat.js 2301 2006-06-24 16:41:48Z ravi $
// $HeadURL: http://qmail2:8081/svn/im-sw/product-catalog/trunk/main/glpcat/gifs/query-pcat.js $

function set()
{

	var total=0;
	
	if(document.getElementById('how_products_sale1').checked)
	{
		total +=1;
	}
	if(document.getElementById('how_products_sale2').checked)
	{
		total +=1;
	}
	if(document.getElementById('how_products_sale3').checked)
	{
		total +=1;
	}
	if(document.getElementById('how_products_sale4').checked)
	{
		total +=1;
	}
	if(document.getElementById('how_products_sale5').checked)
	{
		total +=1;
	}
	if(document.getElementById('how_products_sale6').checked)
	{
		total +=1;
	}
	
	if(!total)
	{
		alert("Kindly select How do you sell your product");
		return false;
	}

	var total1=0;
	for(var i=0; i < document.dataform.annual_turnover.length; i++)
	{
		if(document.dataform.annual_turnover[i].checked)
		{
			total1 +=1;
		}
	}
	if(!total1)
	{
		alert("Kindly select annual turnover");
		return false;
	}




	if(document.dataform.S_description.value == "") {
		alert ("Kindly describe about yourself");
		document.dataform.S_description.focus();
		return false;
	}



	if (document.dataform.S_description.value.length>4000) {
		alert("Kindly describe your requirement within the limit of 4000 characters.");
		document.dataform.S_description.focus();
		return false;
	}
	if (document.dataform.S_fname.value.length == 0)  {
		alert ("Kindly enter your First name.");
		document.dataform.S_fname.focus();
		return false;
	}
	if (document.dataform.S_lname.value.length == 0)  {
		alert ("Kindly enter your Last name.");
		document.dataform.S_lname.focus();
		return false;
	}

	if (document.dataform.dob_date.value == '')  {
		alert ("Kindly Select the Day.");
		document.dataform.dob_date.focus();
		return false;
	}
	if (document.dataform.dob_month.value == '')  {
		alert ("Kindly Select the Mounth.");
		document.dataform.dob_month.focus();
		return false;
	}
	if (document.dataform.dob_year.value == '')  {
		alert ("Kindly Select the Year.");
		document.dataform.dob_year.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.S_ccode.value.length == 0)  {
		alert ("Kindly enter your country code.");
		document.dataform.S_ccode.focus();
		return false;
	}
	if (document.dataform.S_acode.value.length == 0)  {
		alert ("Kindly enter your area code.");
		document.dataform.S_acode.focus();
		return false;
	}
	if (document.dataform.S_phone.value.length == 0)  {
		alert ("Kindly enter your phone number.");
		document.dataform.S_phone.focus();
		return false;
	}

	if (document.dataform.S_streetaddress.value.length == 0)  {
		alert ("Kindly enter your Street Address.");
		document.dataform.S_streetaddress.focus();
		return false;
	}
	if (document.dataform.S_city.value.length == 0)  {
		alert ("Kindly enter your City.");
		document.dataform.S_city.focus();
		return false;
	}
	if (document.dataform.S_pin.value.length == 0)  {
		alert ("Kindly enter your Zip Code.");
		document.dataform.S_pin.focus();
		return false;
	}

	if (document.dataform.S_country.selectedIndex == "")  {
		alert ("Kindly select your country name.");
		document.dataform.S_country.focus();
		return false;
	}
	if(document.dataform.on_internet_auctions.checked==false)
	{
		alert ("Kindly select I swear not to sell any of the items on this website except items under SAY category on Internet Auctions like ebay, Amazon, etc. (a customer must tick the box for proceeding)");
		return false;
	}
	var captcha_txt = document.getElementsByName("txt_captcha");
	var captcha_txt_len = captcha_txt.length;
	if(captcha_txt_len == 1)
	{
		if (document.dataform.txt_captcha.value.length == 0)  {
			alert ("Kindly enter the code as appearing in the Image.");
			document.dataform.txt_captcha.focus();
			return false;
		}
	}

	newCookie = document.dataform.S_fname.value;
	newCookie +="|"+document.dataform.S_lname.value;
	newCookie +="|"+document.dataform.S_email.value;
	newCookie +="|"+document.dataform.S_phone.value;
	newCookie +="|"+document.dataform.S_fax.value;
	newCookie +="|"+document.dataform.S_streetaddress.value;
	newCookie +="|"+document.dataform.S_city.value;
	newCookie +="|"+document.dataform.S_pin.value;
	newCookie +="|"+document.dataform.S_country.selectedIndex;
	newCookie +="|"+document.dataform.S_organization.value;
	newCookie +="|"+document.dataform.S_ccode.value;
	newCookie +="|"+document.dataform.S_acode.value;
	newCookie +="|"+document.dataform.S_ccode_fax.value;
	newCookie +="|"+document.dataform.S_acode_fax.value;
	newCookie +="|"+document.dataform.S_state.value;
	newCookie +="|"+document.dataform.S_gender.selectedIndex;
	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;
}



var d = new Date();
var epoch_time =(d.getTime()-d.getMilliseconds())/1000;
var randomnumber=Math.floor(Math.random()*9999);
var randomnumber1=Math.floor(Math.random()*9999);
var ran_num=randomnumber+"."+epoch_time+"."+randomnumber1;
var url="/cgi/get_captcha.cgi?cref="+ran_num+"&style=2";



function  get()
{
	if( (cookie = getCookie("newImeshID")) > "")
	{
		Values = cookie.split("|");
		if (Values.length >= 7)
		{
			if (Values[0]) document.dataform.S_fname.value  = Values[0];
			if (Values[1]) document.dataform.S_lname.value  = Values[1];
			if (Values[2]) document.dataform.S_email.value = Values[2];
			if (Values[3]) document.dataform.S_phone.value = Values[3];
			if (Values[4]) document.dataform.S_fax.value=Values[4];
			if (Values[5]) document.dataform.S_streetaddress.value=Values[5];
			if (Values[6]) document.dataform.S_city.value=Values[6];
			if (Values[7]) document.dataform.S_pin.value=Values[7];
			if (Values[8]) document.dataform.S_country.options[Values[8]].selected=true;
			if (Values[9]) document.dataform.S_organization.value = Values[9];
			if (Values[10]) document.dataform.S_ccode.value = Values[10];
			if (Values[11]) document.dataform.S_acode.value = Values[11];
			if (Values[12]) document.dataform.S_ccode_fax.value = Values[12];
			if (Values[13]) document.dataform.S_acode_fax.value = Values[13];
			if (Values[14]) document.dataform.S_state.value = Values[14];
			if (Values[15]) document.dataform.S_gender.options[Values[15]].selected=true;
		}
	}
}