var ns6=document.getElementById&&!document.all?1:0
var head="display:''"
var folder=''
String.prototype.trim = function(){
    return( this.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') );
}


function getBulkTranCharge(){

    var domainsarray= null;
    var domainstring = "";
    var total =0.0;

    domainstring = document.frm.domain.value.trim();
    domainsarray = domainstring.split("\n");
    for(i=0; i<domainsarray.length; i++) {
      domainsarray[i]=domainsarray[i].trim();
    }
    for(j=0; j < domainsarray.length; j++) {
       tmpdomain=domainsarray[j];
       if(tmpdomain.length > 0){
         domain = tmpdomain.split(".");
         if(domain.length != 2){
            alert("Domain is Invalid : " + tmpdomain);
            return false;
         }
         if(!ValidSLD(domain[0])){
            alert("Domain is Invalid : " + tmpdomain);
            return false;
         }
         if(!tranPrices[""+domain[1]+""]){
           alert("Invalid Domain:  "+tmpdomain);
           return false;
         }else{
            total += parseFloat(tranPrices[""+domain[1]+""]);
         }
         if(domain[1] == "org"){
            strURL = "orgnotice.jsp";
            window.open(strURL,'Test','width=850,height=400,scrollbars=1,statusbar=0,resizable=1,menubar=1,toolbar=0,location=0')
         }
       }
    }
	//Added to give discount if they have more than 24 domains
	//alert("VR_ID :" + document.frm.vr_id.value + " with flag :" + document.frm.vr_flag.value);

	//if((domainsarray.length > 24) && (document.frm.vr_id.value == 0) && (document.frm.vr_flag.value == 0)){
	if((domainsarray.length > 24) && (document.frm.Host.value == "dmt.aitdomains.com")){
		//total = parseFloat(domainsarray.length * 6.49);
		//total = parseFloat(domainsarray.length * 6.74);
		//total = parseFloat(domainsarray.length * 7.74);
		total = parseFloat(domainsarray.length * 9.28);
		//alert("total of more than 39 domains :" + total);
	}

    document.frm.amount.value='$'+(Math.round(total * 100) / 100);
    return true;
}

function checkBulkTransfer(){

    var domainsarray= null;
    var domainstring = "";

    domainstring = document.frm.domain.value.trim();
    domainsarray = domainstring.split("\n");
    for(i=0; i<domainsarray.length; i++) {
      domainsarray[i]=domainsarray[i].trim();
    }
    if(domainsarray.length < 1){
        alert("No Domains Entered");
        document.frm.domain.focus();
        return false;
    }
    else {
      for(j=0; j < domainsarray.length; j++) {
         domain=domainsarray[j].split(".");
         if(domain.length != 2){
           alert("Domain is Invalid : " + domainsarray[j]);
           document.frm.domain.focus();
           return false;
         }

         if(domain[0].length > 67){
           alert("Domain length is Invalid : " + domainsarray[j]);
           document.frm.domain.focus();
           return false;
         }
      }
    }
    return true;
}


function clearVal(dom){
	dom.value="";
	return true;
}
function PopUpWin(strURL, strTitle) {
    window.open(strURL,strTitle,'width=400,height=465,scrollbars=0,statusbar=0,resizable=0,menubar=1,toolbar=0,location=0')
}

function changeVisibility2(towhat) {
        if (towhat == "showit") {
            eval("P1.style.display=\"block\";");
        }else{
            eval("P1.style.display=\"none\";");
			document.frm.card_num.value="";
        }
}

function changeVisibility3(pid) {
	eval( "cur="+pid+".style.display;");
	
	if (cur=="none") {
		eval(pid+".style.display=\"block\";");
	}
	
	if(cur=="block") {
		eval(pid+".style.display=\"none\";");
	}
}

function changeVisibility(pid) {
	pids = pid+"S";
	pidimage = pid + "M";

	eval( "cur="+pid+".style.display;");
	
	if (cur=="none") {
		eval(pid+".style.display=\"block\";");
		eval("document.images[\""+pidimage+"\"].src = \"images/minus.gif\";");
	}
	
	if(cur=="block") {
		eval(pid+".style.display=\"none\";");
		eval("document.images[\""+pidimage+"\"].src = \"images/plus.gif\";");
	}
}
function reCalcIt(){
	tmpDomainList = dedupe_list(document.frm.domain.value)
	document.frm.domain.value = tmpDomainList;
    var n=0;
    DomainList = tmpDomainList.split("\r\n");
    for(var i=0;i<DomainList.length;i++){
        domain = DomainList[i].trim();
        if(domain.length > 0){
            domain = DomainList[i].split(".");
            if(domain[1] != "com" && domain[1] != "net"){
				alert('Domain ' + DomainList[i] + ' is invalid!');
                return false;
            }
            n++;
        }
    }
    var tmpTotal = n * 69;
    document.frm.nofdomains.value =  '' + n;
    document.frm.amount.value = '$' + (Math.round(tmpTotal * 100) / 100);
}

function checkAgree(){
        if(!document.frm.agreebox.checked){
                alert("You must check the agreement box to continue!");
                document.frm.agreebox.focus();
                return false;
        }
}

function reCalcItRenew(){ 
    tmpTotal = 0;
    for(i=0;i<document.frm.elements.length;i++){
      if(document.frm.elements[i].type=="checkbox"){
             if(document.frm.elements[i].checked && (document.frm.elements[i].name != "pymt")){
                    tmpArray = document.frm.elements[i].value.split(",");
                    var tmpNum = tmpArray[2];
                    var gPeriod = eval("document.frm.period"+tmpNum+".options[document.frm.period"+tmpNum+".selectedIndex].value");
                    domain = tmpArray[0].split(".");
                    tmpTotal += (parseFloat(regPrices[""+domain[1]+""]) * gPeriod);
              }
       }
    }
    document.frm.subTotal.value = '$' + (Math.round(tmpTotal * 100) / 100);
}

function reCalcItReg(){
    var tmpTotal = 0;
    var total_domains = 0;

    // first let's get the period
    var gPeriod = document.frm.gperiod.options[document.frm.gperiod.selectedIndex].value;

    // now we need to parse the domains
	tmpDomainList = dedupe_list(document.frm.domains.value)
    DomainList = tmpDomainList.split("\r\n");

    for(var i=0; i < DomainList.length; i++)
    {
		tmpdomain = DomainList[i].trim();
        if(tmpdomain.length > 0){
           domain = DomainList[i].split(".");
           if(domain.length != 2){
                alert("Domain is Invalid : " + DomainList[i]);
                return false;
            }	   
           if(!ValidSLD(domain[0])){
                alert("Domain is Invalid : " + DomainList[i]);
                return false;
           }
			if((domain[0].length) > 67){
                alert("Invalid Domain Length : " + domain[0] + "\nwhich is : " + domain[0].length + "characters long.");
                return false;
           	}
	   
           if(!regPrices[""+domain[1]+""]){
               alert("Invalid Domain:  "+tmpdomain);
               return false;
           }else{
                tmpTotal += parseFloat(regPrices[""+domain[1]+""]) * parseInt(gPeriod, 10);
           }
	   total_domains = total_domains + 1;
        }
    }


	//Added to give discount if more than 24 domains
	//if((total_domains > 39) && (document.frm.vr_id.value == 0) && (document.frm.vr_flag.value == 0)){
	//Ghana 8/1/2008
	//if((total_domains > 24) && (document.frm.vr_id.value == 0) && (document.frm.vr_flag.value == 0)){
	if((total_domains > 24) && (document.frm.Host.value == "dmt.aitdomains.com")){
		tmpTotal = 0;
		for(var j=0; j < total_domains; j++) {
			//tmpTotal += parseFloat(6.74 * parseInt(gPeriod, 10));
			//tmpTotal += parseFloat(7.74 * parseInt(gPeriod, 10));
			tmpTotal += parseFloat(9.28 * parseInt(gPeriod, 10));
		}
	}
	document.frm.domains.value = tmpDomainList;
    document.frm.nofdomains.value = total_domains; 
    document.frm.amount.value = '$' + (Math.round(tmpTotal * 100) / 100);
}
function checkUser(){
    if(document.frm.regchild.checked)        parent.location="reginfo.jsp?child=yes&child_handle="+document.frm.child_handle[document.frm.child_handle.selectedIndex].value;
    else
        parent.location="reginfo.jsp";
}

function checkChild(){
    if(document.frm.regchild.checked)
        checkUser();
}

function copyData(){
		document.frm.admFName.value = document.frm.orgFName.value;
		document.frm.admLName.value = document.frm.orgLName.value;
		document.frm.admMI.value = document.frm.orgMI.value;
		document.frm.admStreet1.value = document.frm.orgStreet1.value;
		document.frm.admStreet2.value = document.frm.orgStreet2.value;
		document.frm.admCity.value = document.frm.orgCity.value;
		document.frm.admState.value = document.frm.orgState.value;
		document.frm.admPost.value = document.frm.orgPost.value;
		document.frm.admPhone.value = document.frm.orgPhone.value;
		document.frm.admFax.value = document.frm.orgFax.value;
		document.frm.admEmail.value = document.frm.orgEmail.value;
        document.frm.admCountry.selectedIndex = document.frm.orgCountry.selectedIndex;
        
		document.frm.billFName.value = document.frm.orgFName.value;
		document.frm.billLName.value = document.frm.orgLName.value;
		document.frm.billMI.value = document.frm.orgMI.value;
		document.frm.billStreet1.value = document.frm.orgStreet1.value;
		document.frm.billStreet2.value = document.frm.orgStreet2.value;
		document.frm.billCity.value = document.frm.orgCity.value;
		document.frm.billState.value = document.frm.orgState.value;
		document.frm.billPost.value = document.frm.orgPost.value;
		document.frm.billPhone.value = document.frm.orgPhone.value;
		document.frm.billFax.value = document.frm.orgFax.value;
		document.frm.billEmail.value = document.frm.orgEmail.value;
	    document.frm.billCountry.selectedIndex = document.frm.orgCountry.selectedIndex;
    
		document.frm.techFName.value = document.frm.orgFName.value;
		document.frm.techLName.value = document.frm.orgLName.value;
		document.frm.techMI.value = document.frm.orgMI.value;
		document.frm.techStreet1.value = document.frm.orgStreet1.value;
		document.frm.techStreet2.value = document.frm.orgStreet2.value;
		document.frm.techCity.value = document.frm.orgCity.value;
		document.frm.techState.value = document.frm.orgState.value;
		document.frm.techPost.value = document.frm.orgPost.value;
		document.frm.techPhone.value = document.frm.orgPhone.value;
		document.frm.techFax.value = document.frm.orgFax.value;
		document.frm.techEmail.value = document.frm.orgEmail.value;
        document.frm.techCountry.selectedIndex = document.frm.orgCountry.selectedIndex;
	
}

function checkIt(frm){
        if(!document.frm.conf.checked)
        {
                alert("You must verify the nameserver is located in the United States");
                return false;
        }
 }
 function confirmDel(){
        var tmpStr="";
        var firstFlag = 0;
        for(i=0;i<document.frm.deleteNS.length;i++){
                if(document.frm.deleteNS[i].checked){
					var tmpArray = document.frm.deleteNS[i].value.split(",");
					if(firstFlag==0){
						var tmpStr = tmpArray[1];
						firstFlag = 1;
					}else{
						tmpStr = tmpStr + ", " + tmpArray[1];
					}
                }
        }
        if(tmpStr.length == 0)
			if(document.frm.deleteNS.value != "")
				tmpStr = document.frm.deleteNS.value;
        if(tmpStr.length == 0){
            alert("Please select a nameserver to delete");
            return false;
        }else{
            if(confirm("Are you sure you want to delete " + tmpStr + "?") == false)
                    return false;
        }
        return true;
 }
function printpage() {
        window.print();
}
function subtotalit(){
        tmpTotal = 0;
        for(i=0;i<document.frm.elements.length;i++){
          if(document.frm.elements[i].type=="checkbox"){
                 if(document.frm.elements[i].checked){
                        tmpArray = document.frm.elements[i].value.split(",");
                        tmpTotal += parseFloat(tmpArray[1]);
                 }
           }
        }
        document.frm.subtotal.value = '$' + (Math.round(tmpTotal * 100) / 100);
}
function checkDomain(){
		var dmn;
		var domains = null;
		var filter= new RegExp("^((?:[\\w-]+\.)*\\w[\\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$", "i");
		var str;
		var onechar = "";

		dmn = checkit.domain.value;
		str = dmn;

        if(dmn.length < 2 ){
                alert('You must enter a domain name to check for!');
                return false;
        }

		if(dmn.indexOf('.') == -1)
		{
            alert('DOT is missing in  your domain field, You must enter a domain name to check for!');
			return false;
		}

		  for (var n = 0; n < dmn.length; n++) {
			  onechar = dmn.substring(n, n+1);
			  if ((onechar < "0" || onechar > "9") && (onechar < "A" || onechar > "Z") && (onechar < "a" || onechar > "z") && (onechar != "-") && (onechar != ".")) { 
            	  alert('Invalid characters in your domain field, You must enter a domain name to check for!');
				  return false; 
			  }
		 }
		
		if (filter.test(str))
				return true;
		else{
			alert("Invalid domain name entered, please enter a fully qualified domain name to check for!");
			return false;
		}

		domains = dmn.split(".");

		if(!ValidSLD(domains[0])){
			alert("Domain is Invalid : " + dmn);
			return false;
		}
		if(!ValidTLD(domains[1]) && domains[1].length > 1){
			alert("We do not support the following Domain extension : " + dmn);
			return false;
		}
		return true;

}
function checkDisable(){
        if(document.frm.action[1].checked == true){
                document.frm.gperiod.disabled = true;
        }else {
                document.frm.gperiod.disabled = false;
        }
}

function checksearchRadio(field) {
    document.frm.search[field].checked = true;
}
function checkchildRegButton(cbox, field) {
    box = eval(cbox);
alert("See this" + box);
    uncheckOthers(field);
    box.checked = !box.checked;
    checkRegDisable();
}
function checkRegDisable(){
    if(!document.frm.childReg[0].checked)
	document.frm.child_handle.disabled=true;
    else
	document.frm.child_handle.disabled=false;
}
function checkChildRadio(field) {
    document.frm.Child[field].checked = true;
}
function checkactionRadio(field) {
    document.frm.action[field].checked = true;
        checkDisable();
}
function checksearchFieldRadio(field) {
    document.frm.searchField[field].checked = true;
}
function checkBox(cbox) {
    box = eval(cbox);
    box.checked = !box.checked;
}

function checkformatRadio(field) {
    document.frm.format[field].checked = true;
}

function checkDomainReportForm(){
	if(verifyRptType() == false){
		alert("You must enter atleast one report type to generate!");
		return false;
	}	
	if(verifyCheckbox() == false){
		alert("You must enter atleast one tld type for report generation");
		return false;
	}
	//if(checkReport() == false)
	//	return false;		
	return true;
}

function verifyRptType(){
	if(frm.renewals.checked)
		return true;
    if(frm.registrations.checked)
        return true;
    if(frm.transfers.checked)
        return true;
    //if(frm.monitors.checked)
        //return true;
    //if(frm.backorders.checked)
        //return true;
    if(frm.synchronizations.checked)
        return true;
	return false;
}

function verifyCheckbox(){
	if(frm.com.checked)
		return true;
    if(frm.net.checked)
        return true;
    if(frm.org.checked)
        return true;
    if(frm.info.checked)
        return true;
    if(frm.biz.checked)
        return true;
    if(frm.us.checked)
        return true;
	return false;
}

function checkconfirmRadio(field){
    document.frm.confirm[field].checked = true;
}

function expandit(curobj, pidimage){
    folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style
    if (folder.display=="none"){
        folder.display="";
        eval("document.images[\""+pidimage+"\"].src = \"images/minus.gif\";");
    }else{
        folder.display="none";
        eval("document.images[\""+pidimage+"\"].src = \"images/plus.gif\";");
    }
}

function showinfo(curobj){
    folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style
    if (folder.display=="none"){
        folder.display="";
        document.frm.pymt.checked = false;
    }else{
        folder.display="none";
        document.frm.pymt.checked = true;
		document.frm.card_num.value="";
    }
}

function showcontacts(curobj){
    folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style
    if (folder.display=="none"){
        folder.display="";
        document.frm.info.checked = false;
    }else{
        folder.display="none";
        document.frm.info.checked = true;
    }
}

function dedupe_list(tmpDomainList)
{
	var count = 0;
	var mainlist = tmpDomainList;
	mainlist = mainlist.replace(/\r/gi, "\n");
	mainlist = mainlist.replace(/\n+/gi, "\n");
	
	var listvalues = new Array();
	var newlist = new Array();
	
	listvalues = mainlist.split("\n");
	
	var hash = new Object();
	
	for (var i=0; i<listvalues.length; i++)
	{
		if (hash[listvalues[i].toLowerCase()] != 1)
		{
			newlist = newlist.concat(listvalues[i]);
			
			hash[listvalues[i].toLowerCase()] = 1
		}
		else { count++; }
	}
	return(newlist.join("\r\n"));
}

function checkregdomain(){
	tmpDomainList = dedupe_list(document.frm.domains.value)
    DomainList = tmpDomainList.split("\r\n");
	
    for(var i=0; i < DomainList.length; i++)
    {
		domain = DomainList[i].split(".");
		
	    if(!ValidSLD(domain[0])){
            alert("Domain is Invalid : " + DomainList[i]);
            return false;
        }
	    if(!ValidTLD(domain[1]) && domain[1].length > 1){
            alert("We do not support the following Domain extension : " + DomainList[i]);
            return false;
        }      
   	}
	return true;
}

function ValidTLD(TLD)
{
    //var TLDS = new Array("us","com","net","org","biz","info");

    for(i=0; i < TLDS.length; i++){
        if(TLD == TLDS[i]){
            return true;
		}
    }
    return false;
}

function ValidSRSTLD(TLD)
{
    var TLDS = new Array("com","net");

    for(i=0; i < TLDS.length; i++){
        if(TLD == TLDS[i]){
            return true;
		}
    }
    return false;
} 

function ValidSLD(SLD)
{
    var array = new Array("\\",",","'","~","`","!","@","#","$","%","^","&","*","(",")","_","+","=","{","}","|","]","[",";",":","<",">","?", " ");

    for(var i=0; i < array.length; i++)
    {
        if(SLD.indexOf(array[i]) != -1)
        {
			return false;
        }
    }
    return true;
}

function ValidatePhone(p){
	varName = p.name;
	//pVal = p.value;
	var pVal = p.value.replace(/[\(\)\.\-\ ]/g, '');
	var newVal ="";
	if (isNaN(pVal) == true){
		alert("Phone Number is Invalid -- Enter digits only!");
		eval("document.frm."+varName+".focus()");
		eval("document.frm."+varName+".select()");
		return false;
	}
	
	for(i=0;i<pVal.length;i++){
		if(i==0)
			newVal = "(";
		if(i==3)
			newVal += ")";
		if(i==6)
			newVal += "-";
		newVal += pVal.charAt(i);
	}
		eval("document.frm."+varName+".value='"+newVal+"'");
		return true;

}

function checkemail(tmpStr){
	var str = tmpStr.value;
	var filter= new RegExp("^([\\w-]+(?:\.[\\w-]+)*)@((?:[\\w-]+\.)*\\w[\\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$", "i");
	if(str.length > 1){
		if (filter.test(str))
			return true;
		else{
			alert("Invalid Email Address!");
			eval("document.frm."+tmpStr.name+".focus();");
			eval("document.frm."+tmpStr.name+".select();");
			return false;
		}
	}else{
		return true;
	}
}


function LTrim(str){
   var whitespace = new String(" \t\n\r");
   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}

function RTrim(str){
   var whitespace = new String(" \t\n\r");
   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1; 
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }

   return s;
}

