var x=0;function init(text)
{try
{xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async="false";xmlDoc.loadXML(text);}
catch(e)
{try
{parser=new DOMParser();xmlDoc=parser.parseFromString(text,"text/xml");}
catch(e)
{alert(e.message);return;}}
return xmlDoc;}
function ajaxFunction()
{var xmlHttp;try
{xmlHttp=new XMLHttpRequest();}
catch(e)
{try
{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e)
{try
{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e)
{alert("Your browser does not support AJAX!");return false;}}}
return xmlHttp;}
function setcredit()
{var attempt=Number(x)+1;var xmlHttp=ajaxFunction();if(xmlHttp)
{xmlHttp.onreadystatechange=function()
{if(xmlHttp.readyState==4)
{if(xmlHttp.responseText)
{temp=xmlHttp.responseText.split('##');if(temp[2]==1&&attempt==1)
{Header();}
else
{document.getElementById('welcomeuser').innerHTML=' to <strong>HelloTrade!</strong>';document.getElementById('nhavbcrd').style.display="none";}}}}
var params="";var str='/cgi-bin/ht-setcredit.mp';xmlHttp.open("POST",str,true);xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlHttp.setRequestHeader("Content-length",params.length);xmlHttp.setRequestHeader("Connection","close");xmlHttp.send(params);}}
function Header()
{
	var value="";value=readCookie('v4iil');
	var url=document.URL;
	var redirect="";
	if(url.match('/cgi-bin/'))
	{
		var dd=document.referrer;redirect=dd;
		if(dd.match('/cgi-bin/'))
		{
			redirect='http://www.hellotrade.com';
		}
	}
	else
	{
		if(url.match('signout.html'))
		{
			redirect='/';
		}
		else
		{
			redirect=escape(url);
		}
	}
	if(value==null||value=="")
	{
		if(document.getElementById('signinornot'))
		{
			document.getElementById('signinornot').innerHTML='<span id="signinornot"><a href="http://my.hellotrade.com/cgi-bin/ht-joinfree.mp?action=joinfree&modid=HELLOTD&redirect='+redirect+'" rel="nofollow">Join Free</a>  |  <a HREF="http://my.hellotrade.com/cgi-bin/ht-usr-login.mp?login=true&modid=HELLOTD&redirect='+redirect+'" rel="nofollow" target="_top">Login</a></span>';
		}
	}
	else
	{
		if(document.getElementById('signinornot'))
		{
			document.getElementById('signinornot').innerHTML='<span id="signinornot"><A href="http://my.hellotrade.com/" target="_top">My Hellotrade</a>  |  <a href="http://my.hellotrade.com/cgi-bin/ht-usr-login.mp?logoff=true&modid=HELLOTD&redirect='+redirect+'" target="_top">Logout</a></span>';
		}
	}
	var user=getUserName();
	if(user!='')
	{
		document.getElementById('welcomeuser').innerHTML='<strong>'+user+'</strong>';
	}
	else
	{
		document.getElementById('welcomeuser').innerHTML=' to <strong>HelloTrade!</strong>';
	}
	var crtavl=getAvlCredit();
	if(crtavl!=-1)
	{
		crtavl=Math.floor(crtavl / 5);
		document.getElementById('nhavbcrd').innerHTML='Available Balance : <strong>'+crtavl+' US$</strong>';
	}
	else if(value)
	{
		if(crtavl==-1)
		{
			setcredit();
		}
	}
	else
	{
		document.getElementById('nhavbcrd').style.display="none";
	}
}
function getUserName()
{var value="";var value=readCookie('htusr');if(value==null||value=="")
{value='';}
else
{value=unescape(value);}
return value;}
function getAvlCredit()
{var value="";value=readCookie('htavlcrdt');if(value==null||value=="")
{value=-1;}
else
{value=unescape(value);}
return value;}
function Footer()
{
	var value="";value=readCookie('v4iil');
	var url=document.URL;var redirect="";
	if(url.match('/cgi-bin/'))
	{
		var dd=document.referrer;redirect=dd;
		if(dd.match('/cgi-bin/'))
		{	
			redirect='http://www.hellotrade.com';
		}
	}
	else
	{
		if(url.match('signout.html'))
		{
			redirect='/';
		}
		else
		{
			redirect=escape(url);
		}
	}
	if(value==null||value=="")
	{
		if(document.getElementById('signinornot1'))
		{
			document.getElementById('signinornot1').innerHTML='<span id="signinornot1"><a href="http://my.hellotrade.com/cgi-bin/ht-joinfree.mp?action=joinfree&modid=HELLOTD" rel="nofollow">Join Free</a> | <a HREF="http://my.hellotrade.com/cgi-bin/ht-usr-login.mp?login=true&modid=HELLOTD&redirect='+redirect+'" target="_top" rel="nofollow">Login</a></span>';
		}
	}
	else
	{
		if(document.getElementById('signinornot1'))
		{
			document.getElementById('signinornot1').innerHTML='<span id="signinornot1"><a href="http://my.hellotrade.com/" target="_top">My Hellotrade</a> | <a href="http://my.hellotrade.com/cgi-bin/ht-usr-login.mp?logoff=true&modid=HELLOTD&redirect='+redirect+'" target="_top">Logout</a></span>';
		}
	}
}
function readCookie(name)
{var ca=document.cookie.split(';');var nameEQ=name+"=";for(var i=0;i<ca.length;i++)
{var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
var xmlHttp;var Values=new Array();var jsonObj;var total_fcp_count; function displayfcp(id)
{var dataid=jsonObj.fcp[id].dataid;var dataname=jsonObj.fcp[id].dataname;var desc=jsonObj.fcp[id].desc;var size=jsonObj.fcp[id].size;var price=jsonObj.fcp[id].price;var weight=jsonObj.fcp[id].weight;var image=jsonObj.fcp[id].image;var moq=jsonObj.fcp[id].moq;var dataname1=dataname
if(dataname)
{dataname='<h1>'+dataname+'</h1>';}
else
{dataname='';}
if(image)
{image=' <div class="imagearea"><img src="'+image+'" alt="'+dataname1+'"></div>';}
if(desc)
{desc=desc.replace(/\n/ig,'<br>');desc='<div style="clear:both"></div>'+desc+'<div> </div>';}
else
{desc='';}
if(size)
{size=' <tr><td width="50%">Size</td><td width="50%"><strong>'+size+'</strong></td>       </tr>';}
else
{size='';}
if(price)
{price='<tr><td>Price</td><td><strong>'+price+'</strong></td></tr>';}
else
{price='';}
if(weight)
{weight='<tr><td>Weight</td><td><strong>'+weight+'</strong></td></tr>';}
else
{weight='';}
if(moq)
{moq='<tr><td>Minium Order Quanties</td><td><strong>'+moq+'</strong></td></tr>';}
else
{moq='';}
var pre_count=id-1;var first_n_pre='';if(pre_count>-1)
{first_n_pre='<a href="javascript:displayfcp('+pre_count+');" rel="nofollow"><img src="/gifs/prod-prev.gif" align="left" border="0"/></a>';}
else
{first_n_pre='<img src="/gifs/prod-prev.gif" align="left" border="0"/>';}
var nxt_count=id+1;var last_count=total_fcp_count-1;var tot_count=total_fcp_count;var nxt_n_last='';if(nxt_count<total_fcp_count)
{nxt_n_last='<a href="javascript:displayfcp('+nxt_count+');" rel="nofollow"><img src="/gifs/prod-next.gif" align="right" border="0"/></a>';}
else
{nxt_n_last='<img src="/gifs/prod-next.gif" align="right" border="0"/>';}
display1='<div class="abm2" ><div id="scrollcontent"> '+dataname+' '+image+' '+desc+' <table width="100%" border="0" cellspacing="0" cellpadding="2"> '+price+' '+weight+' '+size+' '+moq+' </table> </div><div style="margin-top:3%;">'+first_n_pre+' '+nxt_n_last+'</div></div>';document.getElementById("showinner").innerHTML=display1;showLayer(3);}
function get()
{
	if( (cookie = getCookie("newImeshIDvisitor")) > "")
	{ 
		Values = cookie.split("|"); 
		if (Values.length > 0)
		{ 
			if(typeof(Values[0]) != "undefined")
			{ 
				if (document.dataform.S_first_name.value.length == 0)
				{ document.dataform.S_first_name.value = Values[0];}
				else if(document.dataform.S_first_name.value == "First Name")
				{ document.dataform.S_first_name.value = Values[0];}
			}
			else
			{ 
				document.dataform.S_first_name.value = ''; 
			}

			if(typeof(Values[1]) != "undefined")
			{ 
				if (document.dataform.S_last_name.value.length == 0)
				{ document.dataform.S_last_name.value = Values[1];}
				else if(document.dataform.S_last_name.value == "Last Name")
				{ document.dataform.S_last_name.value = Values[1];}
			}
			else
			{ 
				document.dataform.S_last_name.value = ''; 
			}

			if(typeof(Values[2]) != "undefined")
			{ 
				if (document.dataform.S_email.value.length == 0) 
				document.dataform.S_email.value = Values[2]; 
			}
			else
			{ 
				document.dataform.S_email.value = ''; 
			}
			
			if(typeof(Values[3]) != "undefined")
			{ 
				if (document.dataform.S_country.selectedIndex == 0) document.dataform.S_country.options[Values[3]].selected=true;
				document.dataform.S_country_iso.value=document.dataform.S_country.options[Values[3]].value;
			}
			else
			{ 
				document.dataform.S_country.options[0].selected=true; 
				document.dataform.S_country_iso.value='';
			}

			if(typeof(Values[4]) != "undefined")
			{ 
				if (document.dataform.S_ccode.value.length == 0) 
				document.dataform.S_ccode.value = Values[4]; 
			}
			else
			{ 
				document.dataform.S_ccode.value = ''; 
			}

			if(typeof(Values[5]) != "undefined")
			{ 
				if (document.dataform.S_acode.value.length == 0) 
				document.dataform.S_acode.value = Values[5]; 
			}
			else
			{ 
				document.dataform.S_acode.value = ''; 
			}
				
			if(typeof(Values[6]) != "undefined")
			{
				if (document.dataform.S_phone.value.length == 0) 
				document.dataform.S_phone.value = Values[6]; 
			}
			else
			{ 
				document.dataform.S_phone.value = ''; 
			}
				
			if(typeof(Values[7]) != "undefined")
			{ 
				if (document.dataform.S_mcode && document.dataform.S_mcode.value.length == 0) 
				document.dataform.S_mcode.value = Values[7]; 
			}
			else
			{ 
				if(document.dataform.S_mcode)
				{
					document.dataform.S_mcode.value = '';
				} 
			}
			
			if(typeof(Values[8]) != "undefined")
			{ 
				if (document.dataform.S_mobile && document.dataform.S_mobile.value.length == 0) 
				document.dataform.S_mobile.value = Values[8]; 
			}
			else
			{ 
				if(document.dataform.S_mobile)
				{
					document.dataform.S_mobile.value = '';
				} 
			}
			if(typeof(Values[10]) != "undefined")
			{
				if(document.getElementById('q_counter'))
				{
					document.getElementById('q_counter').value = (Values[10]>=0)?Values[10]:0;
				} 
			}
		}
	}
}

function getCookie(Name)
{var search=Name+"="
if(document.cookie.length>0)
{offset=document.cookie.indexOf(search)
if(offset!=-1)
{offset+=search.length
end=document.cookie.indexOf(";",offset)
if(end==-1)end=document.cookie.length
return unescape(document.cookie.substring(offset,end))}}
return"";}

// 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);return false;}
// else
// {return true;}}

function check_advanced_search(flag)
{
	var str='';
	var from = '';

	if(flag == 1)
	{
		form1 = document.quick_find;
		from = 'TOP-SEARCH FCP';
	}
	else
	{
		form1 = document.quick_find1;
		from = 'BOTTOM-SEARCH FCP';
	}
        var org_val = form1.ss.value;
        form1.ss.value = form1.ss.value.replace(/^\s+/g, '').replace(/\s+$/g, '');
	while(form1.ss.value.indexOf('  ')>0)
	{
		form1.ss.value = form1.ss.value.replace('  ',' ');	
	}
	form1.ss.value = form1.ss.value.replace(/[^a-zA-Z0-9+ ]/g, ' ');
	
	var temp=form1.ss.value.replace(/\s/g, '');

        if (form1.ss.value.length < 3 || org_val == 'enter product name to search...')
        {
                alert("Enter at least three characters for search.");
		form1.ss.value = '';
                form1.ss.focus();
                return false;
        }
        else
        {
		_gaq.push(['_trackEvent', 'Search',from, form1.ss.value]);
		var a = form1.ss.value.replace(/\+/g, ' ');
		a = a.replace(/\s+/g, '+');
		str +='ss='+a;
		str = "http://www.hellotrade.com/suppliers?"+str;
		str = myReplace(str,"\\\\?\\\\&","?");
		window.location = str;
		return false;
	}
	
	
}

function myReplace(str, a, b) {
        var re = new RegExp(a, "g");
        var ret = str.replace(re,b);
        return ret;
}



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

function formvalidation(form1,flag,page)
{
if(flag!=5)
{ 
	  if(form1.Description.value=="") { alert('Please describe your requirement.'); form1.Description.focus(); return false; } 
	  
	  var value = "";
	  value = readCookie('v4iil');

	  if(document.getElementById('queryform').style.display=="none" && (value == null || value == ""))
	  {
		    document.getElementById('queryform').style.display="block";
		    return false;
	  }
	  
	  var name1 = form1.Description.value; if((/^\s+$/.test(name1))) { alert('Please describe your requirement.'); form1.Description.focus(); return false; } if(form1.Description.value.length>2000) { alert("Kindly describe your requirement within the limit of 2000 characters."); form1.Description.focus(); return false; } }

if(form1.S_first_name.value=="")
{
	alert('Please enter your name')
	form1.S_first_name.focus();return false;
}
else if(form1.S_first_name.value=="First Name")
{
	alert('Please enter your name')
	form1.S_first_name.focus();return false;
}
else if(form1.S_first_name.value.length >0)
{
	var urlRegxp = /^\D+\D*$/;
	if (urlRegxp.test(form1.S_first_name.value) != true) 
	{
		alert('Kindly enter your correct Name')
		form1.S_first_name.focus();return false;
	}			
}


if(form1.S_last_name.value=='Last Name')
{
	form1.S_last_name.value='';
}
else if(form1.S_last_name.value.length >0)
{
	var urlRegxp = /^\D+\D*$/;
	if (urlRegxp.test(form1.S_last_name.value) != true) 
	{
		alert('Kindly enter your correct Name')
		form1.S_last_name.focus();return false;
	}
}
if(form1.S_email.value=="")
{
	alert('Please enter a valid e-mail id.')
	form1.S_email.focus();return false;
}
if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form1.S_email.value)))
{
	alert("Invalid e-mail id. kindly enter the correct id.");form1.S_email.focus();
	return false;
}

