function validateit(theForm)
{
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(theForm.email.value)))
	{
		alert("Invalid Email ID. Kindly enter the correct ID.");
		theForm.email.focus();
		return (false);
	}
}
function getblank(this1)  {
	if (this1.value = "Your e-mail here") {
		this1.value = "";
	}
	
    return true;	
}


function check_advanced_search(kw)  {
	error = 0;
	if (kw.length < 3) {
		error_message = "Please enter atleast 3 characters for search";
		error = 1;
	}
	if (kw == "Enter Product / Company Name")
	{
		error_message = "Please enter correct string for search";
			error = 2;
	}
	if (error == 1) {
		alert(error_message);
		return false;
	}
	if (error == 2) {
		alert(error_message);
		document.quick_find.ss.focus();
		return false;
	} 
	else {
		return true;
	}	 
} 

function openchild_nl()
{
	browserName = navigator.appName;
	browserVer = parseInt(navigator.appVersion);
	condition = !(( (browserName.indexOf("Explorer") >=0 ) && (browserVer < 4) ) ||  ((browserName.indexOf("Netscape") >=0 ) && (browserVer < 2) ) ) ;
	if (condition == true  )
		CanAnimate = true;
	else
		CanAnimate = false;

	var email_val = document.theForm.email.value;
	var from_site_val = document.theForm.from_site.value;
	var is_window_val = document.theForm.is_window.value;
	var is_im_val = document.theForm.is_im.value;
	var thisurl="http://industrymart/newsletter/newsletter.cgi";

	var thisurl_string = thisurl + "?email=" + email_val + "&from_site=" + from_site_val + "&is_window=" + is_window_val + "&is_im=" + is_im_val;

	if ( CanAnimate ) {
			msgWindow=window.open( '' ,'subwindow','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,width=550,height=220');
			msgWindow.focus();
			msgWindow.location.href = thisurl_string;
	}
	else {
			msgWindow=window.open( thisurl_string,'subwindow','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,width=550,height=220');
	}
}

browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
condition = !(( (browserName.indexOf("Explorer") >=0 ) && (browserVer < 4) ) ||  ((browserName.indexOf("Netscape") >=0 ) && (browserVer < 2) ) ) ;
if (condition == true  )
    CanAnimate = true;
else
    CanAnimate = false;
	

expires = new Date();
expires.setTime (expires.getTime() + 24 * 60 * 60 * 150 * 1000);


function set(){	

// 	if(document.dataform.subject_other.value == "")
// 	{
// 		alert ("Kindly enter your subject.");
// 		document.dataform.subject_other.focus();
// 		return false;
// 	}

	if(document.dataform.Description.value == "") {
		alert ("Kindly enter your product requirment.");
		document.dataform.Description.focus();
		return false;
	}
	if (document.dataform.Description.value.length>1000) {
		alert("Kindly describe your requirement within the limit of 1000 characters.");
		document.dataform.Description.focus();
		return false;
	}
	if (document.dataform.S_name.value.length == 0)  {
		alert ("Kindly enter your name.");
		document.dataform.S_name.focus();
		return false;
	}
	if(document.dataform.S_email.value == "" ) {
			alert("Kindly enter your E-mail ID.");
			document.dataform.S_email.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_country.selectedIndex == 0)  {
		alert ("Kindly select your country name.");
		document.dataform.S_country.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_phone.value.length == 0)  {
		alert ("Kindly enter your phone number.");
		document.dataform.S_phone.focus();
		return false;
	}
	
	if (document.dataform.captcha_text.value.length == 0)  {
		alert ("Kindly enter the code as appearing in the Image.");
		document.dataform.captcha_text.focus();
		return false;
	}

	newIILCookie = document.dataform.S_name.value;
	newIILCookie +="|"+document.dataform.S_email.value;
	newIILCookie +="|"+document.dataform.S_phone.value;
	newIILCookie +="|"+document.dataform.S_fax.value;
	newIILCookie +="|"+document.dataform.S_streetaddress.value;
	newIILCookie +="|"+document.dataform.S_city.value;
	newIILCookie +="|"+document.dataform.S_pin.value;
	newIILCookie +="|"+document.dataform.S_country.value;
	newIILCookie +="|"+document.dataform.S_organization.value;
	newIILCookie +="|";
	setCookie("newImeshID",newIILCookie);

	newACCookie = document.dataform.S_ccode.value;
	newACCookie +="|"+document.dataform.S_acode.value;
	newACCookie +="|"+document.dataform.S_ccode_fax.value;
	newACCookie +="|"+document.dataform.S_acode_fax.value;
	newACCookie +="|";
	setCookie("newACCodeID",newACCookie);

	// Expire desc cookie if exists
	if( (desccookie = getCookie("NewDescCookie")) > "") {
		document.cookie = "NewDescCookie" + "=" + "" + ";" + "path=/;" ;
	}
} // end set



