loaded = 0; 

ua   = navigator.userAgent.toLowerCase();
dda  = (document.all);
ie6  = (ua.indexOf("msie") && document.all && ua.indexOf("netscape") == -1);
nnf  = (ua.indexOf("netscape")  != -1 && ua.indexOf("gecko") != -1);
nni  = (ua.indexOf("netscape")  != -1 && ua.indexOf("msie") != -1);
nn6  = (ua.indexOf("netscape")  != -1);
gek  = (ua.indexOf("gecko")     != -1);
ff1  = (ua.indexOf("firefox")   != -1);
opr  = (ua.indexOf("opera")     != -1);
mac  = (ua.indexOf("mac")       != -1);
web  = (ua.indexOf("webtv")     != -1);
saf  = (ua.indexOf("safari")    != -1);
kon  = (ua.indexOf("konqueror") != -1);
nn4  = (document.layers);

img1  = new Image();  img1.src  = "/images/uls/bgOver.gif"; 
img2  = new Image();  img2.src  = "/images/uls/tt_1.gif"; 
img3  = new Image();  img3.src  = "/images/uls/tt_2.gif"; 
img4  = new Image();  img4.src  = "/images/uls/tt_3.gif"; 
img5  = new Image();  img5.src  = "/images/uls/tt_4.gif"; 
img6  = new Image();  img6.src  = "/images/uls/tt_5.gif"; 
img7  = new Image();  img7.src  = "/images/uls/tt_6.gif"; 
img8  = new Image();  img8.src  = "/images/uls/tt_7.gif"; 
img9  = new Image();  img9.src  = "/images/uls/tt_8.gif"; 
img10 = new Image();  img10.src = "/images/uls/tt_9.gif"; 
img11 = new Image();  img11.src = "/images/uls/ico_info_16.gif"; 
img12 = new Image();  img12.src = "/images/uls/600.gif"; 
img13 = new Image();  img13.src = "/images/uls/pubh_menu_bg_over.gif"; 
img14 = new Image();  img14.src = "/images/uls/waiting.gif"; 

function err(mess){
	if(!loaded){ mess = 'Page has not completely loaded, you may need to reload the page'; }
	alert(mess); 
}

function checkSubSearch(f){
	if(f.searchdata.value.length < 1){
		err('Please enter a value to search for.');
		f.searchdata.style.background = "#eeeeee";
		f.searchdata.focus();
		return false;
	}
	if(f.searchdata.value.search(/\\w+\\s+\\w+/) >= 0){
		err('Please enter only one word.');
		f.searchdata.style.background = "#eeeeee";
		f.searchdata.focus();
		return false;
	}
	
	f.searchdata.value = f.searchdata.value.replace(/\\s+/g, "");
}

function checkMemSearch(f){
	if(f.searchdata.value.length < 1){
		err('Please enter a value to search for.');
		f.searchdata.style.background = "#eeeeee";
		f.searchdata.focus();
		return false;
	}
	if(f.searchdata.value.search(/\\w+\\s+\\w+/) >= 0){
		err('Please enter only one word.');
		f.searchdata.style.background = "#eeeeee";
		f.searchdata.focus();
		return false;
	}
	
	f.searchdata.value = f.searchdata.value.replace(/\\s+/g, "");
}

popup75 = "";
function pop_winpopup75(url){
	if(popup75){
		if(popup75.closed){
			popup75 = window.open(url, "popup75", "top=60,left=" + ((screen.availWidth/2) - (250 / 2)) + ",width=500,height=400,resizable=1,toolbar=0,scrollbars=1,location=0,status=1,menubar=0");
		} else { 
			popup75.location = url;
		}
	} else {
		popup75 = window.open(url, "popup75", "top=60,left=" + ((screen.availWidth/2) - (250 / 2)) + ",width=600,height=400,resizable=1,toolbar=0,scrollbars=1,location=0,status=1,menubar=0");
	}
}