function Trim(str){
   return RTrim(LTrim(str));
}
function checkDate(myDateStr, myMonthStr) {
	var myDate = new Date( myDateStr );
	var myDate_string = myDate.toGMTString();
	var myDate_array = myDate_string.split( ' ' );
	if (myDate_array[2] == myMonthStr) 
		return true;
	return false;
} 

function compareDate(begDateStr, endDateStr) {
	var begDate = new Date( begDateStr );
	var endDate = new Date( endDateStr );
	var begDate_string = begDate.toGMTString();
	var endDate_string = endDate.toGMTString();
	if(Date.UTC(begDate) <= Date.UTC(endDate)){
		return true
	}
	return false;
}

function checkReport(){
	var begmonth = document.frm.begmonth.value;
	var endmonth = document.frm.endmonth.value;
	var begDateStr = document.frm.begday.value + ' ' + document.frm.begmonth.value + ' ' + document.frm.begyear.value;
	var endDateStr = document.frm.endday.value + ' ' + document.frm.endmonth.value + ' ' + document.frm.endyear.value;

	if(checkDate(begDateStr, begmonth) == false){
		alert("Beginning date is invalid!");
		return false;
	}else if(checkDate(endDateStr, endmonth) == false){
		alert("Ending date is invalid!");
		return false;
	}else if(compareDate(begDateStr, endDateStr) == false){
		alert("Beginning date must be before ending date!");
		return false;
	}	
}

