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

function editAddon(addonId)
{
    window.open('index.php?fuse=admin&view=EditPackageAddon&packageId={packageId}&addonId='+addonId,'editAddon','scrollbars=yes,menubar=no,location=no,width=850,height=155,resizable=yes,screenX=200,screenY=200,top=200,left=200');
}

function deleteAddon(addonId)
{
    if (!confirm(lang('Are you sure you wish to delete this package add-on?'))) {
        return;
    }

    new Ajax.Request(
        'index.php?fuse=admin&action=DeleteAddon',
        {
            parameters  : 'addonId='+addonId,
            onLoading   : function() {resetStatus(lang('Removing'))},
            onComplete  : addonRemoved
        }
    );
}

function addonRemoved(response)
{
    eval(response.responseText);
    if (!isNumber(response.responseText) && typeof domainsToDelete != 'undefined') {
        unsetStatus();
        var errorStr = lang("You can't delete this package add-on until you make the following packages point to this add-on's default option") + ":\n";
        for (var i = 0; i < domainsToDelete.length; i++) {
            errorStr += '- ' + domainsToDelete[i].domainId + ' ' + "owned by" + ' ' + domainsToDelete[i].userName;
        }
        alert(errorStr);
    } else if (isNumber(response.responseText)) {
        unsetStatus(lang('add-on has been removed'), 1000);
        $('liAddon_'+response.responseText).parentNode.removeChild($('liAddon_'+response.responseText));
    } else {
        unsetStatus(lang('Error removing add-on'), 1000);
    }

    domainsToDelete = null;
}

function refreshAddonsList()
{
    var foo = new Ajax.Updater('packageAddonsList',
                               'index.php?fuse=admin&view=RefreshAddonsList&packageid={packageId}',
                               {
                                   onLoading     : function(request) {resetStatus(lang('Loading'))},
                                   onFailure     : function(request) {alert('error')},
                                   onComplete    : function() {unsetStatus(lang('Loaded'), 1000)},
                                   evalScripts   : true
                               });
}

// had to pull this hack, otherwise it won't work under Firefox
function proxyRefreshAddonsList()
{
    setTimeout(refreshAddonsList, 500);
}

function importAddon(addonId)
{
    new Ajax.Updater('packageAddonsList',
                     'index.php?fuse=admin&view=ImportAddon&packageid={packageId}&addonid='+addonId,
                     {
                         onLoading     : function(request) {resetStatus(lang('Loading'))},
                         onFailure     : function(request) {alert('error')},
                         onComplete    : function() {unsetStatus(lang('Loaded'), 1000)},
                         evalScripts   : true
                     });
}

function importPackage(packageId)
{
    location.href = 'index.php?fuse=admin&action=ImportPackage&packageid={packageId}&importpackage='+packageId+'&packageTypeId='+5;
}

function changeStyle(styleName)
{
    new Ajax.Request('index.php?fuse=admin&action=PackageAddonsSetStyle&packageid={packageId}&styleName='+styleName,
                     {
                         onLoading     : function(request) {resetStatus(lang('Loading'))},
                         onFailure     : function(request) {alert('error')},
                         onComplete    : function() {unsetStatus(lang('Loaded'), 1000)},
                         evalScripts   : true
                     });
}

function ToggleUseDefault(optionval)
{
    if (optionval==true){
        $('packagewelcomeemail').style.display="none";
    }else{
        $('packagewelcomeemail').style.display="";
    }
}

function toggleDiv(isChecked, plugin)
{
    div = $('div_' + plugin)
    if (isChecked) {
        div.style.display='';
    } else {
        div.style.display='none';
    }
}

