/*********************************************************************/
/** GALERIA DE FOTOS - ESPAÇOS ***************************************/
/*********************************************************************/
var currentGalleryLink = new Array();

function LoadPicture(pictureName,imageFile){
	
	// FADE IN / FADE OUT - Transição
	if (document.all){
		document.getElementById(pictureName).style.filter="blendTrans(duration=1)";
		document.getElementById(pictureName).filters.blendTrans.Apply();
	}
	
	document.getElementById(pictureName).src = imageFile;
	
	if (document.all){
		document.getElementById(pictureName).filters.blendTrans.Play();
	}
	// Para não usar fades, colocar a linha abaixo.
	// Caso quiser usar, descomentar bloco acima e comentar linha de baixo
	//document.getElementById(pictureName).src = imageFile;
	
	// Which link is currently selected?
	for (i=0; i < document.links.length;i++){
	   	var l=document.links[i];
	   	var n=l.getAttributeNode('onclick');
		if (n){
			var onclick = n.value;
	   		if ((onclick) &&
	   			(onclick.indexOf(pictureName) > 0) &&
	   			(onclick.indexOf(imageFile) > 0))
	   		{
			    currentGalleryLink[pictureName] = i;
			    break;
			}
		}
	}
}
function LoadPrev(pictureName)
{
	var current = currentGalleryLink[pictureName];
	if (current == null) current = document.links.length+1;
	var alt = null;
	for (i=document.links.length-1;i>0;i--){
		var link=document.links[i];
		var node = link.getAttributeNode('onclick');
		if (node){
			var onclick = node.nodeValue;
			if ((onclick) &&
				(onclick.indexOf('LoadPicture') >= 0) &&
				(onclick.indexOf(pictureName) > 0))
			{
				if (i < current){
					eval(onclick);
					return;
				} 
				else if (alt == null)
					alt = onclick;
			}
		}
	}
	if (alt) eval(alt);
}
function LoadNext(pictureName){
	var current = currentGalleryLink[pictureName];
	if (current == null) {
		currentGalleryLink[pictureName]=-1;
		LoadNext(pictureName);
		current = currentGalleryLink[pictureName];
	}
	var alt = null;
	for (i=0;i<document.links.length;i++) {
		var link = document.links[i];
		var node = link.getAttributeNode('onclick');
		if (node){
			var onclick = node.value;
			if ((onclick) &&
				(onclick.indexOf('LoadPicture') >= 0) &&
				(onclick.indexOf(pictureName) > 0))
			{
				if (i > current){
					eval(onclick);
					return;
				} 
				else if (alt == null)
					alt = onclick;
			}
		}
	}
	if (alt) {
		eval(alt);
	}
}


/*********************************************************************/
/** FUNÇÕES PARA CONTROLO DE ELEMENTOS *******************************/
/*********************************************************************/
function setEstado(ctrl, estado){
	document.getElementById(ctrl).disabled = !estado;
}

function toggle(obj, invisible, visible) {
	var x = document.getElementById(obj);
	if ( x.style.display != 'none' ) {
		//x.style.display = 'none';
		document.images['toggle'].src = invisible;
	}
	else {
		//x.style.display = '';
		document.images['toggle'].src = visible;
	}
}

function toggleImage(name, img1, img2) {
	if(document.images[name].src == img1) {
		document.images[name].src = img2;
	}
	if(document.images[name].src == img2) {
		document.images[name].src = img1;
	}
}

function setVisible(ctrl, estado){

	if(estado == '1'){
		ctrl.style.display = 'block';
	}
	if(estado == '0'){
		ctrl.style.display = 'none';
	}
	
	return true;
}

/*********************************************************************/
/** OUTRAS ***********************************************************/
/*********************************************************************/
function adicionaFavoritos(title, url){
    if (document.all)
        window.external.AddFavorite(url, title);
    else if (window.sidebar)
        alert("Pressione Ctrl + D para adicionar este site aos favoritos.");  
}

