<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>
<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;

    // Add the controlbar
    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 validate()
    {
        var cat=document.getElementById('fk_category').value;
        if(cat == '0')
            {
                alert("Please select services categories");
                document.getElementById('fk_category').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(trim(document.getElementById('var_alias').value)== "")
//        {
//            makeLowercase();
//        }
       
//        var text1=document.getElementById('var_alias').value;
//        var len1=text1.length;
//        if(len1 == 1)
//        {
//            alert("Alias should be greater then  one character.");
//            document.getElementById('var_alias').focus();
//            return false;
//        }
//            
//        if(trim(document.getElementById('var_alias').value) != "")
//        {
//            var str=document.getElementById('var_alias').value;
//            var RE=/ /i;
//            if (str.match(RE)==' ')
//            {
//                alert("Alias is not valid. Please remove space.");
//                return false;
//            }
//        }
//       
//        if(!checkingAlias('var_alias','<?// base64_encode("services") ?>','<?// base64_encode($row['int_glcode']) ?>','<?// base64_encode('int_glcode') ?>',"pages"))
//        {
//            return false;
//        }

            
        if(document.getElementById('var_image_logo').value != "" )
        {
            if(!checkvalidImage(document.getElementById('var_image_logo').value ,new Array(".jpg",".JPG",".JPEG",".jpeg",".PNG",".png",".gif",".GIF",".bmp",".BMP")))
            {
                alert("Only .gif, .jpg, .jpeg, .png, .bmp image formats are supported.");
                document.getElementById('var_image_logo').focus();
                return false;
            }
        }
        
        if(document.getElementById('var_image').value != "" )
        {
            if(!checkvalidImage(document.getElementById('var_image').value ,new Array(".jpg",".JPG",".JPEG",".jpeg",".PNG",".png",".gif",".GIF",".bmp",".BMP")))
            {
                alert("Only .gif, .jpg, .jpeg, .png, .bmp image formats are supported.");
                document.getElementById('var_image').focus();
                return false;
            }
        }
            
        if(document.getElementById('int_displayorder').value == "")
        {
            alert("Please enter display order.");
            document.getElementById('asignbannerdisplay').style.display='';
            document.getElementById('int_displayorder').focus();
            return false;
        }
        if(document.getElementById('int_displayorder').value == 0 )
        {
            alert("Please enter proper display order.");
            document.getElementById('asignbannerdisplay').style.display='';
            document.getElementById('int_displayorder').focus();
            return false;
        }
        if(document.getElementById('int_displayorder').value < "0")
        {
            alert("Please enter proper display order.");
            expandcollapsepanel('asignbannerdisplay');
            document.getElementById('int_displayorder').focus();
            return false;
        }
        
            
        copytext();
        document.getElementById('h_save').value ='T';
           
        return true;
    }
    
    
        
        
//    function auto_alias(){
//        if(document.getElementById('var_title').value != '' && document.getElementById('var_alias').value == '')
//        {
//            makeLowercase();
//        }
//    }
            
    
//    
//    function makeLowercase()
//    {
//        var str= trim(document.getElementById('var_title').value).toLowerCase();
//        var temp = new String(str);
//        temp =  temp.replace(/[^a-z A-Z 0-9 \-]+/g,'');
//
//        var strlength = temp.length;
//        for(i=0; i < strlength; i++)
//        {
//            var alias=temp.split(' ').join('-');
//        }
//        document.getElementById('var_alias').value = alias;
//        return true;
//    }

    function limitText(limitField, limitNum) {
        if (limitField.value.length > limitNum) {
            limitField.value = limitField.value.substring(0, limitNum);
        }
    }

    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 chkObject (theVal)
    {
        if (document.getElementById(theVal) != null)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
  
   
    function fun_del_image()
    {
        var conf=confirm("The selected logo will be deleted.Press OK to confirm");
        if(conf==true)
        {
            document.getElementById('divdelbro1').innerHTML='';
            document.getElementById('hidvar_image').value='';

            alert('Logo is deleted successfully.');
        }
    }
        
    function fun_del_image1()
    {
        var conf=confirm("The selected photo will be deleted.Press OK to confirm");
        if(conf==true)
        {
            document.getElementById('divdelbro2').innerHTML='';
            document.getElementById('hidvar_image1').value='';

            alert('Photo is deleted successfully.');
        }
    }
    
     function copytext()
    {
        var abcd=CKEDITOR.instances.text_fulltext.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.text_fulltext.getData()));
      
        if(trim(document.getElementById('var_metatitle').value)=="")
        {
            document.getElementById('var_metatitle').value=trim(document.getElementById('var_title').value).substr(0, 64);
        }
        CountLeft2(document.getElementById('var_metatitle'),document.frmservices.metatitle_left,200);
        if(trim(document.getElementById('var_metakeyword').value)=="")
        {
            document.getElementById('var_metakeyword').value=maintext.substr(0, 180);
        }
        CountLeft2(document.getElementById('var_metakeyword'),document.frmservices.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.frmservices.metadescription_left,400);
    }
    function CountLeft2(field, count, max) 
    {
        // if the length of the string in the input field is greater than the max value, trim it
       
        if (field.value.length > max)
        {
            field.value = field.value.substring(0, max);
        }
        else
        {
            count.value=max - field.value.length;
        }
    }
    
        
          function checkdatediscription()
    {
        if(document.getElementById('desc1').style.display =='none' || (document.getElementById('text_fulltext').value= ""))
        {
            document.getElementById('desc1').style.display='';
        }
        else
        {
            document.getElementById('desc1').style.display='none';
        }
    }
