//declare variables
var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!= -1) ? 1 : 0; 
var is_opera = ((navigator.userAgent.indexOf("Opera6")!= -1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0; 
var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0;

function DisplayToolTip(videoid) {
    MyFireVideosWeb._services.ToolTip.DisplayToolTip(videoid, OnDisplayToolTipComplete, OnTimeOut, OnError);
} //end  DisplayToolTip

function OnDisplayToolTipComplete(tip) {
    document.getElementById("VideoInfo").innerHTML = tip;
} //end OnDisplayToolTipComplete

function OnTimeOut(arg) {
    //alert(arg.get_message());
} //end OnTimeOut

function OnError(arg) {
    //alert(arg.get_message());
} //end OnError

/**
 * Hides tooltip div when the OnMouseOut function is called by the calling element.
 *
 */
function clearDiv(obj) {
	displayObject(obj,false);
} //end if

/**
 * Sets what html element has called the OnMouseOver function.
 * This object is used to place and display the tooltip div.
 */
function getObject(obj) {
	// step 1
	if (document.getElementById) {
		obj = document.getElementById(obj);
	// step 2
	} else if (document.all) {
		obj = document.all.item(obj);
	//step 3
	} else {
		obj = null;
	} //end if

	//step 4
	return obj;
} //end getObject

/**
 * This moves div to the mouse pointer, and passes the element that called
 * the OnMouseOver function.
 */
function moveObject(obj, e) {
	// step 1
	var tempX = 0;
	var tempY = 0;
	var offset = 5;
	var newX = 90;
	var newY = 230;
	var objHolder = obj;

	// step 2
	obj = getObject(obj);

	if (obj == null) return;

	if (screen.width <= 1024) {
	     newY = -5;
	} //end if
	
	// step 3
	if (is_ie) {
	    tempX = event.clientX + document.body.scrollLeft;
	    tempY = event.clientY + document.body.scrollTop;
	} else {
		tempX = e.pageX;
		tempY = e.pageY;
	} //end if

	// step 4
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}

	// step 5
	tempY += offset - tempY + newY;
	tempX += offset - newX;

	obj.style.bottom  = tempY + 'px';
	obj.style.left = tempX + 'px';
	
	// step 6
	displayObject(objHolder, true);
} //end moveObject

/**
 * This displays or hides the tooltip div.
 *
 */
function displayObject(obj, show) {
	// step 1
	obj = getObject(obj);
	if (obj == null) return;

	// step 2
	obj.style.display = show ? 'block' : 'none';
	obj.style.visibility = show ? 'visible' : 'hidden';
} //end displayOjbect
