<?php
if (empty($rowxxx[CATLIMIT]))
        $rowxxx[CATLIMIT] = 3;
?><script src="../library/jumpbox.js"></script>

<script language="JavaScript">

function ChangeFieldName (val) {
        //--------------------------------------
        contents = document.FieldName.CATEGORY.value;
        contentsJB = document.FieldName.JBPOT.value;
        contentsCC = document.FieldName.CATC.value;
        //--------------------------------------

        var myString = contentsJB;
        var mySplitResult = myString.split("onClick");
        for(i = 0; i < mySplitResult.length; i++){ }
        //--------------------------------------

        if (i<="<?php echo $rowxxx[CATLIMIT]; ?>") {
                mySplitResult = val.split("|");

                if (mySplitResult[0]!="--") {

                        document.FieldName.CATC.value=i;

                        document.FieldName.CATEGORY.value=contents+mySplitResult[0];

                        document.FieldName.JBPOT.value=contentsJB+"<div id="+mySplitResult[0]+">"+mySplitResult[1]+
                        " <input type=\"button\" value=\"Delete\" onClick=\"DeleteThis('"+mySplitResult[0]+"|"+mySplitResult[1]+"')\"><br></div> ";

                        document.getElementById('elmID').innerHTML=contentsJB+"<div id="+mySplitResult[0]+">"+mySplitResult[1]+
                        " <input type=\"button\" value=\"Delete\" onClick=\"DeleteThis('"+mySplitResult[0]+"|"+mySplitResult[1]+"')\"><br></div> ";
                }
        }
        //--------------------------------------
}

function DeleteThis(s) {
        //--------------------------------------
        mySplitResult = s.split("|");
        //--------------------------------------

        var cat = document.getElementById('CATEGORY');
        cat.value = cat.value.replace(mySplitResult[0],'');

        //--------------------------------------

        var oNodeToRemove = document.getElementById("CATEGORY");
        oNodeToRemove

        //--------------------------------------

        var cat = document.getElementById('jbpot');
        cat.value = cat.value.replace('<div id='+mySplitResult[0]+'>'+mySplitResult[1]+' <input type="button" value="Delete" onClick="DeleteThis(\''+mySplitResult[0]+'|'+mySplitResult[1]+'\')"><br></div> ','');

        var oNodeToRemove = document.getElementById("jbpot");
        oNodeToRemove

        //--------------------------------------

        var ele = document.getElementById(mySplitResult[0]);
        ele.parentNode.removeChild(ele);

//--------------------------------------
}
</script>

<?php if ($_GET[d] == 1) {

          $sql            = "UPDATE PAGES SET
                IMAGENAME       = '$nil'
                WHERE ID        = '$_GET[id]'";
                $query = mysql_query($sql);

} ?>

<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
<script src="sample.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function removeSpaces(string) {
 return string.split(' ').join('');
}
</script>
<?PHP
$chars = "abcdefghijklmnopqrstuvwxyz";
$len = strlen($chars);
mt_srand((double)microtime() * 1000000);
for ($i = 0; $i < 15; $i++)
{
    $randomize = mt_rand(0, $len);
    $imagename .= $chars{$randomize};
}
?>