if(form1.S_country.options[form1.S_country.selectedIndex].value=='')
{
	alert('Please select a country.');form1.S_country.focus();return false;
}

if(flag!=5)
{
	if(form1.S_website.value.length > 0)
	{
	  	url = form1.S_website.value;
	  	var urlRegxp = /^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([\w]+)(.[\w]+){1,2}$/;
	  	if (urlRegxp.test(url) != true) 
	  	{
		    alert('Please enter a valid url.');
		    form1.S_website.focus();
		    return false;
	  	}
	}
	var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
	if(form1.S_website.value != '' && !(RegExp.test(form1.S_website.value)))
	{
		alert('Please enter a valid Url.')
		form1.S_website.focus();
		return false;
	}  
	if(((form1.S_phone.value.length==0 || form1.S_phone.value == 'Phone Number'))&&((form1.S_mobile && (form1.S_mobile.value.length==0 || form1.S_mobile.value == 'Mobile Number'))))
	{ 
		alert('Please enter a phone number or a mobile number.'); form1.S_phone.focus(); return false; 
	}
	if(form1.S_phone.value.length > 0 && form1.S_phone.value != 'Phone Number') 
	{ 
		var urlRegxp = /^\D+\D*$/;
		if (urlRegxp.test(form1.S_phone.value) == true) 
		{
			alert('Kindly enter a valid phone number.')
			form1.S_phone.focus();
			return false;
		}
		if (isNaN(form1.S_phone.value)) 
		{
			alert('Kindly enter a valid phone number.')
			form1.S_phone.focus();
			return false;
		}
	}
	if(form1.S_phone.value.length > 35)
	{ 
		alert('Phone number can not have more than 35 digits.'); form1.S_phone.focus(); 
		return false;
	}
	if(form1.S_acode.value.length > 0)
	{ 
		var urlRegxp = /^\D+\D*$/;
		if (urlRegxp.test(form1.S_acode.value) == true) 
		{
			if(form1.S_acode.value != 'Area Code')
			{
				alert('Kindly enter a valid area code.')
				form1.S_acode.focus();return false;
			}
		}
	}
	if(form1.S_mobile && form1.S_mobile.value.length > 0 && form1.S_mobile.value != 'Mobile Number') 
	{ 
		var urlRegxp = /^\D+\D*$/;
		if (urlRegxp.test(form1.S_mobile.value) == true) 
		{
			alert('Kindly enter a valid mobile number.')
			form1.S_phone.focus();return false;
		}
		if (isNaN(form1.S_mobile.value)) 
		{
			alert('Kindly enter a valid mobile number.')
			form1.S_phone.focus();return false;
		}
	}
	if(form1.S_mobile && form1.S_mobile.value.length > 40)
 	{
		alert('Mobile number can not have more than 40 digits.'); form1.S_mobile.focus(); 
		return false; 
	}

	
}
else
{
	if(form1.S_phone.value.length==0)
 	{ 
		alert('Please enter a phone number.');
	 	form1.S_phone.focus();
	 	return false; 
	}
	if(form1.S_phone.value.length > 0)
	{ 
		var urlRegxp = /^\D+\D*$/;
		if (urlRegxp.test(form1.S_phone.value) == true) 
		{
			alert('Kindly enter a valid phone number.')
			form1.S_phone.focus();
			return false;
		}
		if (isNaN(form1.S_phone.value)) 
		{
			lert('Kindly enter a valid phone number.')
			form1.S_phone.focus();
			return false;
		}
	}
	if(form1.S_phone.value.length > 35)
 	{ 
		alert('Phone number can not have more than 35 digits.'); form1.S_phone.focus(); 
		return false; 
	}
	if(form1.S_acode.value.length > 0)
 	{ 
		var urlRegxp = /^\D+\D*$/;
		if (urlRegxp.test(form1.S_acode.value) == true) 
		{
			alert('Kindly enter a valid area code.')
			form1.S_acode.focus();return false;
		}
		if (isNaN(form1.S_acode.value)) 
		{
			alert('Kindly enter a valid area code.')
			form1.S_acode.focus();return false;
		}
	}
}

