<?php 
require_once 'library/top_application.php';
require_once 'library/logged.php';


//權限 
$sql_right = mysql_query('SELECT `manage_product` FROM `'.TBL_USER.'` WHERE `uid` = '.$_SESSION['Logged_Uid']);
$row_right = mysql_fetch_assoc($sql_right);

if($row_right['manage_product'] != 1){
	header("Location: listUser.php");
}


if (isset($_GET['p_id'])) {
  $id = $_GET['p_id'];
}


$sql_lang = mysql_query('SELECT `first_language` FROM `general_setting` WHERE `id` = 1');
$row_lang = mysql_fetch_assoc($sql_lang);

if ($row_lang['first_language'] == 1){
	//eng
	$lang_table = 'en_table';
	$lang_btn = 'btn_lang_switch_en';
	
	$cat_name = 'cat_name';
	$subcat_name = 'subcat_name';
} elseif ($row_lang['first_language'] == 2){
	//tc
	$lang_table = 'tc_table';
	$lang_btn = 'btn_lang_switch_tc';
	
	$cat_name = 'cp_cat_name';
	$subcat_name = 'cp_subcat_name';
} elseif ($row_lang['first_language'] == 3){
	//sc
	$lang_table = 'sc_table';
	$lang_btn = 'btn_lang_switch_sc';
	
	$cat_name = 'sp_cat_name';
	$subcat_name = 'sp_subcat_name';
}

$sql = mysql_query("SELECT * FROM `product_list` WHERE `p_id` = ".$id);
$row = mysql_fetch_assoc($sql);

$sql_cate = mysql_query('SELECT * FROM `cate` WHERE  `show` = 1  ORDER BY `rank` ASC');
$row_cate = mysql_fetch_assoc($sql_cate);

$sql_subcate = mysql_query('SELECT * FROM `subcate` WHERE  `show` = 1 AND `match_cat_id` = '.$row['p_cat_id'].' ORDER BY `rank` ASC');
$row_subcate = mysql_fetch_assoc($sql_subcate);

$sql_options = mysql_query('SELECT * FROM `options` WHERE `show` = 1 ORDER BY `rank` ASC');
$row_options = mysql_fetch_assoc($sql_options);

//en 
$sql_options_2 = mysql_query('SELECT * FROM `options` WHERE `show` = 1 ORDER BY `rank` ASC');
$row_options_2 = mysql_fetch_assoc($sql_options_2);

