var url = "http://www.namecheap.com/"
var who = "Namecheap.com - $9.69 Domain name registration"

var ver = navigator.appName
var num = parseInt(navigator.appVersion)
function bookmark () {
	if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
		window.external.AddFavorite (url,who);
	}
	else {
		alert ('Please use your browsers bookmark feature. (Ctrl+D) in Netscape');
	}
	return (false);
}
function email (url) {
	return (openWindow(url, 'scrollbars=no,width=310,height=260,left=180,top=280'));
}
function showWhois(domainName) {
	var whoisurl
//	whoisurl = 'http://namecheap.getwhois.net?domainname=' + (domainName?domainName:'')
	whoisurl = domainName?'http://namecheap.getwhois.net?domain=' + domainName:'http://namecheap.getwhois.net' ;
	return (openWindow(whoisurl, 'scrollbars=yes,width=550,height=500'));
}

function showHelp(linktype, friendlyId) {
	url = 'http://namecheap.simplekb.com/kb.show';

	if (linktype != undefined) {
		url = url + '/' + linktype.substring (0,1);	// adds /a or /c or /t etc
		if (friendlyId != undefined) 
			url = url + '/' + friendlyId;
	}
	
	return (openWindow(url, 'width=700,height=500'));
}
//showHelpLink used for Context sensitive link article 
function showHelpLink(linktype, friendlyId, anchorId) {
	url = 'http://namecheap.simplekb.com/kb.show';

	if (linktype != undefined) {
		url = url + '/' + linktype.substring (0,1);	// adds /a or /c or /t etc
		if (friendlyId != undefined) 
			url = url + '/' + friendlyId;
			if (anchorId != undefined) 
				url = url + '#' + anchorId;
	}

	newWindow = window.open(url, "newWin");
	newWindow.focus();
	return false; 
	
}

function openWindow (url, heightWidth) {
	var newWindow;
	if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
		newWindow = window.open(url,"newWin", "toolbar=no,location=no,status=no,menubar=no,resizable=yes," + heightWidth);
		newWindow.focus();
		return (false);
	}
	else {
		newWindow = window.open(url, "newWin");
		newWindow.focus();
		return (false);
	}
}

//for hiding corner graphic if width is small so that user doesn't have problems clicking links
function getBrowserWidth(){
	if (window.innerWidth){return window.innerWidth;}  
	else if (document.documentElement && document.documentElement.clientWidth != 0){return document.documentElement.clientWidth;    }
	else if (document.body){return document.body.clientWidth;}      
	return 0;
}

//addEvent() by John Resig
function addEvent( obj, type, fn ){ 
   if (obj.addEventListener){ 
      obj.addEventListener( type, fn, false );
   }
   else if (obj.attachEvent){ 
      obj["e"+type+fn] = fn; 
      obj[type+fn] = function(){ obj["e"+type+fn]( window.event ); } 
      obj.attachEvent( "on"+type, obj[type+fn] ); 
   } 
} 


// function that will load a remote URL using script tag (instead of xmlhttprequest)
// Code obtained from: http://www.phpit.net/article/ajax-php-without-xmlhttprequest
function jsajax_do (pUrl) {
	// Create new JS element
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = pUrl;

	// Append JS element (therefore executing the 'AJAX' call)
	document.body.appendChild (jsel);

	return true;
}

//Run cornerShowResize function when page loads and when it resizes. This happens on all pages.
var winPathname = window.location.pathname.toLowerCase();
if (!(winPathname == '/myaccount/addfunds/paypal.asp' || winPathname == '/myaccount/process/complete.asp' || winPathname == '/myaccount/process/paymentbyfunds.asp' || winPathname == '/myaccount/process/payment.asp' || (( winPathname == '/myaccount/' || winPathname == '/myaccount/index.asp') && ver == "Microsoft Internet Explorer"))) {
	addEvent(window, 'load', loadTopCornerAd);
	addEvent(window, 'resize', cornerShowResize);
}
var topCornerAdDivName = 'topcornerpromodisplay';

function loadTopCornerAd () {
	var adGroupId;
	adDiv = document.getElementById(topCornerAdDivName);
	if (typeof (adDiv) != 'undefined') {
		adGroupId = 1; //Ad group to use
		jsajax_do ('/utils/getLink.asp?adgid=' + adGroupId + '&div=' + topCornerAdDivName);
	
		cornerShowResize ();
	}
}

function cornerShowResize(){
	var browserWidth = getBrowserWidth();
	var obj = document.getElementById(topCornerAdDivName);
	if (obj) {
	    if (browserWidth < 820){obj.style.display = "none";}
		else {obj.style.display = "block";}
	}
}

function cornerAdShow (bShow) {
	var obj = document.getElementById(topCornerAdDivName);
	if (obj) {
		if (bShow == true) {
			obj.style.display = "block";
		}
		else if (bShow == false) {
			obj.style.display = "none";
		}
	}
}