function checkSignup(){
	var user = Trim(document.frm.username.value);
	if(user == ""){
		alert("You must enter a username!");
		document.frm.username.focus();
		return false;
	}
	if(user.length < 6 || user.length > 25){
		alert("Username must be between 6 and 25 characters!");
		document.frm.username.focus();
		return false;
	}
	if(username  == "aitdomainsvr"){
		alert("You can not use that username!");
		document.frm.username.focus();
		return false;

	}
	if(checkPass() == false)
		return false;
		
	if(document.frm.question.value == "" || document.frm.question.length > 40){
		alert("You must enter a question of less than 40 characters!");
		document.frm.question.focus();
		return false;
	}
	if(document.frm.answer.value == "" || document.frm.answer.length > 30){
		alert("You must enter an answer less than 30 characters!");
		document.frm.answer.focus();
		return false;
	}
	
	if(checkContact() == false)
		return false;
	else 
		return checkAgree();
}

function checkPass(){
	var pass1 = document.frm.password1.value;
	var pass2 = document.frm.password2.value;
	if(pass1 == ""){
		alert("You must enter a password!");
		document.frm.password1.focus();
		return false;
	}
	if(pass1.length < 7 || pass1.length > 15){
		alert("Password must be between 7 and 15 characters!");
		document.frm.password1.focus();
		return false;
	}
	if(pass2 == ""){
		alert("Please confirm password!");
		document.frm.password2.focus();
		return false;
	}
	if(pass1 != pass2){
		alert("Please check confirmation password!");
		document.frm.password2.focus();
		return false;
	}
	return true;
}
function checkContact(){
	if(document.frm.orgFName.value == ""){
		alert("You must enter organizational contact's first name!");
		document.frm.orgFName.focus();
		return false;
	}
	if(document.frm.orgLName.value == ""){
		alert("You must enter the organizational contact's last name!");
		document.frm.orgLName.focus();
		return false;
	}	
	if(document.frm.orgStreet1.value == ""){
		alert("You must enter organizational contact's street address!");
		document.frm.orgStreet1.focus();
		return false;
	}
	if(document.frm.orgCity.value == ""){
		alert("You must enter organizational contact's city!");
		document.frm.orgCity.focus();
		return false;
	}	
	if(document.frm.orgState.value == ""){
		alert("You must enter organizational contact's state!");
		document.frm.orgState.focus();
		return false;
	}	
	if(document.frm.orgPost.value == ""){
		alert("You must enter organizational contact's zip code!");
		document.frm.orgPost.focus();
		return false;
	}
	if(ValidatePhone(document.frm.orgPhone) == false)
		return false;

	if(ValidatePhone(document.frm.orgFax) == false)
		return false;		
	
	if(checkemail(document.frm.orgEmail) == false)
		return false;
	
	// if the admin contact info is different from org, validate the data
	// We need 2 different checks because the Netscape page is displayed different from the ie interface
	if(document.frm.info.checked == false || !document.frm.info[0].checked){
		if(document.frm.admFName.value == ""){
			alert("You must enter admin contact's first name!");
			document.frm.admFName.focus();
			return false;
		}
		if(document.frm.admLName.value == ""){
			alert("You must enter the admin contact's last name!");
			document.frm.admLName.focus();
			return false;
		}
		if(document.frm.admStreet1.value == ""){
			alert("You must enter admin contact's street address!");
			document.frm.admStreet1.focus();
			return false;
		}		
		if(document.frm.admCity.value == ""){
			alert("You must enter admin contact's city!");
			document.frm.admCity.focus();
			return false;
		}	
		if(document.frm.admState.value == ""){
			alert("You must enter admin contact's state!");
			document.frm.admState.focus();
			return false;
		}	
		if(document.frm.admPost.value == ""){
			alert("You must enter admin contact's zip code!");
			document.frm.admPost.focus();
			return false;
		}	
		if(ValidatePhone(document.frm.admPhone) == false)
			return false;
	
		if(ValidatePhone(document.frm.admFax) == false)
			return false;		
		
		if(checkemail(document.frm.admEmail) == false)
			return false;
			
		if(document.frm.billFName.value == ""){
			alert("You must enter billing contact's first name!");
			document.frm.billFName.focus();
			return false;
		}
		if(document.frm.billLName.value == ""){
			alert("You must enter the billing contact's last name!");
			document.frm.billLName.focus();
			return false;
		}
		if(document.frm.billStreet1.value == ""){
			alert("You must enter billing contact's street address!");
			document.frm.billStreet1.focus();
			return false;
		}		
		if(document.frm.billCity.value == ""){
			alert("You must enter billing contact's city!");
			document.frm.billCity.focus();
			return false;
		}	
		if(document.frm.billState.value == ""){
			alert("You must enter billing contact's state!");
			document.frm.billState.focus();
			return false;
		}	
		if(document.frm.billPost.value == ""){
			alert("You must enter billing contact's zip code!");
			document.frm.billPost.focus();
			return false;
		}	
		if(ValidatePhone(document.frm.billPhone) == false)
			return false;
	
		if(ValidatePhone(document.frm.billFax) == false)
			return false;		
		
		if(checkemail(document.frm.billEmail) == false)
			return false;
		
		if(document.frm.techFName.value == ""){
			alert("You must enter technical contact's first name!");
			document.frm.techFName.focus();
			return false;
		}
		if(document.frm.techLName.value == ""){
			alert("You must enter the technical contact's last name!");
			document.frm.techLName.focus();
			return false;
		}
		if(document.frm.techStreet1.value == ""){
			alert("You must enter technical contact's street address!");
			document.frm.techStreet1.focus();
			return false;
		}		
		if(document.frm.techCity.value == ""){
			alert("You must enter technical contact's city!");
			document.frm.techCity.focus();
			return false;
		}	
		if(document.frm.techState.value == ""){
			alert("You must enter technical contact's state!");
			document.frm.techState.focus();
			return false;
		}	
		if(document.frm.techPost.value == ""){
			alert("You must enter technical contact's zip code!");
			document.frm.techPost.focus();
			return false;
		}	
		if(ValidatePhone(document.frm.techPhone) == false)
			return false;
	
		if(ValidatePhone(document.frm.techFax) == false)
			return false;		
		
		if(checkemail(document.frm.techEmail) == false)
			return false;		
	}else{
		document.frm.admFName.value = document.frm.orgFName.value;
		document.frm.admLName.value = document.frm.orgLName.value;
		document.frm.admMI.value = document.frm.orgMI.value;
		document.frm.admStreet1.value = document.frm.orgStreet1.value;
		document.frm.admStreet2.value = document.frm.orgStreet2.value;
		document.frm.admCity.value = document.frm.orgCity.value;
		document.frm.admState.value = document.frm.orgState.value;
		document.frm.admPost.value = document.frm.orgPost.value;
		document.frm.admPhone.value = document.frm.orgPhone.value;
		document.frm.admFax.value = document.frm.orgFax.value;
		document.frm.admEmail.value = document.frm.orgEmail.value;

		document.frm.billFName.value = document.frm.orgFName.value;
		document.frm.billLName.value = document.frm.orgLName.value;
		document.frm.billMI.value = document.frm.orgMI.value;
		document.frm.billStreet1.value = document.frm.orgStreet1.value;
		document.frm.billStreet2.value = document.frm.orgStreet2.value;
		document.frm.billCity.value = document.frm.orgCity.value;
		document.frm.billState.value = document.frm.orgState.value;
		document.frm.billPost.value = document.frm.orgPost.value;
		document.frm.billPhone.value = document.frm.orgPhone.value;
		document.frm.billFax.value = document.frm.orgFax.value;
		document.frm.billEmail.value = document.frm.orgEmail.value;
	
		document.frm.techFName.value = document.frm.orgFName.value;
		document.frm.techLName.value = document.frm.orgLName.value;
		document.frm.techMI.value = document.frm.orgMI.value;
		document.frm.techStreet1.value = document.frm.orgStreet1.value;
		document.frm.techStreet2.value = document.frm.orgStreet2.value;
		document.frm.techCity.value = document.frm.orgCity.value;
		document.frm.techState.value = document.frm.orgState.value;
		document.frm.techPost.value = document.frm.orgPost.value;
		document.frm.techPhone.value = document.frm.orgPhone.value;
		document.frm.techFax.value = document.frm.orgFax.value;
		document.frm.techEmail.value = document.frm.orgEmail.value;
		
	}
	return true;
}

