<?php //echo "<pre>"; print_r($_REQUEST); exit?>
<html>
<head>
<title>Add Category</title>
<head>
<script type="text/javascript">

  function validateCategory()
  {
//      if(document.getElementById("fk_categories_glcode_quick").value=="0")
//      {
//          alert("Please Select Category.")
//          document.getElementById("fk_categories_glcode_quick").focus();
//          return false;
//      }
//      else
      if(document.getElementById("var_category_quick").value=="")
      {
          alert("Please Enter Category Name.")
          document.getElementById("var_category_quick").focus();
          return false;
      }
      else
      {
             makeLowercase();
          insertCategory();       
      }
      
  }

    function insertCategory()
    {
        var postdata;

        var catalias = document.getElementById('hid_var_alias').value;
        postdata=$("#quickadd").serialize();
                $.ajax({
                type:"POST",
                url:"index.php?module=pages&action=insertpagesquick&catalias="+catalias+"&ajax=Y",
                data:postdata,
                async:false,
                success: function(data){
                   // alert(data);
                     if(data==0)
                     {
                         alert("Error in Inserting Category.");
                         return false;
                        
                     }
                     else
                     {                       
                         
                         document.getElementById("catDisplay").innerHTML=data;
                         
                     }
                }

        });   
 $('#dialog-modal').dialog('close');
 
    }


function makeLowercase()
	{
		if(document.getElementById('hid_var_alias').value=='')
		{
                        var blankspace =  document.getElementById('var_category_quick').value;

                        var remspace = blankspace.split(' ').join('-');
                        
			var str= remspace.toLowerCase();

                       // alert(str);
			var strlength = str.length;
			for( i=0 ; i < strlength ; i++ )
			{
				var alias = str.split(' ').join('-');
			}
		}

                //alert(alias);
		document.getElementById('hid_var_alias').value = alias;
                return true;
	}

</script>
</head>
 <body>

<input type="hidden" name="totaldrp" id="totaldrp" value="<?=$total?>" />
<div class="clear"></div><br/>
<div class="grid-list-inner-table-text">

<form name="quickadd" id="quickadd" action='Javascript:;' method="post" >

<input type="hidden" id="eid" name="eid" value="<?php echo $_REQUEST['eid']; ?>">
<input type="hidden" name="hid_var_alias" id="hid_var_alias" value="">

<table width="100%" border="0" cellspacing="4" cellpadding="0">

    <tr>
    <td valign="top" align="left">Select Category: <span>(required)</span></td>
     <td>

        <?php echo $pagetree_quick; ?>

     </td>
    </tr>

     <tr>
    <td valign="top" align="left">Category Name: <span>(required)</span></td>
     <td><input type="text" class="add-new-user-textarea" id="var_category_quick" name="var_category_quick" /></td>
    </tr>


<tr>
    <td valign="top" align="left">&nbsp;</td>
     <td>
     <br/>
    <input type="image" onmouseout="this.src='<?=GLOBAL_ADMIN_IMAGES_PATH?>submit-button-blue.gif'" onmouseover="this.src='<?=GLOBAL_ADMIN_IMAGES_PATH?>submit-button-blue-hover.gif'" alt="Submit" src="<?=GLOBAL_ADMIN_IMAGES_PATH?>submit-button-blue.gif" value="Submit" name="Submit" onclick="return validateCategory();">
    <a href="javascript:" onclick= $('#dialog-modal').dialog('close');>
    <img onmouseout="this.src='<?=GLOBAL_ADMIN_IMAGES_PATH?>cancel-button.jpg'" onmouseover="this.src='<?=GLOBAL_ADMIN_IMAGES_PATH?>cancel-button-hover.jpg'" alt="Cancel" src="<?=GLOBAL_ADMIN_IMAGES_PATH?>cancel-button.jpg" value="Cancel" name="Cancel" />
    </a>
     </td>
    </tr>


    </table>

</form>
<div style="height:15px; width:100%;"></div>
</div>
    
    </body>
</html>