﻿var isIE = navigator.appName.indexOf("Internet Explorer") > -1 ? true : false;
var isFF = navigator.userAgent.indexOf("Firefox") > -1 ? true : false;
var mouseDown = false;
var mouseMoved = false;
var mouseWheeled = false;
var latTopLeft = 0;
var lonTopLeft = 0;
var latBottomRight = 0;
var lonBottomRight = 0;
var latCenter = 0;
var lonCenter = 0;
var lastSearchLat = -1;
var lastSearchLon = -1;
var map = null;
var pins = null;
var objXML;
var refresh = false;
var delay = true;
var eventOn = false;
var wishlist = new Array();
var minPop = Math.log(20000);
var maxPop = Math.log(32000000);
var overZoom = false;
var overPopMin = false;
var overPopMax = false;
var iPadOverMap = false;
var iPadMapStart = new Array();
var tld = "";
var keyword = "";
var esc = "0";
var checkCookie = true;
var kwList = new Array();
var win = null;
kwList[0] = "auto";
kwList[1] = "autos";
kwList[2] = "clinic";
kwList[3] = "computers";
kwList[4] = "dating";
kwList[5] = "daycare";
kwList[6] = "dentist";
kwList[7] = "dentists";
kwList[8] = "doctor";
kwList[9] = "doctors";
kwList[10] = "electrician";
kwList[11] = "florist";
kwList[12] = "florists";
kwList[13] = "gardener";
kwList[14] = "groomer";
kwList[15] = "homes";
kwList[16] = "hotel";
kwList[17] = "hotels";
kwList[18] = "insurance";
kwList[19] = "limo";
kwList[20] = "limos";
kwList[21] = "loans";
kwList[22] = "massage";
kwList[23] = "mortgages";
kwList[24] = "news";
kwList[25] = "painter";
kwList[26] = "plumber";
kwList[27] = "realestate";
kwList[28] = "restaurant";
kwList[29] = "salon";
kwList[30] = "scholarships";
kwList[31] = "spa";
kwList[32] = "spas";
kwList[33] = "tickets";
kwList[34] = "travel";
kwList[35] = "vet";
document.oncontextmenu = new Function("event.cancelBubble=true;event.returnValue=false;return false;");

