function isValidDomainName(a)
{
	var str = a;
	
	//alert("Domain Name :" + str );

	if(str == null || str == "")
	{
		alert("Domain name is not specified.");
		return false;
	}




	var dotIndex = str.indexOf(".", 0);
	
	if(dotIndex == -1)
	{
		//alert("A domain name must contain a '.'.");
		return false;
	}

	var spaces = str.indexOf(" ",0);
	if(spaces >= 0 && spaces <= str.length)
	{ 
		//alert("Spaces are not allowed.");
		return false;
	}

	if(isAlphaNumericDotOrDash(str) == false)
	{
		alert("A domain name name can only contain letters, numbers, dashes or dots.");
		return false;
	}

	// alert("DomainName is ok.");
	return true;
}


function isValidIP(a)
{
	var str = a;
	var aStrings = new Array(0);
	
	var iCtr = 0;
	var iStart = 0;
	var iEnd = str.indexOf(".",iStart)
	while(iEnd >= 0)
	{	
		var sTemp = str.substring(iStart, iEnd);
		if(sTemp != null && sTemp != "")
		{
			aStrings[iCtr++] = sTemp;
		}
		//iCtr = iCtr + 1;
		iStart = iEnd + 1;
		iEnd = str.indexOf(".",iStart);
		//alert(sTemp + " in while loop")
	}
	
	sTemp = str.substring(iStart, str.length);
	if(sTemp != null && sTemp != "")
		{
			aStrings[iCtr++] = sTemp;
		}
	//alert(sTemp)
	
	if(sTemp == null && sTemp == "")
	{
		//alert("sTemp is null");
		aStrings[iCtr++] = sTemp;
		return false;		
	}
	
	if(aStrings.length != 4)
	{
		//alert("aStrings.length != 4");
		return false;
	}

	for(i=0; i < aStrings.length; i++)
	{
		if((aStrings[i] < 0) || (aStrings[i] > 255))
		{
			alert(aStrings[i] + " is not between 0 and 255.");
			return false;			
		}
	}
	
	if(aStrings[0] == 0 || aStrings[0] == 255 || aStrings[0] == 224)
	{
		alert("The first number cannot be 0, 255, or 224.");
		return false;
	}
	else if(aStrings[0] == 127 && aStrings[1] == 0)
	{
		alert("The second number cannot be a 0 if the first is 127.");
		return false;
	}
	else if(aStrings[0] == 192 && aStrings[1] == 168 && aStrings[2] == 2)
	{
		alert("192.168.2." + aStrings[3] + " is not a valid IP address.");
		return false;
	}
	else if(aStrings[1] == 255 && aStrings[2] == 255 && aStrings[3] == 255)
	{
		alert(aStrings[0] + ".255.255.255 is not a valid IP address");
		return false;
	}
	return true;
}




/* isValidHostName(String) 
** Trevor Wencl 02/26/01
** 
**Rules: Cannot be null or have spaces, atleast one dot must be present, 
** first character must be a letter, and the rest must be Letter,Number,Dash or Dot
*/
function isValidHostName(a)
{
	var str = a;

	//alert("Hostname = " + str);

	if(str == null || str == "")
	{
		alert("Hostname is not specified.");
		return false;
	}

	//alert("firstChar = " + firstChar);
	//var firstChar = str.substring(0, 1);	
	//if(isAlpha(firstChar) == false)
	//{
	//	alert("The first character must be a letter.");
	//	return false;
	//}
	
	var dotIndex = str.indexOf(".", 0);
	if(dotIndex == -1)
	{
		alert("Hostname must contain a '.'.");
		return false;
	}

	var spaces = str.indexOf(" ",0);
	if(spaces >= 0 && spaces <= str.length)
	{ 
		alert("Spaces are not allowed.");
		return false;
	}

	if(isAlphaNumericDotOrDash(str) == false)
	{
		alert("A host name can only contain letters, numbers, dashes or dots.");
		return false;
	}

	// alert("Hostname is ok.");
	return true;
}


