// ikg - general functions and stuff...

// create a popup window 
function popup(url,windowname,width,height) {
   width=(width)?width:screen.width/3;
   height=(height)?height:screen.height/3;
   
   var screenX = (screen.width/2 - width/2);
   var screenY = (screen.height/2 - height/2);

   var features= "width=" + width + ",height=" + height + ",scrollbars=yes";
   features += ",screenX=" + screenX + ",left=" + screenX;
   features += ",screenY=" + screenY  +",top=" + screenY;
   
   windowname = windowname.replace(" " , "_");

   var mywin=window.open(url, windowname, features);
   if (mywin) 
   	mywin.focus();
   
   return mywin;
}

// when the customer does a check for a domain's availability, this re-directs straight to the product options if
// they already own it and are pointing their nameserver records at Inklude
function checkAlreadyOwned() {
   if ((document.getElementById("istransfer")) && (document.getElementById("alreadyowned")) && (document.getElementById("form_whois"))) {
   	// customer owns the domain
   	if ((document.getElementById("alreadyowned").checked) || (document.getElementById("istransfer").checked)) {
   		// submit the form to the main product index instead
   		document.getElementById("action").value = "register";
   		document.getElementById("form_whois").action = "tag4_purchases.php";
   	}
   } 
   
   return true;
}

// record the last zindex, to keep new windows appearing above each other
var zIndexLast = 200;

// show help text on the accounts page
function showHelp(e, id, pushLeft, pushTop) {

	// first of all, get the mouse position
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	
	if (e.pageX || e.pageY)	{
		posx = e.pageX;
		posy = e.pageY;
	} else if (e.clientX || e.clientY) {
		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;
	}
	
	// if the adjustment values aren't present, set them to zero
	if (! pushLeft) {
		var pushLeft = 0;
	}
	if (! pushTop) {
		var pushTop = 0;
	}
	
	// show the help box
	if (document.getElementById("help" + id)) {
		// move it into place
		document.getElementById("help" + id).style.display = "block";
		document.getElementById("help" + id).style.left = posx - document.getElementById("help" + id).clientWidth + pushLeft;
		document.getElementById("help" + id).style.top = posy + pushTop;
		
		// move it to the front
		zIndexLast++;
		document.getElementById("help" + id).style.zIndex = zIndexLast;
	}
	
}

// close help box
function closeHelp(id) {
	// show the help box
	if (document.getElementById("help" + id)) {
		// move it into place
		document.getElementById("help" + id).style.display = "none";
	}
}
