// JavaScript Document

function AjaxRequest() {

	try	{
		// Firefox, Opera 8.0+, Safari
		Ajax=new XMLHttpRequest();
	}

	catch (e)
	{
		// Internet Explorer
		try
		{
		Ajax=new ActiveXObject("Msxml2.XMLHTTP");
		}
	catch (e)
		{
		try
			{
			Ajax=new ActiveXObject("Microsoft.XMLHTTP");
			}
		catch (e)
		{
			alert("Your browser does not support AJAX!");
			return false;
		}
	}
}
}

function randomico() {
	return "?rnd=" + Math.random();
}


function getScrollTop() {
	if (self.pageYOffset) // all except Explorer
	{
		return self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollTop;
	}
}

function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 

	return window.undefined; 
}

function getViewportWidth() {
	var offset = 17;
	var width = null;
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
}


function toolTip(texto, e) {	
	
	if (!e) { e = window.event};
	
	switch(e.type) {
		
		case "mouseover":
			createToolTip(texto, e);
		break;
		
		case "mousemove":
			moveToolTip(e);
		break;
		
		case "mouseout":
			removeToolTip(e)
		break;
		
		
	}	
	
}


function createToolTip(texto, e) {
	var novaDiv = document.createElement("div");
		novaDiv.setAttribute("id", "toolTip");
	var toolTip = document.body.appendChild(novaDiv);

	var posx = 0;
	var posy = 0;

	if (e.clientX) {
		posX = e.clientX;
	} else {
		posX = e.pageX;
	}
	
	if (e.clientY) {
		posY = e.clientY;
	} else {
		posY = e.pageY;
	}
	
	
	with(toolTip.style) {
		position 	= "absolute";
		width		= "250px";
		height		= "auto";
		padding		= "3px";
		border		= "1px solid #CCC";
		backgroundColor = "#FFF";
		top			= ((posY + parseInt(getScrollTop())) + 10) + "px";
		left		= (posX + 10) + "px";
	}
	
	
	toolTip.innerHTML = "<div style='background-color: #F0F0F0; font-size: 10px; padding: 3px;'>" + texto + "</span>";
	
	
}


function moveToolTip(e) {
	var toolTip 	= document.getElementById("toolTip");
	var posx 		= 0;
	var posy 		= 0;

	if (e.clientX) {
		posX = e.clientX;
	} else {
		posX = e.pageX;
	}
	
	if (e.clientY) {
		posY = e.clientY;
	} else {
		posY = e.pageY;
	}
	
	
	with(toolTip.style) {
		top			= ((posY + parseInt(getScrollTop()))+10) + "px";
		left		= (posX+10) + "px";
	}


}


function removeToolTip(e) {
	var toolTip 	= document.getElementById("toolTip");
		document.body.removeChild(toolTip);
}






function contaClick(nome) {
	var url = "/site/TvFMU/contador.asp" + randomico() + "&nomeVideo=" + escape(nome);
	AjaxRequest();
	Ajax.open("GET", url, true);
	Ajax.send(null);
}