function showOptionType($type, $o_id, $id, $er_id, $lang){
	
	//check exist
	$sql_temp = mysql_query('SELECT * FROM `options_value` WHERE `match_p_id` = '.$id.'  AND `match_option_id` = '.$o_id);
	$row_temp = mysql_fetch_assoc($sql_temp);
	
	if($row_temp){
		switch ($type) {
			case 1:
				//文字輸入
				echo '<input type="text" value="'.$row_temp[$lang.'_value'].'" id="value_'.$row_temp['value_id'].'_'.$lang.'" onChange="editTextValue('.$row_temp['value_id'].', \''.$lang.'_value\', '.$er_id.')" style="width:200px">';
				break;
			case 2:
				//數字輸入
				echo '<input type="text" class="num_only" id="value_'.$row_temp['value_id'].'_'.$lang.'" value="'.$row_temp[$lang.'_value'].'" style="width:200px" onChange="editTextValue('.$row_temp['value_id'].', \''.$lang.'_value\', '.$er_id.')">';
				break;
			case 3:
				//下拉選單
				$sql_option = mysql_query('SELECT * FROM `options` WHERE `option_id` = '.$o_id);
				$row_option = mysql_fetch_assoc($sql_option);
				
				echo '<select id="value_'.$row_temp['value_id'].'_'.$lang.'" style="width:150px" onChange="editTextValue('.$row_temp['value_id'].', \''.$lang.'_value\', '.$er_id.')">';
				
				$a = explode(",", $row_option[$lang.'_choice_value']);
				
				foreach ($a  as $option_name) :
				
				 
				if($row_temp[$lang.'_value'] == $option_name){
					$selected = 'selected';
				} else {
					$selected = '';
				}
				echo '<option value="'.$option_name.'" '.$selected.'>'.$option_name.'</option>';
				endforeach;
	
				echo '</select>';
				break;
			case 4:
				//多項選擇
				$sql_option = mysql_query('SELECT * FROM `options` WHERE `option_id` = '.$o_id);
				$row_option = mysql_fetch_assoc($sql_option);
				
				$options = $row_temp[$lang.'_value'];
				
				$a = explode(",", $row_option[$lang.'_choice_value']);
				
				foreach ($a  as $option_name) :
				
				$find = strpos( $options , $option_name);
				
				if ($find === false) {
					$checked = '';
				} else {
					$checked = 'checked="CHECKED"';
				} 

				echo '<input type="checkbox" class="multi_'.$er_id.'" name="multi_'.$row_temp['value_id'].'_'.$lang.'[]" value="'.$option_name.'" rel="update" alt="'.$row_temp['value_id'].'" rev="'.$er_id.'" lang="'.$lang.'" '.$checked.'>'.$option_name.'&nbsp;&nbsp;&nbsp;';
				endforeach;
	
				echo '<input type="hidden" id="value_'.$row_temp['value_id'].'_'.$lang.'" />';
				break;
		}
	} else {
		switch ($type) {
			case 1:
				//文字輸入
				echo '<input type="text" value="請輸入..." style="width:200px" id="input_'.$er_id.'_'.$lang.'" onChange="addTextValue('.$id.', '.$o_id.', '.$er_id.', \''.$lang.'_value\')">';
				break;
			case 2:
				//數字輸入
				echo '<input style="width:200px" class="num_only" id="input_'.$er_id.'_'.$lang.'" onChange="addTextValue('.$id.', '.$o_id.', '.$er_id.', \''.$lang.'_value\')" value="請輸入..." >';
				break;
			case 3:
				//下拉選單
				$sql_option = mysql_query('SELECT * FROM `options` WHERE `option_id` = '.$o_id);
				$row_option = mysql_fetch_assoc($sql_option);
				
				
				echo '<select id="input_'.$er_id.'_'.$lang.'" style="width:150px" onChange="addTextValue('.$id.', '.$o_id.', '.$er_id.', \''.$lang.'_value\')">';
				echo '<option value="NULL" selected>請選擇</option>';
				
				$a = explode(",", $row_option[$lang.'_choice_value']);
	
				foreach ($a  as $option_name) : 
				echo '<option value="'.$option_name.'">'.$option_name.'</option>';
				endforeach;
	
				echo '</select>';
				break;
			case 4:
				//多項選擇
				$sql_option = mysql_query('SELECT * FROM `options` WHERE `option_id` = '.$o_id);
				$row_option = mysql_fetch_assoc($sql_option);
				
				$a = explode(",", $row_option[$lang.'_choice_value']);
	
				foreach ($a  as $option_name) : 
				echo '<input type="checkbox" class="multi_'.$er_id.'_'.$lang.'" name="multi_'.$er_id.'_'.$lang.'[]" value="'.$option_name.'" rel="insert" alt="'.$id.'" rev="'.$o_id.'" lang="'.$lang.'">'.$option_name.'&nbsp;&nbsp;&nbsp;';
				endforeach;
	
				echo '<input type="hidden" id="input_'.$er_id.'_'.$lang.'" />';
				break;
		}
	}
}
$sql_size = mysql_query('SELECT `banner_w`, `banner_h` FROM `general_setting` WHERE `id` = 1');
$row_size = mysql_fetch_assoc($sql_size);
if(!$row_size['photo_w']){
	$pic_w = DEFAULT_PHOTO_W;
} else {
	$pic_w = $row_size['photo_w'];
}
if(!$row_size['photo_h']){
	$pic_h = DEFAULT_PHOTO_H;
} else {
	$pic_h = $row_size['photo_h'];
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Artech Creative</title>

<link href="css/css_admin.css" rel="stylesheet" type="text/css">
<link href="css/anytime.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui-min.js"></script>
<script type="text/javascript" src="../js2/anytime.js"></script>
<script type="text/javascript" src="../js2/droparea.js"></script>
<script type="text/javascript" src="../js/check_function.js"></script>
<!--[if IE]>
    <script src="../js/html5.js"></script>
<![endif]--> 
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript">
$(document).ready(function(){	
	$('#<?php echo $lang_btn;?>').addClass('selected');
	$('.lang_content_table').css('display', 'none');
	$('#<?php echo $lang_table;?>').css('display', 'block');
	
	$('#btn_lang_switch_content a').click(function(){
		$('#btn_lang_switch_content a').removeClass('selected');
		$(this).addClass('selected');
	})
	
	$("#p_cat_id").change(function(){
		var cat_id = $(this).val();
		var p_id = <?php echo $id;?>;
		$.ajax({
			type: "POST",
			url: "ajax/ajax_selectmenu.php",
			data: {"p_cat_id" : cat_id, "p_id" : p_id},
			cache: false,
			success: function(html){
				$("#p_subcat_id").html(html);
				$('#er_cat').show();
				$('#er_cat').text("分類已更新");
				$('#er_cat').stop(true, true).delay(2000).fadeOut(300);
			}
		});
	});
	$("#p_subcat_id").change(function(){
		var subcat_id = $(this).val();
		var p_id = <?php echo $id;?>;
		$.ajax({
			type: "POST",
			url: "ajax/ajax_selectmenu.php",
			data: {"p_subcat_id" : subcat_id, "p_id" : p_id},
			cache: false,
			success: function(html){
				$('#er_cat').show();
				$('#er_cat').text("副分類已更新");
				$('#er_cat').stop(true, true).delay(2000).fadeOut(300);
			}
		});
	});
	
	
	$("input[name=show]").change(function(){
		var input_val = $(this).val();
		var input_id = 'show';
		var p_id = <?php echo $id;?>;
		$.ajax({
			type: "POST",
			url: "ajax/update_product.php",
			data: {"val" : input_val, "field" : input_id, "id" : <?php echo $id;?>},
			cache: false,
			success: function(html){
				$('#er_'+input_id).show();
				$('#er_'+input_id).text("更新城功");	
				$('#er_'+input_id).stop(true, true).delay(2000).fadeOut(300);
			}
		});
	});
	
	$("#p_date").AnyTime_picker({ format: "%Y-%m-%d", labelTitle: "日期"} );
	
	$('.droparea2').droparea({
		'instructions': '<br><br><br><br>drop a file or click to here',
		'init' : function(result){
		//console.log('custom init',result);
		},
		'start' : function($this){
			$('#upload_success').hide();
			$this.area.find('.error').remove(); 
		
		},
		'error' : function(result, input, area){
		$('<div class="error">').html(result.error).prependTo(area); 
		return 0;
		//console.log('custom error',result.error);
		},
		'complete' : function($this, file){
		$('#upload_success').hide();
		console.log('this',$this);
		if((/image/i).test(file.type)){
			var del_img = $this.area.find('img').attr('src');
			if(del_img){
				$.ajax({
					type: "POST",
					url: "ajax/instant_photo_function.php",
					data: {"del_path" : del_img},
					cache: false
				});
			}
			$this.area.find('img').remove();
			$this.area.append($('<img>',{
				//'src': $this.result.path + $this.result.filename + '?' + Math.random()					
				'src': $this.result.filename .replace("../../","../"),
				'width': 440
			}));
		
			var del_img = $('#showImg').attr('src');
			if(del_img){
				$.ajax({
					type: "POST",
					url: "ajax/instant_photo_function.php",
					data: {"del_path" : del_img},
					cache: false
				});
			}
			var image_name = $this.result.filename.replace("../../upload/product_images/","");
			$.ajax({
				type: "POST",
				url: "ajax/instant_photo_function.php",
				data: {"updates_product_image" : image_name, "p_id" : <?php echo $id;?>},
				cache: false,
				success: function(html){
					$('#upload_success').css('display', 'block');
				}
			});
		} 
		//console.log('custom complete',result);
		}
	});
	
	$('#btn_img_edit').click(function(){
		$(this).fadeOut(300);	
		$('#showImg').fadeOut(300);	
		$('.droparea2, #btn_img_submit').delay(300).fadeIn(300);
	})
	
	$('input[type=checkbox]').change(function(){
		
		var this_class = $(this).attr('class');
		var this_er_id = parseInt(this_class.replace('multi_',''));
		var action = $(this).attr('rel');
		
		var this_id = parseInt($(this).attr('alt'));
		var o_id = parseInt($(this).attr('rev'));
		var lang = $(this).attr('lang');
		
		if(action == 'insert'){
			insertAllMulti(this_er_id, lang)
			addTextValue(this_id, o_id, this_er_id, lang+"_value")
		} else {
			updateAllMulti(this_id, lang)
			editTextValue(this_id, lang+"_value", this_er_id)
		}
	})
});

function insertAllMulti(er_id, lang){
	var mutli_checked = []
	$("input[name='multi_"+er_id+"_"+lang+"[]']:checked").each(function(){
		mutli_checked.push($(this).val());
	});
	$('#input_'+er_id+'_'+lang).val(mutli_checked)
}

function updateAllMulti(value_id, lang){
	var mutli_checked = []
	$("input[name='multi_"+value_id+"_"+lang+"[]']:checked").each(function(){
		mutli_checked.push($(this).val());
	});
	$('#value_'+value_id+'_'+lang).val(mutli_checked)
}

function onlyText(input_id, lang){
	var input_val = $.trim($('#'+input_id).val());
	var iChars = "!#$%^@&*+=[]\\\'{}|\":<>?~_";
	var error = false;
	
	if (!input_val){
		$('#'+input_id).addClass("error");
		$('#er_'+input_id).show();
		$('#er_'+input_id).text("不能留空");	
		error = true
	}
	
	for (var i = 0; i < input_val.length; i++) {
		if (iChars.indexOf(input_val.charAt(i)) != -1) {
			$('#'+input_id).addClass("error");
			$('#er_'+input_id).show();
			$('#er_'+input_id).text("不能有符號");	
			error = true
			break;			  
		} else {
			$('#er_'+input_id).hide();
			$('#'+input_id).removeClass("error");			
		}
	}
	
	if(error == true){
		return
	} else {
		$.ajax({
			type: "POST",
			url: "ajax/update_product.php",
			data: {"val" : input_val, "field" : input_id, "id" : <?php echo $id;?>},
			cache: false,
			success: function(html){
				$('#er_'+input_id).show();
				$('#er_'+input_id).text("更新城功");	
				$('#er_'+input_id).stop(true, true).delay(2000).fadeOut(300);
			}
		});
	}
}


function changeInput(input_id){
	var input_val =  $.trim($('#'+input_id).val());
	$.ajax({
		type: "POST",
		url: "ajax/update_product.php",
		data: {"val" : input_val, "field" : input_id, "id" : <?php echo $id;?>},
		cache: false,
		success: function(html){
			$('#er_'+input_id).show();
			$('#er_'+input_id).text("更新城功");	
			$('#er_'+input_id).stop(true, true).delay(2000).fadeOut(300);
		}
	});
}

function addTextValue(id, o_id, er_id, lang){
	var this_lang = lang.substring(0, 2);
	var input_val = $.trim($('#input_'+er_id+'_'+this_lang).val());
	var iChars = "!#$%^@&*+=[]\\\'{}|\":<>?~_";
	var error = false;
	
	if (!input_val){
		$('#input_'+er_id+'_'+this_lang).addClass("error");
		$('#er_ov_'+er_id+'_'+this_lang).show();
		$('#er_ov_'+er_id+'_'+this_lang).text("不能留空");	
		error = true
	}
	
	for (var i = 0; i < input_val.length; i++) {
		if (iChars.indexOf(input_val.charAt(i)) != -1) {
			$('#input_'+er_id+'_'+this_lang).addClass("error");
			$('#er_ov_'+er_id+'_'+this_lang).show();
			$('#er_ov_'+er_id+'_'+this_lang).text("不能有符號");	
			error = true
			break;			  
		} else {
			$('#er_ov_'+er_id+'_'+this_lang).hide();
			$('#input_'+er_id+'_'+this_lang).removeClass("error");			
		}
	}
	
	if(error == true){
		return
	} else {
		$.ajax({
			type: "POST",
			url: "ajax/update_product.php",
			data: {"action" : "add_value", "m_p_id" : id, "m_o_id" : o_id, "val" : input_val, "lang" : lang, "input_id" : er_id},
			cache: false,
			success: function(html){
				$('#er_ov_'+er_id+'_'+this_lang).show();
				$('#er_ov_'+er_id+'_'+this_lang).text("屬性已新增, 2秒後更新");	
				$('#er_ov_'+er_id+'_'+this_lang).stop(true, true).delay(2000).fadeOut(300, function(){
					window.location.reload(true);
				});
			}
		});

	}
}

function editTextValue(id, lang, er_id){
	var this_lang = lang.substring(0, 2);
	var input_val = $.trim($('#value_'+id+'_'+this_lang).val());
	var iChars = "!#$%^@&*+=[]\\\'{}|\":<>?~_";
	var error = false;
	
	if (!input_val){
		$('#value_'+id+'_'+this_lang).addClass("error");
		$('#er_ov_'+er_id+'_'+this_lang).show();
		$('#er_ov_'+er_id+'_'+this_lang).text("不能留空");	
		error = true
	}
	
	for (var i = 0; i < input_val.length; i++) {
		if (iChars.indexOf(input_val.charAt(i)) != -1) {
			$('#value_'+id+'_'+this_lang).addClass("error");
			$('#er_ov_'+er_id+'_'+this_lang).show();
			$('#er_ov_'+er_id+'_'+this_lang).text("不能有符號");	
			error = true
			break;			  
		} else {
			$('#er_ov_'+er_id+'_'+this_lang).hide();
			$('#input_'+er_id+'_'+this_lang).removeClass("error");			
		}
	}
	
	if(error == true){
		return
	} else {
		$.ajax({
			type: "POST",
			url: "ajax/update_product.php",
			data: {"action" : "update_value", "val" : input_val, "lang" : lang, "v_id" : id},
			cache: false,
			success: function(html){
				$('#er_ov_'+er_id+'_'+this_lang).show();
				$('#er_ov_'+er_id+'_'+this_lang).text("更新城功");	
				$('#er_ov_'+er_id+'_'+this_lang).stop(true, true).delay(2000).fadeOut(300);
			}
		});

	}
}
function switch_lang(id){
	$('.lang_content_table:not(#'+id+'_table)').css('display', 'none');
	$('#'+id+'_table').css('display', 'block');
}
</script>
</head>
<body style="background:#fff">
<table width="940" border="0" cellspacing="0" cellpadding="0" height="100%" >
  <tr>
    <td width="460" align="center" valign="top" bgcolor="#000000" >
    <a id="btn_img_edit" >修改主照片</a>
   
    <img src="../upload/product_images/<?=$row['p_image']?>" id="showImg" style="max-height:640px; max-width:440px;">
     <input type="file" class="droparea2 spot2" name="xfile" data-post="upload/drop_Photo_product.php" data-width="<?php echo $pic_w;?>" data-height="<?php echo $pic_h;?>" data-crop="true" data-canvas="true" style="border:none"/>
     
     <div id="upload_success" style="display:none; color:#FFF"><br><strong style="color:red">Photo updated</strong>,  Click or drag photo a photo on the image to re-upload the image.</div>
    </td>
    <td align="center" valign="top" bgcolor="#FFFFFF" width="500px">
    
    <table width="470" border="0" cellspacing="2" cellpadding="2" class="content">
      <tr>
        <td width="100">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
          <td>產品編號:</td>
          <td>
          <input id="p_code" type="text" value="<?php echo $row["p_code"]; ?>" style="width:200px" onChange="onlyText('p_code')" >
            <span id="er_p_code" class="er_msg"></span>
          </td>
      </tr>
      <tr>
          <td>產品價格:</td>
          <td>
          <input id="price" type="text" value="<?php echo $row["price"]; ?>" style="width:200px" onChange="onlyText('price')" >
            <span id="er_price" class="er_msg"></span>
          </td>
      </tr>
      <tr>
          <td>上架日期:</td>
          <td>
          <input id="p_date" type="text" value="<?php echo $row["p_date"]; ?>" style="width:200px" onChange="onlyText('p_date')">
            <span id="er_p_date" class="er_msg"></span>
          </td>
      </tr>
      <tr>
          <td>產品顯示:</td>
          <td>
          <input name="show" type="radio" value="1" <?php if ($row['show'] == 1){ echo 'checked';}?>> 顯示
          <input name="show" type="radio" value="2" <?php if ($row['show'] == 2){ echo 'checked';}?>> 隱藏
            <span id="er_show" class="er_msg"></span>
            </td>
      </tr>
      <tr>
        <td>分類：</td>
        <td><select name="p_cat_id" id="p_cat_id" style="width:120px">
			  <?php do { ?>
              <option value="<?=$row_cate["cat_id"]?>" <? if($row['p_cat_id']==$row_cate["cat_id"]){ echo 'selected';}?>>
                <?=$row_cate[$cat_name]?>
              </option>
              <?php } while ($row_cate = mysql_fetch_assoc($sql_cate));?>
            </select> - 
            <select name="p_subcat_id" id="p_subcat_id" style="width:120px">
            <?php 
                
                
                 if (!$row['p_subcat_id']){
					 echo'<option selected value="NULL">請選擇副分類</option>';
				}
				 echo '<option value="NULL" selected>不需副分類</option>';
                 do{?>
                 <option value="<?=$row_subcate['subcat_id']?>" <?php if ($row_subcate['subcat_id'] == $row['p_subcat_id']){ echo 'selected';}?>><?=$row_subcate[$subcat_name]?></option>
                 <?php } while ($row_subcate = mysql_fetch_assoc($sql_subcate));?>
            </select>
            
         </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><span id="er_cat" class="er_msg"></span></td>
      </tr>
      <tr>
        <td>選擇修改語言:</td>
        <td><div id="btn_lang_switch_content"><a href="javascript:switch_lang('en')" id="btn_lang_switch_en">ENG</a> | <a href="javascript:switch_lang('tc')" id="btn_lang_switch_tc">繁</a> | <!--a href="javascript:switch_lang('sc')" id="btn_lang_switch_sc">簡</a--></div></td>
      </tr>
    </table>
    <hr style="width:470px">
      <table width="470" border="0" cellspacing="2" cellpadding="2" class="content lang_content_table" id="tc_table">
        <tr>
          <td width="100" align="left" valign="top">產品名稱:</td>
          <td>
          <input id="cp_p_name" type="text" value="<?php echo $row["cp_p_name"]; ?>" style="width:200px" onChange="onlyText('cp_p_name')">
                  <span id="er_cp_p_name" class="er_msg"></span>
          </td>
        </tr>
        <?php 
		$i = 1;
		do {?>
        <tr>
          <td align="left" valign="top"><?php echo $row_options['cp_option_name'];?>:</td>
          <td><?php showOptionType($row_options['option_type'], $row_options['option_id'], $id, $i, 'cp');?>
          <span id="er_ov_<?php echo $i;?>_cp" class="er_msg"></span>
          <?php if($row_options['cp_note']){ echo '<br>('.$row_options['cp_note'].')';}?>
          </td>
        </tr>
        <?php 
		$i++;
		} while ($row_options = mysql_fetch_assoc($sql_options));?>
        <tr>
		  <td align="left" valign="top"><p>產品簡介:<br>
            (建議最多<br>
            100字 )</p></td>
          <td valign="top"><textarea rows="5" id="cp_brief" style="width:300px" onChange="changeInput('cp_brief')"><?php echo $row["cp_brief"]; ?></textarea><br>
				<span id="er_cp_brief" class="er_msg"></span>
          </td>
        </tr>
        <tr>
          <td align="left" valign="top"><p>產品內容:<br>
            (可用 HTML)</p></td>
          <td valign="top"><textarea rows="10" id="cp_content" style="width:300px" onChange="changeInput('cp_content')"><?php echo $row["cp_content"]; ?></textarea>
            <br>
            <span id="er_cp_content" class="er_msg"></span></td>
        </tr>
      </table>
      <!---end of tc-->
      
      <table width="470" border="0" cellspacing="2" cellpadding="2" class="content lang_content_table" id="en_table">
        <tr>
          <td width="100" align="left" valign="top">Product Name:</td>
          <td>
          <input id="ep_p_name" type="text" value="<?php echo $row["ep_p_name"]; ?>" style="width:200px" onChange="onlyText('ep_p_name')">
                  <span id="er_ep_p_name" class="er_msg"></span>
          </td>
        </tr>
        <?php 
		$j = 1;
		do {?>
        <tr>
          <td align="left" valign="top"><?php echo $row_options_2['ep_option_name'];?>:</td>
          <td><?php showOptionType($row_options_2['option_type'], $row_options_2['option_id'], $id, $j, 'ep');?>
          <span id="er_ov_<?php echo $j;?>_ep" class="er_msg"></span>
          <?php if($row_options_2['ep_note']){ echo '<br>('.$row_options_2['ep_note'].')';}?>
          </td>
        </tr>
        <?php 
		$j++;
		} while ($row_options_2 = mysql_fetch_assoc($sql_options_2));?>
        <tr>
		  <td align="left" valign="top"><p>Features:<br>
            (Suggesting <br>Max. 100 words)</td>
          <td valign="top"><textarea rows="5" id="ep_brief" style="width:300px" onChange="changeInput('ep_brief')"><?php echo $row["ep_brief"]; ?></textarea><br>
				<span id="er_ep_brief" class="er_msg"></span>
          </td>
        </tr>
        <tr>
          <td align="left" valign="top"><p>Content:<br>
            (HTML enable)</p></td>
          <td valign="top"><textarea rows="10" id="ep_content" style="width:300px" onChange="changeInput('ep_content')"><?php echo $row["ep_content"]; ?></textarea>
            <br>
            <span id="er_ep_content" class="er_msg"></span></td>
        </tr>
      </table>
      <!---end of en-->
      </td>
  </tr>
</table>
<?php include 'library/bottom.php'; ?>
</body>
</html>