function showTT(t, event, keepIt){
	if(!loaded){ return; }
	
	if(document.getElementById("tt")){
		theTTDoc = document;
		theTTDiv = theTTDoc.getElementById("tt");
	}
	
	if(self.parent.document.getElementById("tt")){
		theTTDoc = self.parent.document;
		theTTDiv = theTTDoc.getElementById("tt");
	}
	
	yPlus = 0;
	xPlus = 0;
	if(self.name){
		ttScT   = parseInt(document.body.scrollTop, 10);
		
		yPlus = (getPageOffsetTop(self.parent.document.getElementById(self.name))) - ttScT;
		xPlus = (getPageOffsetLeft(self.parent.document.getElementById(self.name)));
	}
	
	shiftLeft = 0;
	
	if(theTTDiv){
		if(ie6){
			ttX = getPageOffsetLeft(event.srcElement) + xPlus - 20; 
			ttY = getPageOffsetTop(event.srcElement) + yPlus + event.srcElement.offsetHeight + 1;
		} else {
			ttX = getPageOffsetLeft(event.target) + xPlus - 20; 
			ttY = getPageOffsetTop(event.target) + yPlus + event.target.offsetHeight + 1;
		}
		if(ttX > theTTDoc.body.clientWidth - 380){
			shiftLeft = theTTDoc.body.clientWidth - ttX;
			ttX = theTTDoc.body.clientWidth - shiftLeft - 280;
		}
		
		theTTDiv.style.top     = ttY;
		theTTDiv.style.left    = ttX;
		theTTDiv.style.display = "";
		
		theContent  = '';
		
		theContent += '<table cellpadding="0" cellspacing="0" width="350"><tr><td><img src="/images/uls/tt_1.gif" width="16" height="32" alt=""></td>';
		
		if(shiftLeft){
			theContent += '<td background="/images/uls/tt_3.gif" width="100%"><img src="/images/uls/tt_3.gif" width="1" height="32" alt=""></td><td><img src="/images/uls/tt_2.gif" width="32" height="32" alt=""></td>';
		} else {
			theContent += '<td><img src="/images/uls/tt_2.gif" width="32" height="32" alt=""></td><td background="/images/uls/tt_3.gif" width="100%"><img src="/images/uls/tt_3.gif" width="1" height="32" alt=""></td>';
		}
		
		theContent += '<td><img src="/images/uls/tt_4.gif" width="20" height="32" alt=""></td></tr><tr><td background="/images/uls/tt_5.gif"><img src="/images/uls/tt_5.gif" width="16" height="1" alt=""></td><td colspan="2" bgcolor="#ffffff"><table cellpadding="0" cellspacing="0">';
		
		if(keepIt){
			theContent += '<tr><td><img src="/images/uls/ico_info_16.gif" width="16" height="16" align="absmiddle" border="0"></td><td nowrap><b>&nbsp; Helpful Info &nbsp;</b></td><td width="100%"><a href="javascript:hideTT();"><img src="/images/uls/600.gif" width="20" height="20" align="absmiddle" border="0"></a></td></tr><tr><td colspan="3"><br></td></tr><tr><td colspan="3"><div id="ttContent" style="display: block;">';
		} else {
			theContent += '<tr><td><img src="/images/uls/ico_info_16.gif" width="16" height="16" align="absmiddle" border="0"></td><td width="100%"><b>&nbsp; Helpful Info</b></td></tr><tr><td colspan="2"><br></td></tr><tr><td colspan="2"><div id="ttContent" style="display: block;">';
		}
		
		theContent += t + '</div></td></tr></table></td><td background="/images/uls/tt_6.gif"><img src="/images/uls/tt_6.gif" width="20" height="1" alt=""></td></tr><tr><td><img src="/images/uls/tt_7.gif" width="16" height="20" alt=""></td><td background="/images/uls/tt_8.gif" colspan="2"><img src="/images/uls/tt_8.gif" width="1" height="20" alt=""></td><td><img src="/images/uls/tt_9.gif" width="20" height="20" alt=""></td></tr></table>';
		
		theTTDiv.innerHTML = theContent;
		
		if(theTTDoc.getElementById("ttContent").scrollHeight > 200){
			theTTDoc.getElementById("ttContent").style.height = 200 + "px";
			theTTDoc.getElementById("ttContent").style.overflow = "auto";
		}
		
		if(theTTDoc.getElementById("ttContent").scrollWidth > 300){
			theTTDoc.getElementById("ttContent").style.overflow = "auto";
		}
		
		theTTDiv.style.visibility = "visible";
	}
}