function checkTemplate(form, value, pluginInternalName){
    var packageVarsTemplate = $(pluginInternalName + '_package_vars_template').value.split(",");
    
    if (value == ''){
        for(packageVar = 0; packageVar < packageVarsTemplate.length; packageVar++) {
            $(pluginInternalName + '_package_vars_' + packageVarsTemplate[packageVar]).style.display = '';
            $('plugin_' + pluginInternalName + '_package_vars_' + packageVarsTemplate[packageVar]).disabled = false;
        }
    }else{
        for(packageVar = 0; packageVar < packageVarsTemplate.length; packageVar++) {
            $(pluginInternalName + '_package_vars_' + packageVarsTemplate[packageVar]).style.display = 'none';
            $('plugin_' + pluginInternalName + '_package_vars_' + packageVarsTemplate[packageVar]).disabled = true;
        }
    }
}

//-->
</script>

    
<< <a href=index.php?fuse=admin&view=PlanSettings&clienttype={clientType}>[l]Return to packages list[/l]</a><br>
<br>
<!-- BEGIN DYNAMIC BLOCK: signupURLBlock -->
<b>Signup URL:&nbsp;&nbsp;</b>&nbsp;
<a href="{signupURL}" target=_blank><font class=warningtext>{signupURL}</font></a><br><br>
<!-- END DYNAMIC BLOCK: signupURLBlock -->
<TABLE width=100% cellpadding=0 cellspacing=0>
    <TR>
        <TD>
            {headerText}
        </TD>
    </TR>
