var downObj=null;
var upObj=null; 
var moveObj=null; 
var dir=""; 
function startDrag() 
{
downObj=event.srcElement;
if(downObj.tagName=="A") 
{
downObj.setCapture();
var p=downObj.parentElement;
if(p.id=="left_td")
{
dir="left";	
}
else if(p.id=="right_td")
{
dir="right";	
}
}
else
{
downObj=null;	
}
}
function draging() 
{
if(!downObj){return;}
var d=_gId("drag_div"); 
d.style.top=event.y+20;
d.style.left=event.x+20;
moveObj=event.srcElement;
if(moveObj.tagName=='A'&&moveObj!=downObj&&moveObj!=downObj.nextSibling)
{
var p=_gId("event_tb");
set_cur_select(window,p,"A","border_top");
downObj.className="visited_tag";
}
d.style.display="block";
}
function stopDrag()
{
if(moveObj&&downObj)
{
upObj=event.srcElement;
var p=_gId("event_tb");
var arr=p.getElementsByTagName("A");
for(var i=0;i<arr.length;i++)
{
arr[i].className="";	
}
downObj.className="visited_tag";
if(upObj.tagName=="A")
{
upObj.insertAdjacentElement("beforeBegin",downObj);
}
else if(upObj.id=="left_td"||upObj.id=="right_td")
{
upObj.insertAdjacentElement("beforeEnd",downObj);
}
downObj.releaseCapture();
_gId("drag_div").style.display="none";
moveObj=null;
downObj=null;
upObj=null;
}
else
{
if(downObj){downObj.releaseCapture();}
_gId("drag_div").style.display="none";
moveObj=null;
downObj=null;
upObj=null;	
}
}
function lr_move(startObj,endObj,isAll) 
{
var arr=startObj.getElementsByTagName("A");
var obj=null;
for(var i=arr.length;i>=0;i--)
{
if(isAll==true&&arr[i])
{
clear_style(endObj)
endObj.insertAdjacentElement("beforeEnd",arr[i]);
}
else
{		
if(arr[i]&&arr[i].className=="visited_tag")
{
clear_style(endObj)
if(arr[i].nextSibling)
{
var n=arr[i].nextSibling;
while(n&&n.tagName!="A")
{
n=n.nextSibling;
}
if(n)
{
n.className="visited_tag";
}
}
endObj.insertAdjacentElement("afterBegin",arr[i]);
}
}
}
}
function clear_style(obj)
{
var arr=obj.getElementsByTagName("A");
for(var i=0;i<arr.length;i++)
{
if(arr[i]&&arr[i].className=="visited_tag")
{
arr[i].className="";	
}
}
}
function upDown_move(exe)
{
var obj=null;
var arr=_gId("right_td").getElementsByTagName("A");
for(var i=0;i<arr.length;i++)
{
if(arr[i]&&arr[i].className=="visited_tag")	
{
obj=arr[i];	
}
}
if(!obj)return;
if(exe==0) 
{
_gId("right_td").insertAdjacentElement("afterBegin",obj);
}
else if(exe==1) 
{
_gId("right_td").insertAdjacentElement("beforeEnd",obj);	
}
else if(exe=="up") 
{
if(obj.previousSibling)
{
var p=obj.previousSibling;
while(p.tagName!="A")
{
p=p.previousSibling;
if(!p)return;
}
p.insertAdjacentElement("beforeBegin",obj)
}
}
else if(exe=="down")
{
if(obj.nextSibling)
{
var p=obj.nextSibling;
while(p.tagName!="A")
{
p=p.nextSibling;
}
p.insertAdjacentElement("afterEnd",obj)
}		
}
}
function load_items(allStr,itemID)
{
if(itemID.indexOf(':')>-1)
{
var arr=itemID.split(",");
itemID=',';
for (var i=0;i<arr.length;i++)
{
itemID+=arr[i].split(':')[0]+",";
}
}
if(allStr=="")return;
var s="",selStr="";
itemID=","+itemID+",";
if(allStr.indexOf("|/tr|")>0)
{
var arr=allStr.split("|/tr|"),arr1;
for(var i=0;i<arr.length-1;i++)
{
if(arr[i].indexOf("|/td|")>0)
{
var arr1=arr[i].split("|/td|");
s="<a id='"+arr1[0]+"'>"+arr1[1]+"</a>";
if(itemID.indexOf(","+arr1[0]+",")>-1)
{
itemID=itemID.replace(","+arr1[0]+",",","+s+",");
}
else
{
_gId("left_td").insertAdjacentHTML("beforeEnd",s);
}
}
}		
}
_gId("right_td").insertAdjacentHTML("beforeEnd",itemID.replace(/,/g,""));
}
function back_sel_ids(typ)
{
var arr=_gId("right_td").getElementsByTagName("A");
var s="";
for(var i=0;i<arr.length;i++)
{
switch (typ)
{
case 'text': s+=arr[i].innerText+",";break;
case 'id_text': s+=arr[i].id+":"+arr[i].innerText+",";break;
default: s+=arr[i].id+",";			 
}
}
s=s.substring(0,s.length-1)
return s;
}
function back_not_sel_ids(typ)
{
var arr=_gId("left_td").getElementsByTagName("A");
var s="";
for(var i=0;i<arr.length;i++)
{
switch (typ)
{
case 'text': s+=arr[i].innerText+",";break;
case 'id_text': s+=arr[i].id+":"+arr[i].innerText+",";break;
default: s+=arr[i].id+",";			 
}
}
s=s.substring(0,s.length-1)
return s;
}