function openDiv (elemento) {
	if (document.getElementById(elemento).className == 'hide') {
		document.getElementById(elemento).className = 'show';
} else if (document.getElementById(elemento).className == 'show') {
		document.getElementById(elemento).className = 'hide';
	}
}


function abre_indicar(login_usuario,id_pic) {	
	openDiv('indica');
	var url = "/home/include_pix/indica_foto.php?login_usuario=" + login_usuario + "&id_pic=" + id_pic;
	new Ajax.Request(url, {
			method: 'get',    		               					  			
				onComplete:function( txt ) {
					Element.update("indica", txt.responseText);								 								
				}
		});
}

function enviar_indicar(login_usuario,id_pic) {
  
  if (document.formindica.emails.value != '') 
  {	  
	  if (document.formindica.login.value != '') 
  	  {													
			var url = "/home/include_pix/enviar_indica.php?login_usuario=" + login_usuario + "&id_pic=" + id_pic + "&emails=" + document.formindica.emails.value + "&login=" + document.formindica.login.value + "&mensagem=" + document.formindica.mensagem.value;
			$('indica').innerHTML = "<table width=100% height=100><tr><td><div align=center><img src=/home/img/carregando.gif > </div></td></tr></table>";		
			new Ajax.Request(url, {
			method: 'get',    		               					  			
				onComplete:function( txt ) {
					Element.update("indica", txt.responseText);								 								
				}
		});
											  
	  }		
	  else 
	  {
		alert('Informe um login para identificação!')
		document.formindica.login.focus();
	  }
  }		
  else 
  {
	alert('Informe pelo ao menos um email!')
	document.formindica.emails.focus();
  }
  
}

function abre_denunciar(login_usuario,id_pic) {	
	openDiv('indica');
	var url = "/home/include_pix/denunciar.php?login_usuario=" + login_usuario + "&id_pic=" + id_pic;
	new Ajax.Request(url, {
			method: 'get',    		               					  			
				onComplete:function( txt ) {
					Element.update("indica", txt.responseText);								 								
				}
		});
}



function enviar_denunciar(login_usuario,id_pic) {
  
 if (document.formdenuncia.login.value != '') 
 {	  
	  if (document.formdenuncia.mensagem.value != '') 
  	  {													
			var url = "/home/include_pix/enviar_denuncia.php?login_usuario=" + login_usuario + "&id_pic=" + id_pic + "&login=" + document.formdenuncia.login.value + "&mensagem=" + document.formdenuncia.mensagem.value;
			$('indica').innerHTML = "<table width=100% height=100><tr><td><div align=center><img src=/home/img/carregando.gif > </div></td></tr></table>";		
			new Ajax.Request(url, {
			method: 'get',    		               					  			
				onComplete:function( txt ) {
					Element.update("indica", txt.responseText);								 								
				}
		});
											  
	  }		
	  else 
	  {
		alert('Informe o motivo da denuncia!')
		document.formdenuncia.mensagem.focus();
	  }
  }		
  else 
  {
	alert('Informe um login para identificação!')
	document.formdenuncia.login.focus();
  }
  
}

function abre_bloquear(login_usuario) {	
	openDiv('indica');
	var url = "/home/include_pix/bloquear.php?login_usuario=" + login_usuario;
	new Ajax.Request(url, {
			method: 'get',    		               					  			
				onComplete:function( txt ) {
					Element.update("indica", txt.responseText);								 								
				}
		});
}



function enviar_bloquear(login_usuario) {
  													
	var url = "/home/include_pix/enviar_bloquear.php?login_usuario=" + login_usuario;
	$('indica').innerHTML = "<table width=100% height=100><tr><td><div align=center><img src=/home/img/carregando.gif > </div></td></tr></table>";		
	new Ajax.Request(url, {
	method: 'get',    		               					  			
		onComplete:function( txt ) {
			Element.update("indica", txt.responseText);								 								
		}
	});
									  
	  
  
}

