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;
}
function doPremiumEmailLink(clickUrl) {
	var rtn = true;
	if(clickUrl) {
		doPremiumClick(clickUrl);
	}
	return rtn;
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
window.onload="MM_preloadImages('img/home_active.gif','img/profile_active.gif','img/preview_active.gif','img/tool_active.gif','img/friend_active.gif','img/community_active.gif','img/myfavorites_active.gif')";
// Encode Decode Functions //
function urlDecode(str){
    str=str.replace(new RegExp('\\+','g'),' ');
    return unescape(str);
}
function urlEncode(str){
    str=escape(str);
    str=str.replace(new RegExp('\\+','g'),'%2B');
    return str.replace(new RegExp('%20','g'),'+');
}
var END_OF_INPUT = -1;
var base64Chars = new Array(
    'A','B','C','D','E','F','G','H',
    'I','J','K','L','M','N','O','P',
    'Q','R','S','T','U','V','W','X',
    'Y','Z','a','b','c','d','e','f',
    'g','h','i','j','k','l','m','n',
    'o','p','q','r','s','t','u','v',
    'w','x','y','z','0','1','2','3',
    '4','5','6','7','8','9','+','/'
);
var reverseBase64Chars = new Array();
for (var i=0; i < base64Chars.length; i++){
    reverseBase64Chars[base64Chars[i]] = i;
}
var base64Str;
var base64Count;
function setBase64Str(str){
    base64Str = str;
    base64Count = 0;
}
function readBase64(){    
    if (!base64Str) return END_OF_INPUT;
    if (base64Count >= base64Str.length) return END_OF_INPUT;
    var c = base64Str.charCodeAt(base64Count) & 0xff;
    base64Count++;
    return c;
}
function encodeBase64(str){
    setBase64Str(str);
    var result = '';
    var inBuffer = new Array(3);
    var lineCount = 0;
    var done = false;
    while (!done && (inBuffer[0] = readBase64()) != END_OF_INPUT){
        inBuffer[1] = readBase64();
        inBuffer[2] = readBase64();
        result += (base64Chars[ inBuffer[0] >> 2 ]);
        if (inBuffer[1] != END_OF_INPUT){
            result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]);
            if (inBuffer[2] != END_OF_INPUT){
                result += (base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]);
                result += (base64Chars [inBuffer[2] & 0x3F]);
            } else {
                result += (base64Chars [((inBuffer[1] << 2) & 0x3c)]);
                result += ('=');
                done = true;
            }
        } else {
            result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30)]);
            result += ('=');
            result += ('=');
            done = true;
        }
        lineCount += 4;
        if (lineCount >= 76){




            result += ('\n');
            lineCount = 0;
        }
    }
    return result;
}
function readReverseBase64(){   
    if (!base64Str) return END_OF_INPUT;
    while (true){      
        if (base64Count >= base64Str.length) return END_OF_INPUT;
        var nextCharacter = base64Str.charAt(base64Count);
        base64Count++;
        if (reverseBase64Chars[nextCharacter]){
            return reverseBase64Chars[nextCharacter];
        }
        if (nextCharacter == 'A') return 0;
    }
    return END_OF_INPUT;
}

function ntos(n){
    n=n.toString(16);
    if (n.length == 1) n="0"+n;
    n="%"+n;
    return unescape(n);
}
function decodeBase64(str){
    setBase64Str(str);
    var result = "";
    var inBuffer = new Array(4);
    var done = false;
    while (!done && (inBuffer[0] = readReverseBase64()) != END_OF_INPUT
        && (inBuffer[1] = readReverseBase64()) != END_OF_INPUT){
        inBuffer[2] = readReverseBase64();
        inBuffer[3] = readReverseBase64();
        result += ntos((((inBuffer[0] << 2) & 0xff)| inBuffer[1] >> 4));
        if (inBuffer[2] != END_OF_INPUT){
            result +=  ntos((((inBuffer[1] << 4) & 0xff)| inBuffer[2] >> 2));
            if (inBuffer[3] != END_OF_INPUT){
                result +=  ntos((((inBuffer[2] << 6)  & 0xff) | inBuffer[3]));
            } else {
                done = true;
            }
        } else {
            done = true;
        }
    }
    return result;
}

var digitArray = new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
function toHex(n){
    var result = ''
    var start = true;
    for (var i=32; i>0;){
        i-=4;
        var digit = (n>>i) & 0xf;
        if (!start || digit != 0){
            start = false;
            result += digitArray[digit];
        }
    }
    return (result==''?'0':result);
}