if(flag!=5)
{
	if(form1.captcha_text.value=='')
	{
		alert('Please enter the text shown in the image.');
		form1.captcha_text.focus();
		return false;
	}
}
newIILCookie=form1.S_first_name.value;newIILCookie+="|"+form1.S_last_name.value;newIILCookie+="|"+form1.S_email.value;newIILCookie+="|"+form1.S_country.selectedIndex;newIILCookie+="|"+form1.S_ccode.value;newIILCookie+="|"+form1.S_acode.value;newIILCookie+="|"+form1.S_phone.value;
if(flag!=5)
{
	if(form1.S_mcode)
	{
		newIILCookie+="|"+form1.S_mcode.value;
	}
	if(form1.S_mobile)
	{
		newIILCookie+="|"+form1.S_mobile.value;
	}
	newIILCookie+="|"+form1.S_website.value;
}
if(flag!=5)
{sendQuery(form1,flag,page,newIILCookie);return false;}
else
{makeCall();}}
function setCookie(name,value)
{if(value.length>0)
{document.cookie=name+"="+escape(value)+";"+"expires="+expires.toGMTString()+";"+"path=/;";}}
function sendQuery(form1,flag,page,newIILCookie)
{
	thisForm=form1;
	desc=thisForm.Description.value;
	email=thisForm.S_email.value;
	salute=thisForm.S_salute.options[thisForm.S_salute.selectedIndex].value;
	first_name=thisForm.S_first_name.value;
	last_name=thisForm.S_last_name.value;
	countryname=thisForm.S_country.options[thisForm.S_country.selectedIndex].text;country_iso=thisForm.S_country.options[thisForm.S_country.selectedIndex].value;
	ph_country=thisForm.S_ccode.value;
	ph_acode=thisForm.S_acode.value;
	ph_no=thisForm.S_phone.value;
	if(thisForm.S_mobile)
	{
		mobile=thisForm.S_mobile.value;
	}
	else
	{
		mobile='';
	}
	comp=thisForm.S_organization.value;
	website=thisForm.S_website.value;
	s_glusr_id=thisForm.S_glusr_id.value;
	r_glusr_id=thisForm.R_glusr_id.value;
	r_original_refrer=thisForm.original_refer.value;
r_captcha_ref=thisForm.captcha_ref.value;r_captcha_text=thisForm.captcha_text.value;
if(document.getElementById('q_counter'))
{
	q_counter=document.getElementById('q_counter').value;
}
else
{
	q_counter=0;
}
var xmlHttp=ajaxFunction();if(xmlHttp)
{xmlHttp.onreadystatechange=function()
{if(flag==1)
{document.getElementById("showloading").style.display="block";}

if(xmlHttp.readyState==4)
{temp=xmlHttp.responseText;var pattern=/N/i;var myarr=temp.split("###");if(pattern.test(myarr[0]))
{if(flag==1)
{document.getElementById("error").style.display='';document.getElementById("error").innerHTML=myarr[1];document.getElementById("showloading").style.display="none";}
else
{document.getElementById("error1").style.display='';document.getElementById("error1").innerHTML=myarr[1];}
thisForm.captcha_text.value='';showCaptcha(flag);}
else
{if(flag==1)
{document.getElementById("error").innerHTML='Please enter the text shown in the image.';document.getElementById("showloading").style.display="none";}
else
{document.getElementById("error1").innerHTML='Please enter the text shown in the image.';}
thisForm.captcha_text.value='';
if(document.getElementById('q_counter'))
{
	q_counter = document.getElementById('q_counter').value;
	if( (cookie = getCookie("newImeshIDvisitor")) > "")
	{ 
		Values = cookie.split("|"); 
		if (Values.length > 0)
		{ 
			if(typeof(Values[10]) != "undefined")
			{
				q_counter = (Values[10]>=0)?Values[10]:0;
			}
		}
	}
	q_counter=parseInt(q_counter)+1;
	newIILCookie+="|"+q_counter;
	document.getElementById('q_counter').value = q_counter;
}
newIILCookie+="|";
setCookie("newImeshIDvisitor",newIILCookie);
showCaptcha(flag);showLayer(flag);}}}
if(page == 'contact-new' || page == 'contact')
{
	_gaq.push(['_trackEvent', 'Combination1', page, 'submit']);
	if(page == 'contact')
	{
	_gaq.push(['_trackEvent', 'FCP', 'submit', page]);
	}
}
else
{
_gaq.push(['_trackEvent', 'FCP', 'submit', page]);
}
var params='description='+desc+'&email='+email+'&salute='+salute+'&first_name='+first_name+'&last_name='+last_name+'&ph_country='+ph_country+'&ph_no='+ph_no+'&mobile='+mobile+'&company='+comp+'&website='+website+'&country='+countryname+'&ph_acode='+ph_acode+'&country_iso='+country_iso+'&r_original_refrer='+r_original_refrer+'&s_glusr_id='+s_glusr_id+'&r_glusr_id='+r_glusr_id+'&captcha_ref='+r_captcha_ref+'&captcha_text='+r_captcha_text+'&q_counter='+q_counter;var str='/cgi-bin/hello-query-automail.pl';xmlHttp.open("POST",str,true);xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlHttp.setRequestHeader("Content-length",params.length);xmlHttp.setRequestHeader("Connection","close");xmlHttp.send(params);}}
function showCaptcha(flag)
{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;if(flag==1)
{document.dataform.captcha_ref.value=ran_num;document.getElementById('captchaID').innerHTML='<img src="'+url+'" WIDTH="100" HEIGHT="25">';}
else if(flag==2)
{document.dataform1.captcha_ref.value=ran_num;document.getElementById('captchaIDblowup').innerHTML='<img src="'+url+'" WIDTH="100" HEIGHT="25">';}
else
{document.dataform.captcha_ref.value=ran_num;document.getElementById('captchaID').innerHTML='<img src="'+url+'" WIDTH="100" HEIGHT="25">';}}
function showLayer(flag)
{if(flag==1)
{
	document.getElementById("show").style.display="block";
	document.getElementById("enq-thank").src = "/enq-thank.html";
}
else if(flag==2)
{document.getElementById("show1").style.display="block";}
else if(flag==3)
{document.getElementById("showprodetails").style.display="block";}
else if(flag==4)
{document.getElementById("showcallfree").style.display="block";
document.getElementById("callingprog").style.display="none";}}
var data=new Array();data[0]="---Select Your Country---";data[1]="Afghanistan##AF##93";data[2]="Albania##AL##355";data[3]="Algeria##DZ##213";data[4]="American Samoa##AS##1-684";data[5]="Andorra##AD##376";data[6]="Angola##AO##244";data[7]="Anguilla##AI##1-264";data[8]="Antarctica##AQ##672";data[9]="Antigua And Barbuda##AG##1-268";data[10]="Argentina##AR##54";data[11]="Armenia##AM##374";data[12]="Aruba##AW##297";data[13]="Australia##AU##61";data[14]="Austria##AT##43";data[15]="Azerbaijan##AZ##994";data[16]="Bahamas##BS##1-242";data[17]="Bahrain##BH##973";data[18]="Bangladesh##BD##880";data[19]="Barbados##BB##1-246";data[20]="Belarus##BY##375";data[21]="Belgium##BE##32";data[22]="Belize##BZ##501";data[23]="Benin##BJ##229";data[24]="Bermuda##BM##1-441";data[25]="Bhutan##BT##975";data[26]="Bolivia##BO##591";data[27]="Bosnia And Herzegovina##BA##387";data[28]="Botswana##BW##267";data[29]="Bouvet Island##BV##";data[30]="Brazil##BR##55";data[31]="British Indian Ocean Territory##IO##246";data[32]="Brunei##BN##673";data[33]="Bulgaria##BG##359";data[34]="Burkina Faso##BF##226";data[35]="Burundi##BI##257";data[36]="Cambodia##KH##855";data[37]="Cameroon##CM##237";data[38]="Canada##CA##1";data[39]="Cape Verde##CV##238";data[40]="Cayman Islands##KY##1-453";data[41]="Central African Republic##CF##236";data[42]="Chad##TD##235";data[43]="Chile##CL##56";data[44]="China##CN##86";data[45]="China (Hong Kong S.A.R.)##HK##852";data[46]="China (Macau S.A.R.)##MO##853";data[47]="Christmas Islands##CX##61";data[48]="Cocos Islands##CC##672";data[49]="Colombia##CO##57";data[50]="Comoros##KM##269";data[51]="Congo##CG##242";data[52]="Cook Islands##CK##682";data[53]="Costa Rica##CR##506";data[54]="Cote D Ivoire##CI##225";data[55]="Croatia##HR##385";data[56]="Cuba##CU##53";data[57]="Cyprus##CY##357";data[58]="Czech Republic##CZ##420";data[59]="Democractic Republic Of Congo##CD##243";data[60]="Denmark##DK##45";data[61]="Djibouti##DJ##253";data[62]="Dominica##DM##1-767";data[63]="Dominican Republic##DO##1-809";data[64]="East Timor##TL##670";data[65]="Ecuador##EC##593";data[66]="Egypt##EG##20";data[67]="El Salvador##SV##503";data[68]="Equatorial Guinea##GQ##240";data[69]="Eritrea##ER##291";data[70]="Estonia##EE##372";data[71]="Ethiopia##ET##251";data[72]="Faeroe Islands##FO##298";data[73]="Falkland Islands##FK##500";data[74]="Fiji Islands##FJ##679";data[75]="Finland##FI##358";data[76]="France##FR##33";data[77]="French Guiana##GF##594";data[78]="French Polynesia##PF##689";data[79]="French Southern Territories##TF##262";data[80]="Gabon##GA##241";data[81]="Georgia##GE##995";data[82]="Germany##DE##49";data[83]="Ghana##GH##233";data[84]="Gibraltar##GI##350";data[85]="Greece##GR##30";data[86]="Greenland##GL##299";data[87]="Grenada##GD##1-473";data[88]="Guadeloupe##GP##590";data[89]="Guam##GU##1-671";data[90]="Guatemala##GT##502";data[91]="Guinea##GN##224";data[92]="Guinea-Bissau##GW##245";data[93]="Guyana##GY##592";data[94]="Haiti##HT##509";data[95]="Heard And Mcdonald Islands##HM##672";data[96]="Holy See##VA##379";data[97]="Honduras##HN##504";data[98]="Hungary##HU##36";data[99]="Iceland##IS##354";data[100]="India##IN##91";data[101]="Indonesia##ID##62";data[102]="Iran##IR##98";data[103]="Iraq##IQ##964";data[104]="Ireland##IE##353";data[105]="Israel##IL##972";data[106]="Italy##IT##39";data[107]="Jamaica##JM##1-876";data[108]="Japan##JP##81";data[109]="Jordan##JO##962";data[110]="Kazakhstan##KZ##7";data[111]="Kenya##KE##254";data[112]="Kiribati##KI##686";data[113]="Korea##KR##82";data[114]="Korea, North##KP##850";data[115]="Kuwait##KW##965";data[116]="Kyrgyzstan##KG##996";data[117]="Lao People's Democratic Republic##LA##856";data[118]="Latvia##LV##371";data[119]="Lebanon##LB##961";data[120]="Lesotho##LS##266";data[121]="Liberia##LR##231";data[122]="Libya##LY##218";data[123]="Liechtenstein##LI##423";data[124]="Lithuania##LT##370";data[125]="Luxembourg##LU##352";data[126]="Macedonia##MK##389";data[127]="Madagascar##MG##261";data[128]="Malawi##MW##265";data[129]="Malaysia##MY##60";data[130]="Maldives##MV##960";data[131]="Mali##ML##223";data[132]="Malta##MT##356";data[133]="Marshall Islands##MH##692";data[134]="Martinique##MQ##596";data[135]="Mauritania##MR##222";data[136]="Mauritius##MU##230";data[137]="Mayotte##YT##269";data[138]="Mexico##MX##52";data[139]="Micronesia##FM##691";data[140]="Moldova##MD##373";data[141]="Monaco##MC##377";data[142]="Mongolia##MN##976";data[143]="Montenegro##ME##382";data[144]="Montserrat##MS##1-664";data[145]="Morocco##MA##212";data[146]="Mozambique##MZ##258";data[147]="Myanmar##MM##95";data[148]="Namibia##NA##264";data[149]="Nauru##NR##674";data[150]="Nepal##NP##977";data[151]="Netherlands Antilles##AN##599";data[152]="New Caledonia##NC##687";data[153]="New Zealand##NZ##64";data[154]="Nicaragua##NI##505";data[155]="Niger##NE##227";data[156]="Nigeria##NG##234";data[157]="Niue##NU##683";data[158]="Norfolk Island##NF##672";data[159]="Northern Mariana Islands##MP##1-670";data[160]="Norway##NO##47";data[161]="Oman##OM##968";data[162]="Pakistan##PK##92";data[163]="Palau##PW##680";data[164]="Panama##PA##507";data[165]="Papua New Guinea##PG##675";data[166]="Paraguay##PY##595";data[167]="Peru##PE##51";data[168]="Philippines##PH##63";data[169]="Pitcairn Island##PN##872";data[170]="Poland##PL##48";data[171]="Portugal##PT##351";data[172]="Puerto Rico##PR##1";data[173]="Qatar##QA##974";data[174]="Reunion##RE##262";data[175]="Romania##RO##40";data[176]="Russia##RU##7";data[177]="Rwanda##RW##250";data[178]="Saint Helena##SH##290";data[179]="Saint Kitts And Nevis##KN##1-869";data[180]="Saint Lucia##LC##1-758";data[181]="Saint Pierre And Miquelon##PM##508";data[182]="Saint Vincent And The Grenadin##VC##1-784";data[183]="Samoa##WS##685";data[184]="San Marino##SM##378";data[185]="Sao Tome And Principe##ST##239";data[186]="Saudi Arabia##SA##966";data[187]="Senegal##SN##221";data[188]="Serbia##RS##381";data[189]="Serbia And Montenegro##CS##381";data[190]="Seychelles##SC##248";data[191]="Sierra Leone##SL##232";data[192]="Singapore##SG##65";data[193]="Slovakia##SK##421";data[194]="Slovenia##SI##386";data[195]="Solomon Islands##SB##677";data[196]="Somalia##SO##252";data[197]="South Africa##ZA##27";data[198]="South Georgia##GS##995";data[199]="Spain##ES##34";data[200]="Sri Lanka##LK##94";data[201]="Sudan##SD##249";data[202]="Suriname##SR##597";data[203]="Svalbard And Jan Mayen Islands##SJ##47";data[204]="Swaziland##SZ##268";data[205]="Sweden##SE##46";data[206]="Switzerland##CH##41";data[207]="Syria##SY##963";data[208]="Taiwan##TW##886";data[209]="Tajikistan##TJ##992";data[210]="Tanzania##TZ##255";data[211]="Thailand##TH##66";data[212]="The Gambia##GM##220";data[213]="The Netherlands##NL##31";data[214]="Togo##TG##228";data[215]="Tokelau##TK##690";data[216]="Tonga##TO##676";data[217]="Trinidad And Tobago##TT##1-868";data[218]="Tunisia##TN##216";data[219]="Turkey##TR##90";data[220]="Turkmenistan##TM##993";data[221]="Turks And Caicos Islands##TC##1-649";data[222]="Tuvalu##TV##688";data[223]="Uganda##UG##256";data[224]="Ukraine##UA##380";data[225]="United Arab Emirates##AE##971";data[226]="United Kingdom##UK##44";data[227]="United States Minor Outlying I##UM##1";data[228]="United States Of America##US##1";data[229]="Uruguay##UY##598";data[230]="Uzbekistan##UZ##998";data[231]="Vanuatu##VU##678";data[232]="Venezuela##VE##58";data[233]="Vietnam##VN##84";data[234]="Virgin Islands (British)##VG##1-284";data[235]="Virgin Islands (Us)##VI##1-340";data[236]="Wallis And Futuna Islands##WF##681";data[237]="Western Sahara##EH##212";data[238]="Yemen##YE##967";data[239]="Yugoslavia##YU##38";data[240]="Zambia##ZM##260";data[241]="Zimbabwe##ZW##263"; function check_count_change(form1,opt1)
{
	var val=form1.S_country.options[form1.S_country.selectedIndex].value;
	if(val!=form1.S_country_iso.value)
	{
		if(data[form1.S_country.selectedIndex]!='')
		{
			var data1=data[form1.S_country.selectedIndex];
			var my_array=data1.split("##");
			if(my_array[2])
			{
				my_arr=my_array[2].split("-");
				if(my_arr[1])
				{
					form1.S_ccode.value=my_arr[0];
					form1.S_acode.value=my_arr[1];
					if(opt1!=2)
					{
						if(form1.S_mcode)
						{
							form1.S_mcode.value=my_arr[0];
						}
					}
				}
				else
				{
					form1.S_ccode.value=my_array[2];
					if(opt1!=2)
					{
						if(form1.S_mcode)
						{
						form1.S_mcode.value=my_array[2];
						}
					}
					form1.S_acode.value='';
				}
			}
			else
			{
				form1.S_ccode.value='';
				if(opt1!=2)
				{
					if(form1.S_mcode)
					{
						form1.S_mcode.value='';
					}
				}
				form1.S_acode.value='';
			}
		}
	}
	form1.S_country_iso.value=val;
}
function hideLayerNew()
{
	document.getElementById("show").style.display="none";
	document.getElementById("enq-thank").src = "";
	document.getElementById("showloading").style.display="none";
	document.getElementById("show_error_msg").style.display="none";
	document.dataform.Description.value='';
	document.getElementById('queryform').style.display="none";
}
function hideLayerNew1()
{document.getElementById("showprodetails").style.display="none";}
function hideLayerNew2()
{document.getElementById("show1").style.display="none";}
function addOption(text,value,opt)
{
	if(opt==1)
	{
		form1=document.dataform;
	}
	else if(opt==3)
	{
		form1=document.dataform1;
	}

	val=form1.S_country_iso.value;
	var opt=document.createElement("option");
	opt.text=text;
	opt.value=value;
	if(val==value)
	{
		opt.selected=true;
	}
	form1.S_country.options.add(opt);
}

