// JavaScript Document

mostraHTML = '<div id="barramail"><h4>Enviando foto por e-mail</h4><a href="javascript:void(0);" onclick="ajax.fechaEmail();" title="FECHAR">X</a></div><div id="formulario"><form id="mandamai" action="return false;" method="post"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><th>Seu nome: </th></tr><tr><td><input type="text" id="nome" class="campo" onfocus="this.className = \'campofocus\'" onblur="this.className = \'campo\';" /></td></tr><tr><th>Nome do seu amigo: </th></tr><tr><td><input type="text" id="destino" class="campo" onfocus="this.className = \'campofocus\'" onblur="this.className = \'campo\';" /></td></tr><tr><th>E-mail do seu amigo: </th></tr><tr><td><input type="text" id="email" class="campo" onfocus="this.className = \'campofocus\'" onblur="this.className = \'campo\';" /></td></tr><tr><td class="botao"><input type="button" value="Enviar" class="enviar" onmouseover="this.className = \'enviardown\'" onmouseout="this.className = \'enviar\';" onclick="ajax.enviaEmail();" /></td></tr></table></form></div>';

carregandoHTML = '<div id="enviandomail"><img src="img/loaded.gif" />&nbsp;&nbsp;<span>Enviando o e-mail!</span></div>';

var anime = {
	
	setadown : function(item){
		if(item.id == "ant")
			item.src = "img/seta_esq_down.gif";
		
		if(item.id == "prox")
			item.src = "img/seta_dir_down.gif";
		
	},
	
	setaup : function(item){
		if(item.id == "ant")
			item.src = "img/seta_esq_up.gif";
		
		if(item.id == "prox")
			item.src = "img/seta_dir_up.gif";
		
	},
	
	fade : function(item, inicio, fim, time){

		if(fim < inicio) {
			inicio -= 20;
			item.style["filter"] = "Alpha(opacity="+inicio+")";
			item.style["opacity"] = inicio/100;
		}else{
			return;
		}
		
		setTimeout(function(){ anime.fade(item, inicio, fim); }, time);
		
	},
	
	appear : function(item, inicio, fim, time){
		
		if(fim > inicio) {
			inicio += 20;
			item.style["filter"] = "Alpha(opacity="+inicio+")";
			item.style["opacity"] = inicio/100;
		}else{
			return;
		}
		
		setTimeout(function(){ anime.appear(item, inicio, fim); }, time);
		
	},
	
	resizeAbre : function(local, winicio, winc, wfim, hinicio, hinc, hfim){
		
		if(winicio < wfim){
			winicio += winc;
			local.style.width = winicio+"px";
		}else{
			if(hinicio < hfim) {
				hinicio += hinc;
				local.style.height = hinicio+"px";
			}else{
				local.innerHTML = mostraHTML;
				return;
			}
		}
		
		setTimeout(function(){ anime.resizeAbre(local, winicio, winc, wfim, hinicio, hinc, hfim); }, 40);
		
	},
	
	resizeFecha : function(local, winicio, winc, wfim, hinicio, hinc, hfim){
		
		if(hinicio > hfim) {
			hinicio -= hinc;
			local.style.height = hinicio+"px";
		}else{
			if(winicio > wfim){
				winicio -= winc;
				local.style.width = winicio+"px";
			}else{
				div = document.getElementById('tudo');
				div.removeChild(local);
				return;
			}
		}
		
		setTimeout(function(){ anime.resizeFecha(local, winicio, winc, wfim, hinicio, hinc, hfim); }, 40);
	
	},
	
	zoomFoto : function(tipo, status){
		
		imagens = document.getElementById('miniaturas').childNodes;
		
		x = imagens[0].width;
		y = imagens[0].height;
		
		if(tipo == "+") {
			
			if(x < 180) {
				for(i=0;i<imagens.length;i++){
					imagens[i].width = x+20;
					imagens[i].height = y+15;
				}
			}
			
		}else{
			
			if(x > 60) {
			
				for(i=0;i<imagens.length;i++){
					imagens[i].width = x-20;
					imagens[i].height = y-15;
				}
			}
		}
	}
	
}