function hideTT(keepIt){
	if(!loaded){ return; }
	if(keepIt) return;
	if(document.getElementById("tt")){
		theTTDoc = document;
		theTTDiv = theTTDoc.getElementById("tt");
	}
	if(self.parent.document.getElementById("tt")){
		theTTDoc = self.parent.document;
		theTTDiv = theTTDoc.getElementById("tt");
	}
	
	if(theTTDiv){
		theTTDiv.style.visibility = "hidden";
		theTTDiv.style.height = "";
		theTTDiv.style.display = "none";
	}
}

// start member menu code

var activeButton = null;

if(ie6){
	document.onmouseover = pageMousedown;
} else {
	document.addEventListener("mouseover", pageMousedown, true);
}

function pageMousedown(event){
	var el;
	
	if(activeButton == null) return;
	
	if(ie6) el = window.event.srcElement;
	else el = (event.target.tagName ? event.target : event.target.parentNode);
	
	if(el == activeButton) return;
	
	if(getContainerWith(el, "DIV", "menu") == null){
		resetButton(activeButton);
		activeButton = null;
	}
}

function buttonClick(event, menuId){
	var button;
	
	if(!loaded){return}
	
	if(ie6)button = window.event.srcElement;
	else button = event.currentTarget;
	
	button.blur();
	
	// this will keep menu open even after leaving then returning
	if(button == activeButton){
		return;
	}
	
	if(button.menu == null){
		button.menu = document.getElementById(menuId);
		if(button.menu.isInitialized == null) menuInit(button.menu);
	}
	
	if(activeButton != null) resetButton(activeButton);
	
	if(button != activeButton){
		depressButton(button);
		activeButton = button;
	} else {
		activeButton = null;
	}
	
	return false;
}

function buttonMouseover(event, menuId){
	var button;
	
	if(!loaded){return}
	
	if(ie6) button = window.event.srcElement;
	else button = event.currentTarget;
	
	if(activeButton != null && activeButton != button) buttonClick(event, menuId);
}
	
function depressButton(button){
	var x, y;
	
	button.className += " menuButtonActive";
	
	x = getPageOffsetLeft(button);
	y = getPageOffsetTop(button) + button.offsetHeight;
	
	if(ie6){
		x += button.offsetParent.clientLeft;
		y += button.offsetParent.clientTop;
	}
	
	if(ie6){
		xBuff = 3;
		yBuff = 3;
	} else {
		xBuff = 1;
		yBuff = 1;
	}
	
	// 1st level sub menu pos
	button.menu.style.left = x - xBuff + "px";
	button.menu.style.top  = y - yBuff + "px";
	button.menu.style.visibility = "visible";
}

function resetButton(button){
	removeClassName(button, "menuButtonActive");
	
	if(button.menu != null){
		closeSubMenu(button.menu);
		button.menu.style.visibility = "hidden";
	}
}

function mOver(event){
	var menu;

	if(ie6) menu = getContainerWith(window.event.srcElement, "DIV", "menu");
	else menu = event.currentTarget;
	
	if(menu.activeItem != null) closeSubMenu(menu);
}

