function redirect(where) {
    switch (where) {
        case 1: //world
            window.location = '/products/world.aspx';
            break;
        case 2: //continent
            window.location = '/products/continent.aspx';
            break;
        case 3: //country
            window.location = '/products/country_alpha.aspx';
            break;
        case 4: //maps of the us
            window.location = '/products/usa.aspx';
            break;
        case 5: //regional maps
            window.location = '/products/regional.aspx';
            break;
        case 6: //state maps
            window.location = '/products/state.aspx';
            break;
        case 7: //country maps
            window.location = '/products/county.aspx';
            break;
        case 8: //city maps
            window.location = '/products/city.aspx';
            break;
        case 9: //metro maps
            window.location = '/products/metro.aspx';
            break;
    };
}


function openStyle(page) {
    window.open(page, "StyleAdvisor", "width=770,height=600,toolbar=0,menubar=0,location=0,scrollbars=1,resizable=0");
}

function Start2(page) {
    OpenWin = this.open(page, "mapsales_preview", "width=720,height=750,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
}
function Start(page) {
    OpenWin = this.open(page, "mapsales_preview", "width=620,height=650,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
}

var win = null;
function NewWindow(mypage, myname, w, h, scroll, pos) {
    if (pos == "random") { LeftPosition = (screen.width) ? Math.floor(Math.random() * (screen.width - w)) : 100; TopPosition = (screen.height) ? Math.floor(Math.random() * ((screen.height - h) - 75)) : 100; }
    if (pos == "center") { LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition = (screen.height) ? (screen.height - h) / 2 : 100; }
    else if ((pos != "center" && pos != "random") || pos == null) { LeftPosition = 0; TopPosition = 20 }
    settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    win = window.open(mypage, myname, settings);
}



function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + value +
	        ((expires) ? "; expires=" + expires.toGMTString() : "") +
 	       ((path) ? "; path=" + path : "") +
	        ((domain) ? "; domain=" + domain : "") +
	        ((secure) ? "; secure" : "");
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
 	           ((path) ? "; path=" + path : "") +
 	           ((domain) ? "; domain=" + domain : "") +
	            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


function decimal(dec) {
    this.dec = dec;
    this.toBinary = function() { return this.dec.toString(2); }
    this.toHex = function() { return this.dec.toString(16).toUpperCase(); }
    this.toOctal = function() { return this.dec.toString(8); }
}

function checkCookie(refurl) {

    var compare = getCookie('CurrentTestID');
    var compareOld = getCookie('PreviousTestID');

    if (compare != null || compareOld != null) {
        var pageID = getCookie('CurrentPageID');
        var expir = new Date("December 31, 2024");
        var rExp = /\&/g;
        var PageServed = getCookie(compare);
        var PageTested = getCookie('PageTested');
        var SessID = getCookie('SessionID');
        PageTested = PageTested.replace(rExp, "|");
        var PageRefer = getCookie('TestRef');

        var WebUserID = getCookie('WebID');

        var url = location.href.replace(rExp, "|");

        url = url.replace("index.aspx", "");

    }
}


function writeImage() {
    var today = new Date();
    var temp = today.getTime();
    var expiry = new Date("December 31, 2024");
    var hexId = new decimal(temp).toHex();
    var idValue = getCookie("WebID");
    var websrc = getCookie("MSsource");
    var webkwd = getCookie("MSkeyword");
    var website = "MS";
    var url = document.URL;
    var url = window.location.href;

    var refurl = document.referrer;
    //var refurl = "http://www.mapatlasworld.com/result.php?Lfzxpset>Xpsme,Nbqt'f>vt<DB<79<2<2<21982:21<tuzmf2`dvtupn/dtt<3<joufsdptnpt`bggjmjbuf`6`e3s`efsq<tpooz2<tpooz2<33636<42146<dmfbo<<0e0tfbsdi0q0joufsdptnpt0ynm0epnbjomboefs0joum0e3s0gfg0qpqdbu0w30<enynm/joufsdptnpt/pwfsuvsf/dpn'c>cXGxZYStZYO4c4Kt[D6kc31>'qpt>7'tfbsdi`uzqf>sfmbufe'enybsht>17pFOzb5[HKcMVDbyUVNf1nwXx83lxmG3qWs9bGJmYEuJ5Rwd98pJNcU{EvJs1MMZ6SLQ8f:NCRuboQfcuQb7dQKw3KHnYOZOuQJwc83Q3SSYUDvLx{8SPWNpLdYb9NnpT64bXkKmvyuuS9Fs:T9BkQl[dEeEkcGnQ.DKi9RibSRSb97.bH3jKkk1Om:R.mk8RB6O:vqOpwuPqVN1Qxx//-ZU1{&flagVar=yes&websrc=overture3&webkwd=world_maps";
    refurl = escape(refurl);

    refurl = refurl.replace(/\%3C/g, "_").replace(/\%3E/g, "_").replace(/\%7C/g, "|");
    refurl = refurl.replace(/\%3A/g, ":").replace(/\%3F/g, "?").replace(/\%3D/g, "=").replace(/\%26/g, "&");

    if (refurl == '') {
        refurl = 'undefined';
    }
    var flagVar = "no";
    var rExp = /\&/g;
    var url2 = url.replace(rExp, "|").replace(/ /g, "+").replace("#", "_");

    var refurl2 = refurl.replace(rExp, "|").replace("#", "_");


    refurl2 = refurl2.replace("%3a", ":");
    hexId = hexId.toString();

    if (idValue) {
        flagVar = "yes";
    }


    document.write("<img src=\"http://www.mapsales.com/newimage.aspx?website=" + website + "&idValue=" + idValue + "&url=" + url2 + "&refurl=" + refurl2 + "&flagVar=" + flagVar + "&websrc=" + websrc + "&webkwd=" + webkwd + "\">")

}
writeImage();