var win=null;

function whoisDetails (w, h, scroll, pos)
{
	// Show window for "whois" details with given w and h plus pos of random, center or fixed (not center or random)
	// Give window a name: "whoisWindow"
	
	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("about:blank", "whoisWindow", settings);
}

function validateDomain(strDom)
{
	if(strDom.value == "")
	{
		alert("Please enter a value in the domain name box");
		strDom.focus();
		return false;
	}
	if(strDom.value.length < 3)
	{
		alert("Please enter at least 3 characters in the domain name box.");
		strDom.focus();
		return false;
	}
	if(strDom.value.length > 63)
	{
		alert("Please enter at most 63 characters in the domain name box.");
		strDom.focus();
		return false;
	}

	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789--.";
	var checkStr = strDom.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if(ch == checkOK.charAt(j))
				break;
		
		if(j == checkOK.length)
		{
			allValid = false;
			break;
		}
	}
  	if(checkStr.charAt(0)=="-"||checkStr.charAt(checkStr.length-1)=="-")
  	{
    		allValid = false;
  	}
  	if(!allValid)
  	{
    		alert("Please enter only letters, digits and \"-\" characters in the domain name box.\n\nRemembering that domains cannot begin or end with \"-\"");
    		strDom.focus();
    		return false;
  	}
  	return true;
}
