<?php 
	require_once('_approot.php');	
	if(isset($_SESSION['savepcate'])) $_POST=$_SESSION['savepcate']; //saveproducts 变量

	$showstr = "视频";
	$ls_msg = $showstr."";
	$videoText=$_POST['vodioText'];
	$title_sql = "select * from ls_config";
	$title_query = $opendb->query($title_sql);
	$title_value = mysqli_fetch_assoc($title_query);
	$videoPicPath = "images/picture.gif";
	 
	
	$pos = strpos($title_value['companyName'], '-', 1);
	$subCompanyName =" ". substr($title_value['companyName'], (mb_strlen($title_value['companyName'],'utf-8') - $pos) * -1 );

?>
<!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 rel="stylesheet" href="css/style2.css" />
        <script language="JavaScript" src="js/jquery.js"></script>
		<script language="JavaScript" src="js/ls.js"></script>
		<title>无标题文档</title>
<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>
		<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
            <tr>
				<td height="18" style="border-bottom:2px solid #00c0ef; padding-bottom:5px;"><div align="center"><font color="#3c8dbc" style="font-size:16px;">添加<?=$showstr?></font></div>
				</td>
			</tr>
			<tr>
				<td height="213" valign="top"><br>
				 <form name="myform" enctype="multipart/form-data" method="post" action="savevideo.php"  >
					<input type="hidden" value="insert" name="ls">
				   <table border="0" width="98%" align="center">
						<tr>
							<td>提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
							<td align="right"><img src="images/shao.gif">&nbsp;<a href="video.php">返回</a></td>
						</tr>
				   </table>
				   <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#f0f0ee">
					 
					  <tr>
					    <td height="52" style="padding-left:20px;">类别</td>
					    <td><input type="text" name="cateName" id="cateName" style="width:40%;"    value="video"/>
                        <select name="selecttype<?=$acc_rows['ID']?>2" id="selecttype<?=$acc_rows['ID']?>"  onchange="this.form.cateName.value=this.options[this.selectedIndex].text">
                       <option value="0">选择类别：</option> 
                       <?php
					   $videoa=explode(",",$defaultvideo);
					   foreach($videoa as $av){
						   echo "<option value='".$av."'>".$av."</option>";
					   }
                       ?>

            <?php  $select_sql="select distinct cateName from ls_video where cateName!='live' and cateName!='video' and cateName!='broadcast'   order by cateName asc ";
			$select_query=$opendb->query($select_sql);
			while($select_rows2=mysqli_fetch_assoc($select_query))
		  	{
            	echo "<option value=".$select_rows2['ID'].">".$select_rows2['cateName']."</option>";
            } ?>

                    </select>
                        * 
                        <label>
                          <input type="checkbox" name="templ[]" id="templ" title="勾选，创建模板文件，为类别名.html。否则使用 video.html 和 videoshow.html" value="yes"/>
                          创建模板
                        </label></td> 
						<td width="12%" height="28">开始时间</td>
						<td width="37%" height="28"><input type="text" name="date" id="date" style="width:40%;"   value="<?=date('y-m-d H:m:s')?>"/>
						结束					    
					      <input type="text" name="endtime" id="endtime" style="width:32%;"   value=""/></td>
					  </tr>
                      <tr> 
						<td style="padding-left:20px;" width="11%">名称 *</td>
						<td width="40%"><input type="text" name="videoName" id="videoName" value="<?=$_POST['videoName']?>" style="width:90%;"  onblur="if($('#videoName').val().length >0){$('#newsTitle').val($('#videoName').val()+'<?php if(strpos($title_value['companyName'],"-")){echo $subCompanyName;}else{echo " - ".$title_value['MSN4'];}?>');
                        $('#newsKeywords').val('<?=$title_value['siteKeywords']?>');}" >
						*</td>
                        <td colspan="2" rowspan="2"><table border="0" width="98%">
						  <tr>
						    <td width="24%">标题 Title *</td>
						    <td width="76%"><input name="newsTitle" id="newsTitle" type="text" value="<?php echo $_POST['newsTitle'];?>" style="width:90%;"  /></td>
					      </tr>
						  <tr>
						    <td >关键字 Keywords</td>
						    <td><input name="newsKeywords" id="newsKeywords" type="text" value="<?php echo $_POST['newsKeywords'];?>" style="width:90%;"  /></td>
					      </tr>
						  <tr>
						    <td  >描述 Description *</td>
						    <td><textarea name="newsDescription" style="width:90%;"  rows="3" id="newsDescription"><?=$_POST['newsDescription']?> </textarea>
						    *
					        <?=$promlv>1?$seo:""?></td>
					      </tr>
					    </table></td>
                      </tr>
                      <tr > 
						<td style="padding-left:20px;" width="11%">简介</td>
						<td><textarea name="videoText" id="videoText" style="width:90%; height:80px;" onblur="if($('#videoText').val().length > 0){
                        $('#newsDescription').val(this.value);}"><?=$_POST['videoText']?></textarea></td>
                      </tr>
					  <!--<tr bgcolor="#f4f4f4"> 
						<td style="padding-left:50px;" >*缩略图：</td>
						<td style="padding-left:5px;" >
							<img src="images/picture.gif" width="<?php echo $SmallPicW ?>" height="<?php echo $SmallPicH?>" border="1" name="pic" ><br /><input type="file" name="productPic" style="width:400px;" onBlur="document.pic.src=myform.productPic.value;">
						</td>
					  </tr>-->
					</table>
                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#f0f0ee">
                      <tr> 
						<td style="padding-left:20px;" width="11%">视频链接</td>
						<td><textarea name="videoCode" style="width:95%;height:50px;" ><?php echo $_POST['videoCode'];?></textarea></td>
					  </tr>
                      <tr >
                        <td height="167" style="padding-left:20px;" >封面图片</td>
                        <td><div id="preview"><img src="<?php echo $videoPicPath ?>" width="" height="100" border="1" name="pic" /></div>
                          <input type="hidden" value="" name="videoPic1" />
                          <input type="file" name="videoPic" style="width:26%;"  onchange="document.pic.src=this.value;pictype(this);picsize(this);preview(this);"/>                          <?=$nmpic_tips?></td>
                      </tr>
                      <tr >
                        <td style="padding-left:20px;" >视频文件</td>
                        <td><input type="file" name="videoFile" style="width:16%;" />
                          <input type="hidden" value="" name="videoFile1" />
                          <span style="padding-left:10px;">
                          <?=$video_tips?>
                          </span></td>
                      </tr>
					  <tr>
						<td height="67" colspan="2" align="center"><button type="submit" value="确定">确定</button></td>
					  </tr>
					  <tr>
					    <td height="67" colspan="2" align="left" style="padding-left:20px;" ><p> 1、 视频链接优先显示，如为空则显示视频文件 <br />
					      2、
				         视频格式建议MP4 <br />
				         3、 
				         <label>创建模板 </label>
：勾选，创建模板文件，为类别名.html。否则使用 video.html 和 videoshow.html<br />
			            </p></td>
				      </tr>
			       </table>
				</form>
				</td>
			</tr>
		</table>
	</body>
</html>