

var newTop = 0;
var newLeft = 0;

var tmprng;
var tmpSelStart=0;
var tmpSelLen=0;

var TextType="";

var myleft=0;
var mytop=0;
var xmlhttp;

var gsCo="";
var gsUrl="";
var gsUserName="";
var gsTitle="";
var gbLoggedIn=false;
var gsCat="";
var gsCity="";

var gsStreet="";
var gsCounty="";
var gsState="";
var gsZip="";
var gsPhone="";
var gsFax="";
var gsEmail="";
var gsId="";
var gsHashCatId="";
var gsWebsite="";

var gsTwitter="";
var gsFacebook="";
var gsLinkedIn="";
var gsSkype="";
var gsYoutube="";

var gsbPremium="";
var gsbURLVerified="";

var gsAllAmerican = "";
var gsGoingGreen = "";

var gcAllAmerican = "";
var gcGoingGreen = "";


function InitVars(sCo, sUrl, sUserName, sTitle, isLoggedIn, sCat, sCity, sStreet, sState, sZip, sPhone, sFax, sEmail, sId, sCounty, sHashCatId, sWebsite, sTwitter, sFacebook, sLinkedIn, sSkype, sYoutube, sbPremium, sbURLVerified, sbAllAmerican, sbGoingGreen)
{
gsCo=sCo;
gsUrl=sUrl;
gsUserName=sUserName;
gsTitle=sTitle;
gbLoggedIn=isLoggedIn;
gsCat=sCat;
gsCity=sCity;

gsCounty=sCounty;
gsStreet=sStreet;
gsState=sState;
gsZip=sZip;
gsPhone=sPhone;
gsFax=sFax;
gsEmail=sEmail;
gsId=sId;
gsHashCatId=sHashCatId;
gsWebsite=sWebsite;

gsTwitter=sTwitter;
gsFacebook=sFacebook;
gsLinkedIn=sLinkedIn;
gsSkype=sSkype;
gsYoutube=sYoutube;

gsbPremium=sbPremium;
gsbURLVerified = sbURLVerified;

gsAllAmerican = sbAllAmerican;
gsGoingGreen = sbGoingGreen;
if (sbAllAmerican == "true") gcAllAmerican = "checked='checked'";
if (sbGoingGreen == "true") gcGoingGreen = "checked='checked'";
 
}




function clickSearch(iBox)
{

    if(iBox==1 && document.getElementById('co').value=="eg. Estate Agent" || document.getElementById('co').value=="Enter full telephone number")
    {
        document.getElementById('co').value="";
    }

    if(iBox==2 && document.getElementById('loc').value=="eg. Dallas, TX")
    {
        document.getElementById('loc').value="";
    }

}

function CheckSearchInput()
{
sCo = document.getElementById('co').value.replace("eg. Estate Agent","").replace("Enter full telephone number","");
sLoc = document.getElementById('loc').value.replace("eg. Dallas, TX","");

if(sCo.length==0)
    return false; 
else 
    return true; 

}

function checkSearch(iCheckType)
{
    if(iCheckType==0)
    {
        if(document.getElementById('co').value=="") 
            document.getElementById('co').value="eg. Estate Agent";
        if(document.getElementById('loc').value=="") 
            document.getElementById('loc').value="eg. Dallas, TX";
    }
    else if(document.getElementById('co').value=="Enter full telephone number")
    {
        document.getElementById('co').value="eg. Estate Agent";
        document.getElementById('loc').value="eg. Dallas, TX";
    }
    else if(document.getElementById('co').value=="eg. Estate Agent")
    {
        document.getElementById('co').value="Enter full telephone number";
        document.getElementById('loc').value="";
    }

}

function CheckRegisterSettings()
{
CheckNick(document.getElementById('UserName').value);
CheckNickPwd(document.getElementById('UserName').value,document.getElementById('Password').value);
CheckString(document.getElementById('FirstName').value,'FirstNamePreview');
CheckString(document.getElementById('LastName').value,'LastNamePreview');
CheckEmail(document.getElementById('Email').value,'EmailPreview',1);
if(document.getElementById('NickPreview').innerHTML=='ok' 
    && document.getElementById('NickPwdPreview').innerHTML=='ok' 
    && document.getElementById('FirstNamePreview').innerHTML=='ok' 
    && document.getElementById('LastNamePreview').innerHTML=='ok' 
    && document.getElementById('EmailPreview').innerHTML=='ok')
{return true;} 
else 
{return false;}
}

function buildLoginForm(iForm)
{
if(iForm==2)
{
    sL = "\n <form style='text-align:right;' name='RegisterForm' method='post' language='javascript' onsubmit='CheckRegisterSettings();doLogin(2);return false;' id='RegisterForm'>";
    sL = sL + "\n UserName:&nbsp;<input name='UserName' type='text' id='UserName' onkeyup='CheckNick(document.getElementById(\"UserName\").value);'/>&nbsp;&nbsp;<span name=NickPreview id=NickPreview></span>";
    sL = sL + "\n <br/>Password:&nbsp;<input name='Password' type='password' id='Password' onfocus='CheckRegisterSettings()' onkeyup='CheckNickPwd(document.getElementById(\"UserName\").value,document.getElementById(\"Password\").value);'/>&nbsp;&nbsp;<span name=NickPwdPreview id=NickPwdPreview></span>";
    sL = sL + "\n <br/>First Name:&nbsp;<input name='FirstName' type='text' id='FirstName' onfocus='CheckRegisterSettings()' onkeyup='CheckString(document.getElementById(\"FirstName\").value,\"FirstNamePreview\");' />&nbsp;&nbsp;<span name=FirstNamePreview id=FirstNamePreview></span>";
    sL = sL + "\n <br/>Last Name:&nbsp;<input name='LastName' type='text' id='LastName' onfocus='CheckRegisterSettings()' onkeyup='CheckString(document.getElementById(\"LastName\").value,\"LastNamePreview\");' />&nbsp;&nbsp;<span name=LastNamePreview id=LastNamePreview></span>";
    sL = sL + "\n <br/>Email:&nbsp;<input name='Email' type='text' id='Email' onfocus='CheckRegisterSettings()' onkeyup='CheckEmail(document.getElementById(\"Email\").value,\"EmailPreview\");' />&nbsp;&nbsp;<span name=EmailPreview id=EmailPreview></span>";
    sL = sL + "\n <br/><input style='width:80px;height:24px;' type='submit' name='RegisterButton' value='Register' id='RegisterButton'  />&nbsp;&nbsp;<span id='lblStatus' style='color:Navy;'></span>";
    sL = sL + "\n </form>";

    document.getElementById("LoginBox").className = 'RegisterForm';
}
else
{
    sL = "\n <form style='text-align:right;' name='LoginForm' method='post' language='javascript' id='LoginForm' target='_blank' onsubmit='doLogin(1); return false;'>";
    sL = sL + "\n Username:&nbsp;<input name='UserName' type='text' id='UserName'  />";
    sL = sL + "\n <br/>Password:&nbsp;<input name='Password' type='password' id='Password'  />";
    sL = sL + "\n <br/>&nbsp;&nbsp;Remember me&nbsp;<input style='width:12px;height:12px;' name='RememberMe' type='checkbox' id='RememberMe'  />";
    sL = sL + "\n <input style='width:60px;height:24px;' type='submit' name='LoginButton' value='Login' id='LoginButton' />";
    sL = sL + "\n </form>";

    document.getElementById("LoginBox").className = 'LoginForm';
}
	
document.getElementById("LoginBox").innerHTML = sL;
if(document.getElementById("headerphrase")!=null)
    document.getElementById("headerphrase").style.display = 'none';	

}



function CloseURLForm()
{
if(document.getElementById('myHref').innerHTML!='')
{
    document.getElementById('sdescription').focus();
    insertTags('[a href=' + document.getElementById('txtWebsite').value + ']','[/a]','');
    tmprng=null;
    document.getElementById('myHref').innerHTML='';
    return false;
}
}

function CheckZip()
{
    if(document.getElementById("szip").value.length>0)
        doAJAXLookup("","",document.getElementById("szip").value,2)
}

function CheckPhone()
{
    if(document.getElementById("sphone").value.length>0)
        doAJAXLookup("","",document.getElementById("sphone").value,3)
}

function CheckCoForm()
{
    b1 = CheckString(document.getElementById("stitle").value,"stitlePreview");
    b2 = CheckString(document.getElementById("sstreet").value,"sstreetPreview");
    b3 = CheckString(document.getElementById("scity").value,"scityPreview");
    b4 = CheckString(document.getElementById("scounty").value,"scountyPreview");
    b5 = CheckString(document.getElementById("sstate").value,"sstatePreview");
    b6 = CheckString(document.getElementById("szip").value,"szipPreview");
    b7 = CheckString(document.getElementById("sphone").value,"sphonePreview");
    //b8 = CheckEmail(document.getElementById("semail").value,"semailPreview",0);

    if(document.getElementById("szip").value.length>0 && document.getElementById("trState") != null && document.getElementById("trState").style.display == "none")
        doAJAXLookup("","",document.getElementById("szip").value,2)
   
    //if all ok then enable post button:
    if(b1 
        && b2
        && b3
        && b4
        && b5
        && b6
        && b7
        && document.getElementById("CatForm").style.display == "none"
        )
        document.getElementById("CoButton").disabled = false;
}

function CheckString(sVal,c)
{
    sRet = "";
    if(sVal.length=="") 
        sRet = "Required";
    else if(sVal.indexOf("\"")!=-1) 
        sRet = "Double quotes are not allowed.";
    else
        sRet = "";

    
	if(sRet=="")
    {
        document.getElementById(c).innerHTML="ok"; 
        document.getElementById(c).style.color="#008000";
        return true;
    }
	else
    {
        document.getElementById(c).innerHTML=sRet; 
        document.getElementById(c).style.color="#800000";
        return false;
    }
    
    
}

function CheckEmail(sVal,c,isRequired)
{
    sRet = "";
    if(sVal.length=="") 
    {
        if(isRequired==1) 
            sRet = "Required";
    }
    else
    {
        if(sVal.indexOf(".",sVal.indexOf("@")+1)<1 || sVal.indexOf("@")<1)
            sRet = "Invalid Address";
        else
            sRet = "ok";
    }
    
    
	if(sRet=="")
    {
        if(isRequired==1) 
            document.getElementById(c).innerHTML="ok"; 
        document.getElementById(c).style.color="#008000";
    }
	else
    {
        if(sRet=="ok") 
        {
            document.getElementById(c).innerHTML="ok"; 
            document.getElementById(c).style.color="#008000";
        }
        else
        {
            document.getElementById(c).innerHTML=sRet; 
            document.getElementById(c).style.color="#800000";
        }
    }
    
}