function populate(opt)
{
	if(opt != 2)
	{
		if(opt==1)
		{
			form1=document.dataform;
		}
		else if(opt==3)
		{
			form1=document.dataform1;
		}
		form1.S_country.remove(0);
		for(var i=0;i<data.length;i++)
		{
			var data1=data[i];
			var my_array=data1.split("##");
			if(my_array[1])
			{
				addOption(my_array[0],my_array[1],opt)
			}
			else
			{
				addOption(my_array[0],'',opt)
			}
		}
	}
}

function gallery(id,totalcount){for(var i=1;i<=totalcount;i++){if(i==id){document.getElementById('psc'+i).style.display="block";document.getElementById('T'+i).className='selected'}else{document.getElementById('psc'+i).style.display="none";document.getElementById('T'+i).className=""}}}


function openQueryForm()
{
	  var value = "";
	  value = readCookie('v4iil');

	  if(document.getElementById('queryform').style.display=="none" && (value == null || value == ""))
	  {
		    document.getElementById('queryform').style.display="block";
	  }
}
function convertnew(pattern)
{	
	var open_in_same_window=0;
	var my_location=unescape(document.location);
	var new_location='';
	var new_pattern='';
	if(my_location.indexOf('translate_c?')!=-1)
	{
		var indexof_u=my_location.indexOf('u=');
		if(indexof_u==-1)
		{
			new_location=document.location;
		}
		else
		{
			var subs=my_location.substring(indexof_u,my_location.length);
			var  ss=subs.split('&');new_location=ss[0].substring(2,ss[0].length);
		}
	}
	else
	{
		new_location=document.location;
	}
	indexof_p=pattern.indexOf('|');
	var isen='';
	if(indexof_p==-1)
	{
		indexof_p1=pattern.indexOf('><');
		if(indexof_p1==-1)
		{
			new_pattern=pattern;
			if(pattern=='en')
			{
				isen=1;
			}
		}
		else
		{
		var psplit=pattern.split('><');
		new_pattern=psplit[0]+'|'+psplit[1];
		if(psplit[1]=='en')
		{
		isen=1;
		}
		}
	}
	else
	{
		var psplit=pattern.split('|');
		new_pattern=psplit[0]+'|'+psplit[1];
		if(psplit[1]=='en')
		{
		isen=1;
		}
	}
	var thisurl='';
	
	if(isen==1)
	{
		thisurl=new_location;
	}
	else
	{
		thisurl='http://translate.google.com/translate_p?langpair='+new_pattern+'&u='+new_location;
	}
	
	if(open_in_same_window==1)
	{
		window.location.href=thisurl;
	}
	else
	{
		msgWindow=window.open(thisurl,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');
	}
	
}

function getBrowserHeight(){var x=0;var y=0;var bd_ht=document.body.scrollHeight;var bd_wd=document.body.offsetHeight; if(bd_ht>bd_wd){x=document.body.scrollWidth;y=document.body.scrollHeight;}else{x=document.body.offsetWidth;y=document.body.offsetHeight;}return{width:parseInt(x),height:parseInt(y)};}function getPageScroll(){var yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;}else if(document.body){yScroll=document.body.scrollTop;}return{scrollheight:parseInt(yScroll)};}function setLayerPosition(){var ScrollHeight=getPageScroll();var show=document.getElementById("show");var bws=getBrowserHeight();show.style.left=10;show=null;}function set_country(name,iso,hostt){var mystr =window.location;if(iso.length>0){document.cookie=name+"="+escape(iso)+";path=/;";}document.location.href=mystr;}
var Imgs=[];
function ImgLoad(cls) { var as=zxcByClassName(cls); for (var z0=0;z0<as.length;z0++) { if (as[z0].getAttribute('rel')&&as[z0].getElementsByTagName('IMG')[0]) { oop=new Fade(as[z0].getElementsByTagName('IMG')[0],as[z0].getAttribute('rel')); Imgs.push(oop); } } CkTop(); }
function Fade(img,src){ this.img=img; this.src=src; this.opc=0; }
Fade.prototype.fade=function(){ if (this.opc==0) this.img.src=this.src; var oop=this; }
function CkTop(){ for (var z0=0;z0<Imgs.length;z0++){ if (zxcPos(Imgs[z0].img)[1]<zxcWWHS()[1]+zxcWWHS()[3]&&Imgs[z0].opc==0){ Imgs[z0].fade(); Imgs.splice(z0,1); z0--; } } }
function zxcWWHS(){ if (window.innerHeight) return [window.innerWidth-10,window.innerHeight-10,window.pageXOffset,window.pageYOffset]; else if (document.documentElement.clientHeight) return [document.documentElement.clientWidth-10,document.documentElement.clientHeight-10,document.documentElement.scrollLeft,document.documentElement.scrollTop]; return [document.body.clientWidth,document.body.clientHeight,document.body.scrollLeft,document.body.scrollTop]; }
function zxcPos(obj){ var rtn=[0,0]; while(obj){ rtn[0]+=obj.offsetLeft; rtn[1]+=obj.offsetTop; obj=obj.offsetParent; } return rtn; }
function zxcByClassName(nme,el,tag) { if (typeof(el)=='string') el=document.getElementById(el); el=el||document; ary=[]; if(nme != 'undefined') { for (var tag=tag||'*',reg=new RegExp('\\b'+nme+'\\b'),els=el.getElementsByTagName(tag),z0=0; z0<els.length;z0++) { if(reg.test(els[z0].className)) ary.push(els[z0]); } } return ary; }
window.onscroll=CkTop;

