<?php
	require_once('_approot.php');	
	
	$id=$_GET['id'];
	
	$cate_sql="select * from ls_products where ID=".$id." ";
	$cate_query=$opendb->query($cate_sql);
	$cate_rows=mysqli_fetch_assoc($cate_query);
	$ls_msg="添加产品小类";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link href="css/admin.css" rel="stylesheet" type="text/css">
	<link href="css/newui.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="css/style2.css" />
	<script type="text/javascript" src="scripts/jquery-1.4.2.min.js"></script>
	<script language="JavaScript" src="js/ls.js"></script>
	<script type="text/javascript" src="js/newui.js"></script>
	<title>添加产品小类</title>
    <link rel="stylesheet" href="kindeditor-4.1.10/themes/default/default.css" />
	<link rel="stylesheet" href="kindeditor-4.1.10/plugins/code/prettify.css" />
	<script charset="utf-8" src="kindeditor-4.1.10/kindeditor.js"></script>
	<script charset="utf-8" src="kindeditor-4.1.10/lang/zh_CN.js"></script>
	<script charset="utf-8" src="kindeditor-4.1.10/plugins/code/prettify.js"></script>
    <script>
			KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="subcateBrief"]', {
				cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
				uploadJson : 'kindeditor-4.1.10/php/upload_json.php',
				fileManagerJson : 'kindeditor-4.1.10/php/file_manager_json.php',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});

		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="subcateDetail"]', {
				cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
				uploadJson : 'kindeditor-4.1.10/php/upload_json.php',
				fileManagerJson : 'kindeditor-4.1.10/php/file_manager_json.php',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});
	</script>
    <script type="text/javascript">  
function preview(file)
{
var prevDiv = document.getElementById('preview');
if (file.files && file.files[0])
{
var reader = new FileReader();
reader.onload = function(evt){
prevDiv.innerHTML = '<img src="' + evt.target.result + '" width="<?php echo $SmallPicW ?>"  border="1" name="pic" style="float:left;" />';
}  
reader.readAsDataURL(file.files[0]);
}
else  
{
prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
}
}


//图片类型验证 ".jpg", 
function pictype(file)
{
   var fileTypes = [<?=$imagetypes2?>];
    var filePath = file.value;
    //当括号里面的值为0、空字符、false 、null 、undefined的时候就至关于false
    if(filePath){
        var isNext = false;
        var fileEnd = filePath.substring(filePath.indexOf("."));
        for (var i = 0; i < fileTypes.length; i++) {
            if (fileTypes[i] == fileEnd) {
                isNext = true;
                break;
            }
        }
        if (!isNext){
            alert('<?=$imagealert?>');
            file.value = "";
            return false;
        }
    }else {
        return false;
    }
}

//图片大小验证
function picsize(file) {
    var fileSize = 0;
    var fileMaxSize =<?=$PicSize/1000?>;// 1M
    var filePath = file.value;
    if(filePath){
        fileSize =file.files[0].size;
        var size = fileSize / 1024;
        if (size > fileMaxSize) {
            alert("<?=$imagealertsize?>");
            file.value = "";
            return false;
        }else if (size <= 0) {
            alert("图片大小不能为0！");
            file.value = "";
            return false;
        }
    }else{
        return false;
    }
}

</script>
</head>

<body>

<div class="maintitle">
	<strong>添加产品小类</strong>