function enviar_votacao(login_usuario) {
  
 if (document.formvotacao.voto.value != '') 
 {	  
 			var voto;			
			for(var i = 0; i < document.formvotacao.length; i++) {
				if(document.formvotacao[i].checked) {
					voto = document.formvotacao[i].value;
				}
			}
	  													
			var url = "/home/include_pix/enviar_votacao.php?login_usuario=" + login_usuario + "&voto=" + voto;
			$('indica').innerHTML = "<table width=100% height=100><tr><td><div align=center><img src=/home/img/carregando.gif > </div></td></tr></table>";		
			new Ajax.Request(url, {
			method: 'get',    		               					  			
				onComplete:function( txt ) {
					Element.update("indica", txt.responseText);								 								
				}
		});
											  
  }		
  else 
  {
	alert('Informe o voto!')
	document.formvotacao.login.focus();
  }
  
}

function abre_adicionar_favoritos(login_usuario) {	
	openDiv('indica');
	var url = "/home/include_pix/adicionar_favoritos.php?login_usuario=" + login_usuario;
	new Ajax.Request(url, {
			method: 'get',    		               					  			
				onComplete:function( txt ) {
					Element.update("indica", txt.responseText);								 								
				}
		});
}

function abre_votacao(login_usuario, flag_votacao, sexo) {	
	openDiv('indica');
	var url = "/home/include_pix/votacao.php?login_usuario=" + login_usuario + "&flag_votacao=" + flag_votacao+ "&sexo=" + sexo;
	new Ajax.Request(url, {
			method: 'get',    		               					  			
				onComplete:function( txt ) {
					Element.update("indica", txt.responseText);								 								
				}
		});
}

function enviar_adicionar_favoritos(login_usuario) {
  
 													
		var url = "/home/include_pix/enviar_adicionar_favoritos.php?login_usuario=" + login_usuario;
		$('indica').innerHTML = "<table width=100% height=100><tr><td><div align=center><img src=/home/img/carregando.gif > </div></td></tr></table>";		
		new Ajax.Request(url, {
		method: 'get',    		               					  			
			onComplete:function( txt ) {
				Element.update("indica", txt.responseText);								 								
			}
	});					  
  
}

function abre_arquivo(url, parametro) {	
	$('arquivo').innerHTML = "<table width=100% height=434><tr><td><div align=center><img src=/home/img/carregando.gif > </div></td></tr></table>";	
	new Ajax.Request(url, {
			method: 'get', parameters: parametro,    		               					  			
				onComplete:function( txt ) {
					Element.update("arquivo", txt.responseText);								 								
				}
		});
}

function abre_foto(url, parametro) {
    $('foto').innerHTML = "<table width=100% height=434><tr><td><div align=center><img src=/home/img/carregando.gif > </div></td></tr></table>";		
	new Ajax.Request(url, {
			method: 'get', parameters: parametro,    		               					  			
				onComplete:function( txt ) {
					Element.update("foto", txt.responseText);								 								
				}
		});
}

function abre_foto_recarrega(url, parametro) {
    $('foto_recarrega').innerHTML = "<table width=100% height=434><tr><td><div align=center><img src=/home/img/carregando500x375.gif > </div></td></tr></table>";		
	new Ajax.Request(url, {
			method: 'get', parameters: parametro,    		               					  			
				onComplete:function( txt ) {
					Element.update("foto_recarrega", txt.responseText);								 								
				}
		});
}

function abre_slideshow(url, parametro) {
    $('foto_recarrega').innerHTML = "<table width=100% height=434><tr><td><div align=center><img src=/home/img/carregando500x375.gif > </div></td></tr></table>";		
	new Ajax.Request(url, {
			method: 'get', parameters: parametro,    		               					  			
				onComplete:function( txt ) {
					Element.update("foto_recarrega", txt.responseText);								 								
				}
		});
}

function abre_comentario(url, parametro) {	
	$('comentario').innerHTML = "<table width=100% height=434><tr><td><div align=center><img src=/home/img/carregando.gif > </div></td></tr></table>";	
	new Ajax.Request(url, {
			method: 'get', parameters: parametro,    		               					  			
				onComplete:function( txt ) {
					Element.update("comentario", txt.responseText);								 								
				}
		});
}

function abre_mensagem(url, parametro) {	
	$('mensagem').innerHTML = "<table width=100% height=434><tr><td><div align=center><img src=/home/img/carregando.gif > </div></td></tr></table>";	
	new Ajax.Request(url, {
			method: 'get', parameters: parametro,    		               					  			
				onComplete:function( txt ) {
					Element.update("mensagem", txt.responseText);								 								
				}
		});
}

