function searchsubmit(a)
{
	document.quick_find1.pg.value=a;
	document.quick_find1.submit();
	return true;
}

function paginationSubmit(a)
{
	document.quick_find1.pg.value=a;
	document.quick_find1.submit();
	return true;
}



//Head Foot JS Starts

function check_advanced_search()
{
	var kw = document.searc.q.value;
	if (kw.length < 3)
	{
		error_message = "Please enter atleast 3 characters for search";
		alert(error_message);
		document.searc.q.focus();
		return false;
	}
	return true;
}


function check_advanced_search1()
{
	var kw = document.searc1.q.value;
	if (kw.length < 3)
	{
		error_message = "Please enter atleast 3 characters for search";
		alert(error_message);
		document.searc1.q.focus();
		return false;
	}
	return true;
}


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 = escape(url);
	
	if(value == null || value == "")
	{
	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&nbsp;Free</a>&nbsp;&nbsp;|&nbsp;&nbsp;<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
	{
	document.getElementById('signinornot').innerHTML='<span id="signinornot"><A href="http://my.hellotrade.com/" target="_top">My Hellotrade</a>&nbsp;&nbsp;|&nbsp;&nbsp;<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 = escape(url);
	

	if(value == null || value == "")
	{
		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&nbsp;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
	{
		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;
}


//Head Foot JS Ends