function Check_ModReg1() 
{
	if(document.ModReg1.name_title.value == "" ) 
	{
		alert("Kindly enter your Title.");
		document.ModReg1.name_title.focus();
		return false;
	}
	else if(document.ModReg1.url.value == "" ) 
	{
		alert("Kindly enter your URL.");
		document.ModReg1.url.focus();
		return false;
	}
	else if(document.ModReg1.comp_name.value == "" ) 
	{
		alert("Kindly enter your Name.");
		document.ModReg1.comp_name.focus();
		return false;
	}
	else if(document.ModReg1.email.value == "" ) 
	{
		alert("Kindly enter your Email.");
		document.ModReg1.email.focus();
		return false;
	}
	
	
	if (document.ModReg1.email.value.length != 0)
	{
		var e_check  = document.ModReg1.email.value;
		if(document.ModReg1.email.value.indexOf(" ") != -1)	{
		alert("Kindly enter correct E-Mail ID without any spaces in it.");
		document.ModReg1.email.focus();
		return false;
		}
		if(document.ModReg1.email.value.indexOf("@") == -1)	{
		alert("Invalid E-Mail ID! Kindly enter correct E-Mail ID.");
		document.ModReg1.email.focus();
		return false;
		}
		validarr = document.ModReg1.email.value.split("@");
		if(validarr[0].length==0)   	{
		alert("Invalid E-Mail ID! Kindly enter the correct E-mail ID.");
		document.ModReg1.email.focus();
		return false;
		}
		if(validarr[1].indexOf("@") >=0)   	{
		alert("Invalid E-Mail ID! Kindly enter the correct E-mail ID.");
		document.ModReg1.email.focus();
		return false;
		}
		if(validarr[1].length==0)   	{
		alert("Invalid E-Mail ID! Kindly enter the correct E-mail ID.");
		document.ModReg1.email.focus();
		return false;
		}
		if(validarr[1].length != 0)   	{
			if(validarr[1].indexOf(".") == -1)     	{
			alert("Invalid E-Mail ID! Kindly enter the correct E-mail ID.");
			document.ModReg1.email.focus();
			return false;
			}
			validemail = validarr[1].split(".");
			if(validemail[0].length==0)   		{
			alert("Invalid E-Mail ID! Kindly enter the correct E-mail ID.");
			document.ModReg1.email.focus();
			return false;
			}
			if(validemail[1].length==0)  		{
			alert("Invalid E-Mail ID! Kindly enter the correct E-mail ID.");
			document.ModReg1.email.focus();
			return false;
			}
		}   
	}

	if (document.ModReg1.url.value.length != 0)
	{
		if(document.ModReg1.url.value.indexOf(" ") != -1)	
		{
			alert("Kindly enter correct URL without any spaces in it.");
			document.ModReg1.url.focus();
			return false;
		}
		if(document.ModReg1.url.value.indexOf("@") != -1)	
		{
			alert("Invalid Website! Kindly enter correct Url");
			document.ModReg1.url.focus();
			return false;
		}
		if(document.ModReg1.url.value.indexOf(".") == -1)	
		{
			alert("Invalid Website! Kindly enter correct Url");
			document.ModReg1.url.focus();
			return false;
		}
		validarr = document.ModReg1.url.value.split(".");
		if(validarr[0].length<2)   	
		{
			alert("Invalid Website! Kindly enter correct Url");
			document.ModReg1.url.focus();
			return false;
		}
		if(validarr[1].length<2)   	
		{
			alert("Invalid Website! Kindly enter correct Url");
			document.ModReg1.url.focus();
			return false;
		}
	}
	if(document.ModReg1.url.value.length > 70) 
	{
		alert("url should not exceed 70 characters.");
		document.ModReg1.url.focus();
		return false;
		
	}

}



function get() {
		if( (cookie = getCookie("newImeshID")) > "") {
			Values = cookie.split("|");
			if (Values.length >= 8) {
				if (document.dataform.S_name.value.length == 0)     document.dataform.S_name.value = Values[0];
				if (document.dataform.S_email.value.length == 0)    document.dataform.S_email.value = Values[1];
				if (document.dataform.S_phone.value.length == 0)   document.dataform.S_phone.value = Values[2];
				if (document.dataform.S_fax.value.length == 0)     document.dataform.S_fax.value = Values[3];
				if (document.dataform.S_streetaddress.value.length == 0) document.dataform.S_streetaddress.value=Values[4];
				if (document.dataform.S_city.value.length == 0)  document.dataform.S_city.value=Values[5];
				if (document.dataform.S_pin.value.length == 0)   document.dataform.S_pin.value=Values[6];
				if (document.dataform.S_country.value.length == 0) document.dataform.S_country.value=Values[7];
				if (document.dataform.S_organization.value.length == 0) document.dataform.S_organization.value=Values[8];
			}
		}

		if( (nextcookie = getCookie("newACCodeID")) > "") {
			NextValues = nextcookie.split("|");
			if (NextValues.length >= 3){
				if (document.dataform.S_ccode.value.length == 0)     document.dataform.S_ccode.value = NextValues[0];
				if (document.dataform.S_acode.value.length == 0)     document.dataform.S_acode.value = NextValues[1];
				if (document.dataform.S_ccode_fax.value.length == 0)     document.dataform.S_ccode_fax.value = NextValues[2];
				if (document.dataform.S_acode_fax.value.length == 0)     document.dataform.S_acode_fax.value = NextValues[3];
			}
		}

		if( (desccookie = getCookie("NewDescCookie")) > "") {
			document.dataform.Description.value = desccookie;
		}

		return true;
	}  // end get

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

	function getCookie(Name) {
		var search = Name + "="
		if (document.cookie.length > 0) { // if there are any cookies
			offset = document.cookie.indexOf(search)
			//alert("Offset:"+offset);
			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 "";
	}  // end getCookie



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 getblank_nl(this1)  {
	if (this1.value = "Your e-mail here") {
		this1.value = "";
	}
    return true;
}
function searchsubmit(a)
	{
		document.quick_find1.pg.value=a;
		document.quick_find1.submit();
		return true;
	}

function sendquery(id1,id2,id3,id4)
{

document.myform.cid.value=id1;
document.myform.ss.value=id2;
document.myform.mod_id.value='INDUSTRY';
document.myform.comp.value=id3;
document.myform.country.value=id4;
document.myform.from.value='search';
document.myform.submit();
}