function abre_responder(i,login_visitou,total, parametro) {		
	$("responder_"+i).innerHTML = "<table width=100% height=100><tr><td><div align=center><img src=/home/img/carregando.gif > </div></td></tr></table>";	
	openDiv("responder_"+i);
		var j;
		for (j = 1;j<=total;j++){
			if (i != j) {
				document.getElementById("responder_"+j).className = 'hide';
			}
		}
		
		
		//document.getElementById("iframe1").src= "/home/include_pix/responder_teste.php?login_visitou=" + login_visitou + '&i=' + i;
		
		var url = "/home/include_pix/responder.php?login_visitou=" + login_visitou + '&i=' + i + parametro ;		
		
		new Ajax.Request(url, {
				method: 'get',    		               					  			
					onComplete:function( txt ) {
						Element.update("responder_"+i, txt.responseText);								 								
					}
			});
}

function enviar_mensagem(theme,login_visitou, login_usuario, id_user, id_pic, parametros) {	
	if (document.getElementById("nome").value != '') {
	
		if (document.getElementById("msg").value != '') {
			
			var visivel;
			if (document.form_mensagem.visivel[0].checked) {
				visivel = 's';
			} else {
				visivel = 'n';
			}
			var nome = document.getElementById("nome").value;
			var msg = document.getElementById("msg").value;
			var par = "theme="+theme+"&login_visitou=" + login_visitou + "&login_usuario=" + login_usuario + "&id_user=" + id_user + "&id_pic=" + id_pic + "&msg=" + msg + "&visivel=" + visivel + parametros;
				
			$("mensagem").innerHTML = "<table width=100% height=100><tr><td><div align=center><img src=/home/img/carregando.gif > </div></td></tr></table>";	
			var url = "/home/include_pix/enviar_mensagem.php";
			new Ajax.Request(url, {
					method: 'post' 
					, parameters: par 		               					  			
					,	onComplete:function( txt ) {
							Element.update("mensagem", txt.responseText);								 								
						}
					,	onSuccess:function( txt ) {
							abre_comentario("/home/include_pix/comentarios.php","theme="+theme+"&login_usuario="+login_usuario+"&id_user="+id_user+"&id_pic="+id_pic+ parametros);	
							abre_mensagem("/home/include_pix/mensagem.php","theme="+theme+"&login_usuario="+login_usuario+"&id_user="+id_user+"&id_pic="+id_pic+ parametros);	
							Element.update("mensagem", txt.responseText);								 								
						}
				});
		} else {
	
			alert('Informar a mensagem');
			document.getElementById("msg").focus();	
		}
	} else {
	
		alert('Informar o nome');
		document.getElementById("nome").focus();	
	}
}

function salva_responder(i,login_visitou, id_user_visitou, id_pic_visitou) {	
	
	
		if (document.getElementById("msg_"+i).value != '') {
			
			var msg = document.getElementById("msg_"+i).value;
			
			var visivel;
			if (document.getElementById("visivel1_"+i).checked) {
				visivel = 's';
			} else {
				visivel = 'n';
			}
			var par = "login_visitou=" + login_visitou + "&id_user_visitou=" + id_user_visitou + "&id_pic_visitou=" + id_pic_visitou + "&msg=" + msg + "&visivel=" + visivel;
				
			$("responder_"+i).innerHTML = "<table width=100% height=100><tr><td><div align=center><img src=/home/img/carregando.gif > </div></td></tr></table>";	
			var url = "/home/include_pix/enviar_responder.php";
			new Ajax.Request(url, {
					method: 'post'
					, parameters: par
					, onComplete:function( txt ) {
							Element.update("responder_"+i, txt.responseText);								 								
						}
				});
		} else {
	
			alert('Informar a mensagem');
			document.getElementById("msg_"+i).focus();	
		}
}

function salva_convite(url, parametro){
	var salvar = false;
	for (i = 0; i < document.form_convite.elements.length; i++) {
		if (document.form_convite.elements[i].type == "checkbox") {
			
			if (document.form_convite.elements[i].checked == true) {
			
				salvar = true;
				
			}
			
		}
		
	}
	if (salvar == true) {
		abre_arquivo(url,parametro);
	} else {
		document.form_convite.pedir.focus();
		alert('Selecione se vc deseja acessar as fotos')
	}

}