// popup() lets a hyperlink open content in a new "popup" window
// Includes focus() to ensure new window is on top
// Arguments: File to be opened, new window name, height, width, whether scrollbars are present
// Example: <A HREF="javascript:popup('/en_US/copy/folder/file.html','mywindow',300,350,'yes');">
// Mike Wooldridge, 2/16/2001
function popup(winFile,winName,winHeight,winWidth,winScroll) {
	newWin = window.open(winFile, winName, 'height=' + winHeight + ',width=' + winWidth + ',scrollbars=' + winScroll);
	newWin.focus();
}

// popuphelp() is a modified version of popup() above. Name, dimensions, and scrollbars are predefined.
// Arguments: File to be opened
// Example: <A HREF="javascript:popuphelp('/en_US/copy/folder/file.html');">
// Mike Wooldridge, 2/16/2001
function popuphelp(winFile) {
	newWin = window.open(winFile, 'popuphelp', 'height=300,width=450,scrollbars=yes');
	newWin.focus();
}

// openInParent() will open a document in the window that opened the current window (i.e., the window that spawned a current popup).
// Arguments: File to be opened
// Example: <A HREF="javascript:openInParent('/en_US/copy/folder/file.html');">
// Mike Wooldridge, 8/6/2002
function openInParent(winFile) {
	opener.document.location = winFile;
	opener.focus();
}

// calc() lets a hyperlink open a window to display the VDNS/IDNS calculator. Window has no decoration (scroll bars, buttons, etc.)
// Includes focus() to ensure new window is on top
// Arguments: File to be opened, new window name, height, width
// Example: <A HREF="javascript:calc('/en_US/copy/folder/file.html','mywindow',300,350);">
// Mike Wooldridge, 1/16/2003
function calc(winFile,winName,winHeight,winWidth) {
	newWin = window.open(winFile, winName, 'height=' + winHeight + ',width=' + winWidth + ',scrollbars=no');
	newWin.focus();
}

// purchase() opens VDNS/IDNS purchase path popup
// Includes focus() to ensure new window is on top
// Arguments: File to be opened, new window name, height, width
// Example: <A HREF="javascript:purchase('/en_US/copy/folder/file.html','mywindow',300,350);">
// Mike Wooldridge, 1/21/2003
function purchase(winFile,winName,winHeight,winWidth) {
	newWin = window.open(winFile, winName, 'height=' + winHeight + ',width=' + winWidth + ',toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes');
	newWin.focus();
}

// closeWindowOpenInParent() will open a document in the window that opened the current window and close the current window
// Arguments: File to be opened
// Example: <A HREF="javascript:closeWindowOpenInParent('/en_US/copy/folder/file.html');">
// Mike Wooldridge, 2/24/2002
function closeWindowOpenInParent(winFile) {
	opener.document.location = winFile;
	window.close()
	opener.focus();
}

function popupHosting(winFile,winName,winHeight,winWidth) {
	newWin = window.open(winFile, winName, 'height=' + winHeight + ',width=' + winWidth + ',scrollbars=1,resizable=1,toolbar=0');
	newWin.focus();
}

function popupHostingBuilder(winFile,winName,winHeight,winWidth) {
	newWin = window.open(winFile, winName, 'height=' + winHeight + ',width=' + winWidth + ',scrollbars=1,resizable=1,toolbar=1');
	newWin.focus();
}

function popupreg(winFile,winName,winHeight,winWidth) {
	newWin = window.open(winFile, winName, 'height=' + winHeight + ',width=' + winWidth + ',scrollbars=1,resizable=1,toolbar=1');
	newWin.focus();
}

function popup_discountdomains(winFile,winName,winHeight,winWidth,winScroll) {
	newWin = window.open(winFile, 'DiscountDomains', 'height=500,width=500,scrollbars=no');
	newWin.focus();
}
