Commit b301a5b5 authored by Yadd's avatar Yadd
Browse files

New manager

parent 04ed7be6
/*
* jQuery SimpleTree Drag&Drop plugin
* Update on 22th May 2008
* Version 0.3
*
* Licensed under BSD <http://en.wikipedia.org/wiki/BSD_License>
* Copyright (c) 2008, Peter Panov <panov\@elcat.kg>, IKEEN Group http://www.ikeen.com
* All rights reserved.
*
* Modified by Xavier Guimard <x.guimard@free.fr> for Lemonldap::NG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Peter Panov, IKEEN Group nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Peter Panov, IKEEN Group ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Peter Panov, IKEEN Group BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
$.fn.simpleTree = function(opt){
return this.each(function(){
var TREE = this;
var ROOT = $('.root',this);
var mousePressed = false;
var mouseMoved = false;
var dragMoveType = false;
var dragNode_destination = false;
var dragNode_source = false;
var dragDropTimer = false;
var ajaxCache = Array();
TREE.option = {
drag: true,
animate: false,
autoclose: false,
speed: 'fast',
afterAjax: false,
afterMove: false,
afterClick: false,
afterDblClick: false,
// added by Erik Dohmen (2BinBusiness.nl) to make context menu cliks available
afterContextMenu: false,
docToFolderConvert:false
};
TREE.option = $.extend(TREE.option,opt);
$.extend(this, {getSelected: function(){
return $('span.active', this).parent();
}});
TREE.closeNearby = function(obj)
{
$(obj).siblings().filter('.folder-open, .folder-open-last').each(function(){
var childUl = $('>ul',this);
var className = this.className;
this.className = className.replace('open','close');
if(TREE.option.animate)
{
childUl.animate({height:"toggle"},TREE.option.speed);
}else{
childUl.hide();
}
});
};
TREE.nodeToggle = function(obj)
{
var childUl = $('>ul',obj);
if(childUl.is(':visible')){
obj.className = obj.className.replace('open','close');
if(TREE.option.animate)
{
childUl.animate({height:"toggle"},TREE.option.speed);
}else{
childUl.hide();
}
}else{
obj.className = obj.className.replace('close','open');
if(TREE.option.animate)
{
childUl.animate({height:"toggle"},TREE.option.speed, function(){
if(TREE.option.autoclose)TREE.closeNearby(obj);
if(childUl.is('.ajax'))TREE.setAjaxNodes(childUl, obj.id);
});
}else{
childUl.show();
if(TREE.option.autoclose)TREE.closeNearby(obj);
if(childUl.is('.ajax'))TREE.setAjaxNodes(childUl, obj.id);
}
}
};
TREE.setAjaxNodes = function(node, parentId, callback)
{
if($.inArray(parentId,ajaxCache) == -1){
ajaxCache[ajaxCache.length]=parentId;
var url = $.trim($('>li', node).text());
if(url && url.indexOf('url:'))
{
url=$.trim(url.replace(/.*\{url:(.*)\}/i ,'$1'));
var js='';
if(url.indexOf(',js:')){
js=$.trim(url.replace(/.*,js:(.*)/i ,'$1'));
url=$.trim(url.replace(/,js:.*/i ,''));
}
$.ajax({
type: "GET",
url: url,
contentType:'html',
cache:false,
success: function(responce){
node.removeAttr('class');
node.html(responce);
$.extend(node,{url:url});
if($('li',node).length==0)TREE.convertToFolder(node.parent());
TREE.setTreeNodes(node, true);
if(typeof TREE.option.afterAjax == 'function')
{
TREE.option.afterAjax(node);
}
if(typeof callback == 'function')
{
callback(node);
}
if(js.length)$('>span',node.parent()).click(function(){eval(js+'()')});
}
});
}
}
};
TREE.setTreeNodes = function(obj, useParent){
obj = useParent? obj.parent():obj;
$('li>span', obj).addClass('text')
.bind('selectstart', function() {
return false;
}).click(function(){
$('.active',TREE).attr('class','text');
if(this.className=='text')
{
this.className='active';
}
if(typeof TREE.option.afterClick == 'function')
{
TREE.option.afterClick($(this).parent());
}
return false;
}).dblclick(function(){
mousePressed = false;
TREE.nodeToggle($(this).parent().get(0));
if(typeof TREE.option.afterDblClick == 'function')
{
TREE.option.afterDblClick($(this).parent());
}
return false;
// added by Erik Dohmen (2BinBusiness.nl) to make context menu actions
// available
}).bind("contextmenu",function(){
$('.active',TREE).attr('class','text');
if(this.className=='text')
{
this.className='active';
}
if(typeof TREE.option.afterContextMenu == 'function')
{
TREE.option.afterContextMenu($(this).parent());
}
return false;
}).mousedown(function(event){
mousePressed = true;
cloneNode = $(this).parent().clone();
var LI = $(this).parent();
if(TREE.option.drag)
{
$('>ul', cloneNode).hide();
$('body').append('<div id="drag_container"><ul></ul></div>');
$('#drag_container').hide().css({opacity:'0.8'});
$('#drag_container >ul').append(cloneNode);
$("<img>").attr({id : "tree_plus",src : "plus.gif"}).css({width: "7px",display: "block",position: "absolute",left : "5px",top: "5px", display:'none'}).appendTo("body");
$(document).bind("mousemove", {LI:LI}, TREE.dragStart).bind("mouseup",TREE.dragEnd);
}
return false;
}).mouseup(function(){
if(mousePressed && mouseMoved && dragNode_source)
{
TREE.moveNodeToFolder($(this).parent());
}
TREE.eventDestroy();
});
$('li', obj).each(function(i){
var className = this.className;
var open = false;
var cloneNode=false;
var LI = this;
var childNode = $('>ul',this);
if(childNode.size()>0){
var setClassName = 'folder-';
if(className && className.indexOf('open')>=0){
setClassName=setClassName+'open';
open=true;
}else{
setClassName=setClassName+'close';
}
this.className = setClassName + ($(this).is(':last-child')? '-last':'');
if(!open || className.indexOf('ajax')>=0)childNode.hide();
TREE.setTrigger(this);
}else{
var setClassName = 'doc';
this.className = setClassName + ($(this).is(':last-child')? '-last':'');
}
}).before('<li class="line">&nbsp;</li>')
.filter(':last-child').after('<li class="line-last"></li>');
TREE.setEventLine($('.line, .line-last', obj));
};
TREE.setTrigger = function(node){
$('>span',node).before('<img class="trigger" src="'+imagepath+'spacer.gif" border=0>');
var trigger = $('>.trigger', node);
trigger.click(function(event){
TREE.nodeToggle(node);
});
if(!$.browser.msie)
{
trigger.css('float','left');
}
};
TREE.dragStart = function(event){
var LI = $(event.data.LI);
if(mousePressed)
{
mouseMoved = true;
if(dragDropTimer) clearTimeout(dragDropTimer);
if($('#drag_container:not(:visible)')){
$('#drag_container').show();
LI.prev('.line').hide();
dragNode_source = LI;
}
$('#drag_container').css({position:'absolute', "left" : (event.pageX + 5), "top": (event.pageY + 15) });
if(LI.is(':visible'))LI.hide();
var temp_move = false;
if(event.target.tagName.toLowerCase()=='span' && $.inArray(event.target.className, Array('text','active','trigger'))!= -1)
{
var parent = event.target.parentNode;
var offs = $(parent).offset({scroll:false});
var screenScroll = {x : (offs.left - 3),y : event.pageY - offs.top};
var isrc = $("#tree_plus").attr('src');
var ajaxChildSize = $('>ul.ajax',parent).size();
var ajaxChild = $('>ul.ajax',parent);
screenScroll.x += 19;
screenScroll.y = event.pageY - screenScroll.y + 5;
if(parent.className.indexOf('folder-close')>=0 && ajaxChildSize==0)
{
if(isrc.indexOf('minus')!=-1)$("#tree_plus").attr('src','plus.gif');
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show();
dragDropTimer = setTimeout(function(){
parent.className = parent.className.replace('close','open');
$('>ul',parent).show();
}, 700);
}else if(parent.className.indexOf('folder')>=0 && ajaxChildSize==0){
if(isrc.indexOf('minus')!=-1)$("#tree_plus").attr('src','plus.gif');
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show();
}else if(parent.className.indexOf('folder-close')>=0 && ajaxChildSize>0)
{
mouseMoved = false;
$("#tree_plus").attr('src','minus.gif');
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show();
$('>ul',parent).show();
/*
Thanks for the idea of Erik Dohmen
*/
TREE.setAjaxNodes(ajaxChild,parent.id, function(){
parent.className = parent.className.replace('close','open');
mouseMoved = true;
$("#tree_plus").attr('src','plus.gif');
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show();
});
}else{
if(TREE.option.docToFolderConvert)
{
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show();
}else{
$("#tree_plus").hide();
}
}
}else{
$("#tree_plus").hide();
}
return false;
}
return true;
};
TREE.dragEnd = function(){
if(dragDropTimer) clearTimeout(dragDropTimer);
TREE.eventDestroy();
};
TREE.setEventLine = function(obj){
obj.mouseover(function(){
if(this.className.indexOf('over')<0 && mousePressed && mouseMoved)
{
this.className = this.className.replace('line','line-over');
}
}).mouseout(function(){
if(this.className.indexOf('over')>=0)
{
this.className = this.className.replace('-over','');
}
}).mouseup(function(){
if(mousePressed && dragNode_source && mouseMoved)
{
dragNode_destination = $(this).parents('li:first');
TREE.moveNodeToLine(this);
TREE.eventDestroy();
}
});
};
TREE.checkNodeIsLast = function(node)
{
if(node.className.indexOf('last')>=0)
{
var prev_source = dragNode_source.prev().prev();
if(prev_source.size()>0)
{
prev_source[0].className+='-last';
}
node.className = node.className.replace('-last','');
}
};
TREE.checkLineIsLast = function(line)
{
if(line.className.indexOf('last')>=0)
{
var prev = $(line).prev();
if(prev.size()>0)
{
prev[0].className = prev[0].className.replace('-last','');
}
dragNode_source[0].className+='-last';
}
};
TREE.eventDestroy = function()
{
// added by Erik Dohmen (2BinBusiness.nl), the unbind mousemove TREE.dragStart action
// like this other mousemove actions binded through other actions ain't removed (use it myself
// to determine location for context menu)
$(document).unbind('mousemove',TREE.dragStart).unbind('mouseup').unbind('mousedown');
$('#drag_container, #tree_plus').remove();
if(dragNode_source)
{
$(dragNode_source).show().prev('.line').show();
}
dragNode_destination = dragNode_source = mousePressed = mouseMoved = false;
//ajaxCache = Array();
};
TREE.convertToFolder = function(node){
node[0].className = node[0].className.replace('doc','folder-open');
node.append('<ul><li class="line-last"></li></ul>');
TREE.setTrigger(node[0]);
TREE.setEventLine($('.line, .line-last', node));
};
TREE.convertToDoc = function(node){
$('>ul', node).remove();
$('img', node).remove();
node[0].className = node[0].className.replace(/folder-(open|close)/gi , 'doc');
};
TREE.moveNodeToFolder = function(node)
{
if(!TREE.option.docToFolderConvert && node[0].className.indexOf('doc')!=-1)
{
return true;
}else if(TREE.option.docToFolderConvert && node[0].className.indexOf('doc')!=-1){
TREE.convertToFolder(node);
}
TREE.checkNodeIsLast(dragNode_source[0]);
var lastLine = $('>ul >.line-last', node);
if(lastLine.size()>0)
{
TREE.moveNodeToLine(lastLine[0]);
}
};
TREE.moveNodeToLine = function(node){
TREE.checkNodeIsLast(dragNode_source[0]);
TREE.checkLineIsLast(node);
var parent = $(dragNode_source).parents('li:first');
var line = $(dragNode_source).prev('.line');
$(node).before(dragNode_source);
$(dragNode_source).before(line);
node.className = node.className.replace('-over','');
var nodeSize = $('>ul >li', parent).not('.line, .line-last').filter(':visible').size();
if(TREE.option.docToFolderConvert && nodeSize==0)
{
TREE.convertToDoc(parent);
}else if(nodeSize==0)
{
parent[0].className=parent[0].className.replace('open','close');
$('>ul',parent).hide();
}
// added by Erik Dohmen (2BinBusiness.nl) select node
if($('span:first',dragNode_source).attr('class')=='text')
{
$('.active',TREE).attr('class','text');
$('span:first',dragNode_source).attr('class','active');
}
if(typeof(TREE.option.afterMove) == 'function')
{
var pos = $(dragNode_source).prevAll(':not(.line)').size();
TREE.option.afterMove($(node).parents('li:first'), $(dragNode_source), pos);
}
};
TREE.addNode = function(id, text, callback)
{
var temp_node = $('<li><ul><li id="'+id+'"><span>'+text+'</span></li></ul></li>');
TREE.setTreeNodes(temp_node);
dragNode_destination = TREE.getSelected();
dragNode_source = $('.doc-last',temp_node);
TREE.moveNodeToFolder(dragNode_destination);
temp_node.remove();
if(typeof(callback) == 'function')
{
callback(dragNode_destination, dragNode_source);
}
};
TREE.newNodeAfter = function(id, text, callback)
{
var temp_node = $('<li><ul><li id="'+id+'"><span>'+text+'</span></li></u></li>');
TREE.setTreeNodes(temp_node,true);
destination = TREE.getSelected().parent().parent();
dragNode_source = $('.doc-last',temp_node);
TREE.moveNodeToFolder(destination);
temp_node.remove();
if(typeof(callback) == 'function')
{
callback(dragNode_destination, dragNode_source);
}
//existing.after(temp_node);
//temp_node.remove();
};
TREE.delNode = function(callback)
{
dragNode_source = TREE.getSelected();
TREE.checkNodeIsLast(dragNode_source[0]);
dragNode_source.prev().remove();
dragNode_source.remove();
if(typeof(callback) == 'function')
{
callback(dragNode_destination);
}
};
TREE.init = function(obj)
{
TREE.setTreeNodes(obj, false);
};
TREE.init(ROOT);
});
}
/* Compiled from X 4.18 by XC 1.07 on 17Feb09 */
function xEvent(evt){var e=evt||window.event;if(!e)return;this.type=e.type;this.target=e.target||e.srcElement;this.relatedTarget=e.relatedTarget;/*@cc_on if(e.type=='mouseover')this.relatedTarget=e.fromElement;else if(e.type=='mouseout')this.relatedTarget=e.toElement;@*/if(xDef(e.pageX)){this.pageX=e.pageX;this.pageY=e.pageY;}else if(xDef(e.clientX)){this.pageX=e.clientX+xScrollLeft();this.pageY=e.clientY+xScrollTop();}if(xDef(e.offsetX)){this.offsetX=e.offsetX;this.offsetY=e.offsetY;}else if(xDef(e.layerX)){this.offsetX=e.layerX;this.offsetY=e.layerY;}else{this.offsetX=this.pageX-xPageX(this.target);this.offsetY=this.pageY-xPageY(this.target);}this.keyCode=e.keyCode||e.which||0;this.shiftKey=e.shiftKey;this.ctrlKey=e.ctrlKey;this.altKey=e.altKey;if(typeof e.type=='string'){if(e.type.indexOf('click')!=-1){this.button=0;}else if(e.type.indexOf('mouse')!=-1){this.button=e.button;/*@cc_on if(e.button&1)this.button=0;else if(e.button&4)this.button=1;else if(e.button&2)this.button=2;@*/}}}xLibrary={version:'4.18',license:'GNU LGPL',url:'http://cross-browser.com/'};function xAddEventListener(e,eT,eL,cap){if(!(e=xGetElementById(e)))return;eT=eT.toLowerCase();if(e.addEventListener)e.addEventListener(eT,eL,cap||false);else if(e.attachEvent)e.attachEvent('on'+eT,eL);else{var o=e['on'+eT];e['on'+eT]=typeof o=='function'?function(v){o(v);eL(v);}:eL;}}function xCamelize(cssPropStr){var i,c,a=cssPropStr.split('-');var s=a[0];for(i=1;i<a.length;++i){c=a[i].charAt(0);s+=a[i].replace(c,c.toUpperCase());}return s;}function xClientHeight(){var v=0,d=document,w=window;if((!d.compatMode||d.compatMode=='CSS1Compat')&&d.documentElement&&d.documentElement.clientHeight){v=d.documentElement.clientHeight;}else if(d.body&&d.body.clientHeight){v=d.body.clientHeight;}else if(xDef(w.innerWidth,w.innerHeight,d.width)){v=w.innerHeight;if(d.width>w.innerWidth)v-=16;}return v;}function xClientWidth(){var v=0,d=document,w=window;if((!d.compatMode||d.compatMode=='CSS1Compat')&&!w.opera&&d.documentElement&&d.documentElement.clientWidth){v=d.documentElement.clientWidth;}else if(d.body&&d.body.clientWidth){v=d.body.clientWidth;}else if(xDef(w.innerWidth,w.innerHeight,d.height)){v=w.innerWidth;if(d.height>w.innerHeight)v-=16;}return v;}function xDef(){for(var i=0;i<arguments.length;++i){if(typeof(arguments[i])=='undefined')return false;}return true;}function xGetComputedStyle(e,p,i){if(!(e=xGetElementById(e)))return null;var s,v='undefined',dv=document.defaultView;if(dv&&dv.getComputedStyle){s=dv.getComputedStyle(e,'');if(s)v=s.getPropertyValue(p);}else if(e.currentStyle){v=e.currentStyle[xCamelize(p)];}else return null;return i?(parseInt(v)||0):v;}function xGetElementById(e){if(typeof(e)=='string'){if(document.getElementById)e=document.getElementById(e);else if(document.all)e=document.all[e];else e=null;}return e;}function xGetElementsByClassName(c,p,t,f){var r=new Array();var re=new RegExp("(^|\\s)"+c+"(\\s|$)");var e=xGetElementsByTagName(t,p);for(var i=0;i<e.length;++i){if(re.test(e[i].className)){r[r.length]=e[i];if(f)f(e[i]);}}return r;}function xGetElementsByTagName(t,p){var list=null;t=t||'*';p=xGetElementById(p)||document;if(typeof p.getElementsByTagName!='undefined'){list=p.getElementsByTagName(t);if(t=='*'&&(!list||!list.length))list=p.all;}else{if(t=='*')list=p.all;else if(p.all&&p.all.tags)list=p.all.tags(t);}return list||[];}function xHasPoint(e,x,y,t,r,b,l){if(!xNum(t)){t=r=b=l=0;}else if(!xNum(r)){r=b=l=t;}else if(!xNum(b)){l=r;b=t;}var eX=xPageX(e),eY=xPageY(e);return(x>=eX+l&&x<=eX+xWidth(e)-r&&y>=eY+t&&y<=eY+xHeight(e)-b);}function xHeight(e,h){if(!(e=xGetElementById(e)))return 0;if(xNum(h)){if(h<0)h=0;else h=Math.round(h);}else h=-1;var css=xDef(e.style);if(e==document||e.tagName.toLowerCase()=='html'||e.tagName.toLowerCase()=='body'){h=xClientHeight();}else if(css&&xDef(e.offsetHeight)&&xStr(e.style.height)){if(h>=0){var pt=0,pb=0,bt=0,bb=0;if(document.compatMode=='CSS1Compat'){var gcs=xGetComputedStyle;pt=gcs(e,'padding-top',1);if(pt!==null){pb=gcs(e,'padding-bottom',1);bt=gcs(e,'border-top-width',1);bb=gcs(e,'border-bottom-width',1);}else if(xDef(e.offsetHeight,e.style.height)){e.style.height=h+'px';pt=e.offsetHeight-h;}}h-=(pt+pb+bt+bb);if(isNaN(h)||h<0)return;else e.style.height=h+'px';}h=e.offsetHeight;}else if(css&&xDef(e.style.pixelHeight)){if(h>=0)e.style.pixelHeight=h;h=e.style.pixelHeight;}return h;}function xLeft(e,iX){if(!(e=xGetElementById(e)))return 0;var css=xDef(e.style);if(css&&xStr(e.style.left)){if(xNum(iX))e.style.left=iX+'px';else{iX=parseInt(e.style.left);if(isNaN(iX))iX=xGetComputedStyle(e,'left',1);if(isNaN(iX))iX=0;}}else if(css&&xDef(e.style.pixelLeft)){if(xNum(iX))e.style.pixelLeft=iX;else iX=e.style.pixelLeft;}return iX;}function xMoveTo(e,x,y){xLeft(e,x);xTop(e,y);}function xNum(){for(var i=0;i<arguments.length;++i){if(isNaN(arguments[i])||typeof(arguments[i])!='number')return false;}return true;}function xOpacity(e,o){var set=xDef(o);if(!(e=xGetElementById(e)))return 2;if(xStr(e.style.opacity)){if(set)e.style.opacity=o+'';else o=parseFloat(e.style.opacity);}else if(xStr(e.style.filter)){if(set)e.style.filter='alpha(opacity='+(100*o)+')';else if(e.filters&&e.filters.alpha){o=e.filters.alpha.opacity/100;}}else if(xStr(e.style.MozOpacity)){if(set)e.style.MozOpacity=o+'';else o=parseFloat(e.style.MozOpacity);}else if(xStr(e.style.KhtmlOpacity)){if(set)e.style.KhtmlOpacity=o+'';else o=parseFloat(e.style.KhtmlOpacity);}return isNaN(o)?1:o;}function xPageX(e){var x=0;e=xGetElementById(e);while(e){if(xDef(e.offsetLeft))x+=e.offsetLeft;e=xDef(e.offsetParent)?e.offsetParent:null;}return x;}function xPageY(e){var y=0;e=xGetElementById(e);while(e){if(xDef(e.offsetTop))y+=e.offsetTop;e=xDef(e.offsetParent)?e.offsetParent:null;}return y;}function xPreventDefault(e){if(e&&e.preventDefault)e.preventDefault();else if(window.event)window.event.returnValue=false;}function xRemoveEventListener(e,eT,eL,cap){if(!(e=xGetElementById(e)))return;eT=eT.toLowerCase();if(e.removeEventListener)e.removeEventListener(eT,eL,cap||false);else if(e.detachEvent)e.detachEvent('on'+eT,eL);else e['on'+eT]=null;}function xResizeTo(e,w,h){xWidth(e,w);xHeight(e,h);}function xScrollLeft(e,bWin){var offset=0;if(!xDef(e)||bWin||e==document||e.tagName.toLowerCase()=='html'||e.tagName.toLowerCase()=='body'){var w=window;if(bWin&&e)w=e;if(w.document.documentElement&&w.document.documentElement.scrollLeft)offset=w.document.documentElement.scrollLeft;else if(w.document.body&&xDef(w.document.body.scrollLeft))offset=w.document.body.scrollLeft;}else{e=xGetElementById(e);if(e&&xNum(e.scrollLeft))offset=e.scrollLeft;}return offset;}function xScrollTop(e,bWin){var offset=0;if(!xDef(e)||bWin||e==document||e.tagName.toLowerCase()=='html'||e.tagName.toLowerCase()=='body'){var w=window;if(bWin&&e)w=e;if(w.document.documentElement&&w.document.documentElement.scrollTop)offset=w.document.documentElement.scrollTop;else if(w.document.body&&xDef(w.document.body.scrollTop))offset=w.document.body.scrollTop;}else{e=xGetElementById(e);if(e&&xNum(e.scrollTop))offset=e.scrollTop;}return offset;}function xStopPropagation(evt){if(evt&&evt.stopPropagation)evt.stopPropagation();else if(window.event)window.event.cancelBubble=true;}function xStr(s){for(var i=0;i<arguments.length;++i){if(typeof(arguments[i])!='string')return false;}return true;}function xStyle(sProp,sVal){var i,e;for(i=2;i<arguments.length;++i){e=xGetElementById(arguments[i]);if(e.style){try{e.style[sProp]=sVal;}catch(err){e.style[sProp]='';}}}}function xTop(e,iY){if(!(e=xGetElementById(e)))return 0;var css=xDef(e.style);if(css&&xStr(e.style.top)){if(xNum(iY))e.style.top=iY+'px';else{iY=parseInt(e.style.top);if(isNaN(iY))iY=xGetComputedStyle(e,'top',1);if(isNaN(iY))iY=0;}}else if(css&&xDef(e.style.pixelTop)){if(xNum(iY))e.style.pixelTop=iY;else iY=e.style.pixelTop;}return iY;}function xWidth(e,w){if(!(e=xGetElementById(e)))return 0;if(xNum(w)){if(w<0)w=0;else w=Math.round(w);}else w=-1;var css=xDef(e.style);if(e==document||e.tagName.toLowerCase()=='html'||e.tagName.toLowerCase()=='body'){w=xClientWidth();}else if(css&&xDef(e.offsetWidth)&&xStr(e.style.width)){if(w>=0){var pl=0,pr=0,bl=0,br=0;if(document.compatMode=='CSS1Compat'){var gcs=xGetComputedStyle;pl=gcs(e,'padding-left',1);if(pl!==null){pr=gcs(e,'padding-right',1);bl=gcs(e,'border-left-width',1);br=gcs(e,'border-right-width',1);}else if(xDef(e.offsetWidth,e.style.width)){e.style.width=w+'px';pl=e.offsetWidth-w;}}w-=(pl+pr+bl+br);if(isNaN(w)||w<0)return;else e.style.width=w+'px';}w=e.offsetWidth;}else if(css&&xDef(e.style.pixelWidth)){if(w>=0)e.style.pixelWidth=w;w=e.style.pixelWidth;}return w;}/* Compiled from X 4.18 by XC 1.07 on 17Feb09 */
function xEvent(evt){var e=evt||window.event;if(!e)return;this.type=e.type;this.target=e.target||e.srcElement;this.relatedTarget=e.relatedTarget;/*@cc_on if(e.type=='mouseover')this.relatedTarget=e.fromElement;else if(e.type=='mouseout')this.relatedTarget=e.toElement;@*/if(xDef(e.pageX)){this.pageX=e.pageX;this.pageY=e.pageY;}else if(xDef(e.clientX)){this.pageX=e.clientX+xScrollLeft();this.pageY=e.clientY+xScrollTop();}if(xDef(e.offsetX)){this.offsetX=e.offsetX;this.offsetY=e.offsetY;}else if(xDef(e.layerX)){this.offsetX=e.layerX;this.offsetY=e.layerY;}else{this.offsetX=this.pageX-xPageX(this.target);this.offsetY=this.pageY-xPageY(this.target);}this.keyCode=e.keyCode||e.which||0;this.shiftKey=e.shiftKey;this.ctrlKey=e.ctrlKey;this.altKey=e.altKey;if(typeof e.type=='string'){if(e.type.indexOf('click')!=-1){this.button=0;}else if(e.type.indexOf('mouse')!=-1){this.button=e.button;/*@cc_on if(e.button&1)this.button=0;else if(e.button&4)this.button=1;else if(e.button&2)this.button=2;@*/}}}xLibrary={version:'4.18',license:'GNU LGPL',url:'http://cross-browser.com/'};function xAddEventListener(e,eT,eL,cap){if(!(e=xGetElementById(e)))return;eT=eT.toLowerCase();if(e.addEventListener)e.addEventListener(eT,eL,cap||false);else if(e.attachEvent)e.attachEvent('on'+eT,eL);else{var o=e['on'+eT];e['on'+eT]=typeof o=='function'?function(v){o(v);eL(v);}:eL;}}function xPreventDefault(e){if(e&&e.preventDefault)e.preventDefault();else if(window.event)window.event.returnValue=false;}function xRemoveEventListener(e,eT,eL,cap){if(!(e=xGetElementById(e)))return;eT=eT.toLowerCase();if(e.removeEventListener)e.removeEventListener(eT,eL,cap||false);else if(e.detachEvent)e.detachEvent('on'+eT,eL);else e['on'+eT]=null;}function xStopPropagation(evt){if(evt&&evt.stopPropagation)evt.stopPropagation();else if(window.event)window.event.cancelBubble=true;}// xEnableDrag r8, Copyright 2002-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
function xEnableDrag(id,fS,fD,fE)
{
var mx = 0, my = 0, el = xGetElementById(id);
if (el) {
el.xDragEnabled = true;
xAddEventListener(el, 'mousedown', dragStart, false);
}
// Private Functions
function dragStart(e)
{