<script language="javascript">
<!-- Hide for older browsers

function importWelcomeEmail(myfield)
{
    if (myfield.value == 0) {
        $('welcomeemail_subject').value = '';
        $('welcomeemail').innerHTML = '';
        return;
    }

    new Ajax.Request(   'index.php?fuse=admin&action=ImportWelcomeEmail&promotionId=' + myfield.value,
                        {
                          onLoading     : function(){resetStatus(lang('Loading'))},
                          onComplete    : fillWelcomeEmail
                        }
    );
}

function fillWelcomeEmail(responseObj)
{
    unsetStatus(false);
    responseStr = responseObj.responseText;
    var regex = /\\\|/g;
    responseStr = responseStr.replace(regex, '~NE~');
    var responseArr = responseStr.split('|');
    var regex = /~NE~/g;
    responseArr[0] = responseArr[0].replace(regex, '|');
    responseArr[1] = responseArr[1].replace(regex, '|');
    responseArr[2] = responseArr[2].replace(regex, '|');
    $('welcomeemail_subject').value = responseArr[0];
    oEditWelcomeemail.putHTML(responseArr[1]);
    $('welcomeemail[1]').innerHTML = responseArr[2];
}

function dologinname(form,myfield) {
         var domain = myfield.value;
         var username = domain.substring(0,19);
         var username = username.toUpperCase();
     form.code.value =  replaceString(".","",username);
}

function replaceString(oldS,newS,fullS) {
          for (var i=0; i<fullS.length; i++) {
             if (fullS.substring(i,i+oldS.length) == oldS) {
                fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)
             }
          }
          return fullS
       }

function fixaddress(myfield) {
      myfield.value =  replaceString(" ","",myfield.value);
      myfield.value = myfield.value.toLowerCase();
}

function ToggleDomainTable(optionval)
{
    if (optionval==1){
        $('domaintable').style.display="";
    }else{
        $('domaintable').style.display="none";
    }
}

function ToggleIsSub(optionval)
{
    if (optionval==1){
        $('subdomaintable').style.display="";
        $('domainregtable').style.display="none";
    }else{
        $('domainregtable').style.display="";
        $('subdomaintable').style.display="none";
    }
}

//-->
</script>

