
var referenz=new Object();var zIndexTop=0;var no_move=null;function find_obj_id(e)
{if(!document.all)
obj=e.target;else
obj=event.srcElement;if(obj.id&&obj.id.indexOf(prefix)!=-1)
return obj.id;counter=0;while((!obj.id||obj.id.indexOf(prefix)==-1)&&counter<5)
{obj=obj.parentNode;counter++;}
if(obj.id&&obj.id.indexOf(prefix)!=-1)
return obj.id;else
return false;}
function startDrag(e)
{obj_id=find_obj_id(e);if(obj_id)
{no_move=obj_id;if(!document.all)
event=e;document.getElementById(obj_id).style.left=parseInt(document.getElementById(obj_id).style.left)-5+"px";document.getElementById(obj_id).style.top=parseInt(document.getElementById(obj_id).style.top)-2+"px";startX=event.clientX;startY=event.clientY;zIndexTop++;document.getElementById(obj_id).style.zIndex=zIndexTop;XpositionAlt=document.getElementById(obj_id).style.left;YpositionAlt=document.getElementById(obj_id).style.top;document.onmousemove=drag;document.onmouseup=stopDrag;return false;}}
function drag(e)
{if(obj_id)
{if(!document.all)
event=e;Xwert=event.clientX-startX;Ywert=event.clientY-startY;document.getElementById(obj_id).style.left=parseInt(XpositionAlt)+Xwert+"px";document.getElementById(obj_id).style.top=parseInt(YpositionAlt)+Ywert+"px";}
return false;}
function stopDrag()
{no_move=null;if(obj_id)
{document.getElementById(obj_id).style.left=parseInt(document.getElementById(obj_id).style.left)+5+"px";document.getElementById(obj_id).style.top=parseInt(document.getElementById(obj_id).style.top)+2+"px";if(typeof referenz[obj_id][0]!="undefined")
referenz[obj_id][0].reorder(obj_id);}
obj_id=false;return false;}
function Numsort(a,b)
{return a-b;}
function strip_tags(str)
{return str.replace(/<.*?>/gi,'');}
function preset_ranking()
{for(var i=0;i<instances.length;i++)
instances[i].restore_ranking();}
function ranking_class(start_order,positions,selected_objects,current_objects,_range,x_first,x_second,formname,animated)
{this.zIndexTop=0;this.selected_objects=selected_objects;this.current_objects=current_objects;this.start_order=start_order;this.positions=positions;this._range=_range;this.x_first=x_first;this.x_second=x_second;this.formname=formname;this.animated=animated;this.thrust=5;this.reorder=function(o_id)
{if((parseInt(document.getElementById(o_id).style.left)+parseInt(document.getElementById(o_id).style.width))>this._range)
{this.current_objects[o_id]=new Array(this._range,"compute");this.selected_objects[o_id]=true;}
else
{this.current_objects[o_id]=new Array(this.x_first,this.positions[this.start_order[o_id]]);this.selected_objects=this.kick_out(o_id,this.selected_objects);}}
this.move_x=function(object,x_end)
{if(this.animated!=true)
{object.style.left=x_end+"px";if(x_end<this._range)
document.forms[this.formname][referenz[object.id][1]].value=0;}
else
{var curr_pos=parseInt(object.style.left);if(curr_pos<x_end)
object.style.left=curr_pos+(Math.max(2,Math.ceil((x_end-curr_pos)/this.thrust)))+"px";else if(curr_pos>x_end)
object.style.left=curr_pos-(Math.max(2,Math.ceil((curr_pos-x_end)/this.thrust)))+"px";if(Math.abs(curr_pos-x_end)<=2)
object.style.left=x_end+"px";if(curr_pos<this._range)
document.forms[this.formname][referenz[object.id][1]].value=0;}}
this.move_y=function(object,y_end)
{if(this.animated!=true)
object.style.top=y_end+"px";else
{var curr_pos=parseInt(object.style.top);if(curr_pos<y_end)
object.style.top=curr_pos+(Math.max(2,Math.ceil((y_end-curr_pos)/this.thrust)))+"px";else if(curr_pos>y_end)
object.style.top=curr_pos-(Math.max(2,Math.ceil((curr_pos-y_end)/this.thrust)))+"px";if(Math.abs(curr_pos-y_end)<=2)
object.style.top=y_end+"px";}}
this.move_all=function()
{var sort_arr=new Array();var sort_ref=new Array();var order=new Array();for(var o_id in this.selected_objects)
{var curr_y=parseInt(document.getElementById(o_id).style.top);if(sort_ref["p_"+curr_y])
curr_y+=1;sort_arr.push(curr_y);sort_ref["p_"+curr_y]=o_id;}
sort_arr.sort(Numsort);var p=1;for(var s=0;s<sort_arr.length;s++)
{order[sort_ref["p_"+sort_arr[s]]]=p;p++;}
for(o_id in this.current_objects)
{if(no_move==o_id)
continue;x_ret=y_ret=false;if(o_id!=undefined)
{x_end=this.current_objects[o_id][0];if(parseInt(document.getElementById(o_id).style.left)!=x_end)
this.move_x(document.getElementById(o_id),x_end);else
x_ret=true;y_end=this.current_objects[o_id][1];if(y_end=="compute"&&x_end==this.x_second)
{y_end=this.positions[order[o_id]];}
if(parseInt(document.getElementById(o_id).style.top)!=y_end)
this.move_y(document.getElementById(o_id),y_end);else
y_ret=true;if(x_ret==true&&y_ret==true)
{if(parseInt(document.getElementById(o_id).style.left)<this._range)
{this.selected_objects=this.kick_out(o_id,this.selected_objects);document.forms[this.formname][referenz[o_id][1]].value=0;}
else
{document.forms[this.formname][referenz[o_id][1]].value=order[o_id];}}}}}
this.kick_out=function(o_id,arr)
{var temp=new Object();for(oid in arr)
{if(oid!=o_id)
temp[oid]=arr[oid];}
return temp;}
this.restore_ranking=function()
{for(i=0;i<document.forms[0].elements.length;++i)
{varname=document.forms[0].elements[i].name;if(document.getElementById(prefix+varname))
{value=document.forms[0][varname].value;if(this.start_order[prefix+varname]&&value>0)
{this.current_objects[prefix+varname]=new Array(_range,'compute');this.selected_objects[prefix+varname]=true;document.getElementById(prefix+varname).style.top=this.positions[value]+"px";document.getElementById(prefix+varname).style.left=_range+"px";}}}}}