/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint = -50; //Customize x offset of tooltip
var offsetypoint = 20; //Customize y offset of tooltip
var ie = document.all;
var ns6 = document.getElementById && !document.all;
var enabletip = false;
if (ie || ns6)
	var tipobj = document.all? document.all["tooltip"] : document.getElementById? document.getElementById("tooltip") : "";

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

ddrivetip = function (thetext, thecolor, thewidth) {
	if (ns6 || ie) {
		if (typeof thewidth != "undefined") {
			if (thewidth != 'auto')
				tipobj.style.width = thewidth + "px";
			else
				tipobj.style.width = thewidth;
		}
		if (typeof thecolor != "undefined" && thecolor != "")
			tipobj.style.backgroundColor = thecolor;
		tipobj.innerHTML = thetext;
		enabletip = true;
		document.onmousemove = positiontip;
		return false;
	}
};

hideddrivetip = function () {
	if (ns6 || ie) {
		enabletip = false;
//		tipobj.style.display = "none"
		tipobj.style.visibility = 'hidden';
		tipobj.style.top = "0";
		tipobj.style.left = "0";
		tipobj.style.backgroundColor = '';
		tipobj.style.width = '';
		document.onmousemove = null;
	}
};

function positiontip(e){
	if (!enabletip)return;
	else {
		var _offsetx = offsetxpoint;
		var _offsety = offsetypoint;

		var curX = (ns6)?e.pageX : event.clientX + ietruebody().scrollLeft;
		var curY = (ns6)?e.pageY : event.clientY + ietruebody().scrollTop;

		//Find out how close the mouse is to the corner of the window
		var bottomedge = ie&&!window.opera?
			ietruebody().clientHeight - event.clientY - _offsety :
			window.innerHeight - e.clientY - _offsety - 20;

		var _top = 0;
		var _left = 0;

		//same concept with the vertical position
		if (bottomedge < tipobj.offsetHeight) {
			_top = ie ?
				ietruebody().scrollTop + event.clientY - tipobj.offsetHeight - _offsety :
				window.pageYOffset + e.clientY - tipobj.offsetHeight - _offsety;
			_offsetx = 20;
		}
		else
			_top = curY + offsetypoint;

		var rightedge = ie&&!window.opera?
			ietruebody().clientWidth - event.clientX - _offsetx :
			window.innerWidth - e.clientX - _offsetx - 20;
		var leftedge = (_offsetx < 0)?
			_offsetx*(-1) :
			-1000;

		if (_top < 0) {
			_top = ie ?
				ietruebody().scrollTop + (ietruebody().clientHeight - tipobj.offsetHeight)/2 :
				window.pageYOffset + (window.innerHeight - tipobj.offsetHeight)/2;
		}

		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge < tipobj.offsetWidth) {
			//move the horizontal position of the menu to the left by it's width
			_left = ie?
				ietruebody().scrollLeft + event.clientX - _offsetx - tipobj.offsetWidth :
				window.pageXOffset + e.clientX - _offsetx - tipobj.offsetWidth;
		}
		else if (curX < leftedge)
			_left = 20;
		else
			//position the horizontal position of the menu where the mouse is positioned
			_left = curX + _offsetx;

		tipobj.style.top = _top + "px";
		tipobj.style.left = _left + "px";
		tipobj.style.visibility = 'visible';
	}
}


copyToClipboard=function(txt){
	try{
		if(window.clipboardData){
		window.clipboardData.clearData();
		window.clipboardData.setData("Text",txt);
		}
	}
	catch(e){
		return false;
	}
};


shake_all_body = function() {
	//alert('a');
	new Effect.Shake($('body'), {duration:0.1});
};

shake_one = function(targetObj) {
	if ( typeof ( targetObj ) == 'string') {
		targetObj = $(targetObj);
	}
	new Effect.Shake(targetObj, {distance:5, duration:0.2});
};