<br>
[l]You may only need one Package Type if all of your clients have the same packages and price<br>and you are not running any specials, otherwise you can create different Package Types<br>and their associated packages by clicking on the create package type tab.[/l]<br><br><br>
<form method="post" action="index.php?fuse=admin&action=AddEditPlan">
    <input name="r_code" value="Package Type" type="hidden">
    <table border="0" width="650">
        <tr class="primarycolor">
            <td>
                <b>[l]Package Type:[/l]</b><br>
                <input size="20" name="code" class="body" onchange="fixaddress(this);dologinname(form,this)" type="text">&nbsp;&nbsp;
                <a href="javascript:void(0);" onmouseover="return overlib('[ljh]Package Type (code) is used to distinguish what type of packages are available to a client[/ljh]',FIXY,_mousePosY+5,FIXX,_mousePosX+13,DELAY,310,BGCOLOR, '#FFCC00', FGCOLOR, '#FFFFCC',BORDER,1,TEXTCOLOR,'#000000');" onmouseout="return nd();">
                    <img src="templates/Raleigh/images/question.gif" style="position: relative; left: 0px; top: 2px;" border="0" />
                </a>
            </td>
        </tr>
        <tr class="secondarycolor">
            <td valign="top">
                <br><b>[l]Friendly Name[/l]:</b><br>
                <input size="40" name="name" value="" class="body" type="text">
            </td>
        </tr>
        <tr class="primarycolor">
            <td valign="bottom">
                <b>[l]Show Domain Options[/l]:</b><br>
                <select name="regdomain" onchange="ToggleDomainTable(this.options[this.selectedIndex].value)" ;="">
                    <option value="1"> [l]Yes[/l] - [l]Show domain options[/l]&nbsp;&nbsp;</option>
                    <option value="0" selected="selected"> [l]No[/l] - [l]Do not show domain options[/l]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
                </select>
            </td>
        </tr>
    </table>
    <div id="domaintable" style="display: none;">
        <table border="0" width="490">
            <tr>
                <td width="140">
                    <b>[l]Is this for a subdomain?[/l]</b>
                </td>
                <td>
                    <input name="issub" value="0" style="position: relative; top: 3px;" checked="checked" onclick="ToggleIsSub(this.value);" ;="" type="radio"> [l]No[/l] 
                    <input name="issub" value="1" style="position: relative; top: 3px;" onclick="ToggleIsSub(this.value);" ;="" type="radio"> [l]Yes[/l]
                </td>
            </tr>
        </table>
        <div id="subdomaintable" style="display: none;">
            <table border="0" width="490">
                <tr>
                    <td width="145">
                        <b>[l]Main Domain[/l]:</b>
                    </td>
                    <td>
                        <input size="30" name="maindomain" value="" type="text">&nbsp;&nbsp;
                        <a href="javascript:void(0);" onmouseover="return overlib('Used for customers who are providing subdomain hosting.<br>Example: customer.yourdomain.com',FIXY,_mousePosY+5,FIXX,_mousePosX+13,DELAY,310,BGCOLOR, '#FFCC00', FGCOLOR, '#FFFFCC',BORDER,1,TEXTCOLOR,'#000000');" onmouseout="return nd();">
                            <img src="templates/Raleigh/images/question.gif" style="position: relative; left: 0px; top: 2px;" border="0" />
                        </a>
                    </td>
                </tr>
            </table>
        </div>
        <div id="domainregtable" style="">
            <table border="0" width="490">
                <tr>
                    <td>
                        <input name="allowreg" style="position: relative; top: 4px;" type="checkbox">
                        <b>[l]Allow Registration[/l]</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <input name="allowselfmanage" style="position: relative; top: 4px;" type="checkbox">
                        <b>[l]Allow Self Manage[/l]</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <input name="allowtransfer" style="position: relative; top: 4px;" type="checkbox">
                        <b>[l]Allow Transfer[/l]</b>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <table border="0" width="650">
        <tr class="secondarycolor">
            <td colspan="2" valign="top">
                <br><b>[l]Description[/l]:</b>&nbsp;&nbsp;&nbsp;
                <font class="warningtext">([l]HTML is accepted[/l])</font><br>
                <textarea name="description" cols="122" rows="6"></textarea>
            </td>
        </tr>
        <tr class="primarycolor">
            <td colspan="2" valign="top">
                <br>
                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                        <td>
                            <b>[l]Default Welcome E-mail[/l]:</b>&nbsp;&nbsp;&nbsp;(<a href="javascript:void(0);" onmousedown="oldOpenHelpWindow('1')">[l]Click to view tags[/l]</a>)
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan="2" valign="top">
                <br>[l]Subject[/l] : &nbsp;&nbsp;
                <input id="welcomeemail_subject" name="welcomeemail_subject" value="{welcomeEmailSubject}" style="background-color: rgb(255, 250, 239);" size="50" type="text"><br>
                <br>
                <ul class="shadetabs">
                    <li class="selected">
                        <a href="javascript:void(0);" onclick="selectHTMLTab(this, 'welcomeemail')">
                            [l]HTML[/l]
                        </a>
                    </li>
                    <li class="">
                        <a href="javascript:void(0);" onclick="selectPlainTextTab(this, 'welcomeemail')">
                            [l]Plain-Text[/l]
                        </a>
                    </li>
                </ul>
                <div id="richTextWrapper_welcomeemail">
                    <textarea id='welcomeemail[0]' name='welcomeemail[0]' style="width:650px; height:250px;"></textarea>
                    <script type="text/javascript" src="newedge/javascript/editor/scripts/innovaeditor.js?version={VERSION}"></script>
                    <script type="text/javascript">
                        showRichTextEditor("oEditWelcomeemail", 650, '250px',
                                            [
                                                'Undo','Redo','|','Hyperlink','|','JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','|','Numbering','Bullets','|','LTR','RTL','|','XHTMLFullSource','StyleAndFormatting','TextFormatting','ListFormatting','BoxFormatting','ParagraphFormatting','CssText','|','FontName','FontSize','|','Bold','Italic','Underline','|','ForeColor','BackColor'
                                            ],
                                            "welcomeemail[0]");
                    </script>
                </div>
                <textarea id='welcomeemail[1]' name='welcomeemail[1]' style="width:650px; height:250px; display:none;"></textarea>
            </td>
        </tr>
        <tr class="secondarycolor">
            <td valign="top">
                <b>[l]Import Welcome E-mail[/l]:</b>
            </td>
            <td align="right">
                <select name="importwelcomeemail" onchange="importWelcomeEmail(this)" class="body">
                    <option value="0" selected="selected">[l]Do Not Import[/l]&nbsp;&nbsp;</option>
                    <!-- BEGIN DYNAMIC BLOCK: importWelcomeEmail -->
                    <option value="{importPackageTypeWelcomeEmailId}">{importPackageTypeWelcomeEmailLabel}</option>
                    <!-- END DYNAMIC BLOCK: importWelcomeEmail -->
                </select>
            </td>
        </tr>
        <tr>
            <td>
            </td>
        </tr>
        <tr class="primarycolor">
            <td valign="top">
                <b>[l]Import Packages[/l]:</b>
            </td>
            <td align="right">
                <select name="importpackages" class="body">
                    <option value="0" selected="selected">[l]Do Not Import[/l]&nbsp;&nbsp;</option>
                    <!-- BEGIN DYNAMIC BLOCK: importPackages -->
                    <option value="{importPackageTypeId}">{importPackageTypeLabel}</option>
                    <!-- END DYNAMIC BLOCK: importPackages -->
                </select>
            </td>
        </tr>
    </table>
    <br>
    <table border="0" cellpadding="1" cellspacing="0" width="100%">
        <tr valign="center">
            <td align="right" valign="center">
                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr valign="center">
                        <td class="tight" colspan="2" align="left">
                            <input name="action" value="InsertPlan" type="hidden">
                            <input class="button_xlarge" onclick="check(form,form.elements.length);return false;" value="[lh]add new package type[/lh]" type="button">
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</form>