</TABLE>
<form name=package method=post action="index.php?fuse=admin&action=AddEditPackage">
    <table width="100%" cellpadding=0 border="0">
        <tr class=secondarycolor>
            <td width=130  align=right class=formLabel>
                [l]Package Name[/l]:&nbsp;
            </td>
            <td align=left class=formField colspan=2>
                &nbsp;&nbsp;
                <input type=text name=planname size=40 value="{packageName}">
                <input type=hidden name="r_planname" value="[lh]Package Name[/lh]">
            </td>
            <td align=right width=160 class=formLabel>
                <a href=javascript:void(0); onmouseover="return overlib('[ljh]Select Yes if you want this package to be seen as an option in the signup script.<br><br>Select Hidden if you want this package to be available for signups but not shown in the package selection.<br><br>Select No if you do not wish to accept any orders for this package.[/ljh]',FIXY,_mousePosY+5,FIXX,_mousePosX+13,DELAY,310,BGCOLOR, '#FFCC00', FGCOLOR, '#FFFFCC',BORDER,1,TEXTCOLOR,'#000000');" onmouseout="return nd();" >[l]Allow in signup[/l]:</a>&nbsp;
                <select name=showpackage>
                    <option value=1 {allowInSignup_yes}>[l]Yes[/l]</option>
                    <option value=0 {allowInSignup_hidden}>[l]Hidden[/l]</option>
                    <option value=-1 {allowInSignup_no}>[l]No[/l]</option>
                </select>
            </td>
        </tr>
        <!-- Monthly Price -->
        <tr class=primarycolor>
            <td width=130 class=formLabel align=right>
                <a href=javascript:void(0); onmouseover="return overlib('The price does not identify which currency the amount is in.  This is handled in the customer profile of each customer.',FIXY,_mousePosY+5,FIXX,_mousePosX+13,DELAY,310,BGCOLOR, '#FFCC00', FGCOLOR, '#FFFFCC',BORDER,1,TEXTCOLOR,'#000000');" onmouseout="return nd();" >[l]Monthly Billing[/l]:</a>
            </td>
            <td align=left colspan=2 class=formField>
                &nbsp;&nbsp;
                <input type=text name=price size=7 value='{priceMonthly}'>
                <input type=checkbox name='price1included' {priceMonthly_checked}>&nbsp;[l]Allow in signup[/l]
                <input type=hidden name="r_price" value="[lh]Monthly Price[/lh]">
            </td>
            <!-- BEGIN DYNAMIC BLOCK: orderProcessor -->
            <td align=right width=170 class=formLabel>
                <a href=javascript:void(0); onmouseover="return overlib('[ljh]Select Yes if you want this package to use the plugin <i>Order Processor</i>.<br><br>Select No if you do not wish this package to use the plugin <i>Order Processor</i>.<br><br>Plugin <i>Order Processor</i> is enabled, to configure or disable go to <i>admin > plugins > services</i>[/ljh]',FIXY,_mousePosY+5,FIXX,_mousePosX+13,DELAY,310,BGCOLOR, '#FFCC00', FGCOLOR, '#FFFFCC',BORDER,1,TEXTCOLOR,'#000000');" onmouseout="return nd();" >[l]Automatic Activation[/l]:</a>&nbsp;
                <select name=automaticactivation>
                    <option value=1 {automaticActivation_yes}>[l]Yes[/l]</option>
                    <option value=0 {automaticActivation_no}>[l]No[/l]</option>
                </select>
            </td>
            <!-- END DYNAMIC BLOCK: orderProcessor -->
            <!-- BEGIN DYNAMIC BLOCK: taxable1 -->
            <td align=right width=150 class=formLabel>
                <a href=javascript:void(0); onmouseover="return overlib('Select Yes if you want customers signing up for this package to get taxed based on the country state rules.',FIXY,_mousePosY+5,FIXX,_mousePosX+13,DELAY,310,BGCOLOR, '#FFCC00', FGCOLOR, '#FFFFCC',BORDER,1,TEXTCOLOR,'#000000');" onmouseout="return nd();" > [l]Taxable[/l]:</a>&nbsp;
                <select name=taxable>
                    <option value=1 {taxable_yes}>[l]Yes[/l]</option>
                    <option value=0 {taxable_no}>[l]No[/l]</option>
                </select>
            </td>
            <!-- END DYNAMIC BLOCK: taxable1 -->
        </tr>
        <!-- End Monthly Price -->
        <!-- Quarterly Price -->
        <tr class=secondarycolor>
            <td width=130 class=formLabel align=right>
                <a href=javascript:void(0); onmouseover="return overlib('The price does not identify which currency the amount is in.  This is handled in the customer profile of each customer.',FIXY,_mousePosY+5,FIXX,_mousePosX+13,DELAY,310,BGCOLOR, '#FFCC00', FGCOLOR, '#FFFFCC',BORDER,1,TEXTCOLOR,'#000000');" onmouseout="return nd();" >[l]Quarterly Billing[/l]:</a>
            </td>
            <td align=left colspan={colspanQuarterly} class="formField">&nbsp;&nbsp;
                <input type=text name=price3 size=7 value='{priceQuarterly}'>
                <input type=checkbox name='price3included' {priceQuarterly_checked}>&nbsp;[l]Allow in signup[/l]
                <input type=hidden name="r_price3" value="[lh]Quarterly Price[/lh]">
            </td>
            <!-- BEGIN DYNAMIC BLOCK: taxable2 -->
            <td align=right width=150 class=formLabel>
                <a href=javascript:void(0); onmouseover="return overlib('Select Yes if you want customers signing up for this package to get taxed based on the country state rules.',FIXY,_mousePosY+5,FIXX,_mousePosX+13,DELAY,310,BGCOLOR, '#FFCC00', FGCOLOR, '#FFFFCC',BORDER,1,TEXTCOLOR,'#000000');" onmouseout="return nd();" > [l]Taxable[/l]:</a>&nbsp;
                <select name=taxable>
                    <option value=1 {taxable_yes}>[l]Yes[/l]</option>
                    <option value=0 {taxable_no}>[l]No[/l]</option>
                </select>
            </td>
            <!-- END DYNAMIC BLOCK: taxable2 -->
        </tr>
        <!-- End Quarterly Price -->
        <!-- Six-Month Price -->
        <tr class=primarycolor>
            <td width=130 class=formLabel nowrap  nowrap align=right>
                <a href=javascript:void(0); onmouseover="return overlib('The price does not identify which currency the amount is in.  This is handled in the customer profile of each customer.',FIXY,_mousePosY+5,FIXX,_mousePosX+13,DELAY,310,BGCOLOR, '#FFCC00', FGCOLOR, '#FFFFCC',BORDER,1,TEXTCOLOR,'#000000');" onmouseout="return nd();" >[l]Semiannual Billing[/l]:</a>
            </td>
            <td align=left colspan=3 class="formField">&nbsp;&nbsp;
                <input type=text name=price6 size=7 value='{priceSemiannual}'>
                <input type=checkbox name='price6included' {priceSemiannual_checked}>&nbsp;[l]Allow in signup[/l]
                <input type=hidden name="r_price6" value="[lh]Half-Year Price[/lh]">
            </td>
            <td>
            </td>
        </tr>
        <!-- End Six-Month Price -->
        <!-- Yearly Price -->
        <tr class=secondarycolor>
            <td class=formLabel width=130 align=right>
                <a href=javascript:void(0); onmouseover="return overlib('The price does not identify which currency the amount is in.  This is handled in the customer profile of each customer.',FIXY,_mousePosY+5,FIXX,_mousePosX+13,DELAY,310,BGCOLOR, '#FFCC00', FGCOLOR, '#FFFFCC',BORDER,1,TEXTCOLOR,'#000000');" onmouseout="return nd();" >[l]Annual Billing[/l]:</a>
            </td>
            <td align=left colspan=3 class="formField">
                &nbsp;&nbsp;
                <input type=text name=price12 size=7 value='{priceYearly}'>
                <input type=checkbox name='price12included' {priceYearly_checked}>&nbsp;[l]Allow in signup[/l]
                <input type=hidden name="r_price12" value="[lh]Yearly Price[/lh]">
            </td>
            <td>
            </td>
        </tr>
        <!-- End Yearly Price -->
        <!-- 2 Year Price -->
        <tr class=primarycolor>
            <td class=formLabel width=130 align=right>
                <a href=javascript:void(0); onmouseover="return overlib('The price does not identify which currency the amount is in.  This is handled in the customer profile of each customer.',FIXY,_mousePosY+5,FIXX,_mousePosX+13,DELAY,310,BGCOLOR, '#FFCC00', FGCOLOR, '#FFFFCC',BORDER,1,TEXTCOLOR,'#000000');" onmouseout="return nd();" >[l]2 Year Billing[/l]:</a>
            </td>
            <td align=left colspan=3 class="formField">
                &nbsp;&nbsp;
                <input type=text name=price24 size=7 value='{price2Years}'>
                <input type=checkbox name='price24included' {price2Years_checked}>&nbsp;[l]Allow in signup[/l]
                <input type=hidden name="r_price24" value="[lh]2 Year Price[/lh]">
            </td>
            <td>
            </td>
        </tr>
        <!-- End 2 Year Price -->
        <!-- Setup Price -->
        <tr class=secondarycolor>
            <td width=130 class=formLabel align=right>
                <a href=javascript:void(0); onmouseover="return overlib('The price does not identify which currency the amount is in.  This is handled in the customer profile of each customer.',FIXY,_mousePosY+5,FIXX,_mousePosX+13,DELAY,310,BGCOLOR, '#FFCC00', FGCOLOR, '#FFFFCC',BORDER,1,TEXTCOLOR,'#000000');" onmouseout="return nd();" >[l]Setup Price[/l]:</a>
            </td>
            <td  colspan=3 align=left class="formField">&nbsp;&nbsp;
                <input type=text name=setup size=7 value='{priceSetup}'>
                <input type=hidden name="r_setup" value="[lh]Setup Price[/lh]">
            </td>
        </tr>
        <!-- End Setup Price -->
    </table>
    <table width="100%" border=0 cellpadding=4 cellspacing=0>
        <tr class=header>
            <td colspan=3 valign=top>
                [l]Package Description[/l]:
            </td>
        </tr>
        <tr>
            <td colspan=3 valign=top>
                <textarea id="description" name="description" cols=90 rows=2>{packageDescription}</textarea>
                <script type="text/javascript">
                    showRichTextEditor("oEditDescription", 650, '150px',
                                        [
                                            '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'
                                        ],
                                        "description");
                </script>
            </td>
        </tr>
    </table>
    <table width="100%" border=0 cellpadding=4 cellspacing=0>
        <tr class=header>
            <td valign=bottom width=80>
                <b>[l]Welcome E-mail[/l]:</b>
            </td>
            <td valign=top>
                &nbsp;&nbsp;<input onClick="ToggleUseDefault(this.checked);" type=checkbox name=usedefaultwelcome style='position:relative;top:4px;' {useDefaultEmailChecked}> [l]Use Package Group's Default Welcome E-mail[/l]
            </td>
        </tr>
    </table>
    <div id=packagewelcomeemail style="display:{welcomeEmailDisplay}">
        <table width="100%" border=0 cellpadding=4 cellspacing=0>
            <tr>
                <td valign=top colspan=2>
                    <br />[l]Subject[/l] : &nbsp;&nbsp;
                    <input type="text" id="welcomeemail_subject" name="welcomeemail_subject" value="{welcomeEmailSubject}" style="background-color:#FFFAEF;" size="50" /><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;">{welcomeEmailHTML}</textarea>
                        <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;">{welcomeEmailText}</textarea>
                </td>
            </tr>
        </table>
    </div>
    <br>
    <div id="packageAddonsList" >
        {packageAddons}
    </div>
    <table width="100%" border=0 cellpadding=4 cellspacing=0>
        <tr class=header>
            <td colspan=3 valign=top>
                [l]Servers[/l]
            </td>
        </tr>
    </table>
    <b>[l]Select the servers where you wish to install this package. When multiple servers are selected, packages will be installed among them in a round-robin manner, in the order established here.[/l]</b>
    <table border="0" cellpadding="0" cellspacing="0" style="margin:10px 0">
        <tr>
            <td align="left">
                <div align="left" style="width:100%">
                    <select id="serversource" name="serversource" size="10" multiple="true" style="width:140px">
                        <!-- BEGIN DYNAMIC BLOCK: serverList -->
                        <option value="{serverId}">{serverLabel}</option>
                        <!-- END DYNAMIC BLOCK: serverList -->
                    </select>
                </div>
            </td>
            <td width="50">
                <p align="center">
                    <input type="button" onclick="move('remove', 'serversource', 'servertarget')" value=" &raquo; ">
                </p>
                <p align="center">
                    <input type="button" onclick="move('add', 'serversource', 'servertarget')" value=" &laquo; ">
                </p>
            </td>
            <td>
                <div align="left">
                    <select id="servertarget" name="servertarget[]" size="10" multiple="true" style="width:140px">
                        <!-- BEGIN DYNAMIC BLOCK: serverListTarget -->
                        <option value="{serverTargetId}">{serverTargetLabel}</option>
                        <!-- END DYNAMIC BLOCK: serverListTarget -->
                    </select>
                </div>
            </td>
        </tr>
    </table>
    <table width="100%" border=0 cellpadding=4 cellspacing=0>
        <tr class=header>
            <td colspan=3 valign=top>
                [l]Server variables[/l]
            </td>
        </tr>
    </table>
    <b>[l]Enter the associated package names used in the following server plugins[/l]</b><br>
    <!-- BEGIN DYNAMIC BLOCK: serverPlugin -->
    <table width=100% cellpadding=4 cellspacing=1 border=0>
        <tr>
            <td width=75 class=formLabel nowrap align=right valign=top>
                [l]{pluginName}[/l]:
            </td>
            <td class=formField width=100% nowrap>
                <input type=text size='30' name='{inputName}' value='{inputValue}' {pluginInputVarDisabled} onkeyup="checkTemplate(form, this.value, '{pluginInternalName}')"/>&nbsp;
                <!-- BEGIN DYNAMIC BLOCK: resellerAccount -->
                <input type="checkbox" name="plugin_{pluginInternalName}_reseller" onClick="toggleDiv(this.checked, '{pluginInternalName}');" value="1" {resellerAccountChecked} />[l]Reseller account[/l]<br />
                <!-- BEGIN DYNAMIC BLOCK: resellerAclFields -->
                <div id="div_{pluginInternalName}" style="display:{aclDisplay}">
                    <br />
                    <b>[l]Resource Usage[/l]:</b>
                    <div style="margin-left: 50px">
                        <table>
                            <!-- BEGIN DYNAMIC BLOCK: resourcesList -->
                            <tr>
                                <td>
                                    {aclDesc}
                                </td>
                                <td>
                                    <input type="{aclType}" name="plugin_{pluginInternalName}_{aclName}" value="{aclValue}" {aclChecked}/>
                                </td>
                            </tr>
                            <!-- END DYNAMIC BLOCK: resourcesList -->
                        </table>
                    </div>
                    <br />
                    <b>[l]ACL Options[/l]:</b>
                    <div style="margin-left: 50px">
                        <table>
                            <!-- BEGIN DYNAMIC BLOCK: aclOption -->
                            <tr>
                                <td>{aclDesc}</td>
                                <td>
                                    <input type="checkbox" name="plugin_{pluginInternalName}_{aclName}" value="1" {aclOptionChecked}/>
                                </td>
                            </tr>
                            <!-- END DYNAMIC BLOCK: aclOption -->
                        </table>
                    </div>
                </div>
                <!-- END DYNAMIC BLOCK: resellerAclFields -->
                <!-- END DYNAMIC BLOCK: resellerAccount -->
                <!-- BEGIN DYNAMIC BLOCK: packageAttributes -->
                <input type="checkbox" name="plugin_{pluginInternalName}_package_vars" onClick="toggleDiv(this.checked, '{pluginInternalName}');" value="1" {packageAttributesChecked} />Set package attributes<br />
                <div id="div_{pluginInternalName}" style="display:{packageAttributesDivDisplay}">
                    <br /><b>[l]Package Attributes[/l]:</b>
                    <div style="margin-left: 50px">
                        <table>
                            <!-- BEGIN DYNAMIC BLOCK: packageAttributesRow -->
                                <tr id="{pluginInternalName}_package_vars_{packageAttrFieldName}" style="display:{packageAttrDisplay}">
                                    <td>
                                        {packageAttrDescription}
                                    </td>
                                    <td>
                                        <input type="{packageAttrInputType}" id="plugin_{pluginInternalName}_package_vars_{packageAttrFieldName}" name="plugin_{pluginInternalName}_package_vars_{packageAttrFieldName}" value="{packageAttrFieldValue}" {packageAttrChecked} {packageAttrDisabled}/>
                                    </td>
                                </tr>
                            <!-- END DYNAMIC BLOCK: packageAttributesRow -->
                        </table>
                    </div>
                </div>
                <input type=hidden id="{pluginInternalName}_package_vars_template" value='{packageAttrTemplate}'>
                <!-- END DYNAMIC BLOCK: packageAttributes -->
            </td>
        </tr>
    </table>
    <!-- END DYNAMIC BLOCK: serverPlugin -->
    <br>
    <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
            <TR>
                <td colspan=2>
                    <TABLE cellSpacing=0 cellPadding=0 border=0 width=100%>
                        <TBODY>
                            <TR vAlign=center class=actionfooter >
                                <TD align=left class=tight>
                                    <input type=hidden name=clienttype value="{clientType}">
                                    <input type=hidden name=planid value="{clientType}">
                                    <input type=hidden name=packageid value='{packageId}'>
                                    <input type=hidden name=action value={targetAction}>
                                    <input type=button class=button_xlarge onclick="selAll('servertarget');check(form,form.elements.length);return false;" value ="{submitButtonLabel}">
                                </TD>
                                <TD valign=bottom width=200 nowrap align=right>
                                </TD>
                            </TR>
                        </TBODY>
                    </TABLE>
                </td>
            </TR>
        </TBODY>
    </TABLE>
</form>