function mitmOver(event, menuId){
	var item, menu, x, y;
	
	if(ie6) item = getContainerWith(window.event.srcElement, "A", "mitm");
	else item = event.currentTarget;
	
	menu = getContainerWith(item, "DIV", "menu");
	
	if(menu.activeItem != null) closeSubMenu(menu);

	menu.activeItem = item;
	
	item.className += " mitmHighlight";
	
	if(item.subMenu == null){
		item.subMenu = document.getElementById(menuId);
		if(item.subMenu.isInitialized == null) menuInit(item.subMenu);
	}
	
	x = getPageOffsetLeft(item) + item.offsetWidth;
	y = getPageOffsetTop(item);
	
	var maxX, maxY;
	
	if(ie6){
		maxX = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) + (document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);
	maxY = Math.max(document.documentElement.scrollTop, document.body.scrollTop) + (document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
	}

	if(opr){
		maxX = document.documentElement.scrollLeft + window.innerWidth;
		maxY = document.documentElement.scrollTop  + window.innerHeight;
	}

	if(gek){
		maxX = window.scrollX + window.innerWidth;
		maxY = window.scrollY + window.innerHeight;
	}

	maxX -= item.subMenu.offsetWidth;
	maxY -= item.subMenu.offsetHeight;
	
	if(x > maxX) x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth + (menu.offsetWidth - item.offsetWidth));
	y = Math.max(0, Math.min(y, maxY));
	
	// 2nd + levels of sub menus pos
	item.subMenu.style.left = x + 1 + "px";
	item.subMenu.style.top  = y + 0 + "px";
	item.subMenu.style.visibility = "visible";
	
	if(ie6) window.event.cancelBubble = true;
	else event.stopPropagation();
}

function closeSubMenu(menu){
	if(menu == null || menu.activeItem == null) return;
	
	if(menu.activeItem.subMenu != null){
		closeSubMenu(menu.activeItem.subMenu);
		menu.activeItem.subMenu.style.visibility = "hidden";
		menu.activeItem.subMenu = null;
	}
	
	removeClassName(menu.activeItem, "mitmHighlight");
	menu.activeItem = null;
}

