<!-- Javascript: trim leading and trailing spaces -->
<!--Here?s a quick function to remove leading, trailing and multiple spaces from a string using regular expression which is much faster that using loops!-->
function trim(s) {
	s = s.replace(/(^\s*)|(\s*$)/gi,"");
	s = s.replace(/[ ]{2,}/gi," ");
	s = s.replace(/\n /,"\n");
	return s;
}
function makeUrlKeyword(sq)
{
	sq = sq.replace(/\s+/g," ");
	sq = trim(sq, '') 
	//sq = sq.replace(/(\s)/g,'-');
	sq = sq.replace(/[^a-zA-Z0-9-]/g,' ');
	//alert(sq);
	sq = sq.replace(/\s+/g,' ');
	//alert(sq);
	sq = sq.replace(/(\s)/g,'-');
	return sq;

}
function validateSearchBox()
{
	var stext	=	 trim(document.getElementById('stext').value)
	document.getElementById('stext').value	=	stext;
	var url	=	"http://sitagita.com/topic/";
	if (stext == 'type here to search')
	{
		stext = '';
	}

	if(stext=='')
	{
		alert("Please Enter Keyword")
		document.getElementById('stext').focus();
		return false;
	}
	url	=	url+makeUrlKeyword(stext);
	window.document.location	=	url;
	return false
}

function set_serach_value() 
{
	if(document.getElementById("stext")!=null)
	{
		if(document.getElementById("stext").value == "")
			document.getElementById("stext").value = "job keywords";
	}
}
