<?
$itemid			= base64_decode($_REQUEST["itemid"]);
$gall_id		= $_GET["gall_id"];
$subsection		= $_GET["subsection"];
$action			= $_GET["action"];

if($subsection=="chsort")
{

if($subaction=="up")
	{
$current = getItem("select page_int from ann_gall_page  WHERE page_id ='".$itemid."' limit 0,1");
$newsort = $current-1;
$SQL="UPDATE ann_gall_page SET page_int='".$newsort."' WHERE page_id='".$itemid."'";
$RESULT=mysql_query($SQL)or die($SQL);
//จัดของเก่าให้อยู่ตำแหน่งเรา
$BSQL="UPDATE ann_gall_page SET page_int='".$current."' WHERE  page_int='".$newsort."' AND page_id!='".$itemid."' AND page_mag_id ='".$gall_id."'";
$BRESULT=mysql_query($BSQL)or die($BSQL);
	}
elseif($subaction=="down")
	{
$current = getItem("select page_int from ann_gall_page  WHERE page_id ='".$itemid."' limit 0,1");
$newsort = $current+1;
$SQL="UPDATE ann_gall_page SET page_int='".$newsort."' WHERE page_id='".$itemid."'";
$RESULT=mysql_query($SQL)or die($SQL);
//จัดของเก่าให้อยู่ตำแหน่งเรา
$BSQL="UPDATE ann_gall_page SET page_int='".$current."' WHERE  page_int='".$newsort."' AND page_id!='".$itemid."' AND page_mag_id ='".$gall_id."'";
$BRESULT=mysql_query($BSQL)or die($BSQL);
	}
jsalert("เลื่อนลำดับสำเร็จ");
Gotourl("index.php?option=galllist&action=editgalltail&itemid=".$gall_id);
}
?>