function CheckNickPwd(NickName,Password)
{
    sRet = "";

    if(Password.length<5) 
        sRet = "Too short";

    if(Password.length==0) 
        sRet = "Required";

    Password = Password.replace(NickName,"");
    if(sRet=="" && Password.length<5) 
    {
        sRet = "Unique part too short";
    }
    
	if(sRet=="")
    {
    document.getElementById("NickPwdPreview").innerHTML="ok"; 
    document.getElementById("NickPwdPreview").style.color="#008000";
    }
	else
    {
    document.getElementById("NickPwdPreview").innerHTML=sRet; 
    document.getElementById("NickPwdPreview").style.color="#800000";
    }
    
}
function CheckNick(NickName)
{
    if(NickName=="")
    {
        document.getElementById("NickPreview").innerHTML="Reguired";
        document.getElementById("NickPreview").style.color="#800000";
        return
    }
    	
    var aVersions = ["MSXML2.XMLHttp","Microsoft.XMLHttp","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.3.0"];
    var ok = false;
   
    for (var i = 0; i < aVersions.length; i++) {
        if(!ok)
        {
            try {
            
            xmlhttp = new ActiveXObject(aVersions[i]);
            ok = true;
            } catch (oError) {}
        }
    }
    
    
    try {
    xmlhttp = new XMLHttpRequest();
    } catch (oError) {}

    
    if(xmlhttp==null) alert("Ajax functionality not working on your browser!");
	
	
    var sUrl="CheckNick.aspx?NickName=" + NickName;
	
	
	
    try{
	    xmlhttp.open("GET",sUrl,true);
		
        xmlhttp.onreadystatechange=xmlhttpChangeNick;
		
	    xmlhttp.send(null);
    }
    catch(e){
	    //alert(e);
		
    }
}


function xmlhttpChangeNick()
{
	if(xmlhttp.readyState==4)
	{
	    //alert(xmlhttp.status);
	    if(xmlhttp.status==200)
		{
			sRet = xmlhttp.responseText;
				if(sRet=="" || sRet=="ok")
                {
                document.getElementById("NickPreview").innerHTML="ok"; 
                document.getElementById("NickPreview").style.color="#008000";
                }
                else
                {
                document.getElementById("NickPreview").innerHTML=sRet; 
                document.getElementById("NickPreview").style.color="#800000";
                }
                

			
		}
	}
}



function VAjax(sQ)
{

    if (sQ != "")
        sQ = "&" + sQ;
         
	var aVersions = ["MSXML2.XMLHttp","Microsoft.XMLHttp","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.3.0"];
    var ok = false;
   
    for (var i = 0; i < aVersions.length; i++) {
        if(!ok)
        {
            try {
            xmlhttp = new ActiveXObject(aVersions[i]);
            ok = true;
            } catch (oError) {}
        }
    }
    
    try {
    xmlhttp = new XMLHttpRequest();
    } catch (oError) {}

    
    if(xmlhttp==null) 
        return;
		
    if (document.referrer!=null)
        sQ = sQ + "&Ref=" + document.referrer.replace(/\x26/g,"%26");
    	
	var sUrl="VAjax.aspx?a=1" + sQ;
		
	try{
		xmlhttp.open("GET",sUrl,true);
		xmlhttp.send(null);
	}
	catch(e){
		//alert(e);
	}
}

function doLogin(iLogin)
{
	var aVersions = ["MSXML2.XMLHttp","Microsoft.XMLHttp","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.3.0"];
    var ok = false;
   
    for (var i = 0; i < aVersions.length; i++) {
        if(!ok)
        {
            try {
            
            xmlhttp = new ActiveXObject(aVersions[i]);
            ok = true;
            } catch (oError) {}
        }
    }
    
    try {
    xmlhttp = new XMLHttpRequest();
    } catch (oError) {}
    
    if(xmlhttp==null) alert("Ajax functionality not working on your browser!");
	
	var sL = "";
	if(iLogin==1)
	{
	    sL = sL + "login=1&username=" + document.getElementById("UserName").value;
	    sL = sL + "&password=" + document.getElementById("Password").value;
	    sL = sL + "&rememberme=" + document.getElementById("RememberMe").value;
	}
	else if(iLogin==2)
	{
	    sL = sL + "register=1&username=" + document.getElementById("UserName").value;
	    sL = sL + "&password=" + document.getElementById("Password").value;
	    sL = sL + "&FirstName=" + document.getElementById("FirstName").value;
	    sL = sL + "&LastName=" + document.getElementById("LastName").value;
	    sL = sL + "&Email=" + document.getElementById("Email").value;
	    sL = sL + "&RegisterButton=1";
	}
    else
        sL = sL + "logout=1";


	var sUrl="user.aspx?" + sL;

	try{
		xmlhttp.open("GET",sUrl,true);
		
	    xmlhttp.onreadystatechange=xmlhttpChangeLogin;
		
		xmlhttp.send(null);
	}
	catch(e){
		//alert(e);
	}
}


function xmlhttpChangeLogin()
{
	if(xmlhttp.readyState==4)
	{
	    //alert(xmlhttp.status);
	    if(xmlhttp.status==200)
		{
            document.location.reload();
		}
	}
}

function ReplacePhoneNumbers()
{

if(document.getElementById('Telephone')!=null)
{
    sU = document.getElementById('Telephone').innerHTML;

    var RE_SSN = /(\d{3})(\d{3})(\d{4})/g;
    sU=sU.replace(RE_SSN, "($1) $2-$3");

    document.getElementById('Telephone').innerHTML = sU;
}
    
}


function FormatForSql(input)
{

	input = input.replace(/`/gi,"'");
	input = input.replace(/\n/gi,"<br>");
	input = input.replace(/]/gi,">");

	input = input.replace(/\[red/gi,"<font color=red");
	input = input.replace(/\[\/red/gi,"</font");
	input = input.replace(/\[blue/gi,"<font color=blue");
	input = input.replace(/\[\/blue/gi,"</font");
	input = input.replace(/\[navy/gi,"<font color=navy");
	input = input.replace(/\[\/navy/gi,"</font");
	input = input.replace(/\[br/gi,"<br");
	input = input.replace(/\[font/gi,"<font");
	input = input.replace(/\[\/font/gi,"</font");
	input = input.replace(/\[a/gi,"<a");
	input = input.replace(/\[\/a/gi,"</a");
	input = input.replace(/\[p/gi,"<p");
	input = input.replace(/\[\/p/gi,"</p");
	input = input.replace(/\[b/gi,"<b");
	input = input.replace(/\[\/b/gi,"</b");
	input = input.replace(/\[i/gi,"<i");
	input = input.replace(/\[\/i/gi,"</i");
	input = input.replace(/\[hr/gi,"<hr");
	input = input.replace(/\[h/gi,"<h");
	input = input.replace(/\[\/h/gi,"</h");
	input = input.replace(/\[li/gi,"<li");
	input = input.replace(/\[\/li/gi,"</li");
	input = input.replace(/\[u/gi,"<u");
	input = input.replace(/\[\/u/gi,"</u");
	input = input.replace(/\[embed/gi,"<embed");
	input = input.replace(/\[\/embed/gi,"</embed");
	
	return input;
}

function FormatForSqlReverse(input)
{

	input = input.replace(/'/gi,"`");
	input = input.replace(/<br>/gi,"\n");
	input = input.replace(/<br\/>/gi,"\n");
	input = input.replace(/>/gi,"]");

	input = input.replace(/<font/gi,"[font");
	input = input.replace(/<\/font/gi,"[/font");
	input = input.replace(/<a/gi,"[a");
	input = input.replace(/<\/a/gi,"[/a");
	input = input.replace(/<p/gi,"[p");
	input = input.replace(/<\/p/gi,"[/p");
	input = input.replace(/<b/gi,"[b");
	input = input.replace(/<\/b/gi,"[/b");
	input = input.replace(/<i/gi,"[i");
	input = input.replace(/<\/i/gi,"[/i");
	input = input.replace(/<hr/gi,"[hr");
	input = input.replace(/<h/gi,"[h");
	input = input.replace(/<\/h/gi,"[/h");
	input = input.replace(/<li/gi,"[li");
	input = input.replace(/<\/li/gi,"[/li");
	input = input.replace(/<u/gi,"[u");
	input = input.replace(/<\/u/gi,"[/u");	
	input = input.replace(/<embed/gi,"[embed");
	input = input.replace(/<\/embed/gi,"[/embed");
	
	return input;
}


function ReplaceHTMLTagsForTextArea(input)
{

	input = input.replace(/<br>/gi,"\n");
	input = input.replace(/<br\/>/gi,"\n");
	input = input.replace(/</gi,"[");
	input = input.replace(/>/gi,"]");
	
	return input;
}

function insertTags(tagOpen, tagClose, sampleText) 
{
	var txtarea;

	var clientPC = navigator.userAgent.toLowerCase();
	var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1));

	if (document.editform) 
	{
		txtarea = document.editform.sdescription;
	} 
	else 
	{
		// some alternate form?
		var areas = document.getElementsByTagName('textarea');
		txtarea = areas['sdescription'];
	}

	// IE
	if (document.selection  && !is_gecko) 
	{

		txtarea.focus();
		
		var theSelection = document.selection.createRange().text;

		if(tmprng)
		{
		    theSelection= tmprng.text;
		    tmprng.select();
		    
		    
	    }   
		if (!theSelection) 
			theSelection=sampleText;
		
		if(theSelection.length == 0 && tagClose == "[/a]")
		    theSelection = "Enter-Your-Link-Text";

		
		if (theSelection.charAt(theSelection.length - 1) == " ") 
		{ // exclude ending space char, if any
			theSelection = theSelection.substring(0, theSelection.length - 1);
			document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
		} 
		else 
			document.selection.createRange().text = tagOpen + theSelection + tagClose;

	// Mozilla
	} 
	else if(txtarea.selectionStart || txtarea.selectionStart == '0') 
	{
		var replaced = false;
		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;

		txtarea.focus();

		if (endPos-startPos) 
			replaced = true;
		
		var scrollTop = txtarea.scrollTop;
		var myText = (txtarea.value).substring(startPos, endPos);
		if (!myText) 
			myText=sampleText;
				
		if(myText.length == 0 && tagClose == "[/a]")
		    myText = "Enter-Your-Link-Text";
		    
		var subst;
		if (myText.charAt(myText.length - 1) == " ") // exclude ending space char, if any
		    subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
		else 
			subst = tagOpen + myText + tagClose;
		
		txtarea.value = txtarea.value.substring(0, startPos) + subst + txtarea.value.substring(endPos, txtarea.value.length);
		    
		//set new selection
		if (replaced) 
		{
			var cPos = startPos+(tagOpen.length+myText.length+tagClose.length);
			txtarea.selectionStart = cPos;
			txtarea.selectionEnd = cPos;
		} 
		else 
		{
			txtarea.selectionStart = startPos+tagOpen.length;
			txtarea.selectionEnd = startPos+tagOpen.length+myText.length;
		}
		txtarea.scrollTop = scrollTop;

	    // All other browsers get no toolbar.
	    // There was previously support for a crippled "help"
	    // bar, but that caused more problems than it solved.
	}
	// reposition cursor if possible
	if (txtarea.createTextRange)
		txtarea.caretPos = document.selection.createRange().duplicate();

}