//Auto Suggestion JS Code 
//js code for google +
window.onload = function () {
		var f = document.getElementById("txt1");
		f.setAttribute("autocomplete", "off"); 
                var oTextbox = new AutoSuggestControl(document.getElementById("txt1"), new StateSuggestions());
		var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;po.src = 'https://apis.google.com/js/plusone.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
            }

function AutoSuggestControl(oTextbox, oProvider) 
{
    this.cur /*:int*/ = -1;
    this.layer = null;
    this.provider = oProvider;
    this.textbox  = oTextbox;
    this.init();
}
AutoSuggestControl.prototype.autosuggest = function (aSuggestions,bTypeAhead) 
{
    if (aSuggestions.length > 0) 
    {
        if (bTypeAhead) 
	{
           this.typeAhead(aSuggestions[0]);
        }
        this.showSuggestions(aSuggestions);
    } 
    else 
    {
        this.hideSuggestions();
    }
};
AutoSuggestControl.prototype.createDropDown = function () {

    var oThis = this;
    this.layer = document.createElement("div");
    this.layer.className = "suggestions";
    this.layer.style.visibility = "hidden";
    this.layer.style.width = this.textbox.offsetWidth;
    this.layer.onmousedown = 
    this.layer.onmouseup = 
    this.layer.onmouseover = function (oEvent) {
        oEvent = oEvent || window.event;
        oTarget = oEvent.target || oEvent.srcElement;

        if (oEvent.type == "mousedown") {
            oThis.textbox.value = oTarget.firstChild.nodeValue;
            oThis.hideSuggestions();
        } else if (oEvent.type == "mouseover") {
            oThis.highlightSuggestion(oTarget);
        } else {
            oThis.textbox.focus();
        }
    };
    
    
    document.body.appendChild(this.layer);
};

