// JavaScript Document

$(document).ready(function(){

	$("#expandir").click(function(){
		
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			$("body","html").css({height: "100%", width: "100%"});
			$("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
				$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
				$("#TB_overlay").click(function(){
					normalizar(0);
				});
			}
		}else{//all others
			if(document.getElementById("TB_overlay") === null){
				$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
				$("#TB_overlay").css("width",getWidth());
				$("#TB_overlay").click(function(){
					normalizar(0);
				});
			}

		}

		if($.browser.msie){
			var obj = document.getElementsByTagName("object");
			obj = obj[1];
			$(obj).css("z-index","400");
			$(obj).css("width",getWidth()-300);
			$(obj).css("height",getHeight()-100);
			$(obj).css("position","absolute");
			$(obj).css("left","150px");
			$(obj).css("top","50px");
			
			obj = document.getElementsByTagName("embed");
			obj = obj[1];
			$(obj).css("z-index","400");
			$(obj).css("width",getWidth()-300);
			$(obj).css("height",getHeight()-100);
			$(obj).css("position","absolute");
			$(obj).css("left","150px");
			$(obj).css("top","50px");
			
		}else{
			var obj = document.getElementsByTagName("object");
			obj = obj[1];
			$(obj).css("z-index","400");
			$(obj).css("width",getWidth()-300);
			$(obj).css("height",getHeight()-100);
			$(obj).css("position","absolute");
			$(obj).css("left","0px");
			$(obj).css("top","0px");
			

			obj = document.getElementsByTagName("embed");
			obj = obj[1];
			$(obj).css("z-index","400");
			$(obj).css("width",getWidth()-300);
			$(obj).css("height",getHeight()-100);
			$(obj).css("position","absolute");
			$(obj).css("left","0px");
			$(obj).css("top","0px");
			$(obj).css("margin-left","150px");
			$(obj).css("margin-top","50px");
		}
		
		window.scrollBy(0,0);
		
	});

});

$(document).keypress(function(e){
	normalizar(e.which);
});

function getWidth(){
	return window.innerWidth ? window.innerWidth : /* For non-IE */
	document.documentElement ? document.documentElement.clientWidth : /* IE 6+ (Standards Compilant Mode) */
	document.body ? document.body.clientWidth : /* IE 4 Compatible */
	window.screen.width; /* Others (It is not browser window size, but screen size) */
}

function getHeight(){
	return window.innerHeight ? window.innerHeight : /* For non-IE */
	document.documentElement ? document.documentElement.clientHeight : /* IE 6+ (Standards Compilant Mode) */
	document.body ? document.body.clientHeight : /* IE 4 Compatible */
	window.screen.height; /* Others (It is not browser window size, but screen size) */
}

function normalizar(valor){
	
	if(valor==0){
		obj = $("object");
		obj = obj[1];
		$(obj).css("width",760);
		$(obj).css("height",550);
		$(obj).css("position","relative");
		$(obj).css("left","0px");
		$(obj).css("top","0px");
		$(obj).css("z-index","0");
		$(obj).css("margin-left","0px");
		$(obj).css("margin-top","0px");

		obj = $("embed");
		obj = obj[1];
		$(obj).css("width",760);
		$(obj).css("height",550);
		$(obj).css("position","relative");
		$(obj).css("z-index","0");
		$(obj).css("left","0px");
		$(obj).css("top","0px");
		$(obj).css("margin-left","0px");
		$(obj).css("margin-top","0px");
		$("#TB_overlay").remove();
	}
	
}