</script>
<script>
    $(document).ready(function() {
        $("#fk_type").change(function () {
            if($(this).find("option:selected").val() == "1") {            
                $("#startdt").show();
                $("#expiredt").show();            
            }
            else
            {
                $("#startdt").hide();
                $("#expiredt").hide();
            }
        });
    });
</script>
<div id="popupContact" class="dragme"  style="z-index:9999"></div>
<div id="backgroundPopup" style="z-index: 101;"></div>
<?php
if ($_REQUEST['action'] != '') {
    $action = ucwords($_REQUEST['action']);
}
if ($_REQUEST['mode'] == 'copy') {
    $action = 'Add';
}
?>
<div class="breadcrumbs"><a href="index.php">Home </a>&nbsp;>&nbsp; <a href="index.php?module=services">Manage Services </a>&nbsp; >&nbsp; <span class="current"><?= $action ?> Service </span>  </div>
<div class="add-new-user-title">
    <h2><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/add-new-user-icon.png"><?= $action ?> Service<?php
if ($action == 'Edit' ) {
    echo ' - ' . $row['var_title'];
}
?></h2>
</div>
<?= $messagebox ?>
<?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';
}
if ($_REQUEST['action'] == 'edit') {
    $sql = "UPDATE " . DB_PREFIX . "services SET chr_read='N' where int_glcode=" . $_REQUEST['eid'];
    $servicesObj->configObj->glDbObj->query($sql);
}
?>

<form  name="frmservices"  id="frmservices" action="<?= $servicesaction ?>" method="post" onSubmit="return validate();" enctype="multipart/form-data" >
    <input name="hidvar_image" type="hidden" id="hidvar_image" value="<?= $row['var_image_logo']; ?>" />
    <input name="hidvar_image1" type="hidden" id="hidvar_image1" value="<?= $row['var_image']; ?>" />
    
    <div class="web-booking-main">
        <input type="hidden" name="old_displayorder" id="old_displayorder" value="<?= $row['int_displayorder'] ?>">

        <div class="grid-list-subtitle-bg" style="margin-top:10px; cursor:pointer" onClick="javascript:expandcollapsepanel('asignbanner');" >
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td align="left" valign="top" class="grid-td-left">Service Information</td>
                </tr>
            </table>
        </div>
        <div class="information-white-bg" id="asignbanner" >
            <div class="clear"></div>
            <div class="grid-list-inner-table-text">
                <table width="100%" border="0" cellspacing="3" cellpadding="3">

                    <tr>
                        <td width="270" align="left" valign="top" class="add-new-user-text">Service Category: <span>(required)</span> </td>
                        <td width="856" colspan="3" align="left"  valign="top">                   
                            <?php echo $title ?>
                        </td>
                    </tr>
                    
                    <tr>
                        <td align="left" valign="top" class="add-new-user-text" width="200"> Title: <span>(required)</span></td>                    
                        <td align="left" valign="top" width="856">                                                        
                            <input name="var_title" type="text"  class="add-new-user-textarea" id="var_title" value="<?=  htmlspecialchars_decode($row['var_title'])?>"  maxlength="255" style="width:362px;"   />
                        </td>
                    </tr>
                    <?php
                    /*
                    if (DISPLAY_ALIAS == 'Y' || $configObj->glSessionObj->value('admin_id') == '1') {
                        $aliasarray = explode('$$', $row['var_alias']);

                        if ($_REQUEST['mode'] == 'copy') {
                            $alias = '';
                        } else {
                            $alias = $aliasarray[0];
                        }
                        ?>
                        <tr>
                            <td align="left" valign="top" class="add-new-user-text" width="200">Alias: <span>(auto)</span>  </td>
                            <td  align="left" valign="top" width="856">
                                <input name="var_alias" type="text" class="add-new-user-textarea"   onblur="auto_alias();" id="var_alias" style="width: 362px; float:left;"  value="<?= $alias; ?>"   />
                                <div class="fl contact-comment-new position-relative mgl5 mgt5">
                                    <span class="help-icon1"></span>
                                    <div class="contact-hint fl" style="width: 478px; height: 81px; margin-left: 5px !important"><?php echo GLOBAL_ALIAS_NOTE; ?></div>
                                </div>
                                <a herf="javascript:;" style="float: left; margin: 10px 0px 0px 12px;cursor: pointer;" onclick="checkingAlias('var_alias','<?= base64_encode("services") ?>','<?= base64_encode($row['int_glcode']) ?>','<?= base64_encode('int_glcode') ?>','pages');">Check Alias</a>

                                <br/>
                                <div align="center" style="margin-top:-5px; margin-bottom:5px;"  id="aliasmsg" class=""></div>
                            </td>
                        </tr>
                    <?php } else { ?>
                        <input name="var_alias" type="hidden" class="add-new-user-textarea" id="var_alias" value="<?= $row['var_alias']; ?>" maxlength="255"  />
                    <?php } */ ?>
                    
                    <tr>                         
                        <td width="200" align="left" valign="top" class="add-new-user-text">Logo:</td>
                        <td width="856" align="left" valign="top">
                            <table>
                                <tr>
                                    <td>
                                        <input name="var_image_logo" id="var_image_logo" type="file" />
                                    </td>
                                    <td style="width:250px;">
                                        <?php
                                        $imagename = $row['var_image_logo'];
                                        $imagepath = '../upimages/services/logo/';
                                        $image = $imagepath . "" . $imagename;
                                        if ($imagename != "") {
                                            ?>
                                            <div  id="divdelbro1" style="float:right;padding-left:10px;margin-top: 0px;">
                                                <b><a onClick="return hs.expand(this);" href="<?php echo $image; ?>"><img src="<?php echo $image; ?>"  width="20" height="15" ></a></b>
                                                <a href="javascript:;" onclick="fun_del_image(<?= $row['int_glcode'] ?>,'<?= $row['var_image_logo'] ?>',1);">Delete</a>
                                            </div>
                                        <?php } ?>

                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <tr>
                        <td>&nbsp;</td>
                        <td colspan="2"><span>(Width * Height)=(<?= SERVICES_THUMB_WIDTH1 .'px'?> X <?= SERVICES_THUMB_HEIGHT1 .'px' ?>)</span>&nbsp;&nbsp;&nbsp;<span>(Only *.jpg, *.jpeg, *.png, *.gif and *.bmp Image Formats are supported)</span></td>
                    </tr>

                    </tr> 

                    <input name="h_save" type="hidden" id="h_save" value="T" />
                    </tr>