AutoSuggestControl.prototype.getLeft = function () {

    var oNode = this.textbox;
    var iLeft = 0;
    
    while(oNode.tagName != "BODY") {
        iLeft += oNode.offsetLeft;
        oNode = oNode.offsetParent;
    }
    return iLeft;
};

AutoSuggestControl.prototype.getTop = function (){

    var oNode = this.textbox;
    var iTop = 0;
    
    while(oNode.tagName != "BODY") {
        iTop += oNode.offsetTop;
        oNode = oNode.offsetParent;
    }
    
    return iTop;
};

AutoSuggestControl.prototype.handleKeyDown = function (oEvent) {

    switch(oEvent.keyCode) {
        case 38: //up arrow
            this.previousSuggestion();
            break;
        case 40: //down arrow 
            this.nextSuggestion();
            break;
        case 13: //enter
            this.hideSuggestions();
            break;
    }

};

AutoSuggestControl.prototype.handleKeyUp = function (oEvent) {

    var iKeyCode = oEvent.keyCode;

    //for backspace (8) and delete (46), shows suggestions without typeahead
    if (iKeyCode == 8 || iKeyCode == 46) {
        this.provider.requestSuggestions(this, false);
        
    //make sure not to interfere with non-character keys
    } else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
        //ignore
    } else {
        //request suggestions from the suggestion provider with typeahead
        this.provider.requestSuggestions(this, true);
    }
};