function DoVote(Type, ID, Value) {

    if (Type == "Review")
    {
        iCurrScore = Number(document.getElementById("Score" + ID).innerHTML);
        document.getElementById("Score" + ID).innerHTML = iCurrScore + Value;
    }

    var aVersions = ["MSXML2.XMLHttp", "Microsoft.XMLHttp", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.3.0"];
    var ok = false;
   
    
    for (var i = 0; i < aVersions.length; i++) {
        if(!ok)
        {
            try {
            xmlhttp = new ActiveXObject(aVersions[i]);
            ok = true;
            } catch (oError) {}
        }
    }
    
    try {
    xmlhttp = new XMLHttpRequest();
    } catch (oError) {}
    
    if(xmlhttp!=null)
	{

        var sUrl="DoVote.aspx?Type=" + Type + "&ID=" + ID.toString() + "&Value=" + Value.toString();
        try{
	        xmlhttp.open("GET",sUrl,true);		
	        xmlhttp.send(null);
        }
        catch(e){
	        //document.getElementById("myGalleryTMP").innerHTML = e.message;
        }
    }    	
}



function BarClick(iBar)
{
sSelectedBar = document.getElementById('selectedBar').innerHTML;
if(gsbURLVerified == "false" && sSelectedBar=='2') //Free
{
    document.getElementById('selectedBar').innerHTML='1';
    document.getElementById("vw1").style.display="inline";
    //document.getElementById("vw1q").style.display="inline";
    document.getElementById("vc1").style.display="none";
    document.getElementById("packageCo2").style.display="none";
    document.getElementById("PremiumBarHref").className = 'PremiumBarHrefMax';
    document.getElementById("VerifyBarHref").className = 'VerifyBarHref';
    
}
else if (gsbURLVerified == "false") //Purchase
{
    document.getElementById('selectedBar').innerHTML='2';
    document.getElementById("vw1").style.display="none";
    //document.getElementById("vw1q").style.display="none";
    document.getElementById("vc1").style.display="inline";
    document.getElementById("packageCo2").style.display="inline";
    document.getElementById("PremiumBarHref").className = 'PremiumBarHref';
    document.getElementById("VerifyBarHref").className = 'VerifyBarHrefMax';
    
}
}

function ShowQA(qaElement)
{
document.getElementById("packageCo2").innerHTML=document.getElementById(qaElement).innerHTML;
}

function PopulateVerifyCo(iBar)
{

sCo=gsCo;
sUrl=gsUrl;
sUserName=gsUserName;
sTitle=gsTitle;
isLoggedIn=gbLoggedIn;
scat=gsCat;
scity=gsCity;

document.getElementById("gmap").style.display="none";

document.getElementById("coVerify").style.display="inline";
document.getElementById("coFullDiv").style.display="none";

 
var sLogin = "<b>Login</b> or <b>Register</b>";
var sLoginReq = "";
var s = "\n<div>\n<div id='selectedBar' style='display:none'>1</div>";
var sExclLoginCheck = " checked=checked";

//gsbPremium=sbPremium;
//gsbURLVerified=sbURLVerified;


s=s+"\n<h1>Upgrade to a Premium Listing & Get 6 Unique Advantages...</h1>"
+ "\n<br/>"
+ "\n<br/>When you upgrade to a Premium Listing, you'll enjoy:"
+ "\n<br/>"
+ "\n<br/><ul><li><b>Premium Verified status</b>, noted by a green diagonal banner on your listing. Visitors will notice your listing before your competitors!"
+ "\n</li><br/><li><b>Higher rankings on category pages.</b> Premium listings are ranked higher on our category pages, so you get greater exposure to potential clients and customers."
+ "\n</li><br/><li><b>Better search engine rankings for your web site.</b> After manually verifying your site, we will remove the \"no follow\" tags so PageRank will pass to your site. This means you'll get full value from the link from our site to yours!"
+ "\n</li><br/><li><b>Permanent price freeze on renewals.</b> Even if we raise the cost of our Premium Listings, your rate will be locked in forever!"
+ "\n</li><br/><li><b>Ad-free business listing.</b> No other ads will be displayed next to your business listing."
+ "\n</li><br/><li><b>Exclusive editor rights.</b> No other person or business can ever edit your business listing after you've upgraded to a premium listing."
+ "\n</li></ul>"
+ "\n<br/>To instantly upgrade to a premium listing, and enjoy all the benefits of premium status, please select your payment option below."
+ "\n<br/>"
+ "\n<br/><b>You're fully protected by a 30-Day Money-Back Guarantee. If you're not happy, simply contact us within 30 days of your purchase date for a full refund.</b>"
+ "\n<br/>"
+ "\n<br/>Go ahead, sign up now risk-free to start enjoying all the benefits of Premium status."
+ "\n<br/>"
+ "\n<br/>";





s=s+"\n<div class='bVerifyBars' id='bPremiumBar'>";

s=s+"\n<a class='PremiumBarHref' id='PremiumBarHref' onclick='BarClick(2);trackPView(\"Sales - Bar 2\");' href='javascript:void(0)'></a>"
+ "\n<h1>Purchase Premium Listing</h1>"
+ "\n<div style='clear:both;'></div>";

if(isLoggedIn=="False")
{
    sLoginReq = " (Log in required)";
    sExclLoginCheck = "";
}

s=s+""
+ "\n<span id='vc1'>"
+ "\n<div class=packageDetails>"

+ "\n<br />Promo Code: <input type=textbox id=txtPromo onchange='CheckPrice();'> <span id='PromoMessage'></span>";

+"\n<br /><input type=checkbox id=cbVerifyCo checked=checked disabled=disabled>Premium Verified Listing (3 Ranking Points) - $2.78 <a href='javascript:void(0);'><img class='sphere20' src='Images/Q.png' onclick='ShowQA(\"qaVerify\");'></a>";

s = s + "\n<br /><br /><input type=checkbox id=cbRankingPoints onclick='CheckPrice();trackPView(\"Sales - Ranking Points\");'></a>"
+ "\n<select name='s2' id='s2' onchange='document.getElementById(\"cbRankingPoints\").checked = true;CheckPrice();trackPView(\"Sales - Ranking Points Change\");'></a>"
+ "\n<option value='1'>1</option>"
+ "\n<option value='2'>2</option>"
+ "\n<option value='3'>3</option>"
+ "\n<option value='4'>4</option>"
+ "\n<option value='5' selected='selected'>5</option>"
+ "\n<option value='6'>6</option>"
+ "\n<option value='7'>7</option>"
+ "\n<option value='8'>8</option>"
+ "\n<option value='10'>10</option>"
+ "\n<option value='15'>15</option>"
+ "\n<option value='20'>20</option>"
+ "\n<option value='25'>25</option>"
+ "\n</select>"
+ " Ranking Points - $0.59 per point <a href='javascript:void(0);'><img class='sphere20' src='Images/Q.png' onclick='ShowQA(\"qaRankingPoints\");'></a>"
+ "\n<br /><input type=checkbox id=cbPriceFreeze checked=checked disabled=disabled>Price Freeze - Free <a href='javascript:void(0);'><img class='sphere20' src='Images/Q.png' onclick='ShowQA(\"qaPriceFreeze\");'></a>"
+ "\n<br /><input type=checkbox id=cbRemoveDisplay checked=checked disabled=disabled>Remove other Display Advertising - Free <a href='javascript:void(0);'><img class='sphere20' src='Images/Q.png' onclick='ShowQA(\"qaRemoveDisplay\");'></a>"
+ "\n<br /><input type=checkbox id=cbExclusiveEditor"+sExclLoginCheck+" disabled=disabled>Exclusive Editor Rights"+sLoginReq+" - Free <a href='javascript:void(0);'><img class='sphere20' src='Images/Q.png' onclick='ShowQA(\"qaExclusiveEditor\");'></a>";

if(gsbURLVerified == "false")
    s=s+"\n<input type=hidden id=cbVerifyWebsite value='checked'>";
else
    s=s+"\n<br /><br /><input type=hidden id=cbVerifyWebsite value='none'>($1.79 discount for verified listing.)";


s=s+ "\n<br /><br /><input name=cbpay type=radio id=cbMonthly checked='checked' onclick='CheckPrice();trackPView(\"Sales - Pay Monthly\");'>Pay Monthly"
+ "\n<br /><input name=cbpay type=radio id=cbYearly onclick='CheckPrice();trackPView(\"Sales - Pay Yearly\");'>Pay Yearly - Save 25%"
+ "\n<br /><input name=cbpay type=radio id=cbOnce onclick='CheckPrice();trackPView(\"Sales - Pay Once\");'>Pay Once - Best Price"
+ "\n</div>"


+ "\n<div style='clear: left'></div>"
+ "\n<br/><br/><b>&nbsp;&nbsp;Total:</b> $<span id=spAmt>0.79</span> <span id=spPer>per month</span>*"
+ "\n<div style='clear: left'></div>"

+ PopulatePaypalSub(sCo, '2.78', 'M', 'Subscription',sUrl,sUserName,0)

+ "\n<a id='PayPalSeal' href='https://www.paypal.com/us/verified/pal=info%40ebusinessPages%2ecom' target='_blank'><img src='i/paypal_verification_seal.gif' alt='Official PayPal Verified Company Seal'></a>"

+  "\n<div style='clear: left'></div>"
+ "\n&nbsp;&nbsp;*Includes Paypal Fee of $<span id='ppFee'>0.32</span>"
+ "\n</span>"

//Help 
+ "\n<span class=packageCo id=packageCo2>"
+ "\n</span>";

sQI = " <img class='sphere20' src='Images/Q.png'> ";


s=s+"\n<span id='qaVerify' style='display:none;'><h4 style='color:#E36C0A;'>"+sQI+"Premium Listing</h4><DIV class=packageDetails>If you want to get more customers you need a Premium Listing. Premium listings are optimized to get more customer visitors on eBusiness Pages and it will help your website rank better. Get a Premium Listing today and Be Found!<br/><br/><div class='listCompanyPV'><div class='coLeft'><h3><a href='" +gsUrl+ "'>"+gsTitle+"</a></h3><div class='lSum'>"+gsStreet+"<br/>"+gsCity+", "+gsState+"<br/>"+gsZip+"</div><div class='Contact'><span class='icons'><span class='ilink'></span><span class='itwitter'></span><span class='ifacebook'></span><span class='ilinkedin'></span><span class='iyoutube'></span></span></div></div><div class='coRight'><div class='coR1'></div><div class='coR2'></div><div class='coR3'></div><div class='coR4'></div><a href='" +gsUrl+ "'><p>This is and example of what your company listing would look like in the category results.<br/>Set yourself apart from your competition with an eBusinessPages premium listing.</p></a></div></div></DIV></span>"
+ "\n<span id='qaVerifyWebsite' style='display:none;'><h4 style='color:#E36C0A;'>"+sQI+"Verify Website</h4><DIV class=packageDetails>When you purchase a premium listing we will manually check your site and if it meets our quality guidelines we will remove the nofollow tags so that you get the full benefit of the link.</DIV></span>"
+ "\n<span id='qaPriceFreeze' style='display:none;'><h4 style='color:#E36C0A;'>"+sQI+"Price Freeze</h4><DIV class=packageDetails>Your subscription amount will stay the same even when we increase our prices.</DIV></span>"
+ "\n<span id='qaRemoveDisplay' style='display:none;'><h4 style='color:#E36C0A;'>"+sQI+"Remove Display Ads</h4><DIV class=packageDetails>All other display advertising will be removed from your company page.</DIV></span>"
+ "\n<span id='qaExclusiveEditor' style='display:none;'><h4 style='color:#E36C0A;'>"+sQI+"Exclusive Editor Rights</h4><DIV class=packageDetails>You will be the only user allowed to edit your company page.<br/><br/>Note: you must be logged in before clicking on the subscribe button.</DIV></span>"
+ "\n<span id='qaRankingPoints' style='display:none;'><h4 style='color:#E36C0A;'>"+sQI+"Ranking Points</h4><DIV class=packageDetails>The number of Ranking Points determine the ranking in all the categories where you are listed. <br/><br/>For instance if you are a convenience store in Dallas Texas then you will be listed in: <li>Convenience Stores in Dallas</li><li>Convenience Stores in Dallas County</li><li>Convenience Stores in Texas</li><li>Retail Trade in Dallas</li><li>Retail Trade in Dallas County</li><li>Retail Trade in Texas</li><li>All Businesses in Dallas</li><li>All Businesses in Dallas County</li><li>All Businesses in Texas</li><li>All Convenience Stores in the US</li><li>All Retail Trade in the US</li><br/>It should be easy to rank highest in Convencience Stores in a small town, but you will need more ranking points to rank well for Retail Trade in Texas.</DIV></span>";

s=s+"\n</div><div class='bVerifyBars' id='bPremiumBarBottom'></div>"

+ "\n<div style='clear:both;'><br/></div>";



if(gsbURLVerified == "false")
{
    s=s+"\n<br />P.S. Not ready to upgrade right now? Then scroll down for our free option."
    + "\n<br />"
    + "\n<br />"
    + "\n<h1>How to Verify for Free</h1>"
    + "\n<br />Our Premium Listing is our highest level of service that we currently offer. But if you'd rather not upgrade to a Premium Listing, we also offer a way to upgrade your listing for FREE."
    + "\n<br />"
    + "\n<br />Simply add an eBusiness Pages button to your web site linking back to our web site and we will feature your business listing higher on our category pages."
    + "\n<br />"
    + "\n<br />We've included four different buttons below. To add one to your site, simply copy the code in the box below to your site. We will automatically check your site and credit you with 2 extra ranking points so that you appear higher on your category pages, which means higher visibility and more visitors to your web site."
    + "\n<br />"
    + "\n<br />These buttons will fit cleanly into your blog's sidebar, or as a badge at the top of your site, or in the footer of your site. Here are the buttons:"
    + "\n<br />"
    + "\n<br />";


    s = s + "\n<div class='bVerifyBars' id='bVerifyBar'>"
    + "\n<a class='VerifyBarHref' id='VerifyBarHref' onclick='BarClick(1);trackPView(\"Sales - Bar 1\");' href='javascript:void(0)'></a>"
    + "\n<h1>Verify " + sTitle + " for Free</h1>"
    + "\n<div style='clear:both;'></div>"


    + "\n<span id='vw1'><br />Simply copy the html code into your site and click the resulting button to verify your site. We will periodically check the site and code to ensure that it is still functioning. Once your site is verified the verify indicator will turn green and you will receive 2 ranking points.<br /><br />Click on your preferred button or text link:"
    + "\n<br /><br />" + GetVerifiedImage(true);

    s = s + "\n<a style='float:left;' href='javascript:void(0);' onclick='vWTA(\"" + sUrl + "\",\"" + scat + "\",\"" + scity + "\",12);return false;'><img src=\"i/bReviewMe.png\" alt=\"Review Us\" /></a> ";

    if (gsAllAmerican == "true")
        s = s + "\n<a style='float:left;' href='javascript:void(0);' onclick='vWTA(\"" + sUrl + "\",\"" + scat + "\",\"" + scity + "\",10);return false;'><img src=\"i/AA.png\" alt=\"All American " + scat + " in " + scity + "\" /></a> ";

    if (gsGoingGreen == "true")
        s = s + "\n<a style='float:left;' href='javascript:void(0);' onclick='vWTA(\"" + sUrl + "\",\"" + scat + "\",\"" + scity + "\",11);return false;'><img src=\"i/GG.png\" alt=\"Going Green " + scat + " in " + scity + "\" /></a> ";
    
    s = s + "\n<a style='float:left;' href='javascript:void(0);' onclick='vWTA(\"" + sUrl + "\",\"" + scat + "\",\"" + scity + "\",1);return false;'><img  src=\"i/lbg.png\" alt=\"" + scat + " in " + scity + "\" /></a> "
    + "\n<a style='float:left;' href='javascript:void(0);' onclick='vWTA(\"" + sUrl+"\",\"" + scat+"\",\"" + scity+"\",2);return false;'><img src=\"i/lbb.png\" alt=\"" + scat + " in " + scity + "\" /></a> "
    + "\n<a style='float:left;' href='javascript:void(0);' onclick='vWTA(\"" + sUrl+"\",\"" + scat+"\",\"" + scity+"\",3);return false;'><img src=\"i/lbm.png\" alt=\"" + scat + " in " + scity + "\" /></a> "
    + "\n<a style='float:left;' href='javascript:void(0);' onclick='vWTA(\"" + sUrl+"\",\"" + scat+"\",\"" + scity+"\",4);return false;'><img src=\"i/lbs.png\" alt=\"" + scat + " in " + scity + "\" /></a> "
    + "\n<br style='clear:left;'/><br />or <b>Text Link:</b> <a href='javascript:void(0);' onclick='vWTA(\"" + sUrl+"\",\"" + scat+"\",\"" + scity+"\",5);return false;'>" + scat + " in " + scity + "</a>"
    + "\n<br /><br /><textarea id ='xWTA' onfocus='javascript:this.select();' rows='6' ></textarea>"
    + "\n<br /><br />Copy and Paste the html code into your site and click the resulting button to verify."
    + "\n<br /><br />Note: If you are logged in while verifying your site you will gain exclusive editor rights to this company page.</span>"
    +"\n</span>"

    //Help 
    + "\n</div><div class='bVerifyBars' id='bVerifyBarBottom'></div>"

    + "\n<div style='clear:both;'><br/></div>";
}

document.getElementById("coVerify").innerHTML = s;

if(gsbURLVerified == "false")
    vWTA(sUrl, scat, scity, 0);
    
ShowQA("qaVerify");

//if(iBar==2)
//    BarClick(2);
 
CheckPrice();

window.scroll(0, 320); 
}

function GetVerifiedImage(isJS)
{
sMyHref = "href='http://ebusinesspages.com/" + gsUrl + "'";

s="<div style='overflow:hidden;height:90px;background:#FFF url(http://ebusinesspages.com/i/bV.png) no-repeat left top;height:98px;max-width:350px;min-width:210px;float:left;padding:0px;margin:4px 73px 0px 0px;position:relative;z-index:110;'>"
+"\n<a style='font-family:Verdana;float:left;color:#0d4D94;text-decoration:none;' " + sMyHref + ">"
+"\n<div style='font-family:Verdana;float:left;height:90px;padding:5px;'>"
+"<h3 style='font-family:Verdana;font-size:10pt;margin:0px 0px 3px 0px;white-space:nowrap;'>"
+"" + gsTitle + ""
+"</h3>"
+"\n<div style='font-size:8pt;'>"+gsStreet+"<br/>"+gsCity+", "+gsState+"<br/>"+gsZip
+"\n<br/>"
+"\n<div style='background:#FFF url(http://ebusinesspages.com/i/ContactIcons.png);height:16px;width:16px;margin:5px 3px 0px 0px;padding:0px;float:left;background-position:center -95px;'>"
+"\n</div>"
+"\n<div style='background:#FFF url(http://ebusinesspages.com/i/ContactIcons.png);height:16px;width:16px;margin:5px 3px 0px 0px;padding:0px;float:left;background-position:center -48px;'>"
+"\n</div>"
+"\n<div style='background:#FFF url(http://ebusinesspages.com/i/ContactIcons.png);height:16px;width:16px;margin:5px 3px 0px 0px;padding:0px;float:left;background-position:center -64px;'>"
+"\n</div>"
+"\n<div style='background:#FFF url(http://ebusinesspages.com/i/ContactIcons.png);height:16px;width:16px;margin:5px 3px 0px 0px;padding:0px;float:left;background-position:center -32px;'>"
+"\n</div>"
+"\n<div style='background:#FFF url(http://ebusinesspages.com/i/ContactIcons.png);height:16px;width:16px;margin:5px 3px 0px 0px;padding:0px;float:left;background-position:center -16px;'>"
+"\n</div>"
+"\n</div>"
+"\n</div>"
+"\n</a>"
+"\n</div>"
+"\n<div style='background:#FFF url(http://ebusinesspages.com/i/bV.png) no-repeat right top;height:98px;width:73px;float:left;padding:0px;margin:4px 0px 0px -73px;position:relative;z-index:100;'><a style='float:left;height:30px;width:100%;' href='http://ebusinesspages.com/'></a>"
+"\n</div>";

if(isJS)
{
  sMyHref = "href='javascript:void(0);' onclick='vWTA(\"\",\"\",\"\",0);return false;'";
	s="<a style='font-family:Verdana;float:left;color:#0d4D94;text-decoration:none;' " + sMyHref + ">"
	+"\n<div style='overflow:hidden;height:90px;background:#FFF url(http://ebusinesspages.com/i/bV.png) no-repeat left top;height:98px;max-width:350px;min-width:210px;float:left;padding:0px;margin:4px 73px 0px 0px;position:relative;z-index:110;'>"
	
	+"\n<div style='font-family:Verdana;float:left;height:90px;padding:5px;'>"
	+"<h3 style='font-family:Verdana;font-size:10pt;margin:0px 0px 3px 0px;white-space:nowrap;'>"
	+"" + gsTitle + ""
	+"</h3>"
	+"\n<div style='font-size:8pt;'>"+gsStreet+"<br/>"+gsCity+", "+gsState+"<br/>"+gsZip
	+"\n<br/>"
	+"\n<div style='background:#FFF url(http://ebusinesspages.com/i/ContactIcons.png);height:16px;width:16px;margin:5px 3px 0px 0px;padding:0px;float:left;background-position:center -95px;'>"
	+"\n</div>"
	+"\n<div style='background:#FFF url(http://ebusinesspages.com/i/ContactIcons.png);height:16px;width:16px;margin:5px 3px 0px 0px;padding:0px;float:left;background-position:center -48px;'>"
	+"\n</div>"
	+"\n<div style='background:#FFF url(http://ebusinesspages.com/i/ContactIcons.png);height:16px;width:16px;margin:5px 3px 0px 0px;padding:0px;float:left;background-position:center -64px;'>"
	+"\n</div>"
	+"\n<div style='background:#FFF url(http://ebusinesspages.com/i/ContactIcons.png);height:16px;width:16px;margin:5px 3px 0px 0px;padding:0px;float:left;background-position:center -32px;'>"
	+"\n</div>"
	+"\n<div style='background:#FFF url(http://ebusinesspages.com/i/ContactIcons.png);height:16px;width:16px;margin:5px 3px 0px 0px;padding:0px;float:left;background-position:center -16px;'>"
	+"\n</div>"
	+"\n</div>"
	+"\n</div>"
	+"\n</div>"
	+"\n<div style='background:#FFF url(http://ebusinesspages.com/i/bV.png) no-repeat right top;height:98px;width:73px;float:left;padding:0px;margin:4px 0px 0px -73px;position:relative;z-index:100;'>"
	+"\n</div>"
	+"\n</a>";
}


return s;

}

function CheckPrice() 
{

mValue = 0.79;
sPeriod = 'month';
sN = 'http://ebusinesspages.com/ppIPN.aspx?V=1';

var mMulti = 1.00;
var isTrial = false;

if (document.getElementById("txtPromo").value != "") {
    if (document.getElementById("txtPromo").value == "e25perc") {
        mMulti = 0.75;
        document.getElementById("PromoMessage").innerHTML = "<b style='color:green;'>&#10004;</b> 25% Discount Applied";
    }
    else if (document.getElementById("txtPromo").value == "e6mnth") {
        isTrial = true;
        document.getElementById("PromoMessage").innerHTML = "<b style='color:green;'>&#10004;</b> 6 Months Free";
    }
}

if(document.getElementById("cbVerifyWebsite").value == "checked") 
{
	mValue = mValue + 1.99;
	sN = sN + '&VerifyWebsite=1';
}

if(document.getElementById("cbRankingPoints").checked) 
{
	rpNum = parseInt(document.getElementById("s2").value);
	mValue = mValue + (.59 * rpNum);
	sN = sN + '&RankingPoints=' + rpNum;
}

if(document.getElementById("cbMonthly").checked==1) 
{
	sTextPeriod = 'per month';
	sPeriod = 'month';
	document.getElementById('t3').value = 'M';
}

if(document.getElementById("cbYearly").checked==1) 
{
	mValue = mValue * 75/100 * 12;
	sTextPeriod = 'per year';
	sPeriod = 'year';
	sN = sN + '&Yearly=1';
	document.getElementById('t3').value = 'Y';
}



if(document.getElementById("cbOnce").checked==1) 
{

	sTextPeriod = 'for life';
	mValue = mValue * 12;
	sN = sN + '&Once=1';
	document.getElementById('t3').value = '';
}

mValue = mMulti * mValue;

mppFee = (mValue * 2.9 / 100) + 0.30;
sppFee = mppFee+'';
sppFee = sppFee.substr(0,sppFee.indexOf(".") + 3);

sValue = mValue+'';
sValue = sValue.substr(0,sValue.indexOf(".") + 3);

if (isTrial) {
    document.getElementById('submitImg').src = 'Images/btn_StartTrial.png';
    document.getElementById('a1').value = '0';
    document.getElementById('p1').value = '6';
    document.getElementById('t1').value = 'M';
    document.getElementById('notify_url').value = 'http://ebusinesspages.com/ppIPN.aspx?V=1&Trial=1' + sN;

    if (document.getElementById("cbOnce").checked == 1)
        document.getElementById("cbYearly").checked = true;

    document.getElementById("cbOnce").disabled = true;
}

if(document.getElementById("cbOnce").checked==1) 
{

    document.getElementById("amount").value = sValue;
    document.getElementById("a3").value = '';
    document.getElementById('p3').value = '';
	document.getElementById('cmd').value = '_xclick';
	document.getElementById('item_name').value = 'eBusinessPages Payment';
	document.getElementById('bn').value='PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted';
    document.getElementById('submitImg').src = 'Images/btn_BuyNow.png'

}
else
{
    document.getElementById("amount").value = '';
    document.getElementById("a3").value = sValue;
    document.getElementById('p3').value = '1';
   	document.getElementById('cmd').value = '_xclick-subscriptions';
	document.getElementById('item_name').value = 'eBusinessPages Subscription';
	document.getElementById('bn').value='PP-SubscriptionsBF:btn_subscribeCC_LG.gif:NonHosted';
    document.getElementById('submitImg').src = 'Images/btn_Subscribe.png'

}

document.getElementById("spAmt").innerHTML = sValue;
document.getElementById("spPer").innerHTML = sTextPeriod;
document.getElementById("notify_url").value = sN;
document.getElementById("ppFee").innerHTML = sppFee;
}


function PopulatePaypalSub(sCo, sAmt, sPeriod, sItem, sUrl, sUserName, isTrial)
{
sPP = "<div class='packageSub'>";
if(isTrial==1)
    sPP = sPP + "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" onsubmit='trackPView(\"Paypal Trial\");return ClaimCoCheck();' >";
else
    sPP = sPP + "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" onsubmit='trackPView(\"Paypal Sub\");return ClaimCoCheck();' >";

sPP = sPP + "<input type=\"hidden\" name=\"cmd\" id=\"cmd\" value=\"_xclick-subscriptions\">";
sPP = sPP + "<input type=\"hidden\" name=\"business\" value=\"PRZP65K2ZTXKA\">";
sPP = sPP + "<input type=\"hidden\" name=\"lc\" value=\"US\">";
sPP = sPP + "<input type=\"hidden\" name=\"item_name\" id=\"item_name\" value=\"eBusinessPages " + sItem + "\">";
sPP = sPP + "<input type=\"hidden\" name=\"item_number\" value=\"" + sCo  +"\">";
sPP = sPP + "<input type=\"hidden\" name=\"no_note\" value=\"1\">";
sPP = sPP + "<input type=\"hidden\" name=\"no_shipping\" value=\"1\">";
sPP = sPP + "<input type=\"hidden\" name=\"rm\" value=\"1\">";
sPP = sPP + "<input type=\"hidden\" name=\"return\" value=\"http://eBusinessPages.com/" + sUrl + "?ppReturn=1\">";
sPP = sPP + "<input type=\"hidden\" name=\"cancel_return\" value=\"http://eBusinessPages.com/" + sUrl + "?ppReturn=2\">";
sPP = sPP + "<input type=\"hidden\" name=\"currency_code\" value=\"USD\">";
sPP = sPP + "<input type=\"hidden\" name=\"src\" value=\"1\">";
sPP = sPP + "<input type=\"hidden\" name=\"amount\" id=\"amount\">";
sPP = sPP + "<input type=\"hidden\" name=\"a3\" id=\"a3\" value=\"" + sAmt +"\">";
sPP = sPP + "<input type=\"hidden\" name=\"p3\" id=\"p3\" value=\"1\">";
sPP = sPP + "<input type=\"hidden\" name=\"t3\" id=\"t3\" value=\"" + sPeriod +"\">";

if (isTrial == 1) {
    sPP = sPP + "<input type=\"hidden\" name=\"a1\" id=\"a1\" value=\"0\">";
    sPP = sPP + "<input type=\"hidden\" name=\"p1\" id=\"p1\" value=\"6\">";
    sPP = sPP + "<input type=\"hidden\" name=\"t1\" id=\"t1\" value=\"M\">";
    sPP = sPP + "<input type=\"hidden\" name=\"notify_url\" id=\"notify_url\" value=\"http://ebusinesspages.com/ppIPN.aspx?V=1&Trial=1&RankingPoints=1\">";
}
else {
    sPP = sPP + "<input type=\"hidden\" name=\"a1\" id=\"a1\" value=\"\">";
    sPP = sPP + "<input type=\"hidden\" name=\"p1\" id=\"p1\" value=\"\">";
    sPP = sPP + "<input type=\"hidden\" name=\"t1\" id=\"t1\" value=\"\">";
    sPP = sPP + "<input type=\"hidden\" name=\"notify_url\" id=\"notify_url\" value=\"http://ebusinesspages.com/ppIPN.aspx\">";
}

sPP = sPP + "<input type=\"hidden\" name=\"sra\" value=\"1\">";
sPP = sPP + "<input type=\"hidden\" name=\"custom\" value=\"" + sUserName +"\">";
sPP = sPP + "<input type=\"hidden\" name=\"bn\" id=\"bn\" value=\"PP-SubscriptionsBF:btn_subscribeCC_LG.gif:NonHosted\">";
if(isTrial==1)
    sPP = sPP + "<input type=\"image\" src=\"Images/btn_StartTrial.png\" name=\"submit\" id=\"submitImg\" alt=\"PayPal - The safer, easier way to pay online!\">";
else
    sPP = sPP + "<input type=\"image\" src=\"Images/btn_Subscribe.png\" name=\"submit\" id=\"submitImg\" alt=\"PayPal - The safer, easier way to pay online!\">";

sPP = sPP + "</form>";

sPP = sPP + "</div>";

return sPP;

}

function ClaimCoCheck()
{
var returnval;
//returnval = confirm("You must be logged in to claim the company. Click OK to continue without claiming the company.");
returnval = true;
return returnval;
}


function showRanking(iRank,bDesc,bVerifySite,bVerifyCo)
{

iBlue = iRank * 20;
iGray = 365 - (iRank * 20);
if(iBlue>350) 
    {
    iBlue = 350;
    iGray = 20;
    }
    
imgDesc = "Images/Q.png";
imgVerifySite = "Images/Q.png";
imgVerifyCo = "Images/Q.png";

if(bDesc!=0) imgDesc = "Images/sphere_GreenCheck.png";
if(bVerifySite==true) imgVerifySite = "Images/sphere_GreenCheck.png";
if(bVerifyCo==true) imgVerifyCo = "Images/sphere_GreenCheck.png";
   
sR = "\n<div style='clear:right;'></div>"
+ "\n<div class='cr3' style='width:"+ iGray.toString() +"px;'></div>"
+ "\n<div class='cr2' style='width:"+ iBlue.toString() +"px;'></div>"
+ "\n<div class='cr1'>"+ iRank.toString() +"</div>"
+ "\n<div class='rp'>"
+ "\nRanking Points: " + iRank.toString()
+ "\n</div>"
+ "\n<div class='ir'>"
+ "\n<span class='aVerify'>Improve your Ranking</span>"
+ "\n</div>"
+ "\n<div class='RankingFactors' id='RankingFactors'>"
+ "\n<br />	<hr />	<br />"
+ "\n<b><u>Simple ways to improve your Company Ranking:</u></b>";


if(bDesc!=0)
    sR = sR + "\n<br /><br /><img class='sphere20' src='"+imgDesc+"' alt='1 Ranking Point' title='1 Ranking Point'><div class='dRF'>Add a unique description for your company.</div>"
else
    sR = sR + "\n<br /><br /><a href='javascript:void(0)' onclick='doEditCompanyDesc();trackPView(\"editDescription Q\");return false;' ><img class='sphere20' src='"+imgDesc+"' alt='1 Ranking Point' title='1 Ranking Point'><div class='dRF'>Add a unique description for your company.</div></a>"


if (imgVerifySite == "Images/Q.png") sR = sR + "<br /><a href='javascript:void(0)' onclick='PopulateVerifyCo(1);trackPView(\"verifyWebsite Q\");return false;' >";
sR = sR + "<img class='sphere20' src='"+imgVerifySite+"' alt='2 Ranking Points' title='2 Ranking Points'><div class='dRF'>Verify your website.</div>";
if(imgVerifySite=="Images/Q.png") sR = sR + "</a>";


if (imgVerifyCo == "Images/Q.png") sR = sR + "<br /><a href='javascript:void(0)' onclick='PopulateVerifyCo(2);trackPView(\"verifyCompany Q\");return false;' >";
sR = sR + "<img class='sphere20' src='"+imgVerifyCo+"' alt='1 to 26 Ranking Points' title='1 to 26 Ranking Points'><div class='dRF'>Purchase a premium listing.</div>";
if(imgVerifyCo=="Images/Q.png") sR = sR + "</a>";

sR = sR + "\n<br /><img class='sphere20' src='"+imgVerifySite+"' alt='Ranking Points based on Visitor Count' title='Ranking Points based on Visitor Count'><div class='dRF'>Send visitors from your website to your company page.</div>"
+ "\n<div style='clear:left'><br/></div>"	
+ "\n<b><u>Improve your page ranking in Search Engines:</u></b>"
+ "\n<li>Add your company logo and a unique description.</li>"
+ "\n<li>Promote this page using the social bookmarking buttons.</li>"
+ "\n<li>Get friends or employees to promote this page as well.</li>"
+ "\n<li>Get customers to rate and review your company.</li>"
+ "\n"
+ "\n</div>";

document.getElementById("CompanyRanking").innerHTML = sR;

}



function vWTA(sCoUrl, scat, scity, iButton)
{
s = GetVerifiedImage(false);

if(iButton == 0)
    s = GetVerifiedImage(false);
else if(iButton == 1)
    s = "&lt;a href='http://ebusinesspages.com/" + sCoUrl + "'&gt;&lt;img border='0' src='http://ebusinesspages.com/i/lbg.png' alt='" + scat + " in " + scity + "' /&gt;&lt;/a&gt;";
else if(iButton == 2)
    s = "&lt;a href='http://ebusinesspages.com/" + sCoUrl + "'&gt;&lt;img src='http://ebusinesspages.com/i/lbb.png' border='0' alt='" + scat + " in " + scity + "' /&gt;&lt;/a&gt;";
else if(iButton == 3)
    s = "&lt;a href='http://ebusinesspages.com/" + sCoUrl + "'&gt;&lt;img src='http://ebusinesspages.com/i/lbm.png' alt='" + scat + " in " + scity + "' border='0' /&gt;&lt;/a&gt;";
else if(iButton == 4)
    s = "&lt;a href='http://ebusinesspages.com/" + sCoUrl + "'&gt;&lt;img border='0' src='http://ebusinesspages.com/i/lbs.png' alt='" + scat + " in " + scity + "' /&gt;&lt;/a&gt;";
else if(iButton == 5)
    s = "&lt;a href='http://ebusinesspages.com/" + sCoUrl + "'&gt;" + scat + " in " + scity + "&lt;/a&gt;\n&lt;!-- Comment: feel free to change the anchor text --&gt; ";
else if (iButton == 10)
    s = "&lt;a href='http://ebusinesspages.com/" + sCoUrl + "'&gt;&lt;img border='0' src='http://ebusinesspages.com/i/AA.png' alt='All American " + scat + " in " + scity + "' /&gt;&lt;/a&gt;";
else if (iButton == 11)
    s = "&lt;a href='http://ebusinesspages.com/" + sCoUrl + "'&gt;&lt;img border='0' src='http://ebusinesspages.com/i/GG.png' alt='Going Green " + scat + " in " + scity + "' /&gt;&lt;/a&gt;";
else if (iButton == 12)
    s = "&lt;a href='http://ebusinesspages.com/" + sCoUrl + "'&gt;&lt;img border='0' src='http://ebusinesspages.com/i/bReviewMe.png' alt='Review us on eBusinessPages.com' /&gt;&lt;/a&gt;";

s = s.replace(/</gi,"&lt").replace(/>/gi,"&gt");

document.getElementById("xWTA").innerHTML = s;
}

function LookupCatForm()
{
    document.getElementById("CoButton").disabled = true;
    document.getElementById("CatForm").style.display = "inline";
    if(document.getElementById("CompanyRanking")!=null)
        document.getElementById("CompanyRanking").style.display = "none";
}

function LookupCat()
{
    doAJAXLookup("","",document.getElementById("sCatKey").value,1);
}

function CheckCoButton()
{
       
    if(document.getElementById("CoButton").disabled)
    {
        LookupCat();
        return false;
    }
    else
        return true;
}

function CatSelect(sT,sH)
{
    document.getElementById("CoButton").disabled = false;
    document.getElementById("CatForm").style.display = "none";
    
    if(document.getElementById("CompanyRanking")!=null)
        document.getElementById("CompanyRanking").style.display = "inline";
    
    document.getElementById("scatid").value = sH;
    document.getElementById("spanCurrCat").innerHTML = sT;    
}

function ZipCitySelect(sCity, sCounty, sState)
{
    if( document.getElementById("trState") != null)
    {
        document.getElementById("trCity").style.display = "table-row";
        document.getElementById("trCounty").style.display = "table-row";
        document.getElementById("trState").style.display = "table-row";
    }
    
    document.getElementById("scity").value= sCity;
    document.getElementById("scounty").value = sCounty;
    document.getElementById("sstate").value = sState;
    
    CheckCoForm();
}


function doEditCompany()
{

//scity,scounty,sstate,szip,sphone,sfax,semail,surl,bloggedin,suser, sId, sCurrCat, sCat
    
   
    document.getElementById("CompanyView").style.display="none";
    document.getElementById("EditButtons").style.display="none";
    
    
    stitle = gsTitle.replace("`","'");
    sstreet = gsStreet.replace("`","'");
    scity=gsCity;
    scounty=gsCounty;
    sstate=gsState;
    szip=gsZip;
    sphone=gsPhone;
    sfax=gsFax;
    semail=gsEmail;
    sId=gsId;
    sCat=gsCat;

    suser=gsUserName;
    bloggedin=gbLoggedIn;
    surl=gsWebsite;
    sCurrCat=gsHashCatId;


    sEditCo = "\n<table style='float:left;'><tr><td><b>Company</b></td><td><input name='stitle' type='text' id='stitle' value=\"" + stitle + "\" onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;<span name=stitlePreview id=stitlePreview></span></td></tr>";
    sEditCo = sEditCo + "\n<tr><td><b>Street</b></td><td><input name='sstreet' type='text' id='sstreet' value='" + sstreet + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;<span name=sstreetPreview id=sstreetPreview></span></td></tr>";
    sEditCo = sEditCo + "\n<tr><td><b>City</b></td><td><input name='scity' type='text' id='scity' value='" + scity + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;<span name=scityPreview id=scityPreview></span></td></tr>";
    sEditCo = sEditCo + "\n<tr><td><b>County</b></td><td><input name='scounty' type='text' id='scounty' value='" + scounty + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;<span name=scountyPreview id=scountyPreview></span></td></tr>";
    sEditCo = sEditCo + "\n<tr><td><b>State</b></td><td><input name='sstate' type='text' id='sstate' value='" + sstate + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;<span name=sstatePreview id=sstatePreview></span></td></tr>";
    sEditCo = sEditCo + "\n<tr><td><b>Zip</b></td><td><input name='szip' type='text' id='szip' value='" + szip + "' onchange='CheckZip();'  />&nbsp;</td><td>&nbsp;<span name=szipPreview id=szipPreview></span></td></tr>";
    sEditCo = sEditCo + "\n<tr><td><b>Phone</b></td><td><input name='sphone' type='text' id='sphone' value='" + sphone + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;<span name=sphonePreview id=sphonePreview></span></td></tr>";
    sEditCo = sEditCo + "\n<tr><td>Fax</td><td><input name='sfax' type='text' id='sfax' value='" + sfax + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;<span name=sfaxPreview id=sfaxPreview></span></td></tr>";
    sEditCo = sEditCo + "\n<tr><td>Email</td><td><input name='semail' type='text' id='semail' value='" + semail.replace(" AT ","@") + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;<span name=semailPreview id=semailPreview></span></td></tr>";
    sEditCo = sEditCo + "\n<tr><td>Website</td><td><input name='surl' type='text' id='surl' value='" + surl + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;<span name=surlPreview id=surlPreview></span></td></tr>";

    sEditCo = sEditCo + "\n<tr><td>Twitter</td><td><input name='sTwitter' type='text' id='sTwitter' value='" + gsTwitter + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;</td></tr>";
    sEditCo = sEditCo + "\n<tr><td>Facebook</td><td><input name='sFacebook' type='text' id='sFacebook' value='" + gsFacebook + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;</td></tr>";
    sEditCo = sEditCo + "\n<tr><td>LinkedIn</td><td><input name='sLinkedIn' type='text' id='sLinkedIn' value='" + gsLinkedIn + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;</td></tr>";
    sEditCo = sEditCo + "\n<tr><td>Skype</td><td><input name='sSkype' type='text' id='sSkype' value='" + gsSkype + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;</td></tr>";
    sEditCo = sEditCo + "\n<tr><td>Youtube</td><td><input name='sYoutube' type='text' id='sYoutube' value='" + gsYoutube + "' onfocus='CheckCoForm();' />&nbsp;</td><td>&nbsp;</td></tr>";
    
    sEditCo = sEditCo + "\n</table>";



    sEditCo = sEditCo + "\n<div id='Seals' style='float:left;margin-left:20%;'>";
    sEditCo = sEditCo + "\n<span id='AllAmerican'><img src='i/AA.png' border='0' title='All American Company' alt='All American Company' /><br/><input name='cAllAmerican' type='checkbox' id='cAllAmerican' " + gcAllAmerican + " />&nbsp;All American</span>";
    sEditCo = sEditCo + "\n<br/><br/><span id='GreenCompany'><img src='i/GG.png' border='0' title='Going Green Company' alt='Going Green Company' /><br/><input name='cGoingGreen' type='checkbox' id='cGoingGreen' " + gcGoingGreen + " />&nbsp;Going Green</span>";
    sEditCo = sEditCo + "\n</div";


    sEditCo = sEditCo + "\n <div style='clear:left;'></div>";

    sEditCo = sEditCo + "\n<div id='Categories' style='float:left;clear:left;'>";
     if (sCat.length > 0) { sEditCo = sEditCo + "\nCategory:&nbsp;<span id='spanCurrCat'>" + sCat + "</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class='aVerify'><a href='javascript:void(0)' onclick='LookupCatForm();return false;'>Change</a></span></td><td>&nbsp;"; }
     else { sEditCo = sEditCo + "\nCategory:&nbsp;<span id='spanCurrCat'>! None</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class='aVerify'><a href='javascript:void(0)' onclick='LookupCatForm();return false;'>Change</a></span>"; }
    sEditCo = sEditCo + "\n</div";


    sEditCo = sEditCo + "\n<input type='hidden' value='" + stitle + "' id='oldstitle' name='oldstitle' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + sstreet + "' id='oldsstreet' name='oldsstreet' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + scity + "' id='oldscity' name='oldscity' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + scounty + "' id='oldscounty' name='oldscounty' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + sstate + "' id='oldsstate' name='oldsstate' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + szip + "' id='oldszip' name='oldszip' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + sphone + "' id='oldsphone' name='oldsphone' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + sfax + "' id='oldsfax' name='oldsfax' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + semail.replace(" AT ","@") + "' id='oldsemail' name='oldsemail' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + surl + "' id='oldsurl' name='oldsurl' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + gsTwitter + "' id='oldsTwitter' name='oldsTwitter' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + gsFacebook + "' id='oldsFacebook' name='oldsFacebook' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + gsLinkedIn + "' id='oldsLinkedIn' name='oldsLinkedIn' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + gsSkype + "' id='oldsSkype' name='oldsSkype' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + gsYoutube + "' id='oldsYoutube' name='oldsYoutube' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + gsAllAmerican + "' id='oldcAllAmerican' name='oldcAllAmerican' />";
    sEditCo = sEditCo + "\n<input type='hidden' value='" + gsGoingGreen + "' id='oldcGoingGreen' name='oldcGoingGreen' />";

    sEditCo = sEditCo + "\n <div style='clear:left;'></div>";

    sEditCo = sEditCo + "\n<div id='CatForm' style='display:none;width:1000px;clear:left;'>";
    sEditCo = sEditCo + "\n<br/><p>Search for new category by keyword:";
    sEditCo = sEditCo + "\n<br/><input name='sCatKey' type='text' id='sCatKey' />";
    sEditCo = sEditCo + "\n&nbsp;<input type='submit' name='CatButton' value='Search' id='CatButton' />";
    sEditCo = sEditCo + "\n<br/><span id='CatSelect' style='font-size:9pt;'></span>";
    sEditCo = sEditCo + "\n</p></div>";


    sEditCo = sEditCo + "\n <div style='clear:left;'></div><br/><input  type='submit' name='CoButton' value='Submit' id='CoButton' />";
    sEditCo = sEditCo + "\n &nbsp;&nbsp;<a href=\"javascript:void(0)\" style='color:red;font-weight:normal;' onclick='document.getElementById(\"EditCo\").style.display=\"none\";document.getElementById(\"EditButtons\").style.display=\"inline\";document.getElementById(\"CompanyView\").style.display=\"inline\"; return false;'>Cancel</a>";

    if (!bloggedin)
    {
        sEditCo = sEditCo + "\n<br/><br/>Please log in to benefit from your editing efforts, to get a mention on our homepage and to make it faster for us to approve changes. ";
        sEditCo = sEditCo + "<a href=\"javascript:void(0)\" onclick='window.open (\"http://ebusinesspages.com/User.aspx?Login=1\",\"mywindow\",\"status=0,toolbar=1,width=564,height=570\");return false;' >Log In</a>";
        sEditCo = sEditCo + "&nbsp;/&nbsp;<a href=\"javascript:void(0)\" onclick='window.open (\"http://ebusinesspages.com/User.aspx?Register=1\",\"mywindow\",\"status=0,toolbar=1,width=564,height=570\");return false;' >Register</a>";
    }
    else
    {
        sEditCo = sEditCo + "\n<input type='hidden' name='suser' value='" + suser + "' id='suser' />";
    }
    sEditCo = sEditCo + "\n<br/><br/>Note that we employ anti-scraping technology to prevent robots from harvesting email addresses.<br/><br/>";
    sEditCo = sEditCo + "\n<input type='hidden' name='sid' value='" + sId + "' id='sid' />";
    sEditCo = sEditCo + "\n<input type='hidden' name='scatid' value='" + sCurrCat + "' id='scatid' />";
   
    
    document.getElementById("EditCo").innerHTML = sEditCo;
    document.getElementById("EditCo").style.display="inline";

}

function PinpointLocation(bloggedin, suser, sId)
{
sPPoint = "<p><br/><b>To pinpoint your marker, follow these steps:</b>"
sPPoint = sPPoint + "\n<br/><br/>1. Click on <b>View Larger Map</b>.";
sPPoint = sPPoint + "\n<br/>2. Right Click your exact location and select <b>Center Map</b>.";
sPPoint = sPPoint + "\n<br/>3. Click on <b>Link</b> at the top right of the map.";
sPPoint = sPPoint + "\n<br/>4. Select, Right Click and Copy the url in the first textbox.";
sPPoint = sPPoint + "\n<br/>5. Back on this page: Right Click and Paste into the Box below.";
sPPoint = sPPoint + "\n<br/>6. Submit - and you are done.";
sPPoint = sPPoint + "\n</p>";
sPPoint = sPPoint + "\n<form name='EditPIN' method='Post' action='Post.aspx' language='javascript' id='EditPIN' onsubmit='return document.getElementById(\"sPinPoint\").value.length>0;'>";
sPPoint = sPPoint + "\nLink: <input name='sPinPoint' type='text' id='sPinPoint' />";
sPPoint = sPPoint + "\n<input type='submit' name='PinButton' value='Submit' id='PinButton' />";
sPPoint = sPPoint + "\n<input type='hidden' name='sid' value='" + sId + "' id='sid' />";
if (bloggedin) sPPoint = sPPoint + "\n<input type='hidden' name='suser' value='" + suser + "' id='suser' />";
sPPoint = sPPoint + "\n</form>";

document.getElementById("pinLoc").innerHTML = sPPoint;
}

function doEditCompanyDesc()
{
    
    
    suser=gsUserName;
    bloggedin=gbLoggedIn;
    sId=gsId;
    sCurrCat=gsHashCatId;
    

    document.getElementById("ShowDescription").style.display="none";
    document.getElementById("EditButtons").style.display="none";
    
    sdescriptionText = ReplaceHTMLTagsForTextArea(document.getElementById("Description").innerHTML);
    if(sdescriptionText.indexOf("No one has entered a description")!=-1)
        sdescriptionText="";
        
    if (sId != "-1")
    {
        sCoDesc = "\n<b>Company Description:</b><br />";
    
        sCoDesc = sCoDesc + BuildTextArea(sdescriptionText)

        if (!bloggedin)
        {
            sCoDesc = sCoDesc + "\n<br/><br/>Please log in to benefit from your editing efforts, to get a mention on our homepage and to make it faster for us to approve changes. ";
            sCoDesc = sCoDesc + "<a href=\"javascript:void(0)\" onclick='window.open (\"http://ebusinesspages.com/User.aspx?Login=1\",\"mywindow\",\"status=0,toolbar=1,width=564,height=570\");return false;' >Log In</a>";
            sCoDesc = sCoDesc + "&nbsp;/&nbsp;<a href=\"javascript:void(0)\" onclick='window.open (\"http://ebusinesspages.com/User.aspx?Register=1\",\"mywindow\",\"status=0,toolbar=1,width=564,height=570\");return false;' >Register</a>";
        }
        else
        {
            sCoDesc = sCoDesc + "\n<input type='hidden' name='suser' value='" + suser + "' id='suser' />";
        }
        sCoDesc = sCoDesc + "\n<input type='hidden' name='sid' value='" + sId + "' id='sid' />";

    }
    
    document.getElementById("EditCoDescription").innerHTML = sCoDesc;
    document.getElementById("EditCoDescription").style.display="inline";
}

function doEditUserDesc(suser, sdescriptionText)
{

    sCoDesc = BuildTextArea(sdescriptionText)

    sCoDesc = sCoDesc + "\n<input type='hidden' name='suser' value='" + suser + "' id='suser' />";
    sCoDesc = sCoDesc + "\n<input type='hidden' name='isuser' value='1' id='isuser' />";
    
    document.getElementById("EditCoDescription").innerHTML = sCoDesc;
}

function BuildTextArea(sdescriptionText)
{
        sTxt = "\n<div style=\"height:25px;vertical-align:top; padding-top:0px; margin-bottom:-2px;text-align:center;width:534px;FLOAT: left;border:solid 1px grey;border-bottom:0px;background-color:#81B4CB; \"><a style=\"HEIGHT: 20px; COLOR: black; TEXT-DECORATION: none\" onclick=\"insertTags('[b]','[/b]','');return false;\" href=\"javascript:void(0)\"><b>&nbsp;B&nbsp;</b></a>&nbsp;&nbsp;&nbsp;<a style=\"HEIGHT: 20px; COLOR: black; TEXT-DECORATION: none\" onclick=\"insertTags('[i]','[/i]','');return false;\" href=\"javascript:void(0)\"><b><i>&nbsp;I&nbsp;</i></b></a>&nbsp;&nbsp;&nbsp;<a style=\"HEIGHT: 20px; COLOR: black; TEXT-DECORATION: none\" onclick=\"insertTags('[u]','[/u]','');return false;\" href=\"javascript:void(0)\"><b>&nbsp;<u>U</u>&nbsp;</b></a>&nbsp;&nbsp;&nbsp;<a style=\"HEIGHT: 20px\" onclick=\"insertTags('[li]','[/li]','');return false;\" href=\"javascript:void(0)\"><img  alt=\"Bulletted List\" src=\"Images/ed/bulletlist.gif\"></a>&nbsp;&nbsp;&nbsp;<a onclick=\"insertTags('[a href=http://ENTER-YOUR-URL.com/]','[/a]','');return false;\" href=\"javascript:void(0)\"><img alt='Link' src=\"Images/ed/href.gif\"></a>&nbsp;&nbsp;&nbsp;<a style=\"HEIGHT: 20px; COLOR: black; TEXT-DECORATION: none\" onclick=\"insertTags('[h2]','[/h2]','');return false;\" href=\"javascript:void(0)\"><b>&nbsp;H2</b></a>&nbsp;&nbsp;&nbsp;<a style=\"HEIGHT: 20px; COLOR: black; TEXT-DECORATION: none\" onclick=\"insertTags('[h3]','[/h3]','');return false;\" href=\"javascript:void(0)\"><b>&nbsp;H3</b></a>&nbsp;&nbsp;&nbsp;<a style=\"HEIGHT: 20px; COLOR: black; TEXT-DECORATION: none\" onclick=\"insertTags('[h4]','[/h4]','');return false;\" href=\"javascript:void(0)\"><b>&nbsp;H4</b></a>&nbsp;&nbsp;&nbsp;<a style=\"HEIGHT: 20px; COLOR: black; TEXT-DECORATION: none\" onclick=\"insertTags('[hr]','','');return false;\" href=\"javascript:void(0)\"><b>&nbsp;HR&nbsp;</b></a></div><div style=\"POSITION: absolute\" id=myHref></div>";
        //sTxt = sTxt + "\n<div style=\"clear:both;height:1px;margin:0px;padding:0px;\">&nbsp;</div>";

        sTxt = sTxt + "\n<textarea id='sdescription' name='sdescription' style='width:530px;' rows='9' style='margin-top:0px;float:left;' >" + sdescriptionText + "</textarea>";

        sTxt = sTxt + "\n <br/><input type='submit' name='EditCoDescriptionButton' value='Submit' id='EditCoDescriptionButton' />";
        sTxt = sTxt + "\n &nbsp;&nbsp;<a href=\"javascript:void(0)\" style='color:red;font-weight:normal;' onclick='document.getElementById(\"EditCoDescription\").style.display=\"none\";document.getElementById(\"EditButtons\").style.display=\"inline\";document.getElementById(\"ShowDescription\").style.display=\"inline\";return false;'>Cancel</a>";
        return sTxt;

}

function ShowBookmarks(sURL)
{

s = "<div class='addthis_toolbox addthis_default_style'><span>Promote this Company Profile:&nbsp;</span>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' class='addthis_button_twitter' onmousedown='trackPView(\"at_twitter\");'></a>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' class='addthis_button_facebook' onmousedown='trackPView(\"at_facebook\");'></a>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' class='addthis_button_linkedin' onmousedown='trackPView(\"at_linkedin\");'></a>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' class='addthis_button_myspace' onmousedown='trackPView(\"at_myspace\");'></a>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' class='addthis_button_google' onmousedown='trackPView(\"at_google\");'></a>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' class='addthis_button_digg' onmousedown='trackPView(\"at_digg\");'></a>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' class='addthis_button_stumbleupon' onmousedown='trackPView(\"at_stumble\");'></a>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' class='addthis_button_delicious' onmousedown='trackPView(\"at_delicious\");'></a>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' class='addthis_button_misterwong' onmousedown='trackPView(\"at_misterwong\");'></a>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' class='addthis_button_reddit' onmousedown='trackPView(\"at_reddit\");'></a>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' class='addthis_button_email' onmousedown='trackPView(\"at_email\");'></a>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' class='addthis_button_favorites' onmousedown='trackPView(\"at_favorites\");'></a>"
+ "<span class='addthis_separator'>|</span>"
+ "<a rel='nofollow' addthis:url='"+sURL+"' href='http://www.addthis.com/bookmark.php?v=250&amp;username=dtm' class='addthis_button_expanded' onmousedown='trackPView(\"at_more\");'>More</a>"
+ "</div>";

document.getElementById("Share").innerHTML = s;
}

function doAJAXLookup(sHashGeo,sHashCatId,sQuery,iLookupType)
{
    //iLookupType:
    // 0 - Cities
    // 1 - Categories
    // 2 - Zip
    // 3 - Phones

	var aVersions = ["MSXML2.XMLHttp","Microsoft.XMLHttp","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.3.0"];
    var ok = false;
   
    for (var i = 0; i < aVersions.length; i++) {
        if(!ok)
        {
            try {
            
            xmlhttp = new ActiveXObject(aVersions[i]);
            ok = true;
            } catch (oError) {}
        }
    }
    
    try {
    xmlhttp = new XMLHttpRequest();
    } catch (oError) {}
    
    if(xmlhttp==null) alert("Ajax functionality not working on your browser!");
	
	var sUrl="ajaxLookup.aspx?CityLookup=1&sHashGeo=" + sHashGeo + "&sHashCatId=" +sHashCatId + "&sCatTitle=" + sQuery;

    if(iLookupType==1) 
        sUrl="ajaxLookup.aspx?CatLookup=1&sCatTitle=" +sQuery;
    else if(iLookupType==2) 
        sUrl="ajaxLookup.aspx?ZipLookup=1&sZip=" +sQuery;
    else if(iLookupType==3) 
        sUrl="ajaxLookup.aspx?PhoneLookup=1&sPhone=" +sQuery;
    
	try{
		xmlhttp.open("GET",sUrl,true);
		
		if(iLookupType==0)
	        xmlhttp.onreadystatechange=xmlhttpChangeCities;
	    else if(iLookupType==1) 
	        xmlhttp.onreadystatechange=xmlhttpCatLookup;
	    else if(iLookupType==2) 
	        xmlhttp.onreadystatechange=xmlhttpZipLookup;
	    else if(iLookupType==3) 
	        xmlhttp.onreadystatechange=xmlhttpPhoneLookup;
		
		xmlhttp.send(null);
	}
	catch(e){
		//alert(e);
	}
}

function xmlhttpPhoneLookup()
{
	if(xmlhttp.readyState==4)
	{
	    //alert(xmlhttp.status);
	    if(xmlhttp.status==200)
		{
			sRet = xmlhttp.responseText;
			if(sRet.length > 0)
			{   
			    sMsg = "&nbsp;<input type='checkbox' onclick='document.getElementById(\"sDupCoList\").innerHTML=\"\";' />&nbsp;<b>My company is not listed below:</b><br/><br/>";
                document.getElementById("sDupCoList").innerHTML=sMsg+sRet;
            }
    	}
	}
}



function xmlhttpZipLookup()
{
	if(xmlhttp.readyState==4)
	{
	    //alert(xmlhttp.status);
	    if(xmlhttp.status==200)
		{
			sRet = xmlhttp.responseText;
			if(sRet.length > 0)
			{
    			if(sRet.indexOf("|") > 0)
                {
                    var sArr=sRet.split("|");
                    ZipCitySelect(sArr[0],sArr[1],sArr[2]);
                }
                else
                    document.getElementById("szipPreview").innerHTML=sRet;
            }
            else
                document.getElementById("szipPreview").innerHTML="<b>ZipCode not found, please check the code or enter the City, County and State manually.</b>"; 
    
    	}
	}
}

function xmlhttpCatLookup()
{
	if(xmlhttp.readyState==4)
	{
	    //alert(xmlhttp.status);
	    if(xmlhttp.status==200)
		{
			sRet = xmlhttp.responseText;
			if(sRet.length > 0)
                document.getElementById("CatSelect").innerHTML="<br/><b>Select Category: (Click on the category which most accurately describes your company)</b> <br/>" + sRet + "<br/><br/>"; 
            else
                document.getElementById("CatSelect").innerHTML="<br/><b>No categories found, please choose another keyword.</b><br/>"; 
    
    	}
	}
}

function xmlhttpChangeCities()
{
	if(xmlhttp.readyState==4)
	{
	    //alert(xmlhttp.status);
	    if(xmlhttp.status==200)
		{
			sRet = xmlhttp.responseText;
			if(sRet.length > 0)
            {
            document.getElementById("ShowCities").innerHTML=sRet; 
            }
		}
	}
}

function DiplayFooterToolbar() {
    
document.getElementById("ToolbarWrap").innerHTML = "<div id='ToolbarInnerWrap'>"
+ "<div id='ToolbarContent'>" 
+ "We are looking for an Affiliate Member in your area. <a href='Affiliates.html' >Start earning today!</a>"
+ "</div>" 
+ "</div>";

document.getElementById("ToolbarWrap").style.display='inline';
}


function WhatIsMoreListings()
{
trackPView("WhatIsListing Premium");

document.getElementById("MoreListings").innerHTML = "<h1>What are \"More Listings\"?</h1>"
+ "<br/>More Listings are other listings in the same category and town ordered by Ranking Points." 
+ "<h3>How To: Include your Company in other Listings</h3>Simply improve your ranking to be included in other companies' listings."
+ "<h3>How To: Remove other Listings from your Company Listing</h3>You will need to either <a onclick='PopulateVerifyCo(2);trackPView(\"WhatIsListing Premium\");return false;' href='javascript:void(0)'>buy a Premium Listing </a> "
+ "or <a onclick='PopulateVerifyCo(1);trackPView(\"WhatIsListing verifyWebsite\");return false;' href='javascript:void(0)'>Verify your Listing for Free</a>."
+ "<br/>" 
+ "<br/>";
}

function ShowReply(controlName)
{
    var control;
    control = document.getElementById(controlName);
    if(control.style.display == 'none')
        control.style.display = '';
    else
        control.style.display = 'none';
    control = document.getElementById('Comment_');
    if(control.style.display == 'none')
        control.style.display = '';
    else
        control.style.display = 'none';
}

var memx;
var memr;
function RatingMove(evt) {
    document.getElementById("Rating").className = 'RatingY';

    var img_x = GetX(evt);

    var iRating = Math.round(img_x / 11 * 5);
    iRating = iRating / 10;
    //document.getElementById("iRating").innerHTML = iRating;
    var iwidth = iRating * 110 / 5 + 5;
    if (iwidth > 110) iwidth = 110;
    document.getElementById("Rating").style.width = iwidth + "px";
    RatingText(iRating);
}

function GetX(evt) {
    var ev_x;
    if (document.all) { // MSIE
        ev_x = evt.offsetX;
    } else { // Netscape, etc.
        ev_x = evt.clientX;
        for (var offMark = evt.target; offMark; offMark = offMark.offsetParent) {
            ev_x -= offMark.offsetLeft;
        }
    }
    return ev_x;
}

function RatingSet(iRating,iMaxRating,iMaxWidth) {

    memx = iRating / iMaxRating * iMaxWidth;
    memx = memx + "px";
    document.getElementById("Rating").style.width = memx;
    memr = document.getElementById("iRating").innerHTML;
}


function RatingOut() {
    
    document.getElementById("Rating").className = 'Rating';
    document.getElementById("Rating").style.width = memx;
    document.getElementById("iRating").innerHTML = memr;
    
}

function RatingClick(evt) {
    //TODO: Update DB
    window.RatingMove = function RatingMove(evt) { return; };
    window.RatingOut = function RatingOut() { return; };

    var img_x = GetX(evt);
    var iRating = Math.round(img_x / 110 * 5);

    DoVote("Company", gsId, iRating);

    document.getElementById("iRating").innerHTML = "Thank you!";// Please review " + gsTitle;

    window.RatingClick = function RatingClick(evt) { return; };

}

function RatingText(iRating) {

    if (iRating>4)
        document.getElementById("iRating").innerHTML = "Excellent!";
    else if (iRating>3)
        document.getElementById("iRating").innerHTML = "Good";
    else if (iRating > 2)
        document.getElementById("iRating").innerHTML = "OK";
    else if (iRating > 1)
        document.getElementById("iRating").innerHTML = "Poor";
    else if (iRating > 0)
        document.getElementById("iRating").innerHTML = "Stay Away!";

}

function ShowHide(sControlName, bVisible)
{
    if (bVisible)
        document.getElementById(sControlName).style.display='';
    else
        document.getElementById(sControlName).style.display='none';
}

function CheckReview() {
    if (document.getElementById("Comment_Heading").value == "") {
        document.getElementById("ReviewMessage").innerHTML = "Please provide a heading for your review.";
        return;
    }
    if (document.getElementById("Comment_Comment").value.length < 8) {
        document.getElementById("ReviewMessage").innerHTML = "Please provide a longer review.";
        return;
    }

    return;
}


function ScrollEvent() 
{
    if (window.addEventListener) {
        window.addEventListener("scroll", onScrollx, false);
        window.addEventListener('DOMMouseScroll', onScrollx, false);
        window.addEventListener("scroll", onScrollx, false);

    }
    else {
        window.attachEvent("onscroll", onScrollx);
        window.onmousewheel = onScrollx;
        window.onscroll = onScrollx;
    }
}

function onScrollx(e) {
    document.getElementById("ToolbarWrap").style.display = "inline";
    timedFooter();
}

var c = 0;
function timedFooter() {
    c = c + 1;
    if (c < 30) {
        document.getElementById("ToolbarWrap").style.posBottom = c - 55;
        setTimeout("timedFooter()", 10);
    }

    if (c == 30)
        trackPView("pageBottom");
}

var iL = 0;
function timedLogo() {
    iL = iL - 8;
    if (iL < -2496) 
        iL = 0;

    //Pause - Longer on the logo.
    if(iL % 192 == 0)
        setTimeout("timedLogo()", 2000);
    else
        setTimeout("timedLogo()", 20);

    document.getElementById("CoLogoSlide").style.backgroundPosition = iL + "px top";
        
}

function showUploadLogo() {
    document.getElementById("newFormSpan").innerHTML = document.getElementById("FormSpan").innerHTML;
    document.getElementById("FormSpan").innerHTML = "";
    document.getElementById("ChangeImageHref").style.display = "none";
    document.getElementById("newFormSpan").style.display = "inline";
    document.getElementById("sReturn").innerHTML = "";
    document.getElementById("formChangeImage").style.display = "inline";
    return false;
}
