var ext = "";
var isoky = false;
var clkps=1;
var suguname1="";
var suguname2="";

function AddDash(obj) {
 var tmpV=obj.value;
 var tmpN=obj.name;
 if (tmpV.length == 3 && tmpV.charCodeAt(tmpV.length) != 45 && tmpV.charCodeAt(tmpV.length - 1) != 45)
 {
   obj.value = tmpV+"-";
 }
 if (tmpV.length == 7 && tmpV.charCodeAt(tmpV.length) != 45 && tmpV.charCodeAt(tmpV.length - 1) != 45)
 {
   obj.value = tmpV+"-";
 }
};

function upperCaseFirst(obj) {
 var tmpV=obj.value;
 var tmpN=obj.name;
 if (tmpV.length == 1)
 {
   tmpV=tmpV.toUpperCase();
   obj.value = tmpV;
 }
};

function GetSuggest(obj) {
   document.getElementById('username').value = suguname1+suguname2;
};
function SuggestuName1(obj) {
 var tmpV=obj.value;
 var tmpN=obj.name;
 if (tmpV.length == 1)
 {
   suguname1 = tmpV.toLowerCase();
 }
};
function SuggestuName2(obj) {
 var tmpV=obj.value;
 var tmpN=obj.name;
   suguname2 = tmpV.toLowerCase();
};
function maketitle (title) {
document.title="AffordHost Inc. - "+title;
	stitle_id = document.getElementById('spantitle');
	stitle_child = stitle_id.firstChild;
    		if (stitle_child) { 
			stitle_id.removeChild(stitle_child);
		}
		stitle_value = document.createTextNode(title);
stitle_id.appendChild(stitle_value);
}
function maketitle2 (title) {
document.title="AffordHost Inc. - "+title;
	stitle_id = document.getElementById('spantitle2');
	stitle_child = stitle_id.firstChild;
    		if (stitle_child) { 
			stitle_id.removeChild(stitle_child);
		}
		stitle_value = document.createTextNode(title);
stitle_id.appendChild(stitle_value);
}