function copyDataHere(from,to)
{
        to.value = from.value;
}


function checkHostname(){
	if(( document.frm.hostname.value.length < 3 ) || (document.frm.hostname.value.length > 78 )){
            alert("Hostname field length can not be less than 3 and more than 95 characters including .nameservices.net.!");
            document.frm.hostname.focus();
            return false;
    }

    hostname = document.frm.hostname.value;
    if(!ValidSLD(hostname)){
            alert("HostName is Invalid : " + hostname);
            return false;
    }
}

function checkPay(){
        if(document.frm.card_num.value == ""){
                alert("Card Number is required!");
                document.frm.card_num.focus();
                return false;
        }
        /*if(document.frm.sec_code.value == ""){
                alert("CVV2 Code is required!");
                document.frm.sec_code.focus();
                return false;
        } */
        if(document.frm.card_name.value == ""){
                alert("Cardholder name is required!");
                document.frm.card_name.focus();
                return false;
        }
        if(document.frm.bill_street.value == ""){
                alert("Billing street is required!");
                document.frm.bill_street.focus();
                return false;
        }
        if(document.frm.bill_city.value == ""){
                alert("Billing city is required!");
                document.frm.bill_city.focus();
                return false;
        }
        if(document.frm.bill_state.value == ""){
                alert("Billing state is required!");
                document.frm.bill_state.focus();
                return false;
        }
        if(document.frm.bill_zip.value == ""){
                alert("Billing zip is required!");
                document.frm.bill_zip.focus();
                return false;
        }
	return true;
}

