var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function mojotip(){
if (ns6||ie){
tipobj.innerHTML="Trust Level is a points based system MojoPages uses to rank the &quot;trustworthiness&quot; of members.  You will earn 1 point of Trust for every review you write and <span class=TxtOrangeBld>1</span> additional point of Trust for every person who votes one of your reviews as &quot;Helpful&quot;. By earning Trust Points you help other people to &quot;Trust&quot; your reviews because they know you are helpful, involved and respected in the community."
enabletip=true
return false
}
}
function showreviewtip(ReviewTxt){
if (ns6||ie){
tipobj.innerHTML=ReviewTxt;
enabletip=true
return false
}
}
function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"
//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}
function hidemojotip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}
document.onmousemove=positiontip
function getHTTPObject() 
{
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
	try {
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	try {
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (E) {
	xmlhttp = false;
	}
	}
	@else
	xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
	{
		try
		{ 
			xmlhttp = new XMLHttpRequest(); 
		} 
		catch(e) 
		{ 
			xmlhttp = false; 
		} 
	} 
	return xmlhttp;        
}
var ObjHTTP5 = getHTTPObject();
var busloc = "";
function ValidatesearchBusiness_Wid()
{
	var is_zip = 0;	

	frm=document.getElementById("searchFrm1");
	if(frm.busKeyword.value=="name or category")
	{
		alert("Please enter a business name or category");
		frm.busKeyword.focus();
		return false;
	}

	if(frm.busKeyword.value.match(/^\s*$/))
	{
		alert("Please enter a business name or category");
		frm.busKeyword.focus();
		return false;
	}

	if(frm.buslocation.value.match(/^\s*$/))
	{
		alert("Please enter the location as City, State or Zip");
		frm.buslocation.focus();
		return false;
	}
	
	if(frm.busKeyword.value.match(/#/))
	{
		alert("Business name should not have special character like '#'.");
		frm.buslocation.focus();
		return false;
	}
	
	searchLocation=trimAll(frm.buslocation.value);
	if(searchLocation.length<5){
		alert("Search location should be more than 4 characters.\nEnter your location in one of the following formats.\nCity (San Diego) \nCity, State (San Diego, CA)\nCity, State zip (San Diego, CA 92107)\nZip (92107)");
		return false;
		frm.buslocation.focus();
	}
	locationArray=searchLocation.split(",");
	if(locationArray.length==1){ 
		// User has enteredeither city or zipcode only
		if(isNaN(locationArray[0])){
			// If city only
			if(locationArray[0].match(/[0-9]+/)){
				//alert("Please enter proper city name i.e. San Diego");
				alert("Enter your location in one of the following formats.\nCity (San Diego) \nCity, State (San Diego, CA)\nCity, State zip (San Diego, CA 92107)\nZip (92107)");
				frm.buslocation.focus();
				return false;
			} 
		}else if(locationArray[0].length>5){
			// If zip code only			
			alert("Entered zip code should be of five charaters");
			frm.buslocation.focus();
			return false;					
		}
	}else if(locationArray.length==2){
		// location is having more than one element
		locationArray[0]=trimAll(locationArray[0]);
		locationArray[1]=trimAll(locationArray[1]);
		if(locationArray[0].match(/[0-9]+/)){
				//alert("Please enter proper city name i.e. San Diego, CA");
				alert("Enter your location in one of the following formats.\nCity (San Diego) \nCity, State (San Diego, CA)\nCity, State zip (San Diego, CA 92107)\nZip (92107)");
				frm.buslocation.focus();
				return false;
		}else {			
			stateArray=locationArray[1].split(" ");
			if(stateArray.length>2){
				alert("Enter your location in one of the following formats.\nCity (San Diego) \nCity, State (San Diego, CA)\nCity, State zip (San Diego, CA 92107)\nZip (92107)");
				frm.buslocation.focus();
				return false;
			}
			stateArray[0]=trimAll(stateArray[0]);
			if(stateArray[0].match(/[0-9]+/)){
				//alert("Please enter proper State name.");
				alert("Enter your location in one of the following formats.\nCity (San Diego) \nCity, State (San Diego, CA)\nCity, State zip (San Diego, CA 92107)\nZip (92107)");
				frm.buslocation.focus();
				return false;
			} 
			if(stateArray[0].length<2){				
				alert("Enter your location in one of the following formats.\nCity (San Diego) \nCity, State (San Diego, CA)\nCity, State zip (San Diego, CA 92107)\nZip (92107)");
				frm.buslocation.focus();
				return false;
			}	
			if(stateArray.length==2){		
				stateArray[1]=trimAll(stateArray[1]);
				if(!stateArray[1].match(/^[0-9]{5}$/)){				
					//alert("Please enter proper Zipecode after state name, Entered zip code should be of five charaters");
					alert("Enter your location in one of the following formats.\nCity (San Diego) \nCity, State (San Diego, CA)\nCity, State zip (San Diego, CA 92107)\nZip (92107)");
					frm.buslocation.focus();
					return false;
				}
			}
		}
	}
	else if(locationArray.length==3)
	{		
		// location is having more than one element
		locationArray[0]=trimAll(locationArray[0]);
		locationArray[1]=trimAll(locationArray[1]);
		locationArray[2]=trimAll(locationArray[2]);
		if(locationArray[0].match(/[0-9]+/))
		{
			//alert("Please enter proper city name i.e. San Diego, CA");
			alert("Enter your location in one of the following formats.\nCity, State (San Diego, CA)\nCity, State zip (San Diego, CA 92107)\nCity, State, zip (San Diego, CA, 92107)\nZip (92107)");
			frm.buslocation.focus();
			return false;
		}
		else if(locationArray[1].length>2)
		{
			alert("Enter your location in one of the following formats.\nCity, State (San Diego, CA)\nCity, State zip (San Diego, CA 92107)\nCity, State, zip (San Diego, CA, 92107)\nZip (92107)");
			frm.buslocation.focus();
			return false;
		}
		else if(locationArray[1].match(/[0-9]+/))
		{
			//alert("Please enter proper State name.");
			alert("Enter your location in one of the following formats.\nCity, State (San Diego, CA)\nCity, State zip (San Diego, CA 92107)\nCity, State, zip (San Diego, CA, 92107)\nZip (92107)");
			frm.buslocation.focus();
			return false;
		}
		else if(!locationArray[2].match(/^[0-9]{5}$/))
		{				
			//alert("Please enter proper Zipecode after state name, Entered zip code should be of five charaters");
			alert("Enter your location in one of the following formats.\nCity, State (San Diego, CA)\nCity, State zip (San Diego, CA 92107)\nCity, State, zip (San Diego, CA, 92107)\nZip (92107)");
			frm.buslocation.focus();
			return false;
		}
		busloc = locationArray[2];
	}
	else
	{
		alert("Enter your location in one of the following formats.\nCity (San Diego) \nCity, State (San Diego, CA)\nCity, State zip (San Diego, CA 92107)\nZip (92107)");
		frm.buslocation.focus();
		return false;
	}
	//window.location="{/literal}{$HTTP_LOCATION}?mysession={encode paramstring='business_searchLoading'}{literal}&buslocation="+frm.buslocation.value+"&busKeyword="+frm.busKeyword.value;
	//return true;	

	if(busloc == "")
	{
		busloc = frm.buslocation.value;
	}

	if(!isNaN(busloc))
	{
		getCityState_Wid(busloc);
	}
	else
	{
		buslocArray=busloc.split(",");
		city = trimAll(buslocArray[0].toLowerCase());
		city = city.replace(/ /g,"-");
		state = trimAll(buslocArray[1]);
		rowstr = trimAll(buslocArray[1]);
		rowstrarr = rowstr.split(" ");
		state = trimAll(rowstrarr[0].toLowerCase());
		keyword = frm.busKeyword.value.replace(/&/g,"-amp-");
		keyword = keyword.replace(/ /g,"-");
		keyword = keyword.replace(/%/g,"%25");
		keyword = ReplaceSpecialCharsWithBlank(keyword);
		keyword = keyword.toLowerCase();
		url = HTTP_LOCATION+"s/"+keyword+"/"+city+"/"+state;
//		url="{/literal}{$HTTP_LOCATION}?mysession={encode paramstring='business_NormalSearchBusiness'}{literal}&buslocation="+frm.buslocation.value+"&busKeyword="+frm.busKeyword.value+"&mode=search";
		ValidateSearch_Wid(url);
		return false;
	}
}
function ReplaceSpecialCharsWithBlank(keyword)
{	
	var arr;
	arr = new Array('!','@','#','$','^','(',')','{','}','[',']','/','\\','~','`','<','>','"');
	for(i=0; i<arr.length; i++)
	{
		while (keyword.indexOf(arr[i]) > -1) 
		{
			keyword = keyword.replace(arr[i],"");
		}
	}
	return keyword;	
}
function getCityState_Wid(busloc)
{
	var url = "";	
	url = HTTP_LOCATION+"?mysession={/literal}" + encodeBase64('business_getCityState') + "{literal}";
	url = url+"&zip="+busloc;
	ObjHTTP5.open("GET", url , true);
	ObjHTTP5.onreadystatechange = cb_getCityState_Wid;
	ObjHTTP5.send(null);
}
function checkEnter_Wid(e)
{
	var keyCode = null;
	
	if( e.which ) 
	{
	  keyCode = e.which;
	}else if( e.keyCode ){
	  keyCode = e.keyCode;
	}
	
	if( 13 == keyCode )
	{
 	   ValidatesearchBusiness_Wid();
	   return false;
	}
	return true;
}
function cb_getCityState_Wid()
{	
	if (ObjHTTP5.readyState == 4 && ObjHTTP5.status == 200)	
	{				
		var str = ObjHTTP5.responseText;
		buslocarr = str.split(",");
		city = trimAll(buslocarr[0].toLowerCase());
		city = city.replace(/ /g,"-");
		state = trimAll(buslocarr[1].toLowerCase());
		keyword = frm.busKeyword.value.replace(/&/g,"-amp-");
		keyword = keyword.replace(/ /g,"-");
		keyword = keyword.replace(/%/g,"%25");
		keyword = keyword.toLowerCase();
		url = HTTP_LOCATION+"s/"+keyword+"/"+city+"/"+state;
		ValidateSearch_Wid(url);
	}
}
function ValidateSearch_Wid(url)
{
	window.location = url;		
	return false;
}
function trimAll(sString) 
{
	while(sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while(sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
function checkValidData()
{

	if(document.getElementById("keywords").value=="")
	{
		alert("Enter keyword for search")	
		document.getElementById("keywords").focus();
		return false;			
	}
}
