<?php
/*
	[Phpup.Net!] (C)2009-2011 Phpup.net.
	This is NOT a freeware, use is subject to license terms

	$Id: admin.class.php 2010-08-24 10:42 $
*/

if(!defined('IN_PHPUP')) {
	exit('Access Denied');
}
?>
<?php include ROOT_PATH.'/views/admin/header.php';?>
<body>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
	function change_img(oldimg,id)
	{
		url="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=imgmodify&oldimg="+oldimg+"&obj="+id;
		$.get(url, function(data){
			$('#img_area').html(data);
			$('#img_area').show();
		}); 
	}

	function parseMyImgData(data,doid)
	{
		$('#'+doid).val(data);
		if($('#adtype').val()=='image')
		{
			$('#'+doid+'_temp').attr('src',data);
		}
		else if($('#adtype').val()=='flash')
		{
			$('#swfdiv').html('<embed src="'+data+'" width="100px"></embed>');
		}
		$('#img_area').hide();
	}
	function inserthtml(obj)
	{
		$('#content').html($('#content').html()+'<img src="'+$(obj).attr('src')+'"/>');
	}


	function checkform(theform)
	{
		if($('#adtype').val()=='html')
		{
			if($('#content').val()=='')
			{
				alert('请填写内容');
				return false;
			}
		}
		else
		{
			if($('#adindex').val()=='')
			{
				alert('请填写唯一标示');
				return false;
			}

			if($('#title').val()=='')
			{
				alert('请填写标题');
				return false;
			}


			if($('#url').val()=='')
			{
				alert('请填写链接');
				return false;
			}

			if($('#info').val()=='')
			{
				alert('请填写说明');
				return false;
			}
			
			if($('#width').val()=='')
			{
				alert('请填写广告的宽');
				return false;
			}
			
			if($('#height').val()=='')
			{
				alert('请填写广告的高');
				return false;
			}

			if($('#oldurl').val()=='')
			{
				alert('请填写链接');
				return false;
			}

			if($('#oldinfo').val()=='')
			{
				alert('请填写说明');
				return false;
			}
			
			if($('#oldwidth').val()=='')
			{
				alert('请填写广告的宽');
				return false;
			}
			
			if($('#oldheight').val()=='')
			{
				alert('请填写广告的高');
				return false;
			}
		}

	}


//-->
</SCRIPT>
<div class="subnav">
	<div class="content-menu ib-a blue line-x">
	<a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=ad" class="add fb"><em>广告管理</em></a>
	</div>
</div>
<div id="man_zone">
<FORM METHOD="POST" ACTION="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=admodify" enctype="multipart/form-data" onsubmit="return checkform(this);"  >
<INPUT TYPE="hidden" NAME="updateid" value="<?php echo $ad['id'];?>">
<INPUT TYPE="hidden" NAME="commit" value="1">
<table width="100%" border="0" align="center"  cellpadding="3" cellspacing="1" class="table_form">
<tbody>
<tr>
<td width="100px" class="left_title_1"><span class="left-title">广告类型：</span></td>
<td>
<SELECT NAME="adtype" id="adtype" onchange="changead(this.value);">
	<OPTION VALUE="image">图片
	<OPTION VALUE="flash">flash
	<option value="html">HTML代码
</SELECT>
</td>
</tr>
<tr>
<td width="100px" class="left_title_1"><span class="left-title">唯一标志符：</span></td>
<td><INPUT TYPE="text" class="input-text" NAME="adindex"  id="adindex"  value="<?php echo $ad['ad2'][1];?>"></td>
</tr>
<tr>
<td width="100px" class="left_title_1"><span class="left-title">标题：</span></td>
<td><INPUT TYPE="text" class="input-text" NAME="title"  id="title"  value="<?php echo $ad['title'];?>"></td>
</tr>
<tr id="thumbad">
<td width="100px" class="left_title_1" valign="top"><span class="left-title">图片：</span><INPUT TYPE="button" VALUE="增加" ONCLICK="addthumb();" class="button"></td>
<td>
<div class="table-list">
<TABLE width="800px">
<thead>
<TR id="thumblist">
	<Th style="text-align:center;">文件</Th>
	<Th style="text-align:center;">链接</Th>
	<Th style="text-align:center;">说明</Th>
	<Th style="text-align:center;">宽</Th>
	<Th style="text-align:center;">高</Th>
