function abrir_login(){
	if (document.getElementById("login_minha-conta").style.display == "inline"){
		document.getElementById("login_minha-conta").style.display = "none";
	}else{
		document.getElementById("login_minha-conta").style.display = "inline";
	}
}

function fechar_login(){
	document.getElementById("login_minha-conta").style.display = "none";
}


//======================

function mpop(id) {
   window.open('lang.br/fichas/fispq.phtml?id=' + id,'','left=0,top=0,width=770,height=' + (screen.availHeight - 80) + ',scrollbars=yes');
}

function mpopt(id) {
   window.open('lang.br/fichas/ficha_tecnica.phtml?id=' + id,'','left=0,top=0,width=670,height=' + (screen.availHeight - 80) + ',scrollbars=yes');
}
function mpopa(id) {
   window.open('lang.br/fichas/ficha_aplicacao.php?id=' + id,'','left=0,top=0,width=670,height=' + (screen.availHeight - 80) + ',scrollbars=yes');
}
function mpopf(id) {
   window.open('lang.br/fichas/tecnica.php?id=' + id,'','left=0,top=0,width=670,height=' + (screen.availHeight - 80) + ',scrollbars=yes');
}
function mpopc(id){
   window.open('lang.br/fichas/colaborador.php?id=' + id,'','left=0,top=0,width=670,height=' + (screen.availHeight - 80) + ',scrollbars=yes');
}

//======================

var shownWindow;
var contentLoaded = true;

function openWindow(windowID,cwidth,cheight){
	if (!contentLoaded) return ;
	if (shownWindow != null) hideWindow();

	var loadingDiv = document.getElementById( windowID );

	var pageSize = getPageSize();
	var pageScroll = getPageScroll();
	var ctop = pageScroll.yScroll + ((pageSize.windowHeight - cheight - 26) / 2);
	var cleft = ((pageSize.pageWidth - cwidth - 40) / 2);

	var altura1 = pageSize.windowHeight;
	var altura2 = document.body.scrollHeight;
	if (altura1<=altura2) {
		alturaFade = altura2;
	} else {
		alturaFade = altura1;
	}
	//var alturaFade = document.body.scrollHeight;

	var ver = navigator.appVersion;

	if (ver.indexOf("MSIE") != -1) {
		// Internet Explorer
		document.getElementById('fade').style.setAttribute('visibility','visible');
		document.getElementById('fade').style.setAttribute('display','block');
		document.getElementById('fade').style.setAttribute('width',pageSize.pageWidth);
		//document.getElementById('fade').style.setAttribute('height',pageSize.windowHeight);
		document.getElementById('fade').style.setAttribute('height',alturaFade);
		document.getElementById('fade').style.setAttribute('position','absolute');

		loadingDiv.style.setAttribute('position', 'absolute');
		loadingDiv.style.setAttribute('left', parseInt(cleft));
		loadingDiv.style.setAttribute('top', parseInt(ctop));
		loadingDiv.style.setAttribute('visibility', 'visible');
		loadingDiv.style.setAttribute('display', 'block');

	} else {
		// Outros
		$('#fade').css('height',alturaFade);
		$('#fade').show();
		loadingDiv.setAttribute('style',"position:absolute;left:"+cleft+"px;top:"+ctop+"px;visibility:visible");
	}

	shownWindow = loadingDiv;
}

function hideWindow(){
	if (shownWindow == null) return ;

	var ver = navigator.appVersion;

	if (ver.indexOf("MSIE") != -1) {
		// Internet Explorer
		document.getElementById('fade').style.setAttribute('visibility','hidden');
		document.getElementById('fade').style.setAttribute('display','none');
		shownWindow.style.setAttribute( "display" , "none" );
		shownWindow.style.setAttribute( "visibility" , "hidden" );

	} else {
		// Outros
		shownWindow.setAttribute("style","visibility:hidden;position:absolute;display:none;");
		document.getElementById('fade').setAttribute("style","display:none;");

	}

	shownWindow = null;
}

function getScreenSize(){
	var screenW = 0, screenH = 0;
	if (parseInt(navigator.appVersion)>3) {
	 screenW = screen.width;
	 screenH = screen.height;
	}
	else if (navigator.appName == "Netscape"
	    && parseInt(navigator.appVersion)==3
    	&& navigator.javaEnabled()
	   )
	{
	 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
	 var jScreenSize = jToolkit.getScreenSize();
	 screenW = jScreenSize.width;
	 screenH = jScreenSize.height;
	}
	retval={screenW:0,screenH:0};
	retval.screenW = screenW;
	retval.screenH = screenH;
	return retval;
}

function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY){
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	if(yScroll < windowHeight) {
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth) {
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = {pageWidth:pageWidth,pageHeight:pageHeight,windowWidth:windowWidth,windowHeight:windowHeight}
	return arrayPageSize;
	//alert('pageWidth:'+pageWidth+' pageHeight:'+pageHeight+' windowWidth:'+windowWidth+' windowHeight:'+windowHeight);
}

function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = {yScroll:yScroll};
	return arrayPageScroll;
}