<?php
$SQL = "SELECT * from PAGES WHERE ID = '$_GET[id]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result );
if (empty($row[ID]) || $_GET['clone'] == 1) $qt = insert; else $qt = update;
?> 
<FORM METHOD="post" ACTION="../library/query.php?addphoto=1" name="FieldName" ENCTYPE="multipart/form-data" >
<INPUT TYPE="hidden" NAME="controller" VALUE="PAGES~<?php echo $qt; ?>~showpages~<?php if ($_GET['clone'] != 1) echo $_GET[id]; ?>">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr> 
<td class="td3" colspan="2"> <b> Add Video</b></td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr> 
<td class="td4"  width="50%"> Youtube Video URL</td>
<td class="td4"  width="50%"> 
<input type="text" name="URL" size="40"  class="textarea100" value="<?php echo $row[URL]; ?>">
</td>
</tr>
<tr> 
<td class="td4"  width="50%"> Video Title</td>
<td class="td4"  width="50%"> 
<input type="text" name="HEADER" size="40"  class="textarea100" value="<?php echo $row[HEADER]; ?>">
</td>
</tr>
<tr> 
<td class="td4"  width="50%"> Video Caption</td>
<td class="td4"  width="50%"> 
<textarea name="CAPTION" cols="40" class="textarea100" rows="5"><?php echo $row[CAPTION]; ?></textarea>
</td>
</tr>
<?php if ($row[ID] != $nil) { ?>
<?php IF ($row[IMAGENAME] != $NIL) { 

 $filename = "$svr_rootscript/product_images/$row[IMAGENAME].jpg";
        if (file_exists($filename)) $ext = jpg;

 $filename = "$svr_rootscript/product_images/$row[IMAGENAME].png";
        if (file_exists($filename)) $ext = png;
?>
<?php } ?>
<?PHP } ?>
<tr> 
<link href="sample.css" rel="stylesheet" type="text/css" />
<td class="td4" colspan="2"> 
<textarea class="ckeditor" cols="80" id="editor1" name="PAGECONTENT"><?php echo $row[PAGECONTENT]; ?></textarea>
</td>
</tr>
<tr> 
<td class="td4" width="50%">&nbsp;</td>
<td class="td4" width="50%"> 
<input type="submit" name="Submit" value="Submit" />
</td>
</tr>
</table>
<br>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr> 
<td class="td3" colspan="2"> <b> Page Settings</b></td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr> 
<td class="td4"  width="50%"> Don't Publish This Video on the Home Page</td>
<td class="td4"  width="50%"> <b> 
<input type="hidden" name="CAPTIONSHOW">
<input type="checkbox" name="CAPTIONSHOW" value="1" <?PHP if ($row[CAPTIONSHOW] == 1) { ?>checked<?PHP } ?>>
</b></td>
</tr>
<tr> 
<td class="td4"  width="50%"> Show Ads on this Video</td>
<td class="td4"  width="50%"> <b> 
<input type="hidden" name="SHOWADS">
<input type="checkbox" name="SHOWADS" value="1" <?PHP if ($row[SHOWADS] == 1) { ?>checked<?PHP } ?>>
</b></td>
</tr>
<tr> 
<td class="td4"  width="50%"> 
<div id="Layer1" style="position:absolute; width:200px; height:115px; z-index:1; visibility: hidden"> 
<textarea id="jbpot" name="JBPOT" cols="40" rows="10"><?php echo html_entity_decode($row[JBPOT]); ?></textarea>
<input type="text" name="CATEGORY" id="CATEGORY" value="<?php echo $row[CATEGORY]; ?>">
<input type="text" id = "CATC" name="CATC" value="<?php echo $row[CATC]; ?>">
</div>
<table cellpadding="0" cellspacing="0" border="0">
<tr> 
<td class="font3"> 
<div align=right class="font2" id="elmID"> 
<?php if ($_GET[qt] == update || $_GET['clone'] == '1') echo html_entity_decode($row[JBPOT]);  else { ?>
Category(s) 
<?PHP } ?>
</div>
</td>
</tr>
</table>
</td>
<td class="td4"  width="50%"> 
<table width="100%" cellspacing="0" cellpadding="0">
<tr> 
<td> 
<div id="txtHint"> 
<select name="JUMPBOX" size="8" onChange="showCategory(this.value)">
<option selected value = "<?php echo $row[CATEGORY]; ?>"> 
<?PHP ECHO $rowlookup[TITLE]; ?>
</option>
<option>- - - - - - - - - - - - - - - - - - - -</option>
<?PHP $SQLct = "SELECT * from CATEGORIES WHERE CATEGORY = '$nil' ORDER BY TITLE ASC"; $resultct = @mysql_query( $SQLct ); while( $rowct = @mysql_fetch_array( $resultct ) ) { ?>
<?PHP
        $sql_peer = "SELECT count(*) FROM CATEGORIES WHERE CATEGORY = '$rowct[ID]'";
        $res_peer = mysql_query($sql_peer);
        $row_peer = mysql_fetch_row($res_peer);
        ?>
<option <?php if (!empty($row_peer[0])) { ?>style="font-weight: bold"<?PHP } ?> value="<?php echo $rowct[ID]; ?>"> 
<?php echo $rowct[TITLE]; ?>
</option>
<?PHP } ?>
</select>
<br>
<input disabled type="button" value="Add Category" onMouseDown="ChangeFieldName('-<?PHP echo $q; ?>-|<?php echo $row_disp[TITLE]; ?>')" onClick="showCategory('')">
</div>
</td>
</tr>
</table>
</td>
</tr>
<?php if ($row[ID] != $nil) { ?>
<?php IF ($row[IMAGENAME] != $NIL) { 

 $filename = "$svr_rootscript/product_images/$row[IMAGENAME].jpg";
        if (file_exists($filename)) $ext = jpg;

 $filename = "$svr_rootscript/product_images/$row[IMAGENAME].png";
        if (file_exists($filename)) $ext = png;
?>
<?php } ?>
<?PHP } ?>
<tr> 
<td class="td4"  width="50%">&nbsp; </td>
<td class="td4"  width="50%"> 
<input type="submit" name="Submit" value="Submit" />
</td>
</tr>
</table>
<br>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr> 
<td class="td3" colspan="2"> <b> Search Engine Optimization</b></td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr> 
<td class="td4"  width="50%"> Meta Keywords</td>
<td class="td4"  width="50%"> 
<input type="text" name="METAKEY" size="40" class="textarea100" value="<?php echo $row[METAKEY]; ?>">
</td>
</tr>
<tr> 
<td class="td4"  width="50%"> Meta Description</td>
<td class="td4"  width="50%"> 
<input type="text" name="METADESC" size="40" class="textarea100" value="<?php echo $row[METADESC]; ?>">
</td>
</tr>
<tr> 
<td class="td4"> 
<input type="hidden" name="hiddenField">
</td>
<td class="td4"> 
<input type="submit" name="Submit" value="Submit" />
</td>
</tr>
</table>

</FORM>