AutoSuggestControl.prototype.hideSuggestions = function () {
    this.layer.style.visibility = "hidden";
};

AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
    
    for (var i=0; i < this.layer.childNodes.length; i++) {
        var oNode = this.layer.childNodes[i];
        if (oNode == oSuggestionNode) {
            oNode.className = "current"
        } else if (oNode.className == "current") {
            oNode.className = "";
        }
    }
};

AutoSuggestControl.prototype.init = function () {

    //save a reference to this object
    var oThis = this;
    
    //assign the onkeyup event handler
    this.textbox.onkeyup = function (oEvent) {
    
        //check for the proper location of the event object
        if (!oEvent) {
            oEvent = window.event;
        }    
        
        //call the handleKeyUp() method with the event object
        oThis.handleKeyUp(oEvent);
    };
    
    //assign onkeydown event handler
    this.textbox.onkeydown = function (oEvent) {
    
        //check for the proper location of the event object
        if (!oEvent) {
            oEvent = window.event;
        }    
        
        //call the handleKeyDown() method with the event object
        oThis.handleKeyDown(oEvent);
    };
    
    //assign onblur event handler (hides suggestions)    
    this.textbox.onblur = function () {
        oThis.hideSuggestions();
    };
    
    //create the suggestions dropdown
    this.createDropDown();
};