</div>
<div class="mainfield">
	<form name="addsubcate" enctype="multipart/form-data" method="post" action="savesubcate.php" onSubmit="return Checksubaddcate()"  >
	 
	  <input type="hidden" value="insert" name="ls">
	  <input type="hidden" value="<?php echo $id ;?>" name="subcateID">
	  <input type="hidden" name="ChangecatePagePic" value="no">
	 
	<table width="98%" border="0" cellpadding="" cellspacing="0" style="background-color: #f0f0ee;">
	  <tr>
	    <td width="3%" height="34" valign="top">&nbsp;</td>
	    <td width="47%"  >提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
	    <td align="right" style="padding-right:40px;"><img src="images/shao.gif" alt="" />&nbsp;<a href="cate.php">返回</a></td>
      </tr>
	  <tr>
	    <td height="315" colspan="2" valign="top"><fieldset class="infofield" >
	      <table width="100%" border="0" cellspacing="8" cellpadding="">
	        <tr>
	          <td width="17%" height="73" align="right"><span class="gcatelabelnormal">中类名 *</span></td>
	          <td width="83%" valign="top"><span class="">
	            <input type="text" name="midcateName" value="<?php echo $cate_rows['midcateName']?>" readonly class="midcateinputboxnoblank" >
	            </span><br /></td>
	          </tr>
	        <tr>
	          <td height="68" align="right"><span class="gcatelabelnormal">小类名 *</span></td>
	          <td align="left" valign="top"><input type="text" name="subcateName" value="<?php echo $_POST['subcateName'];?>" class="midcateinputboxnoblank" onMouseOver="ibov(this);" onMouseOut="ibou(this);" onKeyUp="addsubcate.subcateFolders.value=addsubcate.cateTitle.value=addsubcate.cateKeywords.value=this.value;this.value=this.value.replace(/&/g, '');"  onblur="addsubcate.cateTitle.value=this.value+' - <?=$config_row['companyNameCn']?>';"></td>
	          </tr>
	        <tr>
	          <td height="71" align="right"><span class="gcatelabelnormal">目录名</span><br /></td>
	          <td align="left" valign="top"><span class="">
	            <input name="subcateFolders" type="text" size="20"  onclick="this.value=subcateName.value" class="midcateinputboxnoblank" onMouseOver="ibov(this);" onMouseOut="ibou(this);" >
	            </span></td>
	          </tr>
	        <tr>
	          <td align="right" style="padding-right:18px;">&nbsp;</td>
	          <td align="left" style="padding-right:;"><?=$cate_tips?>
	            <input type="hidden" name="midcate_id" value="<?php echo $cate_rows['ID']?>" />
	          </tr>
	        </table>
	      </fieldset></td>
	    <td width="50%" valign="top"><fieldset class="infofield"  >
	      <table width="94%" border="0" cellspacing="8" cellpadding="0">
	        <tr>
	          <td align="right" ><br />
	            标题<br />
	            Keywords</td>
	          <td><textarea name="cateTitle" class="inputareashortnoblank" onmouseover="ibov(this);" onmouseout="ibou(this);"  width="100%" ><?php echo $_POST['cateTitle'];?></textarea></td>
	          </tr>
	        <tr>
	          <td width="21%" align="right" ><br />
	            关键字<br />
	            Keywords</td>
	          <td width="79%"><textarea name="cateKeywords" class="inputareashortnoblank" onmouseover="ibov(this);" onmouseout="ibou(this);"  width="100%" ><?php echo $_POST['cateKeywords'];?></textarea></td>
	          </tr>
	        <tr>
	          <td align="right">描述<br />
	            Description *</td>
	          <td><textarea name="cateDescription" class="inputareashortnoblank" onmouseover="ibov(this);" onmouseout="ibou(this);" onblur="addmidcate.midcateBrief.value=(addmidcate.midcateBrief.value.length==0) ? this.value : addmidcate.midcateBrief.value"  width="100%" ><?php echo $_POST['cateDescription'];?></textarea><br/><?=$promlv>1?$seo:""?>
	            </textarea></td>
	          </tr>
	        <tr>
	          <td height="37" colspan="2" align="right" style="padding-top:10px;" ><button name="submit2" type="submit" value="确定" class="ifsinglebutton">确定</button></td>
	          </tr>
	        </table>
	      </fieldset></td>
      </tr>
	  <tr>
	    <td height="325" colspan="4"><table width="100%" border="0" cellspacing="8">
	      <tr>
	        <td width="9%" align="right"> 简介 </td>
	        <td colspan="2"><textarea name="subcateBrief" rows="6" class="inputareabigbrief" onmouseover="ibov(this);" onmouseout="ibou(this);" onblur="addsubcate.cateDescription.value=(addsubcate.cateDescription.value.length==0) ? this.value : addsubcate.cateDescription.value" style="width:98%;"><?php echo $_POST['subcateBrief'];?></textarea>
	          <?=$promlv>1?$brief_tips:""?></td>
	        </tr>
	      <tr>
	        <td height="436" align="right"> 详细 </td>
	        <td colspan="2"><span class="lsgcateeditorarea" style="margin-top:10px; clear:both;"><span class="lsgcateeditorarea" style="margin-top:10px; clear:both;">
	          <textarea name="subcateDetail" style="width:98%;height:480px;visibility:hidden;"><?php echo $_POST['subcateDetail'];?></textarea>
	          </span><span class="gcateprompt2">
	          <?=$catedetails_tips?>
	          </span></span></td>
	        </tr>
	      <tr>
	        <td colspan="3" align="right"><button name="submit2" type="submit" value="确定" class="ifsinglebutton">确定</button></td>
	        </tr>
	      <tr>
	        <td height="38%" align="right"> 代表图 Icon</span></td>
	        <td width="22%"><input type="file" name="subcateIconPic" onblur="document.Iconpic.src=addcate.cateIconPic.value;pictype(this);picsize(this);preview(this);"  onmouseover="ibov(this);" onmouseout="ibou(this);" />
	          </span></td>
	        <td width="69%"><span class="gcatepicleft"><img src="images/picture.gif" alt="" name="Iconpic"   width="100%" border="1" id="Iconpic" /></span></td>
	        </tr>
	      <tr>
	        <td height="70" align="right">主题图 Banner</td>
	        <td><span  >
	          <input type="file" name="productPic" onchange="addsubcate.ChangecatePagePic.value='yes';pictype(this);picsize(this);preview(this);"   onmouseover="ibov(this);" onmouseout="ibou(this);" />
	          </span></td>
	        <td><img src="images/picture.gif" alt="" name="pic" width="97%" height="106" border="1" id="pic" /><br/><?=$nmpic_tips?></td>
	        </tr>
	      <tr>
	        <td height="24">&nbsp;</td>
	        <td>&nbsp;</td>
	        <td>宽度
	          <input type="text" class="ifinfoinputvshort" value="" name="width" onblur="document.pic.width=document.addcate.width.value;" onmouseover="ibov(this);" onmouseout="ibou(this);" />
	          px &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 高度
	          <input type="text" class="ifinfoinputvshort" value="" name="height" onblur="document.pic.height=document.addcate.height.value;" onmouseover="ibov(this);" onmouseout="ibou(this);" />
	          px </td>
	        </tr>
	      </table></td>
      </tr>
	  <script> keypress2();</script>
	  <?php file_exists("widget/ls_language.php")?include '<tr><td colspan="4">'."widget/ls_language.php".'</td></tr>':"" ?>
	  </table>
	</form>
</div>

</body>
</html>