function checkRenewal(){
	if(document.frm.subTotal.value=="$0.00"){
		alert('You must select at least one domain to renew!');
		return false;
	}
        if(document.frm.pymt){
                if(document.frm.pymt.checked == false || !document.frm.pymt[0].checked){
                        return checkPay();
                }
        }else{
                return checkPay();
        }        
	return true;
}

function checkTransfer(){
        domain = document.frm.domain.value.split(".");
        if(domain.length != 2){
            alert("Domain is Invalid : " + document.frm.domain.value);
            document.frm.domain.focus();
            return false;
        }	    
        if(!ValidTLD(domain[1])){
            alert("Domain is Invalid : " + document.frm.domain.value);
            document.frm.domain.focus();
            return false;
       }        
       if(!ValidSLD(domain[0])){
            alert("Domain is Invalid : " + document.frm.domain.value);
            document.frm.domain.focus();
            return false;
       }    

		if(domain[0].length > 67){
            alert("Domain length is Invalid : " + document.frm.domain.value.length +" characters long.");
            document.frm.domain.focus();
            return false;
       }

        if(document.frm.pymt){
                if(document.frm.pymt.checked == false || !document.frm.pymt[0].checked){
                        return checkPay();
                }
        }else{
                return checkPay();
        }        
	return true;
}

