<script language='javascript'>
<!--

var bolReadyToRegister=false;
function ToggleRegisterOption(disabled,checked){
    obj = $('regoptionid1');
    obj.disabled=disabled;
    if (checked){
        obj.checked=true;
    } else {
        obj.checked=false;
    }
}

function ToggleTransferOption(disabled,checked){
    obj = $('regoptionid2');
    obj.disabled=disabled;
    obj.checked=checked;
}

function ToggleSelfManagement(disabled,checked){
    obj = $('regoptionid3');
    obj.disabled=disabled;
    obj.checked=checked;
}

function resetActions(disabled, checked){
    bolReadyToRegister = checked;
    <!-- BEGIN DYNAMIC BLOCK: allowreg -->
    ToggleRegisterOption(disabled, checked);
    <!-- END DYNAMIC BLOCK: allowreg -->
    <!-- BEGIN DYNAMIC BLOCK: allowtransfer -->
    ToggleTransferOption(disabled, checked);
    <!-- END DYNAMIC BLOCK: allowtransfer -->
    <!-- BEGIN DYNAMIC BLOCK: allowselfmanage -->
    ToggleSelfManagement(disabled, checked);
    <!-- END DYNAMIC BLOCK: allowselfmanage -->
}

function DomainCheckReturn(strReturnValue){

    aOptionPairs = strReturnValue.responseText.split('|');
    $('domainsearch').style.display='none';
    switch(aOptionPairs[0]){
        case '-1' :
        innerHTML ='<font class=error>[l]Warning[/l]:</font><br>[l]Domain Name[/l] <b>\''+aOptionPairs[1]+'\'</b> [l]already has an account with us. If you are a current customer please submit a support ticket for assistance.[/l].<p>';
        $('domainwindow').innerHTML = innerHTML;
        $('domainwindow_main').style.display='';
        <!-- BEGIN DYNAMIC BLOCK: allowreg1 -->
        ToggleRegisterOption(true,false);
        <!-- END DYNAMIC BLOCK: allowreg1 -->
        <!-- BEGIN DYNAMIC BLOCK: allowtransfer1 -->
        ToggleTransferOption(true,false);
        <!-- END DYNAMIC BLOCK: allowtransfer1 -->
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage1 -->
        ToggleSelfManagement(true,false);
        <!-- END DYNAMIC BLOCK: allowselfmanage1 -->
        bolReadyToRegister=false;
        break;
        case '0' :
        innerHTML ='<font class=warning>[l]Congratulations[/l]</font><br>[l]The Domain[/l] <b>'+aOptionPairs[1]+'</b> [l]is available[/l].<br><br><p>';
        $('domainwindow').innerHTML = innerHTML;
        $('domainwindow_main').style.display='';
        document.forms['checkdomain'].domain.value=aOptionPairs[1];
        <!-- BEGIN DYNAMIC BLOCK: allowreg2 -->
        ToggleRegisterOption(false,true);
        bolReadyToRegister=true;
        <!-- END DYNAMIC BLOCK: allowreg2 -->
        <!-- BEGIN DYNAMIC BLOCK: allowtransfer2 -->
        ToggleTransferOption(true,false);
        bolReadyToRegister=true;
        <!-- END DYNAMIC BLOCK: allowtransfer2 -->
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage2 -->
        ToggleSelfManagement(false,false);
        bolReadyToRegister=true;
        <!-- END DYNAMIC BLOCK: allowselfmanage2 -->
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage2b -->
        ToggleSelfManagement(false,true);
        bolReadyToRegister=true;
        <!-- END DYNAMIC BLOCK: allowselfmanage2b -->
        break;
        case '1' :
        innerHTML ='<font class=error>[l]Domain Is Already Registered[/l]</font><br>[l]According to registrar records, the domain[/l] <b>'+aOptionPairs[1]+'</b> [l]is already registered.[/l] ';
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanagetransfer -->
        innerHTML +='[l]If you own this domain please choose the[/l] ';
        <!-- BEGIN DYNAMIC BLOCK: allowtransfer3 -->
        innerHTML +='<b>[l]Transfer[/l]</b> ';
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage3 -->
        innerHTML +='[l]or[/l] <b>[l]Self-Management (no cost)[/l]</b> ';
        <!-- END DYNAMIC BLOCK: allowselfmanage3 -->
        <!-- END DYNAMIC BLOCK: allowtransfer3 -->
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage4 -->
        innerHTML +='<b>[l]Self-Management (no cost)[/l]</b> ';
        <!-- END DYNAMIC BLOCK: allowselfmanage4 -->
        innerHTML +='[l]option on the right.[/l]';
        <!-- END DYNAMIC BLOCK: allowselfmanagetransfer -->
        $('domainwindow').innerHTML = innerHTML;
        $('domainwindow_main').style.display='';
        document.forms['checkdomain'].domain.value=aOptionPairs[1];
        <!-- BEGIN DYNAMIC BLOCK: allowreg3 -->
        ToggleRegisterOption(true,false);
        <!-- END DYNAMIC BLOCK: allowreg3 -->
        <!-- BEGIN DYNAMIC BLOCK: allowtransfer4 -->
        ToggleTransferOption(false,true);
        bolReadyToRegister=true;
        <!-- END DYNAMIC BLOCK: allowtransfer4 -->
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage5 -->
        ToggleSelfManagement(false,true);
        bolReadyToRegister=true;
        <!-- END DYNAMIC BLOCK: allowselfmanage5 -->
        break;
        case '2' :
        innerHTML ='<font class=error>[l]Registrar Error[/l]</font><br>[l]Domain extension not recognized or supported[/l]<br><br><p>';
        $('domainwindow').innerHTML = innerHTML;
        $('domainwindow_main').style.display='';
        <!-- BEGIN DYNAMIC BLOCK: allowreg4 -->
        ToggleRegisterOption(true,false);
        <!-- END DYNAMIC BLOCK: allowreg4 -->
        <!-- BEGIN DYNAMIC BLOCK: allowtransfer5 -->
        ToggleTransferOption(true,false);
        <!-- END DYNAMIC BLOCK: allowtransfer5 -->
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage6 -->
        ToggleSelfManagement(false,true);
        bolReadyToRegister=true;
        <!-- END DYNAMIC BLOCK: allowselfmanage6 -->
        break;
        case '3' :
        innerHTML ='<font class=error>{ERROR}:</font><br>[l]Domain Name[/l] <b>\''+aOptionPairs[1]+'\'</b> [l]is not valid. Please try again[/l].<p>';
        $('domainwindow').innerHTML = innerHTML;
        $('domainwindow_main').style.display='';
        <!-- BEGIN DYNAMIC BLOCK: allowreg5 -->
        ToggleRegisterOption(true,false);
        <!-- END DYNAMIC BLOCK: allowreg5 -->
        <!-- BEGIN DYNAMIC BLOCK: allowtransfer6 -->
        ToggleTransferOption(true,false);
        <!-- END DYNAMIC BLOCK: allowtransfer6 -->
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage7 -->
        ToggleSelfManagement(false,true);
        bolReadyToRegister=true;
        <!-- END DYNAMIC BLOCK: allowselfmanage7 -->
        break;
        case '5' :
        innerHTML ='<font class=error>{ERROR}</font><br>[l]Could not contact registry to lookup domain[/l]<br><br>';
        if (typeof aOptionPairs[2] != 'undefined') innerHTML += '[l]Registrar returned[/l]: ' + aOptionPairs[2];
        $('domainwindow').innerHTML = innerHTML;
        $('domainwindow_main').style.display='';
        <!-- BEGIN DYNAMIC BLOCK: allowreg6 -->
        ToggleRegisterOption(true,false);
        <!-- END DYNAMIC BLOCK: allowreg6 -->
        <!-- BEGIN DYNAMIC BLOCK: allowtransfer7 -->
        ToggleTransferOption(true,false);
        <!-- END DYNAMIC BLOCK: allowtransfer7 -->
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage8 -->
        ToggleSelfManagement(false,true); bolReadyToRegister=true;
        <!-- END DYNAMIC BLOCK: allowselfmanage8 -->
        break;
        default :
        innerHTML ='<font class=error>{ERROR}:</font><br>[l]There was a problem trying to register this domain[/l]<br><br><p>';
        $('domainwindow').innerHTML = innerHTML;
        $('domainwindow_main').style.display='';
        <!-- BEGIN DYNAMIC BLOCK: allowreg7 -->
        ToggleRegisterOption(true,false);
        <!-- END DYNAMIC BLOCK: allowreg7 -->
        <!-- BEGIN DYNAMIC BLOCK: allowtransfer8 -->
        ToggleTransferOption(true,false);
        <!-- END DYNAMIC BLOCK: allowtransfer8 -->
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage9 -->
        ToggleSelfManagement(false,true); bolReadyToRegister=true;
        <!-- END DYNAMIC BLOCK: allowselfmanage9 -->
        break;
    }
    return false;
}
function CheckDomain(form){
    form.domainname.value = form.domainname.value.toLowerCase();

    var arraySupportedDomains = [{JSARRAYSUPPORTEDDOMAINS}];
    var domain = form.domainname.value;
    var extension = "";
    var bolSupportsExtension = false;
    var regexDomain = {REGEXDOMAIN};

    var domain_array=domain.split(".");
    for (x=0;x < domain_array.length;x++)
    {
       if (x==0) domain = domain_array[x];
       else extension = extension + "."+ domain_array[x];
    }
    extension = extension.substring(1);
    for(x=0;x<arraySupportedDomains.length;x++){
         if (arraySupportedDomains[x]==extension){
             bolSupportsExtension=true;
         }
    }
    $('domainwindow_main').style.display='none';
    $('domainsearch').style.display='none';
    <!-- BEGIN DYNAMIC BLOCK: allowreg8 -->
    ToggleRegisterOption(true,false);
    <!-- END DYNAMIC BLOCK: allowreg8 -->
    <!-- BEGIN DYNAMIC BLOCK: allowtransfer9 -->
    ToggleTransferOption(true,false);
    <!-- END DYNAMIC BLOCK: allowtransfer9 -->
    <!-- BEGIN DYNAMIC BLOCK: allowselfmanage10 -->
    ToggleSelfManagement(true,false);
    <!-- END DYNAMIC BLOCK: allowselfmanage10 -->
    if (!regexDomain.test(form.domainname.value)) {
        innerHTML ='<font class=error>[l]Format Error[/l]:</font><br>[l]Domain name is not valid.  Please try again.[/l]<p>';
        $('domainwindow').innerHTML = innerHTML;
        $('domainwindow_main').style.display='';
        bolReadyToRegister=false;
        return false;
    } else if(bolSupportsExtension==false){
        innerHTML ='<font class=error>[l]Self-Management Domain Notice[/l]:</font><br>[l]The domain extension[/l] <b>.'+extension+'</b> [l]cannot be registered directly through[/l] {COMPANYNAME} [l]Currently we support the registration for the following top-level domains (TLDs)[/l]: {STRPOPUP}<p>';
        $('domainwindow').innerHTML = innerHTML;
        $('domainwindow_main').style.display='';
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage11 -->
        ToggleSelfManagement(false,true);
        bolReadyToRegister=true;
        <!-- END DYNAMIC BLOCK: allowselfmanage11 -->
        return false;
    } else {
        $('domainsearch').style.display='';
    }
    var opt = {
     	 method		: 'get',
     	 parameters	: 'domain='+domain+'&extension='+extension,
     	 onSuccess	: DomainCheckReturn
    }
    var ajaxexecute = new Ajax.Request('index.php?fuse={FUSE_CLIENTS}&action={ACTION_CHECKDOMAIN}', opt);
    return false;
}

