
var Timeouts = Array();
Timeouts["show"] = Array();
Timeouts["hide"] = Array();
var Increment = 10; // px
var Temps_timeout = 30; //ms

function logos_showInfo(id)
{
	logos_clearTimeout(id, "hide");
	logos_clearTimeout(id, "show");
	_logos_showInfo(id);
}


function _logos_showInfo(id)
{
	var obj = document.getElementById(id);
	if(!obj) return;

	if(obj.style.display != "block"){
		obj.style.height= "1px";
		obj.style.display = "block";
	}

	var newHeight = parseInt(obj.style.height,10) + Increment;
	if(newHeight > 75) newHeight = 75;
	obj.style.height = newHeight+"px";
	obj.style.top = (200-newHeight) + "px";

	if(newHeight < 75){
		Timeouts["show"][id] = setTimeout("_logos_showInfo('"+id+"')", Temps_timeout);
	}
}


function logos_hideInfo(id)
{
	logos_clearTimeout(id, "hide");
	logos_clearTimeout(id, "show");
	_logos_hideInfo(id);
}


function _logos_hideInfo(id)
{
	var obj = document.getElementById(id);
	if(!obj) return;

	var newHeight = parseInt(obj.style.height,10) - Increment;
	if(newHeight < 0) newHeight = 0;
	obj.style.height = newHeight+"px";
	obj.style.top = (200-newHeight) + "px";

	if(newHeight > 0){
		Timeouts["hide"][id] = setTimeout("_logos_hideInfo('"+id+"')", Temps_timeout);
	}
	else{
		obj.style.display = "none";
	}
}


function logos_clearTimeout(id, tipus)
{
	if(typeof Timeouts[tipus][id] == "undefined") Timeouts[tipus][id] = 0;
	if(Timeouts[tipus][id] != 0){
		clearTimeout(Timeouts[tipus][id]);
		Timeouts[tipus][id] = 0;
	}
}


function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function logos_voteLogo(idLogo)
{
	var cookieLogo = readCookie("vote_"+idLogo);
	if(cookieLogo == "1") {
		if(idioma == "angles") 	alert("Only one vote per logo is allowed");
		else					alert("Solo se permite un voto por logo");
		return;
	}
	var frm = document.getElementById("frmVoteLogo");
	if(!frm) return;
	document.getElementById("voteLogoId").value = idLogo;
	frm.submit();
}