function pad(str, len, pad){
    var result = str;
    for (var i=str.length; i<len; i++){
        result = pad + result;
    }
    return result;
}

function encodeHex(str){
    var result = "";
    for (var i=0; i<str.length; i++){
        result += pad(toHex(str.charCodeAt(i)&0xff),2,'0');
    }
    return result;
}

function decodeHex(str){
    str = str.replace(new RegExp("s/[^0-9a-zA-Z]//g"));
    var result = "";
    var nextchar = "";
    for (var i=0; i<str.length; i++){
        nextchar += str.charAt(i);
        if (nextchar.length == 2){
            result += ntos(eval('0x'+nextchar));
            nextchar = "";
        }
    }
    return result;
    
}
// Encode Decode Functions //

// Float Layer Functions //
var persistclose=0 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var startX = 30 //set x offset of bar in pixels
var startY = 0 //set y offset of bar in pixels
var verticalpos="fromtop" //enter "fromtop" or "frombottom"
var slide=1 //enter "fromtop" or "frombottom"

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
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;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function closebar(){
if (persistclose)
document.cookie="remainclosed=1"
document.getElementById("topbar").style.visibility="hidden"
}

function slideMap(e){
	if(document.getElementById("chkFollowMe").checked == true)
		slide = 1;
	else
		slide = 0;
	
	if(typeof(e.type) != undefined && e.type=='click')
		staticbar();
	else{	
		if (window.addEventListener){
			window.addEventListener("load", staticbar, false)
		}else if (window.attachEvent){
			window.attachEvent("onload", staticbar)
		}else if (document.getElementById){
			window.onload=static
		}	
	}
}

if (window.addEventListener){
	window.addEventListener("load", staticbar, false)
}else if (window.attachEvent){
	window.attachEvent("onload", staticbar)
}else if (document.getElementById){
	window.onload=static
}	

function staticbar(){
	if(document.getElementById("topbar")){
		barheight=document.getElementById("topbar").offsetHeight
		var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
		var d = document;
	}
	function ml(id){
		var el=d.getElementById(id);
		if(slide==0){
			el.sP=function(x,y){this.style.left=30+"px";this.style.top=5+"px";};
			return el;
		}else{
			if (!persistclose || persistclose && get_cookie("remainclosed")=="")
			el.style.visibility="visible"
			if(d.layers)el.style=el;
			el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
			el.x = startX;
			if (verticalpos=="fromtop")
			el.y = startY;
			else{
			el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
			el.y -= startY;
			}
			return el;
		}
	}
	
	window.stayTopLeft=function(){
		if(slide==0){
			//alert(2);
			ftlObj.x = 30;
			ftlObj.y = 5;
			ftlObj.sP(ftlObj.x, ftlObj.y);
			setTimeout("stayTopLeft()", 10);
		}else{
			if (verticalpos=="fromtop"){
			var pY = ns ? pageYOffset : iecompattest().scrollTop;
			
			if(pY > 240)
				ftlObj.y += (pY + startY - ftlObj.y - 240)/8;
			else
				ftlObj.y = 5;
			
			}
			else{
			var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
			ftlObj.y += (pY - startY - ftlObj.y)/8;
			}
			ftlObj.sP(ftlObj.x, ftlObj.y);
			setTimeout("stayTopLeft()", 10);
		}	
	}
	//alert(1);
	if(document.getElementById("topbar")){
		ftlObj = ml("topbar");
		stayTopLeft();
	}
}
function getMap(){
	var mapid = document.BusinessForm.elements["mapid[]"];
		var map_chkd=0;		
		if(mapid.length > 0){
		for(k=0; k<mapid.length; k++){
				if(mapid[k].value != ''){
					map_chkd = '1';
					break;
				}
			}
		}else{
		
			if(mapid.value != '' ){ map_chkd = '1'; }
		}
	if(map_chkd != '1'){
		alert("Please select a business to view the map");
		return false;
	}
	else{
		document.BusinessForm.mode.value="map";
		document.BusinessForm.submit();
	}
}