function BackStepOne() {
    document.forms['checkdomain'].elements['clienttype'].value=0;
    document.forms['checkdomain'].elements['package'].value=0;
    document.forms['checkdomain'].elements['step'].value=0;
    document.forms['checkdomain'].submit();
}

function makeReady() {
    bolReadyToRegister=true;
}

//Submit for subdomains

function CheckIfDomainExistsReturn(strReturnValue) {
    $('domainsearch').style.display='none';
    if (strReturnValue==1){
        innerHTML ='<font class=error>[l]Warning[/l]:</font><br>[l]Domain Name[/l] <b>\''+ document.forms['checkdomain'].domainname.value + ".{MAINDOMAIN}\'</b> [l]already has an account with us. If you are a current customer please submit a support ticket for assistance.[/l]<p>";
        $('domainwindow').innerHTML = innerHTML;
        $('domainwindow_main').style.display='';
        return false;
    } else {
        document.forms['checkdomain'].domain.value = document.forms['checkdomain'].domainname.value + ".{MAINDOMAIN}";
        document.forms['checkdomain'].submit();
    }
}

function SubmitStep2c(){
    var regexSubDomain = {REGEXSUBDOMAIN};

    if (!regexSubDomain.test(document.forms['checkdomain'].domainname.value)) {
        alert('[l]Please select a valid domain name and select an option to continue[/l]');
        return false;
    }
    $('domainwindow_main').style.display='none';
    $('domainsearch').style.display='';
    jsrsPOST = 0;
    arr=Array(trim(document.forms['checkdomain'].domainname.value)+".{MAINDOMAIN}");
    setTimeout('jsrsExecute("index.php?fuse={FUSE_CLIENTS}&action={ACTION_CHECKDOMAINEXISTS}",CheckIfDomainExistsReturn, "CheckIfDomainExists", arr)',1500);
    return false;
}

//Submit for non domain option
function SubmitStep2b(){
    if (trim(document.forms['checkdomain'].domainname.value) == ''){
        alert('[l]Please select a valid domain name and select an option to continue[/l]');
        return false;
    }
    document.forms['checkdomain'].domain.value = document.forms['checkdomain'].domainname.value;
    document.forms['checkdomain'].submit();
}

function SubmitStep2(){
    if(!bolReadyToRegister){
        alert('[l]Please select a valid domain name and select an option to continue[/l]');
        return false;
    }
    document.forms['checkdomain'].domain.value = document.forms['checkdomain'].domainname.value;
    document.forms['checkdomain'].submit();
}

//-->
</script>
