<style type="text/css">
<!--
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
-->
</style>
<script type="text/javascript" src="js/thickbox.js"></script>
<link rel="stylesheet" href="css/thickbox.css" type="text/css" media="screen" />

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
        <td width="38" align="left"><img src="img/showlist.jpg" width="38" height="35" /></td>
        <td width="323" align="left"><span class="head">Contact us</span></td>
    
    <? if($_GET["action"]==""){?>
	<!--
    <form action="index.php?option=proticelist" method="post">
    <td align="right"><span class="search">
      <label for="keyword"></label>
      <input type="text" name="keyword" id="keyword" />
      &nbsp; 
      <label for="imageField"></label>
      <input type="image" name="imageField" id="imageField" width="20" height="20" src="images/search.jpeg" />
    </span></td>
    </form>-->
        <? }?>
  </tr>
    </table>
<br />
<?PHP
$option=$_GET["option"];
switch($_GET["action"])
{
case"addform":{
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
        <td width="7" height="5" valign="top"><img src="images/border_01.jpg" width="7" height="5" /></td>
        <td background="images/border_02.jpg" style="background-repeat:repeat-x"></td>
        <td width="6" height="5" valign="top"><img src="images/border_03.jpg" width="6" height="5" /></td>
      </tr>
      <tr>
        <td background="images/border_04.jpg" style="background-repeat:repeat-y"></td>
        <td align="center" valign="top">
		
<form action="index.php?postdb=cont_db" method="post" enctype="multipart/form-data">        
        <table width="85%" border="0" align="center" cellpadding="2" cellspacing="0" class="font">
  <tr>
    <th colspan="2" scope="col">เพิ่มสถานที่ติดต่อใหม่</th>
  </tr>
  <tr>
    <td width="25%"><strong>ชื่อสถานที่ติดต่อ : </strong></td>
    <td width="75%"><input name="cont_name" type="text" id="name" size="50" class="required"></td>
  </tr>
  <tr>
    <td width="25%"><strong>contact name : </strong></td>
    <td width="75%"><input name="cont_name_eng" type="text" value="<?=$ROW["pro_name_eng"]?>" id="name" size="50" class="required"></td>
  </tr>
   <tr>
    <td width="25%"><strong>รายละเอียดที่ติดต่อ: </strong><br> (ไทย)</td>
    <td width="75%"><textarea name="cont_des" id="pro_longtdes"></textarea>
   <?=editor("cont_des");?>
	</td>
	</tr>
	   <tr>
    <td width="25%"><strong>Contact Description: </strong><br> (English)</td>
    <td width="75%"><textarea name="cont_des_eng" id="pro_longtdes_eng"></textarea>
   <?=editor("cont_des_eng");?>
	</td>
	</tr>
    <td width="25%"><strong>ภาพแผนที่: </strong></td>
    <td width="75%"><input type="file" name="cont_thumb" id="prot_thumb" /><i>66x49 px</i></td>
  </tr>
  </tr>
    <td width="25%"><strong>maps: </strong></td>
    <td width="75%"><input type="file" name="cont_thumb_eng" id="prot_thumb_eng" /><i>66x49 px</i></td>
  </tr>
  </tr>
  <tr>
    <td><input name="subsection" type="hidden"  value="contact_db"></td>
    <td><input name="Submit" type="submit" value="Save">
       <input name="input2" type="button" onclick="window.location='index.php?option=<?=$option?>'" value="Cancle" class="button" /></td>
  </tr>
</table>
</form>
</td>
        <td background="images/border_06.jpg" style="background-repeat:repeat-y"></td>
      </tr>
      <tr>
        <td width="7" height="7" valign="top"><img src="images/border_07.jpg" width="7" height="7" /></td>
        <td background="images/border_08.jpg" style="background-repeat:repeat-x">&nbsp;</td>
        <td width="6" height="7" valign="top"><img src="images/border_09.jpg" width="6" height="7" /></td>
      </tr>
    </table>

<? break;}case"editpicture":{?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
        <td width="7" height="5" valign="top"><img src="images/border_01.jpg" width="7" height="5" /></td>
        <td background="images/border_02.jpg" style="background-repeat:repeat-x"></td>
        <td width="6" height="5" valign="top"><img src="images/border_03.jpg" width="6" height="5" /></td>
      </tr>
      <tr>
        <td background="images/border_04.jpg" style="background-repeat:repeat-y"></td>
        <td align="center" valign="top">
		<p align="center" class="user">ท่านกำลังแก้ไขไฟล์ภาพ  <?=$_GET["type"]?> ควรมีขนาด <?=$_GET["size"]?><br> เมื่อแก้ไขเสร็จสิ้้น ต้องกด Save ด้วย <a href = "javascript:history.go(-1)";>กลับไปแก้ไขสถานที่ติดต่อ</a></p>
 <iframe src="imageshub/?imageName=<?=$_GET["picture"]?>" width="700" height="650" style="border:none">
</iframe>
</td>
        <td background="images/border_06.jpg" style="background-repeat:repeat-y"></td>
      </tr>
      <tr>
        <td width="7" height="7" valign="top"><img src="images/border_07.jpg" width="7" height="7" /></td>
        <td background="images/border_08.jpg" style="background-repeat:repeat-x">&nbsp;</td>
        <td width="6" height="7" valign="top"><img src="images/border_09.jpg" width="6" height="7" /></td>
      </tr>
    </table>

<? break;}case"editcontdetail":{ 
 $sql="SELECT * FROM sbs_contact WHERE cont_id='".$_GET["itemid"]."'";
 $result=mysql_query($sql) or die ($sql);
 $ROW=mysql_fetch_array($result);
?>
<form action="index.php?postdb=cont_edit_db" method="post" enctype="multipart/form-data">        
        <table width="85%" border="0" align="center" cellpadding="2" cellspacing="0" class="font">
  <tr>
    <th colspan="2" scope="col">แก้ไขสถานที่ติดต่อ</th>
  </tr>
  <tr>
    <td width="25%"><strong>Contact name : </strong></td>
    <td width="75%"><input name="cont_name_eng" type="text" value="<?=$ROW["cont_name_eng"]?>" id="name" size="50" class="required"></td>
  </tr>
    <td width="25%"><strong>Contact Description: </strong><br> (English)</td>
    <td width="75%"><textarea name="cont_des_eng" id="cont_des_eng"><?=$ROW["cont_des_eng"]?></textarea>
   <?=editor("cont_des_eng");?>
	</td>
	</tr>
	 <!--tr>
    <td width="25%"><strong>Map: </strong></td>
    <td width="75%">
		<? if($ROW["cont_thumb_eng"] !=="")
	{
	echo "<IMG SRC=\"../datacenter/".$ROW["cont_thumb_eng"]."\" height=\"75\">";
	echo "<BR>";
	}
	?>
	<input type="file" name="cont_thumb_eng" id="cont_thumb_eng" /></td>
    </tr-->
     <? if($_GET["itemid"]=="10"){?>
	 <!--tr>
    <td width="25%"><strong>Google maps: </strong></td>
    <td width="75%">
	<br><br>
    <a href="googlemaps.php?mapcase=<?=$ROW["cont_id"]?>&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=600&width=800&modal=true" title="" class="thickbox">Click here to point</a>
	<br><br>
	</td>
   </tr-->
 <?}?>
  <tr>
    <td><input name="cont_id" type="hidden"  value="<?=base64_encode($ROW["cont_id"])?>">
	<input name="walkto" type="hidden"  value="index.php?option=contactus&action=editcontdetail&itemid=<?=$ROW["cont_id"]?>">
	</td>
    <td><input name="Submit" type="submit" value="Save">
       <input name="input2" type="button" onclick="window.location='index.php?option=<?=$option?>'" value="Cancle" class="button" /></td>
  </tr>
</table>
</form>
</td>
        <td background="images/border_06.jpg" style="background-repeat:repeat-y"></td>
      </tr>
      <tr>
        <td width="7" height="7" valign="top"><img src="images/border_07.jpg" width="7" height="7" /></td>
        <td background="images/border_08.jpg" style="background-repeat:repeat-x">&nbsp;</td>
        <td width="6" height="7" valign="top"><img src="images/border_09.jpg" width="6" height="7" /></td>
      </tr>
    </table>
<? break;}default:{ ?>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
        <td width="7" height="5" valign="top"><img src="images/border_01.jpg" width="7" height="5" /></td>
        <td background="images/border_02.jpg" style="background-repeat:repeat-x"></td>
        <td width="6" height="5" valign="top"><img src="images/border_03.jpg" width="6" height="5" /></td>
      </tr>
      <tr>
        <td background="images/border_04.jpg" style="background-repeat:repeat-y"></td>
        <td>
                  <?PHP

$limit="20";
if(empty($_GET["page"])) {
	$page = 1;
} else {
	$page = $_GET["page"];
}	

$keyword=$_POST["keyword"];
if($_POST["keyword"]==""){
$keyword=$_GET["keyword"];
}


if($keyword!=""){	 		
$sql="select  * from sbs_contact  where cont_name like '%".$keyword."%' order by cont_id desc";
} else{
$sql="select  * from sbs_contact  order by cont_id desc";
}

$total = mysql_num_rows(mysql_query($sql));
$total=$total;
if($total % $limit) {
	$total_page = floor($total / $limit) + 1;	
} else {
	$total_page = floor($total / $limit);	
}
$start = (($page - 1) * $limit);
$sql = $sql." limit $start, $limit";
$query =mysql_query($sql)or die($sql);
$n = 1;
?>
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
            <td height="5" colspan="4" align="center" class="font"></td>
            </tr>
         <tr>
            <td height="20" colspan="4" align="right" class="font"><table width="300" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="right"><span class="font-menu">Page&nbsp;                    <?
$end_page = 2;
$start = $page - $end_page;
if($page <= $end_page) {
	$start = 1;
}
$stop = $page + $end_page;
if($stop >= $total_page) {
	$stop = $total_page;
}
for($i = $start; $i <= $stop; $i ++) {
	if($i == $page) {
?>
                    <span class='page-numbers current'>
                      [<?=$page?>]                      </span>
                    <? } else { ?>
<a class='page-numbers' href='index.php?option=<?=$option?>&page=<?=$i?>&keyword=<?=$keyword?>'>&nbsp;<?=$i?>&nbsp;</a><? }}?></span></td>
                <td width="5" align="right"><span class="font-menu"><!--<a href="index.php?option=<?=$option?>&action=addform"><img src="img/add.jpg" width="70" height="26" border="0" /></a>--></span></td>
              </tr>
            </table></td>
            </tr>
          <tr>
            <td height="10" colspan="3" align="center" class="font"></td>
            </tr>
          <tr>
            <td width="5%" height="30" align="center" bgcolor="#BDD5F6" class="font"><strong>List</strong></td>
            <td align="center" bgcolor="#BDD5F6" class="font"><strong>Name</strong></td>
            <td width="10%" align="center" bgcolor="#BDD5F6" class="font"><strong>Process</strong></td>
        </tr>
<?
$start = (($page - 1) * $limit);
$bg="#FFD79F";
while($Row = mysql_fetch_array($query)) {
	if($bg=="#FFD79F"){
				$bg="#EDF4FE";
			}else if($bg=="#EDF4FE"){
				$bg="#FFD79F";
			}	
			
	
				?>
          <tr class="font">
            <td align="center" bgcolor="<?=$bg;?>"><?=$start+$n++;?>.</td>
            <td bgcolor="<?=$bg;?>"> &nbsp;<?=$Row["cont_name_eng"]?></td>
            <td align="center" bgcolor="<?=$bg;?>"><img src="images/faqseditconticon.gif" width="13" height="13" border="0"  style="cursor:pointer" onClick="window.location='index.php?option=contactus&action=editcontdetail&itemid=<?=$Row["cont_id"]?>'">&nbsp;
				
			</td>
          </tr>
          <? }?>
                    <tr>
            <td height="10" colspan="3" align="center" class="font"></td>
            </tr>
          <tr>
            <td colspan="3" align="center" class="font"><span class="font-menu">      <? if($page <= $total_page) {
					 $prevpage = $page - 1; 
					 if($prevpage < "1")
						$prevpage="1";
					 ?>
      <a href='index.php?option=<?=$option?>&page=1&keyword=<?=$keyword?>'><span class="hproduct">First</span></a>&nbsp;  <a href='index.php?option=<?=$option?>&page=<?=$prevpage?>&keyword=<?=$keyword?>'><span class="hproduct">Back</span></a>
      <? } ?>&nbsp;Page&nbsp;             
                    <?
$end_page = 2;
$start = $page - $end_page;
if($page <= $end_page) {
	$start = 1;
}
$stop = $page + $end_page;
if($stop >= $total_page) {
	$stop = $total_page;
}
for($i = $start; $i <= $stop; $i ++) {
	if($i == $page) {
?>
                    <span class='page-numbers current'>
                      [<?=$page?>]                      </span>
                    <? } else { ?>
<a class='page-numbers' href='index.php?option=<?=$option?>&page=<?=$i?>&keyword=<?=$keyword?>'>&nbsp;<?=$i?>&nbsp;</a><? }}?>&nbsp;<? if($page <= $total_page) { 
						$nextpage = $page + 1; 
						if($nextpage > $total_page)
						$nextpage=$total_page;
						?>
      <a href='index.php?option=<?=$option?>&page=<?=$nextpage?>&keyword=<?=$keyword?>'><span class="hproduct">Next</span></a> <a href='index.php?option=<?=$option?>&page=<?=$total_page?>&keyword=<?=$keyword?>'><span class="hnews">&nbsp; End</span></a>
      <? } ?> &nbsp;&nbsp;&nbsp;Page <?=$page?> of <?=$total_page?> &nbsp;&nbsp;Total list &nbsp;<?=$total;?> list</td>
</tr>
                      <tr>
            <td height="5" colspan="3" align="center" class="font"></td>
            </tr>
        </table>
</td>
        <td background="images/border_06.jpg" style="background-repeat:repeat-y"></td>
      </tr>
      <tr>
        <td width="7" height="7" valign="top"><img src="images/border_07.jpg" width="7" height="7" /></td>
        <td background="images/border_08.jpg" style="background-repeat:repeat-x">&nbsp;</td>
        <td width="6" height="7" valign="top"><img src="images/border_09.jpg" width="6" height="7" /></td>
      </tr>
    </table>
    <? }}?>