function getComparison(){
	var compid = document.BusinessForm.elements["compid[]"];
	var cmp_chkd=0;
	if(compid.length > 0){
		for(k=0; k<compid.length; k++){
			if(compid[k].checked == true){
				cmp_chkd = '1';
				break;
			}
		}
	}else{
		if(compid.checked == true ){ cmp_chkd = '1'; }
	}
	if(cmp_chkd != '1'){
		alert("Please select businesses you want to compare");
		return false;
	}
	else{
		document.BusinessForm.action = HTTP_LOCATION +  "?mysession=" + encodeBase64('business_businessactions');
		document.BusinessForm.mode.value="compare";
		document.BusinessForm.submit();
	}
}

function displayBusinessDetail($id){
	var tags = "tags" + $id;
	var addressDetail = "addressDetail" + $id;
	var businessDetail = "businessDetail" + $id;
	var img = "img" + $id;

	if(document.getElementById(businessDetail).style.display == 'none')
	{
		document.getElementById(businessDetail).style.display = 'block';
		document.getElementById(addressDetail).style.display = 'none';
		document.getElementById(tags).style.display = 'none';
		document.getElementById(img).src = IMAGE_NEW_HTTP_LOCATION + 'MinusSign.gif';
	}
	else
	{
		document.getElementById(businessDetail).style.display = 'none';
		document.getElementById(addressDetail).style.display = '';
		document.getElementById(tags).style.display = '';
		document.getElementById(img).src = IMAGE_NEW_HTTP_LOCATION + 'PlusSign.gif';
	}
}

function displayPremiumBusinessDetail($id){
	var premiumTags = "premiumTags" + $id;
	var premiumAddressDetail = "premiumAddressDetail" + $id;
	var premiumBusinessDetail = "premiumBusinessDetail" + $id;
	var primg = "primg" + $id;

	if(document.getElementById(premiumBusinessDetail).style.display == 'none')
	{
		document.getElementById(premiumBusinessDetail).style.display = 'block';
		document.getElementById(premiumAddressDetail).style.display = 'none';
		document.getElementById(premiumTags).style.display = 'none';
		document.getElementById(primg).src = IMAGE_NEW_HTTP_LOCATION + 'MinusSign.gif';
	}
	else
	{
		document.getElementById(premiumBusinessDetail).style.display = 'none';
		document.getElementById(premiumAddressDetail).style.display = '';
		document.getElementById(premiumTags).style.display = '';
		document.getElementById(primg).src = IMAGE_NEW_HTTP_LOCATION + 'PlusSign.gif';
	}
}

function doPhoneLink(clickUrl, phoneClickURL, suffix) {
	var rtn = true;
	if(showObject('phoneLink'+suffix)) {
		rtn = false;
		hideObject('phoneLink'+suffix);
		showObject('phoneLabel'+suffix);
		if(clickUrl) {
			logClick(clickUrl);
			logMojoClick(phoneClickURL);
		}
	}
	return rtn;
}

function doEmailLink(clickUrl, emailClickURL, suffix) {
	var rtn = true;
	if(clickUrl) {
		logClick(clickUrl);
		logMojoClick(emailClickURL);
	}
	return rtn;
}

var delayID;
var doBusinessNameURL;
function doBusinessNameClick(mojoClickURL, flagClickURL, superPagesClickURL) {	
	logClick(superPagesClickURL);
	doBusinessNameURL = mojoClickURL + "&isjs=" + TRUECLICK;
	delayID = setInterval("countClick()",2000);
}

function countClick(){	
	window.location = doBusinessNameURL;
	clearInterval(delayID);
}

function doWebsiteClick(mojoClickURL, flagClickURL, superPagesClickURL) {
	mojoClickURL = mojoClickURL + "&webClickURL=" + encodeBase64(superPagesClickURL) + "&isjs=" + TRUECLICK;
	window.location = mojoClickURL;
}

function getObject(objID) {
	if (document.all) {
		var obj = document.all[objID];
	} else if (document.getElementById) {
		var obj = document.getElementById(objID);
	}
	return obj;
}

function hideObject(objID) {
	var obj = getObject(objID);
	var rtn = false;
	if (obj != null) {
		obj.style.display = "none";
		rtn = true;
	}
	return rtn;
}
function showObject(objID) {
	var obj = getObject(objID);
	var rtn = false;
	if (obj != null) {
		obj.style.display = "inline";
		rtn = true;
	}
	return rtn;
}

function logClick(clickUrl) {
	var img1 = new Image();
	img1.src = clickUrl; 
}

function logMojoClick(clickUrl) {
	var img2 = new Image();
	img2.src = HTTP_LOCATION + clickUrl; 
}

