<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>[lj]Warning[/lj]:</font><br>[lj]Domain Name[/lj] <b>\''+aOptionPairs[1]+'\'</b> [lj]already has an account with us. If you are a current customer please submit a support ticket for assistance.[/lj].';
        $('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>[lj]Congratulations[/lj]</font><br>[lj]The Domain[/lj] <b>'+aOptionPairs[1]+'</b> [lj]is available[/lj].';
        $('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>[lj]Domain Is Already Registered[/lj]</font><br>[lj]According to registrar records, the domain[/lj] <b>'+aOptionPairs[1]+'</b> [lj]is already registered.[/lj] ';
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanagetransfer -->
        innerHTML +='[lj]If you own this domain please choose the[/lj] ';
        <!-- BEGIN DYNAMIC BLOCK: allowtransfer3 -->
        innerHTML +='<b>[lj]Transfer[/lj]</b> ';
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage3 -->
        innerHTML +='[lj]or[/lj] <b>[lj]Self-Management (no cost)[/lj]</b> ';
        <!-- END DYNAMIC BLOCK: allowselfmanage3 -->
        <!-- END DYNAMIC BLOCK: allowtransfer3 -->
        <!-- BEGIN DYNAMIC BLOCK: allowselfmanage4 -->
        innerHTML +='<b>[lj]Self-Management (no cost)[/lj]</b> ';
        <!-- END DYNAMIC BLOCK: allowselfmanage4 -->
        innerHTML +='[lj]option on the right.[/lj]';
        <!-- 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>[lj]Registrar Error[/lj]</font><br>[lj]Domain extension not recognized or supported[/lj]';
        $('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>[lj]Domain Name[/lj] <b>\''+aOptionPairs[1]+'\'</b> [lj]is not valid. Please try again[/lj].';
        $('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>[lj]Could not contact registry to look up domain[/lj]';
        if (typeof aOptionPairs[2] != 'undefined') innerHTML += '[lj]Registrar returned[/lj]: ' + 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>[lj]There was a problem trying to register this domain[/lj]';
        $('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(){
    var form = document.forms['checkdomain'];
    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>[lj]Format Error[/lj]:</font><br>[lj]Domain name is not valid.  Please try again.[/lj]';
        $('domainwindow').innerHTML = innerHTML;
        $('domainwindow_main').style.display='';
        bolReadyToRegister=false;
        return false;
    } else if(bolSupportsExtension==false){
        innerHTML ='<font class=error>[lj]Self-Management Domain Notice[/lj]:</font><br>[lj]The domain extension[/lj] <b>.'+extension+'</b> [lj]cannot be registered directly through[/lj] {COMPANYNAME} [lj]Currently we support the registration for the following top-level domains (TLDs)[/lj]: {STRPOPUP}';
        $('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 = {
     	 onSuccess	: DomainCheckReturn
    }
    var ajaxexecute = new Ajax.Request('index.php?fuse=clients&action={ACTION_CHECKDOMAIN}&domain='+domain+'&extension='+extension, opt);
    return false;
}

function ChangeTLD()
{
    $('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 -->
    bolReadyToRegister=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(responseObj)
{
    $('domainsearch').style.display='none';
    var strReturnValue = responseObj.responseText;
    if (strReturnValue==1){
        innerHTML ='<font class=error>[lj]Warning[/lj]:</font><br>[lj]Domain Name[/lj] <b>\''+ document.forms['checkdomain'].domainname.value + ".{MAINDOMAIN}\'</b> [lj]already has an account with us. If you are a current customer please submit a support ticket for assistance.[/lj]";
        $('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('[lj]Please select a valid domain name and select an option to continue[/lj]');
        return false;
    }
    $('domainwindow_main').style.display='none';
    $('domainsearch').style.display='';

    new Ajax.Request(   'index.php?fuse=clients&action=CheckDomainExists',
                        {   parameters  : 'domainName=' + trim(document.forms['checkdomain'].domainname.value)+".{MAINDOMAIN}",
                            onSuccess   : checkIfDomainExistsReturn}
    );
    return false;
}

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

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

function toggleDomainOption()
{
    if ($('domainoption_own').checked) {
        $('subdomain_area').style.display='none';
        $('domain_area').style.display='';
        $('searchbutton').onclick = CheckDomain;
        $('registration_options').style.display='';
        $('registration_options_continue').style.display='';
    } else {
        $('domain_area').style.display='none';
        $('subdomain_area').style.display='';
        $('searchbutton').onclick = SubmitStep2c;
        $('registration_options').style.display='none';
        $('registration_options_continue').style.display='none';
    }
    ChangeTLD();
}

//-->
</script>