function menuInit(menu){
	var itemList, spanList;
	var textEl, arrowEl;
	var itemWidth;
	var w, dw;
	var i, j;
	
	itemList = menu.getElementsByTagName("A");
	
	if(itemList.length > 0) itemWidth = itemList[0].offsetWidth;
	else return;
	
	for(i = 0; i < itemList.length; i++){
		spanList = itemList[i].getElementsByTagName("SPAN");
		textEl  = null;
		arrowEl = null;
		
		for(j = 0; j < spanList.length; j++){
			if(hasClassName(spanList[j], "mitmText")){
				textEl = spanList[j];
			}
	
			if(hasClassName(spanList[j], "mitmArrow") || hasClassName(spanList[j], "mitmRight")){
				arrowEl = spanList[j];
			}
		}
		
		if(textEl != null && arrowEl != null){
			textEl.style.paddingRight = (itemWidth - (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
	
			if(opr){
				arrowEl.style.marginRight = "0px";
			}
		}
	}
	
	if(ie6){
		w = itemList[0].offsetWidth;
		itemList[0].style.width = w + "px";
		dw = itemList[0].offsetWidth - w;
		w -= dw;
		itemList[0].style.width = w + "px";
	}
	
	menu.isInitialized = true;
}

function getContainerWith(node, tagName, className){
	while (node != null){
		if(node.tagName != null && node.tagName == tagName && hasClassName(node, className)) return node;
		node = node.parentNode;
	}
	return node;
}

function hasClassName(el, name){
	var i, list;
	
	list = el.className.split(" ");
	for(i = 0; i < list.length; i++) if(list[i] == name) return true;
	
	return false;
}

function removeClassName(el, name){
	var i, curList, newList;
	
	if(el.className == null) return;
	
	newList = new Array();
	curList = el.className.split(" ");
	
	for(i = 0; i < curList.length; i++) if(curList[i] != name) newList.push(curList[i]);
	
	el.className = newList.join(" ");
}

function getPageOffsetLeft(el){
	var x = 0;
	
	if(el){
		if(el.offsetLeft != null){
			x = el.offsetLeft;
			if(el.offsetParent != null){
				x += getPageOffsetLeft(el.offsetParent);
			}
		}
	}
	return x;
}

function getPageOffsetTop(el){
	var y = 0;
	if(el){
		if(el.offsetTop != null){
			y = el.offsetTop;
			if(el.offsetParent != null){
				y += getPageOffsetTop(el.offsetParent);
			}
		}
	}
	return y;
}

function addbookmark(title, url) {
	if(window.sidebar){
		window.sidebar.addPanel(title, url, "");
	} else if(window.opera && window.print){
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} else if(document.all){
		window.external.AddFavorite(url, title);
	}
}

// start scrolling cat menu code

function msDown(w){
	if(!loaded){ return; }
	// msArgs[w] = [width, height, wrap, dir, manspeed, autospeed, delay];
	
	msBkStg = document.getElementById(w + 'BackStage');
	msFtSge = document.getElementById(w + 'FrontStage');
	
	/*
	document.getElementById('debug').innerHTML = 
	"Menu: "       + w + "; " + 
	"Width: "      + msArgs[w][0] + "; " + 
	"Height: "     + msArgs[w][1] + "; " + 
	"Wrap: "       + msArgs[w][2] + "; " + 
	"Dir: "        + msArgs[w][3] + "; " + 
	"Manspeed: "   + msArgs[w][4] + "; " + 
	"Autospeed: "  + msArgs[w][5] + "; " + 
	"Delay: "      + msArgs[w][6] + "; " + 
	"BSWidth: "    + msBkStgW[w] + "; " + 
	"BSHeight: "   + msBkStgH[w] + "; " + 
	"msPixPos: "   + msPixPos[w] + "; " + 
	"ScrollLeft: " + msFtSge.scrollLeft + "; " + 
	"ScrollTop: "  + msFtSge.scrollTop + "; " + 
	"ScrollSpeed: " + msSpeed[w] + "; ";
	*/
	
	if(msArgs[w][3] == 1){
		if(!msArgs[w][2]){
			if(msFtSge.scrollLeft < 1){
				msPixPos[w] = 0;
				return;
			}
		}
		
		msPixPos[w] -= msSpeed[w];
		msFtSge.scrollLeft = msPixPos[w];
	} else if(msArgs[w][3] == 2){
		if(!msArgs[w][2]){
			if(msFtSge.scrollLeft + msArgs[w][0] >= msBkStgW[w]){
				return;
			}
		}
		
		msPixPos[w] += msSpeed[w];
		msFtSge.scrollLeft = msPixPos[w];
	} else if(msArgs[w][3] == 3){
		if(!msArgs[w][2]){
			if(msFtSge.scrollTop + msArgs[w][1] >= msBkStgH[w]){
				return;
			}
		}
		
		msPixPos[w] -= msSpeed[w];
		msFtSge.scrollTop = msPixPos[w];
	} else if(msArgs[w][3] == 4){
		if(!msArgs[w][2]){
			if(msFtSge.scrollTop + msArgs[w][1] >= msBkStgH[w]){
				return;
			}
		}
		
		msPixPos[w] += msSpeed[w];
		msFtSge.scrollTop = msPixPos[w];
	}
	
	if(msArgs[w][3] == 1){
		if(msFtSge.scrollLeft >= msBkStgW[w] * 2){
			msPixPos[w] = msBkStgW[w];
		}
		if(msFtSge.scrollLeft <= 0){
			msPixPos[w] = msBkStgW[w];
		}
	} else if(msArgs[w][3] == 2){
		if(msFtSge.scrollLeft >= msBkStgW[w]){
			msPixPos[w] = 0;
		}
	} else if(msArgs[w][3] == 3){
		if(msFtSge.scrollTop >= msBkStgH[w] * 2){
			msPixPos[w] = msBkStgH[w];
		}
		if(msFtSge.scrollTop <= 0){
			msPixPos[w] = msBkStgH[w];
		}
	} else if(msArgs[w][3] == 4){
		if(msFtSge.scrollTop >= msBkStgH[w]){
			msPixPos[w] = 0;
		}
	}
	
	toSpeed = 10; if(w == 'jmpMenu') { toSpeed = 75; }
	
	msTimer[w] = setTimeout("msDown('" + w + "')", toSpeed);
}

function msRestart(w){
	if(!loaded){ return; }
	if(msArgs[w][5]){
		msSpeed[w] = msArgs[w][5];
		msStop(w);
		msDown(w);
	} else {
		msStop(w);
	}
}

function msStop(w){
	if(!loaded){ return; }
	msTimer[w] = clearTimeout(msTimer[w]);
}

function msScrollDir(w, d){
	if(!loaded){ return; }
	msSpeed[w] = msArgs[w][4]; // manual speed
	
	msArgs[w][3] = d;
	msStop(w);
	msDown(w);
}

function msSlowDown(w){
	if(!loaded){ return; }
	if(msArgs[w][5]){
		msSpeed[w] = msArgs[w][5];
	} else {
		msStop(w);
	}
}

msArgs   = new Array();
msPixPos = new Array();
msBkStgW = new Array();
msBkStgH = new Array();
msTimer  = new Array();
msSpeed  = new Array();

// multiScroll
// dir : 1 = left, 2 = right, 3 = up, 4 = down

function msInit(w, width, height, wrap, dir, manspeed, autospeed, delay){
	msArgs[w] = [width, height, wrap, dir, manspeed, autospeed, delay];
	
	msBkStg = document.getElementById(w + 'BackStage');
	msFtSge = document.getElementById(w + 'FrontStage');
	
	msSpeed[w]  = autospeed;
	msPixPos[w] = 0;
	msBkStgW[w] = msBkStg.offsetWidth;
	msBkStgH[w] = msBkStg.offsetHeight;
	
	if(dir < 3){
		if(msBkStgW[w] > width){
			msFtSge.style.width  = width + "px";
			msBkStg.width        = msBkStgW[w] + "px";
			msBkStg.align        = "left";
			
			if(wrap == 1){
				msFtSge.innerHTML = msFtSge.innerHTML + msFtSge.innerHTML;
			}
			
			if(autospeed){
				if(delay < 1){ delay = 1; }
				msTimer[w] = setTimeout("msDown('" + w + "')", delay * 1000);
			}
		}
	} else {
		if(msBkStgH[w] > height){
			msFtSge.style.height = height + "px";
			msBkStg.height       = msBkStgH[w] + "px";
			msBkStg.align        = "";
			
			if(wrap == 1){
				msFtSge.innerHTML = msFtSge.innerHTML + msFtSge.innerHTML;
			}
			
			if(autospeed){
				if(delay < 1){ delay = 1; }
				msTimer[w] = setTimeout("msDown('" + w + "')", delay * 1000);
			}
		}
	}
}

function menuHover(obj,i, clr){
	if(!loaded){ return; }
	if(i == 1)
	obj.style.backgroundColor = clr;
	else 
	obj.style.backgroundColor = '';
}

function dragMin(w){
	doResize(w, 1);
}
function dragMax(w){
	doResize(w, 2);
}
function dragClose(w){
	document.getElementById(w).style.display = 'none';
}

sTimer          = "";
dragScrollSpeed = 12;

function doResize(w, d){
	contDiv    = w + 'Cont';
	contHeight = eval(w + 'Height');
	
	dMenu = document.getElementById(contDiv).style;
	
	if(d == 1){
		dMenu.height  = 0;
		dMenu.display = 'none';
		dMenu.visibility = 'hidden';
	} else {
		dMenu.display = '';
		dMenu.visibility = 'visible';
		currH = parseInt(dMenu.height, 10) + dragScrollSpeed;  
		
		if(currH < contHeight){
			dMenu.height = currH;
			sTimer = setTimeout("doResize('" + w + "'," + d + ")",1);
		}
	}
}

// http://www.dynamicdrive.com/dynamicindex11/domdrag/

var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};