function doPremiumClick(clickUrl) {
	var img3 = new Image();
	img3.src = HTTP_LOCATION + clickUrl; 
}
var gForm = "searchFrm1";
var busloc = "";
function ValidatesearchBusiness(frmname,act)
{
	//frm = document.searchFrm1;
	if(frmname == "SearchFormEND")
		gForm = "SearchFormEND";
	else if(frmname == "widgetSearchFrm")
		gForm = "widgetSearchFrm";
	else if(frmname == "widgetSearchFrmEND")
		gForm = "widgetSearchFrmEND";	

	frm = eval("document."+gForm);
	var is_zip = 0;	
	
	if(frm.busKeyword.value.match(/^\s*$/) || frm.busKeyword.value=='name or category')
	{
		alert("Please enter a business name or category to perform a search");
		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)\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)\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)\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)\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)\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)\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)\nCity, State, zip (San Diego, CA, 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)\nCity, State, zip (San Diego, CA, 92107)\nZip (92107)");
		frm.buslocation.focus();
		return false;
	}

	if(frmname=='widgetSearchFrm' || frmname=='widgetSearchFrmEND')
	{
		url= HTTP_LOCATION + '?mysession='+ encodeBase64("business_widgetSearchBusiness") +'&buslocation='+frm.buslocation.value+'&pid='+frm.pid.value+'&busKeyword='+frm.busKeyword.value.replace(/&/g,"-amp-")+'&mode=search';
		document.getElementById('showkey').innerHTML = frm.busKeyword.value;
		ValidateSearch_H(url);
	}
	else
	{
		if(act==2)
			url= HTTP_LOCATION + '?mysession='+ encodeBase64("reviews_SearchBusiness") +'&buslocation='+frm.buslocation.value+'&busKeyword='+frm.busKeyword.value.replace(/&/g,"-amp-")+'&mode=search';			
	
		if(busloc == "")
			busloc = frm.buslocation.value;

		if(!isNaN(busloc))
		{
			is_zip = 1;
		}
		else if(act == 1)
		{
			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 = ReplaceSpecialCharsWithBlank(keyword);
			keyword = keyword.replace(/ /g,"-");
			keyword = keyword.replace(/%/g,"%25");
			keyword = keyword.toLowerCase();
			showkeyword = frm.busKeyword.value;
			showkeyword = ReplaceSpecialCharsWithBlank(showkeyword);
			document.getElementById('showkey').innerHTML = showkeyword;
			url = HTTP_LOCATION+"s/"+keyword+"/"+city+"/"+state;
			ValidateSearch_H(url);
		}
		
		if(act==1 && is_zip)
		{
			getCityState(busloc);
		}
		else if(act == 2)
		{
			document.getElementById('showkey').innerHTML = frm.busKeyword.value;
			ValidateSearch_H(url);
		}		
	}
}

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(busloc)
{
	var url = "";	
	url = HTTP_LOCATION + "?mysession=" + encodeBase64('business_getCityState');
	url = url+"&zip="+busloc;
	ObjHTTP5.open("GET", url , true);
	ObjHTTP5.onreadystatechange = cb_getCityState;
	ObjHTTP5.send(null);
}

function cb_getCityState()
{	
	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 = ReplaceSpecialCharsWithBlank(keyword);
		keyword = keyword.replace(/ /g,"-");
		keyword = keyword.replace(/%/g,"%25");
		keyword = keyword.toLowerCase();
		showkeyword = frm.busKeyword.value;
		showkeyword = ReplaceSpecialCharsWithBlank(showkeyword);
		document.getElementById('showkey').innerHTML = showkeyword;
		url = HTTP_LOCATION+ "s/"+keyword+"/"+city+"/"+state;
		ValidateSearch_H(url);
	}
}

