<link type="text/css" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/themes/base/jquery.ui.datepicker.css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/ui/jquery.ui.datepicker.js"></script>

<link type="text/css" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/themes/base/jquery.ui.datepicker.css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/ui/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/highslide-with-gallery.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/highslide.css" />

<script type="text/javascript">
    hs.graphicsDir = '<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/graphics/';
    hs.align = 'center';
    hs.transitions = ['expand', 'crossfade'];
    hs.wrapperClassName = 'dark borderless floating-caption';
    hs.fadeInOut = true;
    hs.dimmingOpacity = .75;
    if (hs.addSlideshow) hs.addSlideshow({
        slideshowGroup: 'group1',
        interval: 5000,
        repeat: false,
        useControls: true,
        fixedControls: 'fit',
        overlayOptions: {
            opacity: .6,
            position: 'bottom center',
            hideOnMouseOut: true
        }
    });
</script>

<script type="text/javascript">
    function LimitAttach(file,id)
    {
        allowSubmit = false;
        if (!file) return false;
        var extArray = new Array(".jpg",".jpeg",".png",".bmp",".gif");
        while (file.indexOf("\\") != -1)
            file = file.slice(file.indexOf("\\") + 1);
        ext = file.slice(file.lastIndexOf(".")).toLowerCase();
        for (var i = 0; i < extArray.length; i++) {
            if (extArray[i] == ext) { allowSubmit = true; break; }
        }
        if (allowSubmit) return true
        else
            return false;
    }
    function CountLeft2(field, count, max) 
    {
        if (field.value.length > max)
        {
            field.value = field.value.substring(0, max);
        }
        else
        {
            count.value=max - field.value.length;
        }
    }
    function copytext()
    {
        var abcd=CKEDITOR.instances.var_description.getData();
        
       var def=abcd.replace(/<a(\s[^>]*)?>.*?<\/a>/ig,"")
       var abc = def.replace(/^(\s*)|(\s*)$/g, '').replace(/\s+/g, ' ');
        var maintext=trim(removeHTMLTags(abc));
        //        var maintext=trim(removeHTMLTags(CKEDITOR.instances.var_description.getData()));
        if(trim(document.getElementById('var_metatitle').value)=="")
        {
            document.getElementById('var_metatitle').value=trim(document.getElementById('var_title').value).substr(0, 149);
        }
        CountLeft2(document.getElementById('var_metatitle'),document.frmpackage.metatitle_left,200);
        if(trim(document.getElementById('var_metakeyword').value)=='')
        {
            document.getElementById('var_metakeyword').value=trim(document.getElementById('var_title').value).substr(0, 64);
        }
        CountLeft2(document.getElementById('var_metakeyword'),document.frmpackage.metakeyword_left,400);
        if(trim(document.getElementById('var_metadescription').value)=='')
        {
            document.getElementById('var_metadescription').value=maintext.substr(0, 180);
        }
        CountLeft2(document.getElementById('var_metadescription'),document.frmpackage.metadescription_left,400);
    }
    function validate()
    {
        if(trim(document.getElementById('var_packagetype').value)== 0)
        {
            alert("Please select package type.");
            document.getElementById('var_packagetype').focus();
            return false;
        }
        if(trim(document.getElementById('var_title').value)=="")
        {
            alert("Please enter title.");
            document.getElementById('var_title').value = "";
            document.getElementById('var_title').focus();
            return false;
        }
        if(document.getElementById('var_image').value != '' && !LimitAttach(document.getElementById('var_image').value,'var_image'))
        {   
            alert('Only *.jpg, *.bmp, *.jpeg, *.png, *.gif Image Formats are supported.');
            document.getElementById('var_image').focus();
            return false;
        }
        if(trim(document.getElementById('var_price').value)=="")
        {
            alert("Please enter price.");
            document.getElementById('var_price').value = "";
            document.getElementById('var_price').focus();
            return false;
        }
        if (CKEDITOR.instances.var_description.getData().length==0)
            {
                alert('Please enter description.');
                CKEDITOR.instances.var_description.focus();
                return false;
            }
            
        else if(chkObject('int_displayorder') && document.getElementById('int_displayorder').value == "")
        {
            alert("Please enter display order.");
            document.getElementById('int_displayorder').focus();
            return false;
        }
        else if(document.getElementById('int_displayorder').value == 0)
        {
            alert("Please enter proper display order.");
            document.getElementById('int_displayorder').focus();
            return false;
        }
        copytext();
        document.getElementById('h_save').value ='T';
        return true;
    }
 
    function valButton(btn) {
        var cnt = -1;
        for (var i=btn.length-1; i > -1; i--) {
            if (btn[i].checked) {cnt = i; i = -1;}
        }
        if (cnt > -1) return btn[cnt].value;
        else return null;
    }

    function fun_del_image()
    {
        document.getElementById('divdelbro1').innerHTML='';
        document.getElementById('hidvar_image').value='';
        alert('Photo is deleted successfully.');
    }
    function chkObject (theVal)
    {
        if (document.getElementById(theVal) != null)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
</script>
<script type="text/javascript">
    hs.graphicsDir = '<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/graphics/';
    hs.align = 'center';
    hs.transitions = ['expand', 'crossfade'];
    hs.wrapperClassName = 'dark borderless floating-caption';
    hs.fadeInOut = true;
    hs.dimmingOpacity = .75;
    if (hs.addSlideshow) hs.addSlideshow({
        slideshowGroup: 'group1',
        interval: 5000,
        repeat: false,
        useControls: true,
        fixedControls: 'fit',
        overlayOptions: {
            opacity: .6,
            position: 'bottom center',
            hideOnMouseOut: true
        }
    });
</script>
<script type="text/javascript">
    $(function() {
        $('#dt_startdate').datepicker({
            changeMonth: true,
            changeYear: true,
            minDate:0,
            dateFormat:'<?php echo $date_package1; ?>',
            onSelect: function(selectedDate){
            }});
    });
<?php
if ($_REQUEST['action'] == 'edit' && $_REQUEST['preview'] == 'yes') {
    $action = 'edit';
    $actionvar_title = 'Add';
} else if ($_REQUEST['action'] == 'add') {
    $action = 'add';
    $actionvar_title = 'Add';
} else if ($_REQUEST['action'] == 'edit' && $_REQUEST['mode'] == 'copy') {
    $action = 'add';
    $actionvar_title = 'Edit';
} else {
    $action = 'edit';
    $var_title = '-' . ' ' . $row['var_title'];
    $actionvar_title = 'Edit';
}
?>
</script>
<?php if ($_REQUEST['action'] != '') $action = ucwords($_REQUEST['action']); ?>
<div class="breadcrumbs"><a href="index.php">Home </a>&nbsp;>&nbsp; <a href="index.php?module=package">Manage Packages</a>&nbsp; >&nbsp; <span class="current"><?= $action ?> Package</span>  </div>
<div class="add-new-user-title">
    <h2><img alt="add-new-listing" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/add-new-user-icon.png"> <?= $action ?> Package<? //= $pagevar_title     ?>  <?php echo $var_title; ?></h2>
</div>

<?= $messagebox ?>
<form  id="tblflash" name="frmpackage"  id="frmpackage" action="<?= $frmpackage; ?>&QT=1" method="post"  onSubmit="return validate();" enctype="multipart/form-data" >
    <input type="hidden" name="fk_modules" id="fk_modules" value="<?= $fk_modules ?>">
      <input type="hidden" name="startdateY" id="startdateY" value="<?= $startdatehidden[0] ?>">
    <input type="hidden" name="startdateM" id="startdateM" value="<?= $startdatehidden[1] ?>">
    <input type="hidden" name="startdateD" id="startdateD" value="<?= $startdatehidden[2] ?>">

    <input type="hidden" name="enddateY" id="enddateY" value="<?= $enddatehidden[0] ?>">
    <input type="hidden" name="enddateM" id="enddateM" value="<?= $enddatehidden[1] ?>">
    <input type="hidden" name="enddateD" id="enddateD" value="<?= $enddatehidden[2] ?>">
    <input type="hidden" name="dateformat" id="dateformat" value="<?= $date_special1 ?>">
    <input type="hidden" name="old_displayorder" id="old_displayorder" value="<?= $row['int_displayorder'] ?>">
    <input type="hidden" name="hidvar_image" id="hidvar_image" value="<?= $row['var_image'] ?>">
    <input name="h_save" type="hidden" id="h_save" value="T" />
    <?php
    if ($row['int_displayorder'] != '') {
        $int_disporder = $row['int_displayorder'];
    } else {
        $int_disporder = '1';
    }
    if ($row['chr_publish'] != '') {
        $hidden_chr_publish = $row['chr_publish'];
    } else {

        $hidden_chr_publish = 'Y';
    }
    ?>
    <div class="web-booking-main" id="myform">
        <div class="grid-list-subtitle-bg" style="margin-top:10px; cursor:pointer;" onClick="javascript:expandcollapsepanel('asignbanner1');" >
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td align="left" valign="top" class="grid-td-left">Package Information</td>
                </tr>
            </table>
        </div>
        <div class="information-white-bg" id="asignbanner1" >
            <div class="clear"></div>
            <div class="grid-list-inner-table-text">
                <table width="100%" border="0" cellspacing="3" cellpadding="3" >
                    <tr>
                        <td align="left" valign="top" class="add-new-user-text">Package Type: <span>(required)</span></td>
                        <td  width="856" colspan="3" align="left" valign="top" class="add-new-user-text2">
                            <table>
                                <tr>
                                    <td align="left"><span id="usercombo">
                                            <?= $cattype; ?></span></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td width="212" align="left" valign="top" class="add-new-user-text">Title: <span>(required)</span> </td>
                        <td width="856" colspan="3" align="left" valign="top">
                            <input name="var_title" type="text"  style="width: 350px;"  class="add-new-user-textarea" id="var_title" value="<?= htmlspecialchars($row['var_title']); ?>"  maxlength="255"   />
                        </td>
                    </tr>
             
                    <tr>
                        <td width="200" align="left" valign="top" class="add-new-user-text">Image: </td>
                        <td width="856" align="left" valign="top">
                            <table>
                                <tr>
                                    <td>
                                        <input name="var_image" id="var_image" type="file"/>
                                    </td>
                                    <td style="width:350px;"  id="divdelbro1">
                                        <?php
                                        $imagename = $row['var_image'];
                                        $imagepath = '../upimages/package/images/main/thumb_package_';
                                        $image = $imagepath . "" . $imagename;
                                        if ($imagename != "") {
                                            ?>
                                            <div style="float:left;">
                                                <b>
                                                    <a onClick="return hs.expand(this);" href="<?php echo $image; ?>">
                                                        <img src="<?php echo $image; ?>"  width="20" height="15" >
                                                    </a>
                                                </b>
                                                <a  onclick="fun_del_image(<?= $row['int_glcode'] ?>,'<?= $row['var_image'] ?>',1);" href="javascript:;">Delete</a>
                                            </div>
                                        <?php } ?>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><div>
                                <span>&nbsp;(Only .bmp, .gif, .jpg, .jpeg , .png image formats are supported.) </span>
                                <span id="imageSize">(Size for Photo 982 X  359 Pixels)</span>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <?php
                            $select = "select * from  ecl_general_settings";
                            $query = mysql_query($select);
                            $value = mysql_fetch_array($query);
                            $value['var_currencysymbol'];
                        ?>
                        <td width="212" align="left" valign="top" class="add-new-user-text">Price(<?php echo $value['var_currencysymbol']; ?>): <span>(required)</span> </td>
                        <td width="856" colspan="3" align="left" valign="top">
                            <input name="var_price"  type="text"  style="width: 350px;"  class="add-new-user-textarea" id="var_price" value="<?= htmlspecialchars($row['var_price']); ?>"   />
                        </td>
                    </tr>
<!--                    <tr>
                        <td width="257" align="left" valign="top" class="add-new-user-text"> Short Description: </td>
                      
                        <td width="824" align="left" valign="top">
                            <textarea id="var_short_description" name="var_short_description" class="textarea2" maxlength="500" style="width:350px;" 
                                      onKeyDown="CountLeft(this.form.var_short_description,this.form.description_left,500);"
                                      onKeyUp="CountLeft(this.form.var_short_description,this.form.description_left,500);"><?= $row['var_short_description'] ?></textarea>
                            <input disabled="disabled" type="text" name="description_left" value="<?= (500 - strlen($row['var_short_description'])) ?>" class="add-new-user-textarea" style="width:35px;"/><span valign="bottom" style="color:#000000;"> characters left</span>
                        </td>
                    </tr>-->
                    <tr id="desc" name="desc">
                        <td align="left" valign="top" class="add-new-user-text" width="230px" >
                        <div class="fl">Description:<span>(required)</span></div>    
                        <div class=" contact-comment-new position-relative mgl5 fl">
                                    <span class="help-icon1" ></span>
                                    <div class="contact-hint fl" style="width: 800px; height: 30px;"><?php echo GLOBAL_DESCRIPTION_NOTE; ?></div>
                                </div>
                        
                        </td>
                         
                        <td width="824" align="left" valign="top">
                            &nbsp;
                        </td>
                    </tr>
                 
                    <tr name="desc1" >
                       
                              <td  align="left" valign="top"colspan="4" width="" class="add-new-user-text" > 
                            <?php echo $configObj->glLibraryObj->load_ckeditor('var_description', $row['var_description']); ?>
                        </td>
                    </tr>
                  
                </table>
            </div>
        </div>
        <div class="clear"></div>
            <input name="var_metatitle" type="hidden"  id="var_metatitle" value="<?= $row['var_metatitle']; ?>"  />
            <input name="var_metakeyword" type="hidden"  id="var_metakeyword" value="<?= $row['var_metakeyword']; ?>" />
            <input type="hidden"  id="var_metadescription" name="<?= $row['var_metadescription']; ?>" />
        <div class="grid-list-subtitle-bg" style="margin-top:10px; cursor:pointer" onClick="javascript:expandcollapsepanel('asignbannerdisplay');" >
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td align="left" valign="top" class="grid-td-left">Display Information</td>
                </tr>
            </table>
        </div>
        <?php
        if ($row['int_displayorder'] != '')
            $int_disporder = $row['int_displayorder'];
        else
            $int_disporder = '1';
        ?>
        <div class="information-white-bg" id="asignbannerdisplay" style="display:none;">
            <div class="clear"></div>
            <div class="grid-list-inner-table-text">
                <table width="100%" border="0" cellspacing="3" cellpadding="3">
                    <tr>
                        <td width="167" align="left" valign="top" class="add-new-user-text">Display Order: <span>(required)</span></td>
                        <td width="724" align="left" valign="top">
                            <input name="int_displayorder" type="text" class="date-textarea fl" id="int_displayorder" value="<?= $int_disporder; ?>" maxlength="3" onkeypress="return KeycheckOnlyNumeric(event);" />
                            <div class=" contact-comment-new position-relative mgt5 mgl10 fl" >
                                <span class="help-icon1"></span>
                                <div class="contact-hint fl" style="width: 590px; height: 30px; top: 10px; left:10px;position: absolute ;" ><?php echo "Package are usually ordered alphabetically, but you may choose to put a number in the display order fields to change the promotion listing priority."; ?></div>
                            </div> 
                        </td>
                    </tr>
                    <tr>
                        <td width="167" height="30" align="left" valign="middle" class="add-new-user-text">Publish: <span>(required)</span></td>
                        <td width="724" height="30" align="left" valign="middle" class="add-new-user-text2">
                            <table width="27%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td width="22%">
                                        <?php if ($row['chr_publish'] == 'Y') { ?>
                                            <input type="radio" name="chr_publish" id="chr_publishY" value="Y" checked="checked" class="form-rediobutton "/>
                                        <?php } else { ?>
                                            <input type="radio" name="chr_publish" id="chr_publishY" value="Y"  checked="checked" class="form-rediobutton "/><?php } ?>
                                        <a href="javascript:" onClick="if(document.getElementById('chr_publishY').checked!=true) document.getElementById('chr_publishY').checked=true;" style="text-decoration:none;">
                                            Yes</a></td>
                                    <td width="20%"> <?php if ($row['chr_publish'] == 'N') { ?>
                                            <input name="chr_publish" type="radio" class="form-rediobutton " checked="checked" id="chr_publishN" value="N"    />
                                        <?php } else { ?>
                                            <input name="chr_publish" type="radio" class="form-rediobutton " id="chr_publishN" value="N"  /><?php } ?>
                                        <a href="javascript:" onClick="if(document.getElementById('chr_publishN').checked!=true) document.getElementById('chr_publishN').checked=true;" style="text-decoration:none;">
                                            No</a>
                                    </td>
                                    <td align="left" valign="middle" class="add-new-user-text2"><img width="16" height="16" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>help.png" onmouseover="showDiv(event,'dvhlpvarwebsite')" onmouseout="hidediv('dvhlpvarwebsite');" alt="">
                                        <div id="dvhlpvarwebsite" style=" z-index:99999; position: absolute;background-color: #d5ecfa;width: 400px;height:35px;padding: 10px;color:#0b336a;border: #95d0f2 2px solid;display: none;font-family:Tahoma, Arial, Verdana;font-size:13px;font-weight:bold;">Note : Please select 'Yes' if you want to display / activate this record. Otherwise please select 'NO'. </div></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <br />
        <?= $BottomSubmitButtons ?>
        <div class="clear"></div>
        <div class="add-new-user-button"></div>
    </div>
</form>