var IsPhotoOut = false;
var IsTopicOut = false;
var IsMSIE = false;
var mouseX, mouseY;

if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
	IsMSIE = true;
}


function getMousePos(e){
	if (!e)
	var e = window.event||window.Event;

	if('undefined'!=typeof e.pageX){
		mouseX = e.pageX-20;
		mouseY = e.pageY-20;
	}
	else{
		mouseX = e.clientX + document.body.scrollLeft;
		mouseY = e.clientY + document.body.scrollTop;
	}

	if(IsPhotoOut){
		PosicionaFoto();
	}

}


if(window.Event && document.captureEvents)
document.captureEvents(Event.MOUSEMOVE);

document.onmousemove = getMousePos;

function SacaFoto(IMGFile, Texto){

	if(!IsPhotoOut){
		
		var InHTML = '<body topmargin="0" leftmargin="0" style="background-color: #737270;"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" align="center" bgcolor="#737270"><tr><td height="20"></td></tr><tr><td align="center">';
		InHTML = InHTML + '<img src="'+ IMGFile +'"></td></tr><tr><td><br><p><font face="Verdana" size="1" color="#000000"><b>';
		InHTML = InHTML + Texto +'</font></p></b></td></tr></table></body>';

		document.getElementById('photo_div').style.visibility = "visible";
		if(!IsMSIE){
			document.getElementById('photo_div').innerHTML = InHTML;
		}
		else{
			document.getElementById('frame_photo').style.visibility = "visible";
			document.frames.frame_photo.document.body.innerHTML = InHTML;
		}

		PosicionaFoto();
		IsPhotoOut = true;

	}

}


function MeteFoto(){
	document.getElementById('photo_div').style.visibility = "hidden";
	if(IsMSIE){
	document.getElementById('frame_photo').style.visibility = "hidden";
	}
	IsPhotoOut = false;
}


function PosicionaFoto(){

	var PosX;
	var PosY;
	
	var Margen = 40;
	
	if(IsMSIE){
		if(mouseY <= (screen.height / 2)){PosY = mouseY;}
		else{PosY = mouseY - 350;}

		if(mouseX <= (screen.width / 2)){PosX = mouseX + Margen + document.body.scrollLeft;}
		else{PosX = mouseX - 350 - Margen + document.body.scrollLeft;}
	}
	else{

		PosY = mouseY;
		if(mouseX <= (screen.width / 2)){PosX = mouseX + Margen + document.body.scrollLeft;}
		else{PosX = mouseX - 350 - Margen + document.body.scrollLeft;}
	}

	document.getElementById('photo_div').style.top = PosY;
	document.getElementById('photo_div').style.left = PosX;
	
}

function RedirToGall(Group){
	document.getElementById("redirect" + Group).submit();
}

function ShowTopic(Topic, Explain){
	
	

	if(!IsTopicOut){
		
		var InHTML = '<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center"><tr><td align="left"><img src="../images/topic_arrow.gif"></td></tr><tr><td bgcolor="#f2e6ae" height="120" valign="top" style="padding:10px;"><p class="topic_tit">'+Topic+'<hr class="topic"><font class="topic">'+Explain+'</font></td></tr></table>';

		document.getElementById('topic_div').style.visibility = "visible";
		document.getElementById('topic_div').innerHTML = InHTML;
		
		PosicionaTopic();
		IsTopicOut = true;

	}

}

function HideTopic(){
	document.getElementById('topic_div').style.visibility = "hidden";
	IsTopicOut = false;
}

function PosicionaTopic(){

	var PosX;
	var PosY;
	
	var Margen = 40;
	
	if(IsMSIE){

		PosY = mouseY;
		
		PosX = mouseX;
	}
	else{

		PosY = mouseY;
		if(mouseX <= (screen.width / 2)){PosX = mouseX + Margen + document.body.scrollLeft;}
		else{PosX = mouseX - 350 - Margen + document.body.scrollLeft;}
	}

	document.getElementById('topic_div').style.top = PosY;
	document.getElementById('topic_div').style.left = PosX;
	
}

function SacaDivBanner(urlVideo){
	document.movieplayer.SetVariable("inicio", "1");
	document.movieplayer.SetVariable("urlVideo", urlVideo);	
	document.getElementById("moviediv").style.visibility="visible";
	
	
}
function EscondeDivBanner(){
	document.getElementById("moviediv").style.visibility="hidden"
}