function ValidateSearch_H(url)
{
	if(document.getElementById('videoDiv'))
	{
		document.getElementById('videoDiv').style.visibility="hidden";
	}
	showTimer(20,30,"searchTimer");
	if (gForm == "searchFrm1" || gForm == "widgetSearchFrm" || gForm == "widgetSearchFrmEND")
	{
		window.location = url;
	}
	else if (gForm == "SearchFormEND")
	{
		/*gfrm = eval("document."+gForm);
		gfrm.action = url;	
		gfrm.submit();*/
		window.location = url;
	}
}
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 checkBusiness()
{
	if(document.searchFrm1.busKeyword.value == "name or category")
		document.searchFrm1.busKeyword.value="";
	return true;
}
function checkBusinessWidget()
{
	if(document.widgetSearchFrm.busKeyword.value == "name or category")
		document.widgetSearchFrm.busKeyword.value="";
	return true;
}
function checkEnter(e){
	var keyCode = null;
	
	if( e.which ) {
	  keyCode = e.which;
	}else if( e.keyCode ){
	  keyCode = e.keyCode;
	}
	
	if( 13 == keyCode )	{
		ValidatesearchBusiness('searchFrm1',1);
	   return false;
	}
	return true;
}
function checkEnterWidget(e){
	var keyCode = null;
	
	if( e.which ) {
	  keyCode = e.which;
	}else if( e.keyCode ){
	  keyCode = e.keyCode;
	}
	
	if( 13 == keyCode )	{
		ValidatesearchBusiness('widgetSearchFrm',1);
	   return false;
	}
	return true;
}
var	BrowserDetect = {
init: function () {
	this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
	this.version = this.searchVersion(navigator.userAgent)
		|| this.searchVersion(navigator.appVersion)
		|| "an unknown version";
	this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
	for (var i=0;i<data.length;i++)	{
		var dataString = data[i].string;
		var dataProp = data[i].prop;
		this.versionSearchString = data[i].versionSearch || data[i].identity;
		if (dataString) {
			if (dataString.indexOf(data[i].subString) != -1)
				return data[i].identity;
		}
		else if (dataProp)
			return data[i].identity;
	}
},
searchVersion: function (dataString) {
	var index = dataString.indexOf(this.versionSearchString);
	if (index == -1) return;
	return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
},
dataBrowser: [
	{ 	string: navigator.userAgent,
		subString: "OmniWeb",
		versionSearch: "OmniWeb/",
		identity: "OmniWeb"
	},
	{
		string: navigator.vendor,
		subString: "Apple",
		identity: "Safari"
	},
	{
		prop: window.opera,
		identity: "Opera"
	},
	{
		string: navigator.userAgent,
		subString: "Firefox",
		identity: "Firefox"
	},
	{		// for newer Netscapes (6+)
		string: navigator.userAgent,
		subString: "Netscape",
		identity: "Netscape"
	},
	{
		string: navigator.userAgent,
		subString: "MSIE",
		identity: "Explorer",
		versionSearch: "MSIE"
	},
	{
		string: navigator.userAgent,
		subString: "Gecko",
		identity: "Mozilla",
		versionSearch: "rv"
	},
	{ 		// for older Netscapes (4-)
		string: navigator.userAgent,
		subString: "Mozilla",
		identity: "Netscape",
		versionSearch: "Mozilla"
	}
],
dataOS : [
	{
		string: navigator.platform,
		subString: "Win",
		identity: "Windows"
	},
	{
		string: navigator.platform,
		subString: "Mac",
		identity: "Mac"
	},
	{
		string: navigator.platform,
		subString: "Linux",
		identity: "Linux"
	}
]

};
BrowserDetect.init();
	
function showTimer(H, W, Id){
	var DvLayerId = document.getElementById("searchBackground"); 			// Var for Main full Opaque Layer
	var DvMessageId = document.getElementById(Id); // Var for Main content div popup Layer
	var ScrollHeight = document.body.scrollHeight; 														// Value for scroll height of the page
	var ScrollWidth = document.body.scrollWidth; 																// Value for scroll width of the page
	var ClientHeight = document.documentElement.clientHeight; 			// Value for browser height of the page
	var ClietnWidth = document.documentElement.clientWidth; 					// Value for Browser width of the page
	var OffsetHeight = document.documentElement.offsetHeight; 			// Value for scroll height for Safari of the page
	var OffsetWidth = document.documentElement.offsetWidth; 					// Value for height height for Safari of the page
		
	DvLayerId.style.display="";
	
	 if(ScrollHeight<ClientHeight) {
		if(BrowserDetect.browser=="Explorer" || BrowserDetect.browser=="Firefox" || BrowserDetect.browser=="Netscape")
			DvLayerId.style.height=ClientHeight+30+"px";
		else
			DvLayerId.style.height=ScrollHeight+30+"px";
	}
	else
		DvLayerId.style.height=ScrollHeight+100+"px";
	
	PosLeft = W/2;
	
	DvLayerId.style.width=ClietnWidth+"px";
	DvLayerId.style.top=0+"px";
	DvLayerId.style.left=0+"px";
	DvMessageId.style.left=450+"px";
	DvMessageId.style.top=270+"px";
	DvMessageId.style.width=500+"px";
	DvMessageId.style.display="";
}
// JavaScript Menu //
var menuwidth='165px' //default menu width
var menubgcolor='#F0F6FC'  //menu bgcolor
var disappeardelay=500  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
	document.write('<div class="Dropdiv" id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function delayhidemenu(){
	if (ie4||ns6)
		delayhide=setTimeout("hidemenu()",disappeardelay)
}

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth, menuheight){
	if (ie4||ns6)
		dropmenuobj.style.left=dropmenuobj.style.top="-500px"
	if (menuwidth!=""){
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.width=menuwidth
	}
	
	if (menuheight!=""){
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.height=menuheight
	}

	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
		obj.visibility=visible
	else if (e.type=="click")
		obj.visibility=hidden
}

