<%@ Page CodeBehind="Photo_Sort.aspx.cs" Language="c#" AutoEventWireup="True" Inherits="Typhoto.Photo_Sort" %>
<%@ Register TagPrefix="uc1" TagName="UIFrameLeft" Src="Controls/UIFrameLeft.ascx" %>
<%@ Register TagPrefix="uc1" TagName="UIFrameTop" Src="Controls/UIFrameTop.ascx" %>
<%@ Register TagPrefix="uc1" TagName="UIHead" Src="Controls/UIHead.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style>
.jkDrag_dragObj { MARGIN: 5px; POSITION: relative; BACKGROUND-COLOR: white }
.jkDrag_ObjHeader { CURSOR: move; BACKGROUND-COLOR: #cccccc }
.jkDrag_tipDivCss { DISPLAY: inline; FONT-SIZE: 1px; Z-INDEX: 10; WIDTH: 2px; LINE-HEIGHT: 2px; POSITION: absolute; HEIGHT: 80px; BACKGROUND-COLOR: red }
</style>
<script language="javascript">
var jkDrag_isMoving=false;
var jkDrag_sourceObj=null;
var jkDrag_ObjHeader=null;
var jkDrag_tipDiv=null;
var currdrag;

function jkDrag_mousedown(mouseEvent,obj){
 if(mouseEvent==null) mouseEvent=window.event ;
 jkDrag_sourceObj=(/jkDrag_dragObj/).test(obj.className) ? obj : obj.offsetParent;
 jkDrag_sourceObj.style.zIndex=10;
 jkDrag_sourceObj.mouseDownY=mouseEvent.clientY;
 jkDrag_sourceObj.mouseDownX=mouseEvent.clientX;
 jkDrag_isMoving=true;
 jkDrag_ObjHeader=obj;
 currdrag=obj.id.substr(1);
 if(jkDrag_ObjHeader.setCapture)jkDrag_ObjHeader.setCapture();
 else if(mouseEvent.preventDefault) mouseEvent.preventDefault( );
 jkDrag_setTipDivPosition(mouseEvent);
}
function jkDrag_mousemove(mouseEvent,obj){
 if(mouseEvent==null) mouseEvent=window.event ;
 if(!jkDrag_isMoving) return;
 jkDrag_sourceObj.style.top = mouseEvent.clientY-jkDrag_sourceObj.mouseDownY;
 jkDrag_sourceObj.style.left = mouseEvent.clientX-jkDrag_sourceObj.mouseDownX;
 jkDrag_setTipDivPosition(mouseEvent);
}
function jkDrag_mouseup(mouseEvent,obj){
 if(!jkDrag_isMoving) return;
 if(jkDrag_ObjHeader.releaseCapture)jkDrag_ObjHeader.releaseCapture();
 jkDrag_sourceObj.style.top=0;
 jkDrag_sourceObj.style.left=0;
 jkDrag_sourceObj.style.zIndex=0;
 jkDrag_isMoving=false;
 window.setTimeout("jkDrag_swapFun()",20);
}
function jkDrag_swapFun() 
{
 jkDrag_tipDiv.parentNode.insertBefore(jkDrag_sourceObj,jkDrag_tipDiv);
 jkDrag_tipDiv.style.display="none";
}

function jkDrag_setTipDivPosition(mouseEvent){
 if(mouseEvent==null) mouseEvent=window.event;
 if (jkDrag_tipDiv==null) {
  jkDrag_tipDiv=document.createElement("div");
  jkDrag_tipDiv.className="jkDrag_tipDivCss";
  jkDrag_tipDiv.innerHTML="&nbsp;";
 }
 jkDrag_tipDiv.style.display="";
 var allDragObjs=jkDrag_getAllReferenceObjs();
 for(var i=0;i<allDragObjs.length;i++) {
  if(allDragObjs[i]==jkDrag_sourceObj) continue;
  if((/jkDrag_dragObj/).test(allDragObjs[i].className) && isMouseInBox(allDragObjs[i],mouseEvent)){
   allDragObjs[i].parentNode.insertBefore(jkDrag_tipDiv,allDragObjs[i]);
	document.getElementById("hidphoto").value=document.getElementById("hidphoto").value.replace(","+currdrag+",",",");
	document.getElementById("hidphoto").value=document.getElementById("hidphoto").value.replace(","+allDragObjs[i].id.substr(1)+",",","+currdrag+","+allDragObjs[i].id.substr(1)+",");
   return;
  }
 }
 jkDrag_sourceObj.parentNode.insertBefore(jkDrag_tipDiv,jkDrag_sourceObj);
}
function jkDrag_getAllReferenceObjs()
{
	if(window.jkDrag_allReferenceObjs) return window.jkDrag_allReferenceObjs;
	var objArray=new Array();
	var objTags="Table,Div,Img".split(",");
	for(var i=0;i<objTags.length;i++)
	{
		var allTagObjs=document.getElementsByTagName(objTags[i]);
		for(var j=0;j<allTagObjs.length;j++){
			if((/jkDrag_dragObj/).test(allTagObjs[j].className) ) objArray[objArray.length]=allTagObjs[j];
		}
	}
	window.jkDrag_allReferenceObjs=objArray;
	return objArray;
}
function isMouseInBox(obj,mouseEvent){ 
 if(mouseEvent==null) mouseEvent=window.event;
 var point1=new Array(mouseEvent.clientX+document.body.scrollLeft,mouseEvent.clientY+document.body.scrollTop); 
 var point2=getObjPosition(obj); 
 return( (point1[0]>=point2[0]) && point1[1]>=point2[1] && point1[0]-point2[0]<=obj.offsetWidth && point1[1]-point2[1]<=obj.offsetHeight );
} 
function getObjPosition(obj){ 
 var point=new Array(0,0); 
 while(obj!=document.body){
  point[0]+=obj.offsetLeft;
  point[1]+=obj.offsetTop;
  obj=obj.offsetParent;
 }
 return point;
}

</script>
<script defer >
document.onmousemove=jkDrag_mousemove; 
document.onmouseup=jkDrag_mouseup;  
</script>
</HEAD>
<body class=body_1 scroll=no>
<form id=Form1 name=Form1 runat="server"> 
<table id=Table1 height="100%" cellSpacing=0 cellPadding=0 width="100%" border=0>
  <tr>
    <td height=60><uc1:uihead id=UIHead1 runat="server"></uc1:uihead></td></tr>
  <tr>
    <td height=10><uc1:uiframetop id=UIFrameTop1 runat="server"></uc1:uiframetop></td></tr>
  <tr>
    <td>
      <table id=Table2 height="100%" cellSpacing=0 cellPadding=0 width="100%" 
      border=0>
        <tr>
          <td class=frame_left_1 vAlign=top width=193><uc1:uiframeleft id=UIFrameLeft1 runat="server" Current="MyAlbum"></uc1:uiframeleft></td>
          <td class=frame_body_1 vAlign=top>
            <table height="100%" cellSpacing=0 cellPadding=0 width="100%" 
            border=0>
              <tr>
                <td height=32>
                  <div class=main_tool_1 style="WIDTH: 100%" 
                  >
                  <table cellSpacing=0 cellPadding=0 width="100%" border=0 
                  >
                    <tr>
                      <td><input class=button1 id=bSort type=button value="±£´æÅÅÐò" runat="server" onserverclick="bSort_ServerClick"></td>
                      </tr></table>
                  </div></td></tr>
              <tr>
                <td class=main_title_1 height=32>
                  <table cellSpacing=2 cellPadding=3 width="100%" border=0 
                  >
                    <tr>
                      <td><IMG src="images/icon_album.gif" align=absMiddle > &nbsp;<A class=link_1 href="Album_List.aspx" > 
                        ÎÒµÄÏà²á</A> -&gt; <%=lAlbumName%> -&gt; ÅÅÐò</td>
                      <td align=right><A href="javascript:history.back();" ><IMG src="images/link_back.gif" align=absMiddle ></A></td></tr></table></td></tr>
              <tr>
                <td>
                  <table height="100%" cellSpacing=0 cellPadding=0 width="100%" 
                  border=0>
                    <tr>
                        <td valign="middle" class=main_content_1 
                        ><div class=main_content_2 id=content
                        >
<asp:repeater id=dPhotos runat="server" EnableViewState="False">
<ItemTemplate>
																		<img border=1 src='<%# tuurl(DataBinder.Eval(Container.DataItem, "alias").ToString()) %>' border="0" id='a<%# DataBinder.Eval(Container.DataItem, "id") %>' class="jkDrag_dragObj jkDrag_ObjHeader" onmousedown='jkDrag_mousedown(event,this)' width="100" height="75">
</ItemTemplate>
							</asp:repeater>
                  </div></td></tr></table></td></tr>
              <tr>
                <td class=main_title_1 height=32>&nbsp;</td>
              </tr></table></td></tr></table></td></tr></table><INPUT id="hidphoto" type="hidden" name="hidphoto" runat="server" value=,></form>
	</body>
</HTML>
