///////////////////////////////////////////////////////////
//// JUMP MENU ////////////////////////////////////////////
///////////////////////////////////////////////////////////
function jumpMenu(targ,selObj,restore){ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
///////////////////////////////////////////////////////////
// POP-UP /////////////////////////////////////////////////
///////////////////////////////////////////////////////////
function popup(page,name,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
	window.open(page,name,settings);
}
///////////////////////////////////////////////////////////
// MOSTRA-ESCONDE /////////////////////////////////////////
///////////////////////////////////////////////////////////
function toggleLayer(layer){
	if(document.getElementById(layer).style.display == "none"){
		document.getElementById(layer).style.display = "";
	}else{
		document.getElementById(layer).style.display = "none";
	}
}
function showLayer(layer){
	if(document.getElementById(layer).style.display == "none"){
		document.getElementById(layer).style.display = "";
	}
}
function hideLayer(layer){
	if(document.getElementById(layer).style.display == ""){
		document.getElementById(layer).style.display = "none";
	}
}
///////////////////////////////////////////////////////////
// SWAP-IMAGES ////////////////////////////////////////////
///////////////////////////////////////////////////////////
function swapImage(control,image){
	document.getElementById(control.id).src = image;
}

///////////////////////////////////////////////////////////
// FITFOTO : Ajusta a janela ao tamanho da imagem /////////
///////////////////////////////////////////////////////////
function fitImage() {
	if (window.innerWidth){
		iWidth = window.innerWidth;
		iHeight = window.innerHeight;
	}else{
		iWidth = document.body.clientWidth;
		iHeight = document.body.clientHeight;
	}
	iWidth = document.getElementById("image").width - iWidth;
	iHeight = document.getElementById("image").height - iHeight;
	window.resizeBy(iWidth, iHeight);
};


function modal(titulo,legenda,imagem){
	
	var winH;
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 > test2){
		winH = document.body.scrollHeight;
	}else{
		winH = document.body.offsetHeight;
	}
	document.getElementById('imageModal').style.display = 'none';
	document.getElementById('imageModal').src = 'images/ajax-loader.gif';
	document.getElementById('imageModal').style.display = 'block';
	
	document.getElementById('imageModalTitulo').innerHTML = '';
	document.getElementById('imageModalLegenda').innerHTML = '';
	
	document.getElementById('modal').style.display = 'block';
	document.getElementById('modalbg').style.display = 'block';
	document.getElementById('modalbg').style.height = winH;
	
	document.getElementById('imageModal').src = imagem;
	document.getElementById('imageModalTitulo').innerHTML = titulo;
	document.getElementById('imageModalLegenda').innerHTML = legenda;

/*
	alert(
		  'imagem: '+imagem+'\n'+
		  'titulo: '+titulo+'\n'+
		  'legenda: '+legenda+'\n'
		  );
	*/
}