function iecompattest1(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=ie4 && !window.opera? iecompattest1().scrollLeft+iecompattest1().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}else{
		var topedge=ie4 && !window.opera? iecompattest1().scrollTop : window.pageYOffset
		var windowedge=ie4 && !window.opera? iecompattest1().scrollTop+iecompattest1().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
			edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
			if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
				edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
		}
	}
	return edgeoffset
}

function populatemenu(what){
	if (ie4||ns6)
		dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth, menuheight){
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	clearhidemenu()
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
	populatemenu(menucontents)
	
	if (ie4||ns6){
		showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth, menuheight)
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	}

	return clickreturnvalue()
}

function clickreturnvalue(){
	if (ie4||ns6) return false
	else return true
}

function contains_ns6(a, b) {
	while (b.parentNode)
		if ((b = b.parentNode) == a)
		return true;
	return false;
}

function dynamichide(e){
	if (ie4&&!dropmenuobj.contains(e.toElement))
		delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		delayhidemenu()
}

function hidemenu(e){
	if (typeof dropmenuobj!="undefined"){
		if (ie4||ns6)
			dropmenuobj.style.visibility="hidden"
	}
}

function clearhidemenu(){
	if (typeof delayhide!="undefined")
		clearTimeout(delayhide)
}

document.onclick=hidemenu

function checkBox(ob,clk){
	document.getElementById(clk).onclick=function(){};
}



var offsetxpoint=-60
var offsetypoint=20 
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="This is a Mojo Bar.  A member earns 1 point of Mojo for every review they write and <span class=TxtOrangeBld>1</span> additional point of Mojo for every person who voted one of their reviews as &quot;Helpful&quot;. The Mojo bar is a way to quickly see how much Mojo a member has earned. The more Mojo a member has, the more involved they are in the community and the more helpful their reviews are. Go get some Mojo... yeah baby!"
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;
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 (rightedge<tipobj.offsetWidth)
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
tipobj.style.left=curX+offsetxpoint+"px"
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;
var delayID1;
var searchURL;
var keyword;
var ObjHTTP4 = getHTTPObject(); // We create the HTTP Object
var ObjHTTP5 = getHTTPObject(); // We create the HTTP Object
//var ObjHTTP6 = getHTTPObject(); // We create the HTTP Object
function expandAllListing1(keyword, buslocation){
	var url = "";
	var isZip = 0;
	url = HTTP_LOCATION + "?mysession=" + encodeBase64('business_setSearchViewType');
	url = url+"&searchViewType=expanded";
	ObjHTTP4.open("GET", url , true);
	ObjHTTP4.send(null);

	if(!isNaN(buslocation))
		isZip = 1;
	else {
		arrLocation = buslocation.split(",");
		city = trimAll(arrLocation[0].toLowerCase());
		city = city.replace(/ /g,"-");
		state = trimAll(arrLocation[1].toLowerCase());

		keyword = keyword.replace(/&/g,"-amp-");
		keyword = ReplaceSpecialCharsWithBlank(keyword);
		keyword = keyword.replace(/ /g,"-");
		keyword = keyword.replace(/%/g,"%25");
		keyword = keyword.toLowerCase();

		searchURL = HTTP_LOCATION+ "s/" + keyword + "/" + city + "/" + state;
	}
	
	if(isZip)
		getCityState(buslocation);
	else
		delayID1 = setInterval("redirect()",2000);
}
function expandAllListing(numOfMojoNormBus){
	for($i=1;$i<=numOfMojoNormBus;$i++){
		var tags = "tags" + $i;
		var addressDetail = "addressDetail" + $i;
		var businessDetail = "businessDetail" + $i;
		var img = "img" + $i;
	
		if(document.getElementById(img)){
			document.getElementById(businessDetail).style.display = 'block';
			document.getElementById(addressDetail).style.display = 'none';
			document.getElementById(tags).style.display = 'none';
			document.getElementById(img).src = IMAGE_NEW_HTTP_LOCATION + 'MinusSign.gif';
		}
	}
	
	for($i=1;$i<=2;$i++){
		var premiumTags = "premiumTags" + $i;
		var premiumAddressDetail = "premiumAddressDetail" + $i;
		var premiumBusinessDetail = "premiumBusinessDetail" + $i;
		var primg = "primg" + $i;

		if(document.getElementById(primg)){
			document.getElementById(premiumBusinessDetail).style.display = 'block';
			document.getElementById(premiumAddressDetail).style.display = 'none';
			document.getElementById(premiumTags).style.display = 'none';
			document.getElementById(primg).src = IMAGE_NEW_HTTP_LOCATION + 'MinusSign.gif';	
		}
	}

	var url = "";
	url = HTTP_LOCATION + "?mysession=" + encodeBase64('business_setSearchViewType');
	url = url+"&searchViewType=expanded";
	ObjHTTP4.open("GET", url , true);
	//ObjHTTP4.onreadystatechange = cb_setSearchViewType;
	ObjHTTP4.send(null);
}