AutoSuggestControl.prototype.nextSuggestion = function () {
    var cSuggestionNodes = this.layer.childNodes;

    if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
        var oNode = cSuggestionNodes[++this.cur];
        this.highlightSuggestion(oNode);
        this.textbox.value = oNode.firstChild.nodeValue; 
    }
};

AutoSuggestControl.prototype.previousSuggestion = function () {
    var cSuggestionNodes = this.layer.childNodes;

    if (cSuggestionNodes.length > 0 && this.cur > 0) {
        var oNode = cSuggestionNodes[--this.cur];
        this.highlightSuggestion(oNode);
        this.textbox.value = oNode.firstChild.nodeValue;   
    }
};

AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*:int*/) {

    //use text ranges for Internet Explorer
    if (this.textbox.createTextRange) {
        var oRange = this.textbox.createTextRange(); 
        oRange.moveStart("character", iStart); 
        oRange.moveEnd("character", iLength - this.textbox.value.length);      
        oRange.select();
        
    //use setSelectionRange() for Mozilla
    } else if (this.textbox.setSelectionRange) {
        this.textbox.setSelectionRange(iStart, iLength);
    }     

    //set focus back to the textbox
    this.textbox.focus();      
}; 

AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
    
    var oDiv = null;
    this.layer.innerHTML = "";  //clear contents of the layer
    
    for (var i=0; i < aSuggestions.length; i++) {
        oDiv = document.createElement("div");
    	oDiv.style.fontSize = "14px";	
        oDiv.appendChild(document.createTextNode(aSuggestions[i]));
        this.layer.appendChild(oDiv);
	if(i == 20)
	{	
		break;
	}	
    }
	
	if(document.location.href == 'http://hellotrade/' || document.location.href == 'http://www.hellotrade.com/')
	{
		this.layer.style.width = "519px";
	}
	else
	{
		this.layer.style.width = "333px";
	}
    	
    this.layer.style.left = this.getLeft() + "px";
    this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
    this.layer.style.visibility = "visible";
    this.layer.style.background = "#FFEEF6";
    this.layer.style.fontFamily = "Verdana, Geneva, sans-serif";
};

AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) {

    //check for support of typeahead functionality
    if (this.textbox.createTextRange || this.textbox.setSelectionRange){
        var iLen = this.textbox.value.length; 
        this.textbox.value = sSuggestion; 
        this.selectRange(iLen, sSuggestion.length);
    }
};


/**
 * Provides suggestions for state names (USA).
 */
var states = [];
function StateSuggestions() {
    
}

/**
 * Request suggestions for the given autosuggest control. 
 */
StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl ,
                                                          bTypeAhead) {
    var aSuggestions = [];
    var sTextboxValue = oAutoSuggestControl.textbox.value;
    var flag = 0;
    var len = sTextboxValue.replace(/\s+/g,"");
    len = len.length;
    
    if(states.length == 0 && len>2)
    {
	flag=1;
    }
if(flag == 0)
    {
	if (sTextboxValue.length > 0)
	{
		//search for matching states
		for (var i=0; i < states.length; i++) { 
			if (states[i].toUpperCase().indexOf(sTextboxValue.toUpperCase()) == 0) {
			aSuggestions.push(states[i]);
			
			}
		}
		if(aSuggestions.length < 1 && len == 3)
		{
			flag=1;
		}
	
    	}
    oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
    }	
// 	alert(flag);		
    if(flag)
    {
// 	document.getElementById('wait').innerHTML='Wait....';
    	try
	{
   		// Opera 8.0+, Firefox, Safari
   		ajaxRequest = new XMLHttpRequest();
 	}catch (e)
	{
   		// Internet Explorer Browsers
   		try
		{
      			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
   		}catch (e) 
		{
      			try
			{
         			ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
      			}catch (e)
			{
         			// Something went wrong
         			alert("Your browser broke!");
        	 		return false;
			}
   		}
 	}
 	ajaxRequest.onreadystatechange = function()
	{
   		if(ajaxRequest.readyState == 4)
		{
			states=ajaxRequest.responseText.split(",");
// 			document.getElementById('wait').innerHTML='';
// 			
			if (sTextboxValue.length > 0)
			{
  				//search for matching states
				for (var i=0; i < states.length; i++) 
				{ 
					if(states[i].toUpperCase().indexOf(sTextboxValue.toUpperCase()) == 0) 
					{
					aSuggestions.push(states[i]);
					} 
				}
    			}
			oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);	
   		}
 	}
 	// Now get the value from user and pass it to
 	// server script.
 			
 	var queryString = "?query=" + sTextboxValue+"&from=txt" ;
 	ajaxRequest.open("GET", "/cgi-bin/lucene-suggestion.pl" + 
        queryString, true);
 	ajaxRequest.send(null);
   }
	
   //provide suggestions to the control
    
};
