<?php 
	require_once('_approot.php');	
	$ls_msg="添加主题图片操作";
	$motifText=$_POST['motifText'];
?>
<!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/ls.js"></script>
		<title>无标题文档</title>
		
	</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;">添加主题图片</font></div>
				</td>
			</tr>
			<tr>
				<td height="213" valign="top"><br>
				 <form name="myform" enctype="multipart/form-data" method="post" action="savemotif.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="motif.php">返回</a></td>
						</tr>
					</table>
					<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" style="background-color: #f0f0ee;">
					 
					  <tr bgcolor="#f0f0ee">
						<td height="37" colspan="2"></td>
					  </tr>
					  <tr> 
						<td width="11%" style="padding-left:15px;" >缩略图 *</td>
						<td width="89%" style="padding-left:5px;" >
							<div id="preview"><img src="images/picture.gif" width="700" height="<?php echo $SmallPicH; ?>" border="1" name="pic" style="float:left;"></div>
							<br><br>
<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 + '" height="<?php echo $SmallPicH?>" 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>
                            <br><br></td>
					  </tr>
					  <tr> 
						<td style="padding-left:15px;" >图片</td>
						<td style="padding-left:15px;"><input type="file" name="productPic" onchange="pictype(this);picsize(this);preview(this)" />						  <span style="padding-left:5px;"><?=$nmpic_tips?></span></td>
					  </tr>
					  <tr bgcolor="#f4f4f4">
					    <td style="padding-left:15px;" >图片名称 *</td>
					    <td colspan="2" style="padding-left:15px;"><input type="text" name="motif_name"   style="width: 700px;"  value="banner-1.jpg"/></td>
				      </tr>
                      <tr> 
						<td style="padding-left:15px;" >图片链接</td>
						<td colspan="2" style="padding-left:15px;"><input type="text" name="motif_href" value="<?=$motif_rows['motif_href'] ?>" style="width: 700px;"/></td>
						</tr>
					  <tr> 
						<td style="padding-left:15px;" width="11%">介绍</td>
						<td style="padding-left:15px;">
                            <textarea name="motifText" style="width:700px; height:40px;" ><?php echo $motifText;?></textarea>
                            </td>
					  </tr>
					  <tr bgcolor="#f0f0ee"> 
						<td height="47" colspan="2" align="center"><button type="submit" value="保存">保存</button></td>
					  </tr>
					</table>
				</form>
				</td>
			</tr>
		</table>
	</body>
</html>