function redirect(){	
	window.location = searchURL;
	clearInterval(delayID1);
}
function compactAllListing(numOfMojoNormBus){
	for($i=1;$i<=numOfMojoNormBus;$i++){
		var tags = "tags" + $i;
		var addressDetail = "addressDetail" + $i;
		var businessDetail = "businessDetail" + $i;
		var img = "img" + $i;
	
		if(document.getElementById(img)){
			document.getElementById(businessDetail).style.display = 'none';
			document.getElementById(addressDetail).style.display = 'block';
			document.getElementById(tags).style.display = 'block';
			document.getElementById(img).src = IMAGE_NEW_HTTP_LOCATION + 'PlusSign.gif';
		}
	}
	
	for($i=1;$i<=2;$i++){
		var premiumTags = "premiumTags" + $i;
		var premiumAddressDetail = "premiumAddressDetail" + $i;
		var premiumBusinessDetail = "premiumBusinessDetail" + $i;
		var primg = "primg" + $i;

		if(document.getElementById(primg)){
			document.getElementById(premiumBusinessDetail).style.display = 'none';
			document.getElementById(premiumAddressDetail).style.display = 'block';
			document.getElementById(premiumTags).style.display = 'block';
			document.getElementById(primg).src = IMAGE_NEW_HTTP_LOCATION + 'PlusSign.gif';	
		}
	}

	var url = "";
	url = HTTP_LOCATION + "?mysession=" + encodeBase64('business_setSearchViewType');
	url = url+"&searchViewType=compact";
	ObjHTTP5.open("GET", url , true);
	ObjHTTP5.send(null);
}
function compactAllListing1(keyword, buslocation){
	var url = "";
	var isZip = 0;
	url = HTTP_LOCATION + "?mysession=" + encodeBase64('business_setSearchViewType');
	url = url+"&searchViewType=compact";
	ObjHTTP4.open("GET", url , true);

	ObjHTTP4.send(null);
	
	//searchURL = HTTP_LOCATION + "?mysession=" + encodeBase64('business_newNormalSearchBusiness&') + "&buslocation=" + location + "&busKeyword=" + keyword + "&mode=search"
	if(!isNaN(buslocation))
		isZip = 1;
	else {
		arrLocation = buslocation.split(",");
		city = trimAll(arrLocation[0].toLowerCase());
		city = city.replace(/ /g,"-");
		state = trimAll(arrLocation[1].toLowerCase());

		keyword = keyword.replace(/&/g,"-amp-");
		keyword = ReplaceSpecialCharsWithBlank(keyword);
		keyword = keyword.replace(/ /g,"-");
		keyword = keyword.replace(/%/g,"%25");
		keyword = keyword.toLowerCase();

		searchURL = HTTP_LOCATION+ "s/" + keyword + "/" + city + "/" + state;
	}
	
	if(isZip)
		getCityState(buslocation);
	else
		delayID1 = setInterval("redirect()",2000);
}