function checkMonitor(){
	if(document.frm.amount.value=="$0.00"){
		alert('You must enter atleast one domain name!');
		return false;
	}
	if(reCalcIt() == false)
		return false;
        if(document.frm.pymt){
                if(document.frm.pymt.checked == false || !document.frm.pymt[0].checked){
                        return checkPay();
                }
        }else{
                return checkPay();
        }        
	return true;
}

function checkNServer(){
	if( document.regfrm.host_name.value.length < 5 ){
                alert("Nameserver name is Invalid or Invalid length!");
                document.regfrm.host_name.focus();
                return false;
        } else {
                nameservername = Trim(document.regfrm.host_name.value);
				if((nameservername.toLowerCase().indexOf(".ait.") > -1) || (nameservername.toLowerCase().indexOf(".aitcom.") > -1) || (nameservername.toLowerCase().indexOf(".aitdomains.") > -1)) {
					alert("Nameserver name is invalid.");
					document.regfrm.host_name.focus();
					return false;
				}
                nsname = nameservername.split(".");

                if((nsname[nsname.length -1].toUpperCase() == "COM") || (nsname[nsname.length -1].toUpperCase() == "NET") || (nsname[nsname.length -1].toUpperCase() == "US") || (nsname[nsname.length -1].toUpperCase() == "INFO") || (nsname[nsname.length -1].toUpperCase() == "BIZ") || (nsname[nsname.length -1].toUpperCase() == "ORG")){
                }else{
                        alert("Invalid Nameserver extension!");
                        document.regfrm.host_name.focus();
                        return false;

                }
                if(((nsname[nsname.length -1].toUpperCase() == "COM") || (nsname[nsname.length -1].toUpperCase()== "NET")) && (nameservername.length > 79 )){
                alert("Invalid Nameserver length for .com/.net domain name : " + nameservername.length + " characters long.");
                document.regfrm.host_name.focus();
                return false;
                }
                if(((nsname[nsname.length -1].toUpperCase() == "INFO") || (nsname[nsname.length -1].toUpperCase()== "ORG") || (nsname[nsname.length -1].toUpperCase() == "US") || (nsname[nsname.length -1].toUpperCase()== "BIZ")) && (nameservername.length > 133 )){
                alert("Invalid Nameserver length for .us/.org/.info/.biz domain name : " + nameservername.length + " characters long.");
                document.regfrm.host_name.focus();
                return false;
                }

        }

	if(document.regfrm.host_ip1.value==""){
		alert("Nameserver IP is required!");
		document.regfrm.host_ip1.focus();
		return false;
	}
	
	if(validateIP(document.regfrm.host_ip1.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip1.focus();
		return false;
	}
	if(document.regfrm.host_ip2.value != "" && validateIP(document.regfrm.host_ip2.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip2.focus();
		return false;
	}
	if(document.regfrm.host_ip3.value != "" && validateIP(document.regfrm.host_ip3.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip3.focus();
		return false;
	}
	if(document.regfrm.host_ip4.value != "" && validateIP(document.regfrm.host_ip4.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip4.focus();
		return false;
	}	
	if(document.regfrm.host_ip5.value != "" && validateIP(document.regfrm.host_ip5.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip5.focus();
		return false;
	}	
	if(document.regfrm.host_ip6.value != "" && validateIP(document.regfrm.host_ip6.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip6.focus();
		return false;
	}			
	if(document.regfrm.host_ip7.value != "" && validateIP(document.regfrm.host_ip7.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip7.focus();
		return false;
	}	
	if(document.regfrm.host_ip8.value != "" && validateIP(document.regfrm.host_ip8.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip8.focus();
		return false;
	}	
	if(document.regfrm.host_ip9.value != "" && validateIP(document.regfrm.host_ip9.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip9.focus();
		return false;
	}	
	if(document.regfrm.host_ip10.value != "" && validateIP(document.regfrm.host_ip10.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip10.focus();
		return false;
	}	
	if(document.regfrm.host_ip11.value != "" && validateIP(document.regfrm.host_ip11.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip11.focus();
		return false;
	}	
	if(document.regfrm.host_ip12.value != "" && validateIP(document.regfrm.host_ip12.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip12.focus();
		return false;
	}	
	if(document.regfrm.host_ip13.value != "" && validateIP(document.regfrm.host_ip13.value) == false){
		alert("Invalid IP address");
		document.regfrm.host_ip13.focus();
		return false;
	}				
	return true;
}

function validateIP(what) {
	var validChars = '.0123456789';
    if (!what)
        return false;

    dots = 0;

    for (var i = 0; i < what.length; i++) {
       var chr = what.substring(i,i+1);
       if (validChars.indexOf(chr) == -1)
           return false;
       if (chr == '.') {
           dots++;
           eval('dot' + dots + ' = ' + i);
       }
    }

    if (dots != 3)
        return false;
    
    if (what.substring(0,1) == '.' || what.substring(what.length,what.length+1) == '.')
        return false;

    ip1 = what.substring(0,dot1);
    if (!ip1 || ip1 >255)
        return false;
    ip2 = what.substring(dot1+1,dot2);
    if (!ip2 || ip2 >255)
        return false;
    ip3 = what.substring(dot2+1,dot3);
    if (!ip3 || ip3 >255)
        return false;
    ip4 = what.substring(dot3+1,what.length+1);
    if (!ip4 || ip4 >255)
        return false;

    if (ip1 == 0 && ip2 == 0 && ip3 == 0 && ip4 == 0)
        return false;

    return true;
}

function checkSearch(){
	if(document.frm.searchfor.value==""){
		alert("Please enter a value to search for!");
		document.frm.searchfor.focus();
		return false;
	}
	return true;
}

function checkConfirm(){
	if(document.frm.confcode.value == ""){
		alert("Confirmation Code is required");
		document.frm.confcode.focus();
		return false;
	}
	/*var tmpdomain = document.frm.domain[document.frm.domain.selectedIndex].value;
	var tmpArray = tmpdomain.split(".");

	if(tmpArray[1] != "com" && tmpArray[1] != "net"){
		if(document.frm.authinfo.value == ""){
			alert("Authorization Info is required");
			document.frm.authinfo.focus();
			return false;	
		}
	}*/
	return true;
}

function checkChangePass(){
    if(document.frm.oldpass){
	    var tmpOldpass = document.frm.oldpass.focus();
	    if(tmpOldpass==""){
		    alert("Please enter your current password!");
		    document.frm.oldpass.focus();
		    return false;
	    }
    }
		
	if(checkPass() == false)
		return false;
		
	if(tmpOldpass == document.frm.password1.value){
		alert("You haven't specified a new password!");
		document.frm.password1.focus();
		return false;
	}
	return true;
}

function checkTicket(){
	if(document.frm.domain.value == ""){
		alert("Domain Name is required");
		document.frm.domain.focus();
		return false;
	}
	
	domain = document.frm.domain.value.split(".");
	if(domain.length != 2){
		alert("Invalid Domain " + document.frm.domain.value);
		document.frm.domain.focus();
		return false;
	}
	if(!ValidSLD(domain[0])){
		alert("Invalid Domain " + document.frm.domain.value);
		document.frm.domain.focus();
		return false;
	}
	if(!ValidTLD(domain[1]) && domain[1].length > 1){
		alert("Invalid Domain " + document.frm.domain.value);
		document.frm.domain.focus();
		return false;
	} 
	if(Trim(document.frm.ticketBody.value) == ""){
		alert("Please enter a problem!");
		document.frm.ticketBody.focus();
		return false;
	} 
	if(ValidatePhone(document.frm.phone) == false)
		return false;

	if(checkemail(document.frm.email) == false)
		return false;	
	return true;	
}

function checkTicketID(){
	if(document.frm.ticketid.value == ""){
		alert("Please enter a ticket id!");
		document.frm.ticketid.focus();
		return false;
	}
	if(isNaN(document.frm.ticketid.value)){
		alert("Ticket ID must be numeric!");
		document.frm.ticketid.focus();
		return false;
	}	
	return true;
}

function checkRates(){
	var bo_checked = 0;
	var mon_checked = 0;
	// we will loop through and make sure all rates are entered into the form.  
	// we need to check and make sure it is not a checkbox for the backorder and monitoring
	for(i=0;i<document.forms[1].elements.length;i++){
		if(document.forms[1].elements[i].type == "text"){
			tmpName = document.forms[1].elements[i].name;
			if(document.forms[1].elements[i].value=="" &&
				tmpName != "combo" && tmpName != "netbo" && tmpName != "common" && tmpName != "netmon"){
					alert("You must enter all rates!");
					document.forms[1].elements[i].focus();
					return false;
				//}
			}
			if(isNaN(document.forms[1].elements[i].value)){
				alert("Invalid Rate!");
				document.forms[1].elements[i].focus();
				document.forms[1].elements[i].select();
				return false;		
			}
		}
		// This will check to see if the checkbox has been checked
		if(document.forms[1].elements[i].type == "checkbox"){
			if(document.forms[1].elements[i].checked == true){
				if(document.forms[1].elements[i].name == "monitor"){
					mon_checked = 1;
					if(document.frm.common.value == "" || isNaN(document.frm.common.value)){
						alert("Please enter a valid common rate!");
						document.frm.common.focus();
						document.frm.common.select();
						return false;
					}
					if(document.frm.netmon.value == "" || isNaN(document.frm.netmon.value)){
						alert("Please enter a valid netmon rate!");
						document.frm.netmon.focus();
						document.frm.netmon.select();
						return false;
					}					
				}else{
					bo_checked = 1;
					if(document.frm.combo.value == "" || isNaN(document.frm.combo.value)){
						alert("Please enter a valid combo rate!");
						document.frm.combo.focus();
						document.frm.combo.select();
						return false;
					}
					if(document.frm.netbo.value == "" || isNaN(document.frm.netbo.value)){
						alert("Please enter a valid netbo rate!");
						document.frm.netbo.focus();
						document.frm.netbo.select();
						return false;
					}				
				}
					
			}
			return true;
		}
	}
}

function checkCode(){
	if(document.frm.confcode.value == ""){
		alert("Please enter the confirmation code!");
		document.frm.confcode.focus();
		return false;
	}
		
}

function checkVREmail(){
	if(checkemail(document.frm.fromaddr) == false)
		return false;

	/*if(Trim(document.frm.signature.value=="")){
		alert("Please enter a mail signature!");
		document.frm.signature.focus();
		return false;
	}*/
	return true;
}

function checkEmailList(){
    var flag = 0;
	if(document.frm.org_email.checked)
        flag=1;
    else if(document.frm.adm_email.checked)
        flag=1;
    else if(document.frm.tech_email.checked)
        flag=1;
    else if(document.frm.bill_email.checked)
        flag=1;
        
    if(flag==1)
        return true;
    else{
	    alert("Please select atleast one email type!");
	    return false;
    }
}

function checkPayInfo(){
    if(document.frm.pymt){
            if(document.frm.pymt.checked == true)
                return confirm('Are you sure you want to remove your payment information?');
            else{
                if(document.frm.pymt){
                        if(document.frm.pymt.checked == false || !document.frm.pymt[0].checked)
                                return checkPay();
                else
                        return checkPay();
                }   
            }
    }else
            return checkPay();
}

function checkList(){
    if(!document.frm.domain.checked){
        for(i=0;i<document.frm.domain.length;i++){
            if(document.frm.domain[i].checked || document.frm.domain.checked)
                return true;
        }
    }else
        return true;
	alert('Please select a domain to modify!');
	return false;
}

function checkRegDomainPayNS(){
        if(document.frm.pymt){
                if(document.frm.pymt.checked == false || !document.frm.pymt[0].checked){
                        if(checkPay() == false)
                                return false;
                }
        }else{
                if(checkPay() == false)
                        return false;
        }        
        return true;
}
function uncheckOthers(tmpNum){
    document.frm.childReg[tmpNum].checked=false;
}

function verifyVRSettings(){
    if(checkRates() == false)
        return false;
    else
		if(checkPay() == false)
			return false;
		else
			return checkHostname();
}

function checkRates(){
    
}

var submitcount=0;   

function checkSubmit() 
{     

    if (submitcount == 0){ 
        submitcount++; return true; 
    }else { 
       alert('Request has already been submitted!' ); 
       return false; 
    } 
}

function getNewRates(){
    parent.location="aitvrates.jsp?virtualreg="+document.frm.virtualreg[document.frm.virtualreg.selectedIndex].value;
}

function loadRegDomain(){
    frm.domains.select();
    frm.domains.focus();
    reCalcItReg();
    checkRegDisable();
}

function checkSubscribeRadio(field) {
    document.frm.subscribe[field].checked = true;
}

function checkRadio(field) {
    eval(field+".checked = true");
}

function recalcSynch(){ 
    var tmpTotal = 0;
    var tmpMonths = 0;

    for(i=0;i<document.frm.elements.length;i++){
      if(document.frm.elements[i].type=="checkbox"){
         if(document.frm.elements[i].checked && (document.frm.elements[i].name != "pymt")){
            tmpArray = document.frm.elements[i].value.split(",");
            var rate = tmpArray[2];
            var fee = tmpArray[3];
            tmpMonths = getMonthsToCharge(tmpArray[4]);
            tmpTotal += ((parseFloat(tmpArray[2]) * parseInt(tmpMonths)) + parseFloat(tmpArray[3]));
          }
       }
    }
    document.frm.amount.value = '$' + (Math.round(tmpTotal * 100) / 100);
}

function getMonthsToCharge(expDate){
    var monthSel = parseInt(document.frm.month.value);
    var daySel = parseInt(document.frm.day.value);
    expArray = expDate.split("/");
    var expMonth = parseInt(expArray[0]);
    var expDay = parseInt(expArray[1]);
    var months = 0;

    if(monthSel > expMonth)   // if anniversary month Larger than current expiration month
        months = monthSel - expMonth;
    else if(monthSel < expMonth)  // if anniversary month Less than current expiration month
        months = monthSel + 12 - expMonth;
    else  // They are same, we have to compare their day
    {
        if(daySel > expDay)
            months = 1;
        else if(daySel < expDay)
            months = 11;
    }
    return(months);
}

function getTranCharge(){
	tmpdomain = document.frm.domain.value.trim();
    if(tmpdomain.length > 0){
       domain = tmpdomain.split(".");
       if(domain.length != 2){
            alert("Domain is Invalid : " + tmpdomain);
            return false;
        }	   
       if(!ValidSLD(domain[0])){
            alert("Domain is Invalid : " + tmpdomain);
            return false;
       }	   
       if(!tranPrices[""+domain[1]+""]){
           alert("Invalid Domain:  "+tmpdomain);
           return false;
       }else{
            total = parseFloat(tranPrices[""+domain[1]+""]);
       }
       document.frm.amount.value='$'+(Math.round(total * 100) / 100);
	   if(domain[1] == "org"){
			strURL = "orgnotice.jsp";
			window.open(strURL,'Test','width=850,height=400,scrollbars=1,statusbar=0,resizable=1,menubar=1,toolbar=0,location=0')
	   }
    }
}

function checkVReg(){
	if(document.frm.vreg.value.trim() == ""){
		alert('Please enter the Virtual Registrar you would like to activate');
		document.frm.vreg.focus();
		return false;
	}
	return true;
}

function checkTrans_id(){
	if(document.frm.trans_id.value.trim() == ""){
		alert('Please enter the transaction ID!');
		document.frm.trans_id.focus();
		return false;
	}
	return true;
}

function checkCreate_pymt(){
	if(document.frm.traceNum.value.trim() == ""){
		alert('Please enter the Trace Number!');
		document.frm.traceNum.focus();
		return false;
	}
	if(document.frm.virtualreg.selectedIndex == 0){
		alert('Please enter the Virtual Registrar!');
		return false;
	}
	if(document.frm.amount.value.trim() == ""){
		alert('Please enter the Payment Amount!');
		document.frm.amount.focus();
		return false;
	}
	return true;
}

function checkAITRates(){
    for(i=0;i<document.frm.elements.length;i++){
      if(document.frm.elements[i].type=="text"){
         if(document.frm.elements[i].value.trim() == ""){
            alert('Please enter a value!');
            document.frm.elements[i].focus();
            return false;
          }
       }
    }
    return true;
}
function showtip(current,e,text)
{
        if (document.all)
        {
                thetitle=text.split('<br>')
                if (thetitle.length > 1)
                {
                thetitles=""
                for (i=0; i>thetitle.length; i++)
                thetitles += thetitle[i] + "\r\n"
                current.title = thetitles
                }else 
                        current.title = text
        }else if (document.layers){
                document.tooltip.document.write(
                   '<layer bgColor="#FFFFE7" style="border:1px ' +
                        'solid black; font-size:12px;color:#000000;">' + text + 
                        '</layer>')
        document.tooltip.document.close()
        document.tooltip.left=e.pageX+5
        document.tooltip.top=e.pageY+5
        document.tooltip.visibility="show"
        }
                
}
function hidetip()
{
        if (document.layers)
                document.tooltip.visibility="hidden"
}
function validForm(frm)
{
    var tmp = radioval(frm.cat_purp);
    if(tmp=="-1")
    {
            alert("You must select a category");
            return false;
    }
        
    if(frm.cat_purp[tmp].value=="C21")
    {
            if((frm.entity_type.value=="other") && (frm.entText.value == ""))
            {
                    alert("You must enter entity type if you select other");
                    frm.entText.focus();
                    return false;
            }
                        
            if(frm.jurisdiction.value=="")
            {
                    alert("You must enter Jurisdiction if you select US Company");
                    frm.jurisdiction.focus();
                    return false;
            }
    }
                

    if(frm.cat_purp[tmp].value=="C31" || frm.cat_purp[tmp].value=="C32")
    {
                        
            if((!frm.qualifier1.checked) && (!frm.qualifier2.checked) && (!frm.qualifier3.checked) && (!frm.qualifier4.checked))
            {
                    alert("You must select the basis for your .us Domain Application");
                    return false;
            }
    }
    return true;
}
function radioval(obj) {
	var flag = -1
	for (var k = 0; k < obj.length; k++) {
    if (obj[k].checked) {
        flag = k
        }
    }
	return flag
}

function getLowerVal(field){
	field.value = field.value.toLowerCase();
}

function checkExpDate(tmpDate){
	var d1 = new Date(tmpDate);
	var d2 = new Date();
	d2.getDate();
	if(d2 >= d1){
		alert("The Domain you selected for auto-renew has already expired! Expired domains can not be auto-renewed.");
		return false;
	}
	return true;
}