function runclock () {
	clock_id = document.getElementById('clock');
	clock_child = clock_id.firstChild;
    		if (clock_child) { 
			clock_id.removeChild(clock_child);
		}
	if (clkps==1) {
		clock_value = document.createTextNode("|");
	}
	if (clkps==2) {
		clock_value = document.createTextNode("/");
	}

	if (clkps==3) {
		clock_value = document.createTextNode("-");
	}

	if (clkps==4) {
		clock_value = document.createTextNode("\\");
	}

	if (clkps==5) {
		clock_value = document.createTextNode("|");
	}
	if (clkps==6) {
		clock_value = document.createTextNode("/");
	}
	if (clkps==7) {
		clock_value = document.createTextNode("-");
	}
	if (clkps==8) {
		clock_value = document.createTextNode("\\");
		clkps=0;
	}
clkps++;
clock_id.appendChild(clock_value);
timerID=setTimeout("runclock();",1000);
}
function check_ext () {
	if (ext == "com" || ext == "COM") isoky=true;
        if (ext == "net" || ext == "NET") isoky=true;
        if (ext == "org" || ext == "ORG") isoky=true;
        if (ext == "ca" || ext == "CA") isoky=true;
        if (ext == "biz" || ext == "BIZ") isoky=true;
        if (ext == "us" || ext == "US") isoky=true;
        if (ext == "name" || ext == "NAME") isoky=true;
        if (ext == "info" || ext == "INFO") isoky=true;
        if (ext == "mobi" || ext == "MOBI") isoky=true;
        if (ext == "be" || ext == "BE") isoky=true;
        if (ext == "de" || ext == "DE") isoky=true;
        if (ext == "dk" || ext == "DK") isoky=true;
        if (ext == "eu" || ext == "EU") isoky=true;
        if (ext == "es" || ext == "ES") isoky=true;
        if (ext == "fr" || ext == "FR") isoky=true;
        if (ext == "it" || ext == "IT") isoky=true;
        if (ext == "nl" || ext == "NL") isoky=true;
        if (ext == "uk" || ext == "UK") isoky=true;
        if (ext == "at" || ext == "AT") isoky=true;
        if (ext == "cc" || ext == "CC") isoky=true;
        if (ext == "cn" || ext == "CN") isoky=true;
        if (ext == "tv" || ext == "TV") isoky=true;
        if (ext == "ch" || ext == "CH") isoky=true;
        if (isoky == false) ext="";
}
function checkforvals (obj) {
	for (var i =0; i < obj.length; i++)    {
			var tmpV = obj[i].value;
			var tmpN = obj[i].name;
		if (tmpN == "Phone" && tmpV.length >0 )	{
			for (var ii =0; ii < tmpV.length; ii++)    {
   				var c = tmpV.charCodeAt(ii); 
				//dashes && numbers only
				if ( (c > 57 || c < 48) && c != 45)        
				{
					alert("Allowed text for this field\ndigits 0-9\nPlease Re-enter");
					obj[i].focus();
					return false;
				}
			}
		}
		if (tmpN == "Phone" && tmpV.length < 12 ){
			alert("Please Complete The Phone Number With Area Code");
			obj[i].focus();
			return false;
		}
		if (tmpV.length == 0 && tmpN !="Phone" && tmpN != "register_domain" && tmpN != "Address_Suite" && tmpN != "Prov/state" && tmpN != "Extras_Space" && tmpN != "extra_redirect" && tmpN != "extra_Stats" && tmpN != "extra_email" && tmpN != "Notes" && tmpN != "agreement" && tmpN != "Package" && tmpN != "domain_agree")	 {
			alert("This field must be filled out.\nPlease Complete");
			obj[i].focus();
			return false;
		}
	}
		var tmpV = obj["Domain_name"].value;
		var tmpN = obj["Domain_name"].name;
		ext = "";
		isoky = false;
		if (tmpN == "Domain_name") {
			for (i=tmpV.length;i> 1;i--) {
                		var b = tmpV.charAt(i);
				if (b == ".") {
                			for (f=i+1;f< tmpV.length;f++) {
						ext=ext+tmpV.charAt(f);
                        		}
					check_ext ();
				}
        		}
        		if (isoky == false) {
                	alert ("Invalid domain name (Example: affordhost.com).\n If unsure of extension check the pricing chart");
                	return false;
        		}
	}
	if (obj["passwd"].value != obj["confpass"].value)	{
		alert ("Please Confirm Password/Password not match Password Confirm");
		return false;
	}
	if (obj["register_domain"].checked)	{
		if (obj["domain_agree"].checked==false)	{
		alert("Please confirm that you have read the registration agreement");
		obj["agreement"].focus;
		return false;
		}
	}
	if (obj["agreement"].checked)	{
		return true;
	}
	else	{
		alert("Please confirm that you have read the above agreement and that you agree to all the above");
		obj["agreement"].focus;
		return false;
	}
} 
function checkfordomvals (obj) {
		var tmpV = obj["domain"].value;
		var tmpN = obj["domain"].name;
		ext = "";
		isoky = false;
		if (tmpN == "domain") {
			for (i=tmpV.length;i> 1;i--) {
                		var b = tmpV.charAt(i);
				if (b == ".") {
                			for (f=i+1;f< tmpV.length;f++) {
						ext=ext+tmpV.charAt(f);
                        		}
					check_ext ();
				}
        		}
        		if (isoky == false) {
                	alert ("Invalid domain name (Example: affordhost.com).\n");
                	return false;
        		}
			else {
			return true;
			}
		}
} 
function checkfordomvals2 (obj) {
		var tmpV = obj["domain"].value;
		var tmpN = obj["domain"].name;
		ext = "";
		isoky = false;
		if (tmpN == "domain") {
			for (i=tmpV.length;i> 1;i--) {
                		var b = tmpV.charAt(i);
				if (b == ".") {
                			for (f=i+1;f< tmpV.length;f++) {
						ext=ext+tmpV.charAt(f);
                        		}
					check_ext ();
				}
        		}
        		if (isoky == true) {
                	alert ("Invalid domain search, please do not enter a TLD  (the letters after the dot)\n (Example: affordhost).\n");
                	return false;
        		}
			else {
			return true;
			}
		}
} 
function Openprice(url)  {
helpWin = window.open('domainreg.html','','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=300,height=380,screenX=10,screenY=10,Left=10,Top=10');
  helpWin.focus();
};
function Openlic(url)  {
helpWin = window.open('License-agreement.pdf','','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=550,screenX=10,screenY=10,Left=10,Top=10');
  helpWin.focus();
};
function checksupvals (obj) {
	for (var i =0; i < obj.length; i++)    {
			var tmpV = obj[i].value;
			var tmpN = obj[i].name;
		if (tmpN == "Phone")	{
			for (var ii =0; ii < tmpV.length; ii++)    {
   				var c = tmpV.charCodeAt(ii); 
				//dashes && numbers only
				if ( (c > 57 || c < 48) && c != 45)        
				{
					alert("Allowed text for this field\ndigits 0-9\nPlease Re-enter");
					obj[i].focus();
					return false;
				}
			}
		}
		if (tmpV.length == 0 && tmpN !="Phone" && tmpN !="Domain_name")	 {
			alert("This field must be filled out.\nPlease Complete");
			obj[i].focus();
			return false;
		}
	}
		var tmpV = obj["Domain_name"].value;
		var tmpN = obj["Domain_name"].name;
		ext = "";
		isoky = false;
		if (tmpN == "Domain_name") {
			for (i=tmpV.length;i> 1;i--) {
                		var b = tmpV.charAt(i);
				if (b == ".") {
                			for (f=i+1;f< tmpV.length;f++) {
						ext=ext+tmpV.charAt(f);
                        		}
					check_ext ();
				}
        		}
        		if (isoky == false) {
                	alert ("Invalid domain name (Example: affordhost.com).\n If unsure of extension check the pricing chart");
                	return false;
        		}
	}
return true;
} 
function Opentld(url)  {
helpWin = window.open('tld.html','','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=300,height=380,screenX=10,screenY=10,Left=10,Top=10');
  helpWin.focus();
};
function Openprice(url)  {
helpWin = window.open('domainreg.html','','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=300,height=380,screenX=10,screenY=10,Left=10,Top=10');
  helpWin.focus();
};
function Openlic(url)  {
helpWin = window.open('License-agreement.pdf','','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=550,screenX=10,screenY=10,Left=10,Top=10');
  helpWin.focus();
};

