function openBDPopunders()
{
  if (need_openbd){
    // open it
    popW = 850;
    popH = 525;
    str = "width=" + popW + ",height=" + popH + ",scrollbars,toolbar,resizable,location,menubar,top=0,screenY=0,left=0,screenX=0";

    var url='http://www.buydomains.com/?domain=' + thisDomain + '&pop=false&utm_source=Pops&utm_medium=click&utm_campaign=Pops';
    var x = window.open(url,'pop_buydomains',str);

    // popunder
    x.blur();
  }
  need_openbd = 0;
}

function openANPopunders()
{
    if (need_openan){
        // open it
        popW = 837;
        popH = 572;
        str = "width=" + popW + ",height=" + popH + ",scrollbars,toolbar,resizable,location,menubar,top=0,screenY=0,left=0,screenX=0";

        var url='http://www.afternic.com/name.php?domain=' + thisDomain + '&ref_name=' + thisDomain + '&popup=1';
        var x = window.open(url,'pop_afternic',str);

        // popunder
        x.blur();
    }
    need_openan = 0;
}

function openMelbournePopunders()
{
    if (need_open_melbourne){
        // open it
        popW = 837;
        popH = 572;
        str = "width=" + popW + ",height=" + popH + ",scrollbars,toolbar,resizable,location,menubar,top=0,screenY=0,left=0,screenX=0";

        var url='http://www.melbourneit.com.au/cc/domainname/index';
        var x = window.open(url,'pop_melbourne',str);

        // popunder
        x.blur();
    }
    need_open_melbourne = 0;
}

function openRelatedPopunder(urlHost)
{
        // open it
        popW = 495;
        popH = 485;
        str = "width=" + popW + ",height=" + popH + ",toolbar=0, location=0, directories=0, status=0, menubar=0, marginwidth=0, marginheight=0,scrollbars=0, resizable=0,top=0,screenY=0,left=0,screenX=0";
        var url='http://' + urlHost + '?forceTemplate=Mini_Related';
        var x = window.open(url,'pop_related',str);

        // popunder
        if (x) x.blur(); 
}

function openCustomPopunders(url)
{
    var popWidth = 500;
    var popHeight = 500;
    var str = "width=" + popWidth + ",height=" + popHeight;

    var customPopWindow = window.open(url, '', 'width=500, height=500, toolbar=0, location=0, status=0, resizable');

    // popunder
    customPopWindow.blur();

}

function openIGNPopunders(){
  if (need_openign1){
    openIGNPop1(ignUrl1);
    need_openign1=0;
  }
  if (need_openign2){
    // broken: case 3220
    //openIGNPop2(ignUrl2);
      need_openign2=0;
    }
}

function handleOnUnload(){
  openIGNPopunders();
  openBDPopunders();
}

function openIGNPop1(url)
{
    var x = window.open(url,"iGuide1","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=490,height=545,left=10,top=10,marginwidth=0,marginheight=0");
    if (x) x.blur();
    window.focus();
}

function openIGNPop2(url)
{
  var intWidth = 720;
  var intHeight = 300;

  // to center pop-under, use xTop & yTop
  // var xTop = screen.width/2 - (intWidth/2);
  // var yTop = screen.height/2 - (intHeight/2);
  // to push to bottom right corner
  var xTop = screen.width - (intWidth + 20);
  var yTop = screen.height - (intHeight + 90);
  var y = window.open(url,"iGuide2","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=" + intWidth + ",height=" + intHeight + ",left=" + xTop + ",top=" + yTop + ",marginwidth=0,marginheight=0");

  if (y) y.blur();
  window.focus();
}

function cookieVal(cookieName) {
    thisCookie = document.cookie.split("; ");

    for (i=0 ; i < thisCookie.length ; i++) {
        if (cookieName == thisCookie[i].split("=")[0]) {
            return thisCookie[i].split("=")[1]
        }
    }
    return ""
}

// Check the user's computer to see if can use bookmark function (only IE on PCs)
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

// pulls in domain name, and if there's any HTML that goes before or after the link, such as a <br /> tag
function addBookmark(domain, displayName, prefix, suffix) {
	if (checkIt('msie') && checkIt('win')) {
		document.write(prefix + "<a class=\"footerLink\" href=\"javascript:void window.external.AddFavorite('http://" + domain + "', '" + escape(displayName) + "')\">Bookmark This Page</a>" + suffix);
	}	
}