</TR>
</thead>
<tbody>
<TR>
	<TD><INPUT TYPE="file" NAME="thumb[]"></TD>
	<TD align="center"><INPUT TYPE="text" NAME="url[]" id="url"  size="15" class="input-text"></TD>
	<TD align="center"><INPUT TYPE="text" NAME="info[]"  id="info"  size="15" class="input-text"></TD>
	<TD align="center"><INPUT TYPE="text" NAME="width[]"  id="width"  size="10" class="input-text"></TD>
	<TD align="center"><INPUT TYPE="text" NAME="height[]"  id="height" size="10" class="input-text"></TD>
</TR>
<?php foreach($ad['content'] as $k=>$v){?>
<TR id="temp<?php echo $k;?>">
	<TD><div id="swfdiv">
	<?php if($ad['ad2'][0]=='flash'){?>
	<embed src="<?php echo $v['img'];?>" width="100px"></embed>
	<?php } else{?>
	<img src="<?php echo $v['img'];?>" id="oldthumb<?php echo $k;?>_temp" width="220px"/>
	<?php }?>
	</div>
	<INPUT TYPE="hidden" value="<?php echo $v['img'];?>" name="oldthumb[]" id="oldthumb<?php echo $k;?>">
	</TD>
	<TD><INPUT TYPE="text" NAME="oldurl[]"  id="oldurl"  size="15" class="input-text" value="<?php echo $v['url'];?>"></TD>
	<TD><INPUT TYPE="text" NAME="oldinfo[]" id="oldinfo"   size="15" class="input-text" value="<?php echo $v['info'];?>"></TD>
	<TD><INPUT TYPE="text" NAME="oldwidth[]" id="oldwidth"  size="10" class="input-text" value="<?php echo $v['width'];?>"></TD>
	<TD><INPUT TYPE="text" NAME="oldheight[]" id="oldheight"  size="10" class="input-text" value="<?php echo $v['height'];?>"><INPUT TYPE="button" VALUE="删除" ONCLICK="$('#temp<?php echo $k;?>').remove();"></TD>
</TR>
<?php }?>
</tbody>
</TABLE>
</div>
</td>
</tr>
<tr id="htmlad" style="display:none;">
<td width="100px" class="left_title_1"><span class="left-title">内容：</span></td>
<td>
<textarea NAME="content"  id="content" style="width:500px;height:100px;"><?php echo $ad['content'];?></textarea></td>
</tr>
<td colspan="2" align="center"><INPUT TYPE="submit" value="提交" class="button"></td>
</tr>
<tr><td colspan="2"><DIV ID="tempimg"></DIV></td>
</tbody>
</tr>
</table>
</FORM>

</div>

<SCRIPT LANGUAGE="JavaScript">
<!--
	var k=0;
	window.onload=function()
	{
		var madtype="<?php echo $ad['ad2'][0];?>";
		$('#adtype').children().each(function(i){if(madtype==$(this).val()){$(this).attr('selected',true)}});
		changead(madtype);
	}
	function changead(madtype)
	{
		
		switch(madtype)
		{
			case 'html':
				$('#htmlad').show();
				$('#thumbad').hide();
			break;
			case 'image':
				$('#thumbad').show();
				$('#htmlad').hide();
			break;
			default:
				$('#thumbad').show();
				$('#htmlad').hide();
			break;
		}
	}
	function addthumb()
	{
		var data='<TR id="atemp'+k+'"><TD style="text-align:center;"><INPUT TYPE="file" NAME="thumb[]"></TD><TD style="text-align:center;"><INPUT TYPE="text" NAME="url[]" size="15" class="input-text"></TD><TD style="text-align:center;"><INPUT TYPE="text" NAME="info[]" size="15" class="input-text"></TD><TD style="text-align:center;"><INPUT TYPE="text" NAME="width[]" size="10" class="input-text"></TD><TD style="text-align:center;"><INPUT TYPE="text" NAME="height[]" size="10" class="input-text"><INPUT TYPE="button" VALUE="删除" ONCLICK="$(\'#atemp'+k+'\').remove();"></TD></TR>';
		k++;
		$('#thumblist').after(data);
	}
//-->
</SCRIPT>
<DIV id="img_area" style="display:none;border:2px solid #ccc;width:330px;position:absolute;left:330px;top:60px;height:30px;background:#fff;z-index:10px;padding:10px;">
</DIV>

</body>
</html>