<!-------------------------------------------------------ck--------------------------------->  

                    <?php
                    if ($row['chr_displaycontent'] == 'N' && $row['int_glcode'] > 1) {
                        ?>
                        <input name="text_fulltext" type="hidden" class="add-new-user-textarea" id="text_fulltext" value="<?= $row['var_description']; ?>"/>
                        <?php
                    } else {
                        ?>
                        
                        <tr>
                            <td  align="left" valign="top" class="add-new-user-text" colspan="1"><div class="fl">Description:</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>
                                 <?php
                            if ($row['text_fulltext'] != '') {
                                $id = 'checked = "checked"';                                
                                ?>
                                <?php
                            } else {                                
                                $id='';
                            }
                            ?>
                                <input type="checkbox" id="var_desc" name="var_desc" <?php echo $id; ?> value="Y" onclick="checkdatediscription()">
                            </td>                              
                        </tr>
                       
                        <?php
                    if ($row['text_fulltext'] != '') {
                        $style = 'style="display:;"';
                    } else {
                        $style = 'style="display:none;"';
                    }
                    ?>
                        <tr id="desc1" name="desc1" <?= $style ?>>
                            
                                 <td  align="left" valign="top"colspan="4" width="" class="add-new-user-text" > 
                                <?php echo $configObj->glLibraryObj->load_ckeditor('text_fulltext', $row['text_fulltext']); ?>
                            </td>
                        </tr>
                          </table>
            </div>
        </div>
                    <?php } ?>
        <div class="clear"></div> 
<!----------------------------------------------end ckeditor------------------------>        
                </table>
            </div>
        </div>
        <div class="clear"></div>
        <?php // if ($configObj->glSessionObj->value('admin_id') == '1' || DISPLAY_ALL_SEO == 'Y') { ?>
<!--            <div class="grid-list-subtitle-bg" style="margin-top:10px; cursor:pointer;" onClick="javascript:expandcollapsepanel('asignbannerseo');" >
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td align="left" valign="top" class="grid-td-left">SEO Information</td>
                    </tr>
                </table>
            </div>
            <div class="information-white-bg" id="asignbannerseo" style="display:none;">
                <div class="clear"></div>
                <div class="grid-list-inner-table-text">
                    <?php echo $configObj->glLibraryObj->seo_textdetails($row['var_metatitle'], $row['var_metakeyword'], $row['var_metadescription']); ?>
                </div>
            </div>
            <div class="clear"></div>-->
        <?php //  } else { ?>
<!--            <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="var_metadescription" value="<?= $row['var_metadescription']; ?>" />-->
        <?php // } ?>
        <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 "Promotions are usually ordered alphabetically, but you may choose to put a number in the display order fields to change the services 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><br><br>
        <div class="add-new-user-button"></div>
    </div>
</form>