function o(name)
{ return document.getElementById(name); }
function init()
{
    o("geoSidebarInfo").style.display = "block";
    o("geoSidebarSearch").style.display = "none";
    o("geoAvail").innerHTML = "";
    o("geoAuction").innerHTML = "";
    o("txtSearch").value = "Location Name";
    o("txtSearch").style.color = "#AEAEAE";
    o("txtSearch").hasFocus = false;
    disableSelect(o("popMinS"));
    disableSelect(o("popMaxS"));
    disableSelect(o("imgZoomMarker"));
    if (token != "")
    {
        map = new VEMap("msMap");
        var mapOptions = new VEMapOptions();
        mapOptions.EnableBirdseye = false;
        map.SetCredentials("AsqqJEJ0rYgeV7d3k_omprCJZtxeA5j4hyvaPqjsNw37X3aM4A6-MU_akG453bhQ");
        map.LoadMap(new VELatLong(39.876, -95.537, 0, VEAltitudeMode.RelativeToGround), 4, VEMapStyle.Road, false, VEMapMode.Mode2D, false, 1, mapOptions);
        map.AttachEvent("onendzoom", onEndZoom);
        map.AttachEvent("ontokenexpire", onTokenExpire);
        map.AttachEvent("ontokenerror", onTokenError);
        map.AttachEvent("onendpan", onEndPan);
        if (isIE)
        {
            o("msMap").attachEvent("onmousedown", onMouseDown);
            o("msMap").attachEvent("onmouseup", onMouseUp);
            o("msMap").attachEvent("onmousemove", onMouseMove);
            o("msMap").attachEvent("onmousewheel", onMouseWheel);
            o("divRefine").attachEvent("onmousemove", onMouseMove);
            o("divRefine").attachEvent("onmouseup", onMouseUp);
            o("divAdvKW").style.display = "inline";
            o("divRefKW").style.display = "block";
            o("ddlRefineKeyword").style.marginBottom = "-3px";
            o("txtAdvKeyword").style.height = "100%";
            o("txtRefineKeyword").style.height = "100%";
        }
        else
        {
            o("msMap").addEventListener("mousedown", onMouseDown, true);
            o("msMap").addEventListener("mouseup", onMouseUp, true);
            o("msMap").addEventListener("mousemove", onMouseMove, true);
            o("msMap").addEventListener("touchstart", onMouseDown, true);
            o("msMap").addEventListener("touchend", onMouseUp, true);
            o("msMap").addEventListener("touchmove", onMouseMove, true);
            o("msMap").addEventListener("DOMMouseScroll", onMouseWheel, false);
            o("divRefine").addEventListener("mousemove", onMouseMove, true);
            o("divRefine").addEventListener("touchstart", onMouseDown, true);
            o("divRefine").addEventListener("touchend", onMouseUp, true);
            o("divRefine").addEventListener("touchmove", onMouseMove, true);
            o("divRefine").addEventListener("mouseup", onMouseUp, true);
        }
        if (isFF)
        {
            o("divAdvKW").style.marginBottom = "-4px";
            o("divRefKW").style.marginBottom = "-4px";
        }
        var html = "";
        for (i = 0; i < kwList.length; i++)
        {
            html += "<div style=\"width:100%;height:20px;\" onmouseover=\"this.style.backgroundColor='#CECECE';\" onmouseout=\"this.style.backgroundColor='white';\" onclick=\"setKeyword('" + kwList[i] + "');\">" + kwList[i] + "</div>";
        }
        o("divAdvKeyword").innerHTML = html;
        o("divRefineKeyword").innerHTML = html;
        checkGeoSearch();
        onResize();
    }
    else //Bing Maps unavailable
    {
        o("msMap").innerHTML = "<div style=\"color:white;width:400px;margin-top:100px;margin-left:200px;\">Sorry!<br /><br />The map is unavailable at this time, please try again by reloading this page.<br /><br />If the problem persists, please try again later.</div>";
    }
}
function onMouseDown(e)
{
	mouseDown = true;
	if (e.type == "touchstart")
	{ iPadMapStart = new Array(e.targetTouches[0].pageX, e.targetTouches[0].pageY); }
}
function onMouseUp(e)
{
    mouseDown = false;
    if (mouseMoved)
    {
        mouseMoved = false;
        setTimeout("delay = false;", 4000);
    }
    if (overZoom)
    {
        onEndZoom(null);
        overZoom = false;
    }
    overPopMin = false;
    overPopMax = false;
}
function onMouseMove(e)
{
	if (mouseDown)
    { delay = true; }
    var xCoord = -1;
    if (isIE)
    { xCoord = e.clientX + document.documentElement.scrollLeft; }
    else if (e.type == "touchmove")
    {
		if (overZoom || overPopMin || overPopMax)
    	{ e.preventDefault(); }
    	xCoord = e.targetTouches[0].pageX;
    }
    else
    { xCoord = e.pageX; }
    if (overZoom)
    {
    	var zMinX = 761;
    	var zMaxX = 861;
    	if (xCoord >= zMinX && e.pageX <= zMaxX)
    	{
    		var iZoom = 0;
    		o("imgZoomMarker").style.left = (xCoord - 673) + "px";
    		iZoom = Math.floor(18 * (1 - (zMaxX - xCoord) / (zMaxX - zMinX))) + 1;
    		if (map.GetZoomLevel() != iZoom)
    		{ map.SetZoomLevel(iZoom); }
    		document.getElementById("divZoomLevel").innerHTML = iZoom;
    	}
    }
    else if (overPopMin)
    {
    	var pMinX = 730;
    	var pMaxX = parseInt(o("popMaxS").style.left) + 659;
    	if (xCoord >= pMinX && xCoord <= pMaxX)
    	{
    		o("popMinS").style.left = (xCoord - 660) + "px";
    		o("popFill").style.left = (parseInt(o("popMinS").style.left) + 5) + "px";
    		try { o("popFill").style.width = (parseInt(o("popMaxS").style.left) - parseInt(o("popMinS").style.left) - 5) + "px"; }
    		catch (ex) { }
    		var pMin = (maxPop - minPop) / (890 - 730) * (parseInt(o("popMinS").style.left) + 660 - 730);
    		pMin = Math.ceil(Math.exp(pMin + minPop))
    		pMin = pMin.toString();
    		var i = pMin.length;
    		var sTmp = "";
    		while (i >= 0)
    		{
    			sTmp = pMin.substring(i, i + 1) + sTmp;
    			if (i < pMin.length && (pMin.length - i) % 3 == 0)
    			{ sTmp = "," + sTmp }
    			i--;
    		}
    		if (sTmp.indexOf(",") == 0)
    		{ sTmp = sTmp.substring(1, sTmp.length); }
    		o("popMin").innerHTML = sTmp;
    	}
    }
    else if (overPopMax)
    {
    	var pMinX = parseInt(o("popMinS").style.left) + 661;
    	var pMaxX = 890;
    	if (xCoord >= pMinX && xCoord <= pMaxX)
    	{
    		o("popMaxS").style.left = (xCoord - 660) + "px";
    		o("popFill").style.left = (parseInt(o("popMinS").style.left) + 5) + "px";
    		try { o("popFill").style.width = (parseInt(o("popMaxS").style.left) - parseInt(o("popMinS").style.left) - 5) + "px"; }
    		catch (ex) { }
    		var pMax = (maxPop - minPop) / (890 - 730) * (parseInt(o("popMaxS").style.left) + 660 - 730);
    		pMax = Math.floor(Math.exp(pMax + minPop));
    		pMax = pMax.toString();
    		var i = pMax.length;
    		var sTmp = "";
    		while (i >= 0)
    		{
    			sTmp = pMax.substring(i, i + 1) + sTmp;
    			if (i < pMax.length && (pMax.length - i) % 3 == 0)
    			{ sTmp = "," + sTmp }
    			i--;
    		}
    		if (sTmp.indexOf(",") == 0)
    		{ sTmp = sTmp.substring(1, sTmp.length); }
    		o("popMax").innerHTML = sTmp;
    	}
    }
    else if (iPadOverMap)
    {
		var yCoord = e.targetTouches[0].pageY;
		map.Pan(iPadMapStart[0] - xCoord, iPadMapStart[1] - yCoord);
    }
    mouseMoved = true;
}
function onMouseWheel(e)
{
    mouseMoved = false;
    delay = true;
    setTimeout("delay = false;", 4000);
}
function onResize(e)
{
    if (document.getElementById("divOverlay").style.display == "block")
    {
        document.getElementById("divOverlay").style.width = "100%";
        document.getElementById("divOverlay").style.height = "100%";
    }
}
function onTokenExpire()
{ alert("The Bing Maps session has expired, please reload the page to continue."); }
function onTokenError()
{ alert("The Bing Maps session has encountered an error, please reload the page to try again.\n\nIf the error persists, please try again later."); }
function onEndPan()
{
}
function openVideo()
{
    win = window.open("about:blank", "_ActionCast", "width=800,height=540,scrollbars=1");
    setTimeout("showVideo();", 100);
}
function showVideo()
{
    var objFlash = null;
    var flashVer = 0;
    try
    {
        if (isIE)
        {
            objFlash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            if (objFlash != null && objFlash.GetVariable("$version").indexOf("WIN ") > -1)
            {
                flashVer = objFlash.GetVariable("$version").substring(3);
                flashVer = parseInt(flashVer.substring(0, flashVer.indexOf(",")));
            }
        }
        else
        {
            objFlash = (navigator.plugins["Shockwave Flash"] || navigator.plugins["Shockwave Flash 2.0"]);
            if (objFlash != null && objFlash.description != "")
            {
                flashVer = objFlash.description.replace("Shockwave Flash ", "");
                flashVer = parseInt(flashVer.substring(0, flashVer.indexOf(".")));
            }
        }
    }
    catch (ex)
    { flashVer = "9"; }
    var html = "";
    if (flashVer > 8)
    {
        html = "<html><head><title>Go Daddy GeoDomainMap</title></head><body bgcolor=\"black\"><center>\n";
        html += "<object width=\"720\" height=\"480\">\n";
        html += "<param name=\"movie\" VALUE=\"" + urlImg + "GeoDomains_Branded.swf\">\n";
        html += "<param name=\"quality\" VALUE=\"high\">\n";
        html += "<param name=\"bgcolor\" VALUE=\"#000000\">\n";
        html += "<embed id=\"eGeo\" src=\"" + urlImg + "GeoDomains_Branded.swf\" bgcolor=\"#000000\" width=\"720\" height=\"480\" type=\"application/x-shockwave-flash\"></embed>\n";
        html += "</object><br />\n";
        html += "<span style=\"font:10px Arial;color:#CECECE;\">Can't see video here?&nbsp;Get the latest Flash player here: <a href=\"http://get.adobe.com/flashplayer\" style=\"color:#7777FF;\">get.adobe.com/flashplayer</a></span>\n";
        html += "</center></body></html>";
    }
    else
    {
        html = "<html><head><title>Go Daddy GeoDomainMap</title></head><body bgcolor=\"white\" style=\"font-family:Arial;\"><br />";
        html += "<h3>Can't see video here?&nbsp; Your Flash player may be outdated or blocked.&nbsp; Try these steps...</h3>";
        html += "<ol><li>Verify that you are running Adobe(r) Flash(r) 9.0.115 or above.&nbsp; You can ";
        html += "get the latest Flash player here: <a href=\"http://get.adobe.com/flashplayer\" style=\"color:#000088;\">get.adobe.com/flashplayer</a><br>&nbsp;<br></li>";
        html += "<li>Check that your browser or plugin settings are not preventing Flash from running.&nbsp;  Some javascript and ad blockers interfere with Flash.<br>&nbsp;<br></li>";
        html += "<li>Make sure your previous Flash version is fully uninstalled.&nbsp; Sometimes your browser will try to use an older version, even after you've installed an upgrade.</li></ol>";
    }
    win.document.write(html);
}
function checkGeoSearch()
{
    if (!delay)
    {
        delay = true;
        { asgSearch(); }
    }
    setTimeout("checkGeoSearch();", 500);
}
function onEndZoom(e)
{
    var zoomTop = "";
    var zoomLeft = "";
    document.getElementById("divZoomLevel").innerHTML = map.GetZoomLevel();
    for (i = 1; i <= 19; i += 2)
    {
        if (i <= map.GetZoomLevel())
        {
            zoomTop = getTop(o("imgZoom" + i));
            zoomLeft = getLeft(o("imgZoom" + i));
            o("imgZoom" + i).src = urlImg + "orb_filled.gif";
        }
        else
        { o("imgZoom" + i).src = urlImg + "orb_empty.gif"; }
    }
    if (!overZoom && zoomLeft.toString() != "");
    {
        o("imgZoomMarker").style.top = (parseInt(zoomTop) - 131) + "px";
        o("imgZoomMarker").style.left = (parseInt(zoomLeft) - 663) + "px";
    }
}
function openKeyword(n)
{
    o("divAdvKeyword").style.left = (parseInt(getLeft(o("txtAdvKeyword"))) - 176) + "px";
    o("divAdvKeyword").style.top = (parseInt(getTop(o("txtAdvKeyword"))) + 18) + "px";
    o("divRefineKeyword").style.left = (parseInt(getLeft(o("txtRefineKeyword"))) - 153) + "px";
    o("divRefineKeyword").style.top = (parseInt(getTop(o("txtRefineKeyword"))) + 18) + "px";
    o(n).style.display = (o(n).style.display == "block" ? "none" : "block");
}
function setKeyword(n)
{
    o("divAdvKeyword").style.display = "none";
    o("divRefineKeyword").style.display = "none";
    o("txtAdvKeyword").value = n;
    o("txtRefineKeyword").value = n;
}
function locationSearch(n)
{
    refresh = true;
    map.Find(null, n, VEFindType.Businesses, null, null, 5, false, false, true, true, asgSearch);
}
function geoAdvSearch()
{
    o("geoAdvSearch").style.display = "none";
    o("txtSearch").value = "";
    styleTBBlur(o("txtSearch"));
    if (o("txtAdvLocation").value == "")
    {
        refresh = true;
        asgSearch();
    }
    else
    { locationSearch(o("txtAdvLocation").value); }
    o("txtAdvLocation").value = "";
}
function geoSearch(asg)
{
    if (checkCookie)
    {
        deleteCookie("test");
        setCookie("test", "ok");
        if (getCookie("test") != "ok")
        {
            alert("Browser cookies are required to support GeoDomainMap search.\n\nPlease enable cookie support before proceeding.");
            return;
        }
        else
        {
            checkCookie = false;
            deleteCookie("test");
        }
    }
    if (o("geoSidebarSearch").style.display != "block")
    {
        o("divShare").style.display = "none";
        o("img123").style.display = "none";
        o("geoSidebarInfo").style.display = "none";
        o("geoSidebarSearch").style.display = "block";
        o("divRefine").style.display = "block";
        onEndZoom(null);
    }
    if (objXML == null || objXML.readyState == 4)
    {
        var inputs = document.getElementsByTagName("input");
        var bAllTldChecked = true;
        for (i = 0; i < inputs.length; i++)
        {
            if (inputs[i].id != null && inputs[i].id.substring(0, 6) == "chkTLD")
            {
            	if (o(inputs[i].id).checked)
            	{ tld += inputs[i].value + ","; }
            	else
            	{ bAllTldChecked = false; }
            }
        }
        if (o("txtAdvKeyword").value != "")
        {
            keyword = o("txtAdvKeyword").value;
            esc = o("ddlAdvKeyword").selectedIndex;
        }
        var view = map.GetMapView();
        if (refresh || (lastSearchLat != view.TopLeftLatLong.Latitude || lastSearchLon != view.TopLeftLatLong.Longitude))
        {
            o("geoAdvSearch").style.display = "none";
            o("divAdvKeyword").style.display = "none";
            o("divRefineKeyword").style.display = "none";
            o("aSelAll").innerText = "Select All";
            refresh = false;
            var sSearchingHTML = "<br><br><br><br><center>Searching...<br><br><img src=\"" + urlImg +"loading.gif\" width=\"16\" height=\"16\"></center>";
            o("geoAvail").innerHTML = sSearchingHTML;
            o("geoAuction").innerHTML = sSearchingHTML;
            latTopLeft = view.TopLeftLatLong.Latitude;
            lonTopLeft = view.TopLeftLatLong.Longitude;
            latBottomRight = view.BottomRightLatLong.Latitude;
            lonBottomRight = view.BottomRightLatLong.Longitude;
            lastSearchLat = latTopLeft;
            lastSearchLon = lonTopLeft;
            var url = "";
            if (o("chkUS").checked)
            { url += "city=US&"; }
            url += "lat1=" + latTopLeft + "&lon1=" + lonTopLeft + "&lat2=" + latBottomRight + "&lon2=" + lonBottomRight;
            if (keyword != "")
            {
            	try { keyword = keyword.substring(0, 1).toUpperCase() + keyword.substring(1, keyword.length); }
            	catch (ex) {}
            	url += "&keyword=" + keyword;
            }
            url += "&kw=" + esc;
            keyword = "";
            if (!bAllTldChecked)
            { url += "&tld=" + tld; }
            tld = "";
            var pMin = o("popMin").innerHTML;
            while (pMin.indexOf(",") > -1)
            { pMin = pMin.replace(",", ""); }
            url += "&pMin=" + pMin;
            var pMax = o("popMax").innerHTML;
            while (pMax.indexOf(",") > -1)
            { pMax = pMax.replace(",", ""); }
            url += "&pMax=" + pMax;
            esc = "0";
            if (isIE)
            { objXML = new ActiveXObject("Msxml2.XMLHTTP"); }
            else { objXML = new XMLHttpRequest(); }
            if (objXML.overrideMimeType)
            { objXML.overrideMimeType("text/html"); }
            objXML.open("POST", "GeoDomain.aspx", true);
            objXML.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            objXML.setRequestHeader("Content-length", url.length);
            objXML.setRequestHeader("Connection", "close");
            objXML.onreadystatechange = function()
            {
                if (objXML.readyState == 4)
                {
                    var html = objXML.responseText;
                    o("geoAuction").innerHTML = html.substring(0, html.indexOf("<!-- %% -->"));
                    o("geoAvail").innerHTML = html.substring(html.indexOf("<!-- %% -->") + 11);
                    var divs = document.getElementsByTagName("div");
                    for (var i = 0; i < divs.length; i++)
                    {
                        if (divs[i].id != null && divs[i].id.substring(0, 3) == "dv_")
                        {
                            var n = divs[i].id.substring(3, divs[i].id.length)
                            if (wishlist.toString().indexOf(n) > -1)
                            { o("dv_" + n).innerHTML = "In Wishlist"; }
                        }
                    }
                    showPins();
                    if (html.indexOf("No matching available domains found.") > -1)
                    o("txtSearch").value = "Location Name";
                    if (o("txtSearch").hasFocus)
                    { styleTBBlur(o("txtSearch")); }
                    else
                    { o("txtSearch").blur(); }
                }
            }
            objXML.send(url);
        }
    }
}
function showPins()
{
    var coords = document.getElementsByTagName("input");
    var s = "";
    map.Clear();
    pins = new Object();
    var iAvailCount = 0;
    var iAuctionCount = 0;
    for (i = coords.length-1; i >= 0; i--)
    {
        if (coords[i].id != null && coords[i].id.indexOf("coords") == 0)
        {
            if (s.indexOf(coords[i].value) == -1)
            {
                var activeTab = (coords[i].id.indexOf("Avail") > -1 ? "Avail" : "Auction");
                s += coords[i].id;
                eval("var t = new Array(" + coords[i].value + ");");
                var name = t[0];
                var lat = t[1];
                var lon = t[2];
                var price = t[3];
                var timeleft = t[4];
                var miid = t[5];
                var aut = t[6];
                var pin = new VEShape(VEShapeType.Pushpin, new VELatLong(lat, lon));
                if (activeTab == "Avail")
                {
                    pin.SetCustomIcon(urlImg + "pin_or.png");
                    var desc = "<b>" + name + "</b><br/ ><br/ >";
                    if (wishlist.toString().indexOf(name.toUpperCase()) > -1)
                    { desc += "<img src=\"" + urlImg + "btn_inwish.gif\" width=\"82\" height=\"22\" title=\"" + name + " is in your Wishlist\" />&nbsp;&nbsp;"; }
                    else
                    { desc += "<img src=\"" + urlImg + "btn_wishlist_onwht.gif\" width=\"80\" height=\"22\" title=\"Add " + name + " to Wishlist\" style=\"cursor:pointer;\" onclick=\"aw('" + name + "');this.src='" + urlImg + "btn_inwish.gif';this.style.width='82px';this.title='" + name + " is in your Wishlist';this.style.cursor='default';\" />&nbsp;&nbsp;"; }
                    desc += "<img src=\"" + urlImg + "btn_buy.gif\" width=\"74\" height=\"22\" title=\"Buy " + name + " Now\" style=\"cursor:pointer;\" onclick=\"rn('" + name + "');\" />";
                    pin.SetDescription(desc);
                    iAvailCount++;
                }
                else
                {
                    pin.SetCustomIcon(urlImg + "pin_gr.png");
                    var desc = "<b>" + name + "</b><br/ ><br/ >";
                    desc += price + "&nbsp&nbsp;&nbsp;&nbsp;" + timeleft + "<br /><br/ >";
                    if (aut.indexOf("N") > -1)
                    { desc += "<a href=\"" + urlAuctionSingle + miid + "\" target=\"_newWindow\"><img src=\"" + urlImg + "btn_buy.gif\" width=\"74\" height=\"22\" alt=\"\" title=\"Buy Now\" style=\"border:0px;\" /></a>" + (aut.length > 0 ? "&nbsp;&nbsp;&nbsp;" : ""); }
                    if (aut.indexOf("B") > -1)
                    { desc += "<a href=\"" + urlAuctionSingle + miid + "\" target=\"_newWindow\"><img src=\"" + urlImg + "btn_place.gif\" width=\"76\" height=\"22\" alt=\"\" title=\"Place Bid\" style=\"border:0px;\" /></a>"; }
                    if (aut.indexOf("O") > -1)
                    { desc += "<a href=\"" + urlAuctionSingle + miid + "\" target=\"_newWindow\"><img src=\"" + urlImg + "btn_makeoffer.gif\" width=\"84\" height=\"22\" alt=\"\" title=\"Make Offer\" style=\"border:0px;\" /></a>"; }
                    pin.SetDescription(desc);
                    iAuctionCount++;
                }
                map.AddShape(pin);
                pins[name.toUpperCase()] = pin.GetID();
            }
        }
    }
}
function styleTBFocus(n)
{
    n.hasFocus = true;
    if (n.value == "Location Name")
    {
        n.value = "";
        n.style.color = "black";
        n.style.fontStyle = "normal";
    }
}
function styleTBBlur(n)
{
    n.hasFocus = false;
    if (n.value == "" || n.value == "Location Name")
    {
        n.value = "Location Name";
        n.style.color = "#AEAEAE";
        n.style.fontStyle = "italic";
    }
}
function validateTB(n)
{
    if (n == o("txtSearch") || n == o("txtAdvLocation"))
    { n.value = n.value.replace(new RegExp("[^a-zA-Z0-9 -,.]", "g"), ""); }
    else
    { n.value = n.value.replace(new RegExp("[^a-zA-Z0-9 -]", "g"), ""); }
    if (n == o("txtAdvLocation"))
    {
    	o("chkUS").checked = false;
    	o("chkWorld").checked = false;
    }
}
function geoAdvSearchBtn()
{
    o("divAdvKeyword").style.display = "none";
    if (o("geoAdvSearch").style.display != "block")
    { o("geoAdvSearch").style.display = "block"; }
    else
    { o("geoAdvSearch").style.display = "none"; }
}
function showInfo(c, td, n)
{
    td.style.backgroundColor = c;
    var pin = map.GetShapeByID(pins[n.toUpperCase()]);
    map.ShowInfoBox(pin);
}
function hideInfo(td)
{
    td.style.backgroundColor = "";
    map.HideInfoBox();
}
function rn(sDomain)
{
    showOverlay(true);
    o("divAvail").style.display = "block";
    var s = "<b style=\"font-size:20px;\">" + sDomain + "</b><hr style=\"height:1px;\">"
    s += "<img src=\"" + urlImg + "loading.gif\" width=\"16\" height=\"16\" style=\"margin-left:200px;\" alt=\"\" />";
    s += "<br /><br />Verifying <b>" + sDomain + "</b> availability...";
    o("divAvailContent").innerHTML = s;
    url = "av=" + encodeURI(sDomain);
    if (objXML == null || objXML.readyState == 4)
    {
        if (isIE)
        { objXML = new ActiveXObject("Msxml2.XMLHTTP"); }
        else { objXML = new XMLHttpRequest(); }
        if (objXML.overrideMimeType)
        { objXML.overrideMimeType("text/html"); }
        objXML.open("POST", "GeoDomain.aspx", true);
        objXML.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        objXML.setRequestHeader("Content-length", url.length);
        objXML.setRequestHeader("Connection", "close");
        objXML.onreadystatechange = function()
        {
            if (objXML.readyState == 4)
            {
                var html = objXML.responseText;
                html = "<b style=\"font-size:20px;\">" + sDomain + "</b><hr style=\"height:1px;\">" + html;
                html += "<br /><br />";
                html += "<img src=\"" + urlImg + "btn_return.gif\" width=\"213\" height=\"22\" alt=\"\" style=\"cursor:pointer;margin-left:10px;\" title=\"Return to GeoDomainMap Search\" onmouseover=\"this.src='" + urlImg + "btn_return_h.gif';\" onmouseout=\"this.src='" + urlImg + "btn_return.gif';\"; onmousedown=\"this.src='" + urlImg + "btn_return_a.gif';\" onmouseup=\"this.src='" + urlImg + "btn_return.gif';\" onclick=\"showOverlay(false);o('divAvail').style.display='none';\" />";
                if (html.indexOf("<font color=\"green\">Available</font>") > -1)
                { html += "<img src=\"" + urlImg + "btn_buy.gif\" width=\"74\" height=\"22\" alt=\"\" style=\"cursor:pointer;margin-left:10px;\" title=\"Buy Now\" onmouseover=\"this.src='" + urlImg + "btn_buy_h.gif';\" onmouseout=\"this.src='" + urlImg + "btn_buy.gif';\"; onmousedown=\"this.src='" + urlImg + "btn_buy_a.gif';\" onmouseup=\"this.src='" + urlImg + "btn_buy.gif';\" onclick=\"addToCart('" + sDomain + "');\" />"; }
                o("divAvailContent").innerHTML = html;
            }
        }
        objXML.send(url);
    }
}
function ViewWishlist()
{
    if (objXML == null || objXML.readyState == 4)
    {
        showOverlay(true);
        o("divWishlist").style.display = "block";
        var s = "<b style=\"font-size:20px;\">Wishlist</b><hr style=\"height:1px;\">";
        if (wishlist.length > 0)
        {
            s += "<img src=\"" + urlImg + "loading.gif\" width=\"16\" height=\"16\" style=\"margin-left:200px;\" alt=\"\" />";
            s += "<br /><br />Verifying " + wishlist.length + " domains for availability...";
            o("divWishlistContent").innerHTML = s;
            n = "av=";
            for (var i = 0; i < wishlist.length; i++)
            {
                n += wishlist[i];
                if (i < wishlist.length - 1)
                { n += ","; }
            }
            n += "&w=1";
            if (objXML == null || objXML.readyState == 4)
            {
                if (isIE)
                { objXML = new ActiveXObject("Msxml2.XMLHTTP"); }
                else { objXML = new XMLHttpRequest(); }
                if (objXML.overrideMimeType)
                { objXML.overrideMimeType("text/html"); }
                objXML.open("POST", "GeoDomain.aspx", true);
                objXML.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                objXML.setRequestHeader("Content-length", n.length);
                objXML.setRequestHeader("Connection", "close");
                objXML.onreadystatechange = function()
                {
                    if (objXML.readyState == 4)
                    {
                        var html = objXML.responseText;
                        html = "<a href=\"javascript:ClearWishlist();\" style=\"float:right;\">Remove All</a><b style=\"font-size:20px;\">Wishlist</b><hr style=\"height:1px;\">" + html;
                        html += "<br /><br />";
                        html += "<img src=\"" + urlImg + "btn_return.gif\" width=\"213\" height=\"22\" alt=\"\" style=\"cursor:pointer;margin-left:10px;\" title=\"Return to GeoDomainMap Search\" onmouseover=\"this.src='" + urlImg + "btn_return_h.gif';\" onmouseout=\"this.src='" + urlImg + "btn_return.gif';\"; onmousedown=\"this.src='" + urlImg + "btn_return_a.gif';\" onmouseup=\"this.src='" + urlImg + "btn_return.gif';\" onclick=\"showOverlay(false);o('divWishlist').style.display='none';\" />";
                        if (html.indexOf("0 Available Domains") == -1 && html.indexOf("Unable to check availability") == -1)
                        { html += "<img src=\"" + urlImg + "btn_proceed.gif\" id=\"imgBtnProceed\" width=\"142\" height=\"22\" alt=\"\" style=\"cursor:pointer;margin-left:10px;\" title=\"Proceed to Checkout\" onmouseover=\"this.src='" + urlImg + "btn_proceed_h.gif';\" onmouseout=\"this.src='" + urlImg + "btn_proceed.gif';\"; onmousedown=\"this.src='" + urlImg + "btn_proceed_a.gif';\" onmouseup=\"this.src='" + urlImg + "btn_proceed.gif';\" onclick=\"addToCart('');\" />"; }
                        o("divWishlistContent").innerHTML = html;
                    }
                }
                objXML.send(n);
            }
        }
        else
        { o("divWishlistContent").innerHTML = s + "No items in Wishlist.<br /><br /><img src=\"" + urlImg + "btn_return.gif\" width=\"213\" height=\"22\" alt=\"\" style=\"cursor:pointer;margin-left:10px;\" title=\"Return to GeoDomainMap Search\" onmouseover=\"this.src='" + urlImg + "btn_return_h.gif';\" onmouseout=\"this.src='" + urlImg + "btn_return.gif';\"; onmousedown=\"this.src='" + urlImg + "btn_return_a.gif';\" onmouseup=\"this.src='" + urlImg + "btn_return.gif';\" onclick=\"showOverlay(false);o('divWishlist').style.display='none';\" />"; }
    }
}
function aw(n)
{
    if (wishlist.length < 300 && wishlist.toString().indexOf(n.toUpperCase()) == -1)
    {
        wishlist[wishlist.length] = n.toUpperCase();

        var pin = map.GetShapeByID(pins[n.toUpperCase()]);
        var desc = "<b>" + n + "</b><br/ ><br/ >";
        desc += "<img src=\"" + urlImg + "btn_inwish.gif\" width=\"82\" height=\"22\" title=\"" + n + " is in your Wishlist\" />&nbsp;&nbsp;";
        desc += "<img src=\"" + urlImg + "btn_buy.gif\" width=\"74\" height=\"22\" title=\"Buy " + n + " Now\" style=\"cursor:pointer;\" onclick=\"rn('" + n + "');\" />";
        pin.SetDescription(desc);
        o("dv_" + n.toUpperCase()).innerHTML = "In Wishlist";
        o("divWlCount").innerHTML = wishlist.length + " in Wishlist";
    }
    else if (wishlist.length >= 300)
    { alert("No more than 300 total items may be added to your Wishlist.\n\nPlease process your current list before proceeding."); }
}
function rw(n, m)
{
    if (wishlist.toString().indexOf(n.toUpperCase()) != -1)
    {
        for (var i = 0; i < wishlist.length; i++)
        {
            if (wishlist[i] == n.toUpperCase())
            {
                wishlist.splice(i, 1);
                break;
            }
        }
        var pin = map.GetShapeByID(pins[n.toUpperCase()]);
        if (pin != null)
        {
            var desc = "<b>" + n + "</b><br/ ><br/ >";
            desc += "<img src=\"" + urlImg + "btn_wishlist_onwht.gif\" width=\"80\" height=\"22\" title=\"Add " + n + " to Wishlist\" style=\"cursor:pointer;\" onclick=\"aw('" + n + "');this.src='" + urlImg + "btn_inwish.gif';this.style.width='82px';this.title='" + n + " is in your Wishlist';this.style.cursor='default';\" />&nbsp;&nbsp;";
            desc += "<img src=\"" + urlImg + "btn_buy.gif\" width=\"74\" height=\"22\" title=\"Buy " + n + " Now\" style=\"cursor:pointer;\" onclick=\"rn('" + n + "');\" />";
            pin.SetDescription(desc);
            o("dv_" + n.toUpperCase()).innerHTML = "<a title=\"Add " + n + " to Wishlist\" href=\"javascript:aw('" + n + "');\">Wishlist</a>";
        }
        o("wl_" + n.toUpperCase()).style.display = "none";
        o("divWlCount").innerHTML = wishlist.length + " in Wishlist";
        o("s" + m).innerText = (parseInt(o("s" + m).innerText) - 1);
        if (parseInt(o("sA").innerText) == 0)
        { o("imgBtnProceed").style.display = "none"; }
    }
}
function AddSelectedToWishlist()
{
    var geoAvail = "";
    var inputs = document.getElementsByTagName("input");
    for (i = 0; i < inputs.length; i++)
    {
        if (inputs[i].id != null && inputs[i].id.indexOf("av_") == 0)
        {
            if (o(inputs[i].id).checked)
            {
                var n = inputs[i].id.substring(3, inputs[i].id.length);
                if (wishlist.length < 300)
                { aw(n); }
            }
        }
    }
    if (wishlist.length >= 300)
    { alert("No more than 300 total items may be added to your Wishlist.\n\nPlease process your current list before proceeding."); }
}
function ClearWishlist()
{
    var links = document.getElementsByTagName("a");
    for (i = 0; i < links.length; i++)
    {
        if (links[i].id != null && links[i].id.indexOf("rw_") == 0)
        {
            var name = links[i].id.replace("rw_A_", "").replace("rw_T_", "");
            var av = links[i].id.substring(3, 4);
            rw(name, av);
        }
    }
}
function addToCart(n)
{
    if (n == "")
    {
        o("divWishlist").style.cursor = "wait";
        n = "buy=";
        for (var i = 0; i < wishlist.length; i++)
        {
            if (o("dWlA").innerText.indexOf(wishlist[i]) > -1)
            {
                n += wishlist[i];
                if (i < wishlist.length - 1)
                { n += ","; }
            }
        }
        if (objXML == null || objXML.readyState == 4)
        {
            if (isIE)
            { objXML = new ActiveXObject("Msxml2.XMLHTTP"); }
            else { objXML = new XMLHttpRequest(); }
            if (objXML.overrideMimeType)
            { objXML.overrideMimeType("text/html"); }
            objXML.open("POST", "GeoDomain.aspx", true);
            objXML.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            objXML.setRequestHeader("Content-length", n.length);
            objXML.setRequestHeader("Connection", "close");
            objXML.onreadystatechange = function()
            {
                if (objXML.readyState == 4)
                {
                    var html = objXML.responseText;
                    if (html.indexOf("Cart") > -1)
                    {
                        if (html != "Cart")
                        { setCookie(sc, html.replace("Cart", "")); }
                        document.location = urlCart;
                    }
                    else
                    {
                        o("divWishlist").style.cursor = "default";
                        alert("Unable to add items to cart.");
                        showOverlay(false);
                        o("divWishlist").style.display = "none";
                    }
                }
            }
            objXML.send(n);
        }
    }
    else
    {
        o("divAvail").style.cursor = "wait";
        var url = "buy=" + n;
        if (objXML == null || objXML.readyState == 4)
        {
            if (isIE)
            { objXML = new ActiveXObject("Msxml2.XMLHTTP"); }
            else { objXML = new XMLHttpRequest(); }
            if (objXML.overrideMimeType)
            { objXML.overrideMimeType("text/html"); }
            objXML.open("POST", "GeoDomain.aspx", true);
            objXML.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            objXML.setRequestHeader("Content-length", url.length);
            objXML.setRequestHeader("Connection", "close");
            objXML.onreadystatechange = function()
            {
                if (objXML.readyState == 4)
                {
                    var html = objXML.responseText;
                    if (html.indexOf("Cart") > -1)
                    {
                        if (html != "Cart")
                        { setCookie(sc, html.replace("Cart", "")); }
                        document.location = urlCart;
                    }
                    else
                    {
                        o("divAvail").style.cursor = "default";
                        alert("Unable to add item to cart.");
                        showOverlay(false);
                        o("divAvail").style.display = "none";
                    }
                }
            }
            objXML.send(url);
        }
    }
}
function selectAll()
{
    var inputs = document.getElementsByTagName("input");
    for (i = 0; i < inputs.length; i++)
    {
        if (inputs[i].id != null && inputs[i].id.substring(0,3) == "av_")
        { o(inputs[i].id).checked = (o("aSelAll").innerText == "Select All"); }
    }
    o("aSelAll").innerText = (o("aSelAll").innerText == "Select All" ? "Unselect All" : "Select All");
}
function selectAllTLDs()
{
    var inputs = document.getElementsByTagName("input");
    for (i = 0; i < inputs.length; i++)
    {
    	if (inputs[i].id != null && inputs[i].id.substring(0, 3) == "chk" && inputs[i].id != "chkUS" && inputs[i].id != "chkWorld")
        { o(inputs[i].id).checked = (o("aSelAllTLDs").innerText == "Select All"); }
    }
    o("aSelAllTLDs").innerText = (o("aSelAllTLDs").innerText == "Select All" ? "Unselect All" : "Select All");
}
function chkKey(e)
{
    var keyCode = ((e.keyCode) ? e.keyCode : ((e.which) ? e.which : e.charCode));
    alert(keyCode);
}
function getLeft(obj)
{
    var iLeft = obj.offsetLeft;
    while (obj.offsetParent != null)
    {
        objP = obj.offsetParent;
        iLeft += objP.offsetLeft;
        obj = objP;
    }
    return iLeft;
}
function getTop(obj)
{
    var iTop = obj.offsetTop;
    while (obj.offsetParent != null)
    {
        objP = obj.offsetParent;
        iTop += objP.offsetTop;
        obj = objP;
    }
    return iTop;
}
function showOverlay(n)
{
    document.getElementById("divOverlay").style.display = (n ? "block" : "none");
    document.getElementById("divOverlay").style.width = "100%";
    document.getElementById("divOverlay").style.height = "100%";
}
function resetMap()
{
    var ok = true;
    if (wishlist.length > 0)
    { ok = confirm("Resetting GeoDomainMap will reset your Wishlist.\n\nAre you sure?"); }
    if (ok)
    { window.location.reload(); }
}
function getCookie(name)
{
    var retval = null;
    var cookieValue = document.cookie.match(name + '=(.*?)(;|$)');
    if (cookieValue)
    { retval = unescape(cookieValue[1]); }
    return retval;
}
function setCookie(name, value)
{
    var cookie_string = name + "=" + escape(value);
    var dateNow = new Date();
    var expires = new Date(dateNow.getFullYear(), dateNow.getMonth() + 1, dateNow.getDate());
    cookie_string += ";expires=" + expires.toGMTString();
    cookie_string += ";path=/";
    cookie_string += ";domain=" + urlRoot;
    document.cookie = cookie_string;
}
function deleteCookie(name)
{
    var dateNow = new Date();
    dateNow.setTime(dateNow.getTime() - 1);
    document.cookie = name += "=; expires=" + dateNow.toGMTString();
}
function clearForms()
{
    o("txtSearch").value = "";
    styleTBBlur(o("txtSearch"));
    o("txtAdvLocation").value = "";
    o("txtAdvKeyword").value = "";
    o("txtRefineKeyword").value = "";
    o("ddlAdvKeyword").selectedIndex = 0;
    o("ddlRefineKeyword").selectedIndex = 0;
    o("aSelAllTLDs").innerText = "Unselect All";
    selectAllTLDs();
    o("aSelAll").innerText = "Select All";
    o("chkUS").checked = false;
    o("chkWorld").checked = false;
}
function disableSelect(obj)
{
	obj.onselectstart = function() { return false; };
	obj.unselectable = "on";
	obj.style.MozUserSelect = "none";
}
