
function cargaContenido(valor,url){
	valor_cat = document.getElementById('categoria').options[document.getElementById('categoria').selectedIndex].value;
	document.location =url+"galeriamultimedia/"+valor+"/"+valor_cat;
}
function cargaContenidoCat(valor,url){
	valor_tipus = document.getElementById('tipus_contingut').options[document.getElementById('tipus_contingut').selectedIndex].value;
	document.location =url+"galeriamultimedia/"+valor_tipus+"/"+valor;
}

function envia_comentario(){
	
	alias=document.getElementById("alias").value;
	comentario=document.getElementById("comentario_foto").value;
	id=document.getElementById("id_foto").value;
	if((alias !="")&&( comentario !="")){
		$.ajax({
		   type: "POST",
		   url: "secciones/tumaremagnum/inserta_comentario.php",
		   data: "id="+id+"&comentario="+comentario+"&alias="+alias,
		   success: function(msg){
					ocultaComentarioVideo();
					$("#mensaje_ok").fadeIn("slow");
					document.forms.coment_foto.reset();
					}
				 });	  
	}else{
		ocultaComentarioVideo();
		if(alias ==""){					  
			$("#no_alias").fadeIn("slow");			
		}				
		if(comentario==""){
			$("#no_comentario").fadeIn("slow");
		}
	}
}
function ocultaRecomiendaFoto(){
	$("#no_email").fadeOut("slow");
	$("#no_nombre").fadeOut("slow");
	$("#mensaje_mail_ok").fadeOut("slow");
	}
function recomienda_foto(){
	ocultaRecomiendaFoto();
	tunombre=document.getElementById("tunombre").value;
	tuemail=document.getElementById("tuemail").value;
	sunombre=document.getElementById("sunombre").value;
	suemail=document.getElementById("suemail").value;
	tucomentario=document.getElementById("tucomentario").value;
	id_foto=document.getElementById("id_foto").value;
	if(( suemail !="")&&( tunombre !="")){
	$.ajax({
		   type: "POST",
		   url: "secciones/tumaremagnum/recomienda_foto.php",
		   data: "tunombre="+tunombre+"&tuemail="+tuemail+"&sunombre="+sunombre+"&suemail="+suemail+"&tucomentario="+tucomentario+"&id_foto="+id_foto,
		   success: function(msg){
			   //alert(msg);
			 ocultaRecomiendaFoto();
			$("#mensaje_mail_ok").fadeIn("slow");
			document.getElementById("recomendar").reset();
		
		   }
 		});	  
	}else{
		if(suemail=="")
		$("#no_email").fadeIn("slow");
		if(tunombre=="")
		$("#no_nombre").fadeIn("slow");
		
		}
}
function ocultaTodo(){
	$("#no_nombre").fadeOut("slow");
	$("#no_file").fadeOut("slow");
	$("#no_titulo").fadeOut("slow");
	$("#no_check").fadeOut("slow");
	$("#mensaje_ok").fadeOut("slow");
	}
function ocultaTodoVideo(){
	$("#no_nombre").fadeOut("slow");
	$("#no_codigo").fadeOut("slow");
	
	$("#no_file").fadeOut("slow");
	$("#no_titulo").fadeOut("slow");
	$("#no_check").fadeOut("slow");
	$("#mensaje_ok").fadeOut("slow");
	}	

function envia_foto(){
			$.ajax({
			
				   type: "POST",
				   url: "secciones/tumaremagnum/inserta_foto.php",
				   processData: true,
				   data: "nombre="+nombre+"&titulo="+titulo,
				   success: function(msg){
					//alert(msg);
					ocultaTodo();
					$("#mensaje_ok").fadeIn("slow");
					document.getElementById("publica_foto").reset();
					   }
			 });
		
			


}

function ajaxFileUpload(){
			
			nombre=document.getElementById("nombre").value;
			titulo=document.getElementById("titulo").value;
			fileToUpload=document.getElementById("fileToUpload").value;
			checked=document.getElementById("checkbox").checked;
			if((fileToUpload !="")&&( nombre !="")&&( titulo !="")&&( checked)){
					$("#loading")
					.ajaxStart(function(){
						$(this).show();
					})
					.ajaxComplete(function(){
						$(this).hide();
					});
			
					$.ajaxFileUpload
					(
						{
							url:'secciones/tumaremagnum/doajaxfileupload.php',
							secureuri:false,
							fileElementId:'fileToUpload',
							dataType: 'json',
							success: function (data, status)
							{
								if(typeof(data.error) != 'undefined')
								{
									if(data.error != '')
									{
										alert(data.error);
									}else
									{
										
										//alert(data.msg);
										envia_foto();
									}
								}
							},
							error: function (data, status, e)
							{
								alert(e);
							}
						}
					)					
					return false;
			}else{
				ocultaTodo();
				if(nombre=="")
				$("#no_nombre").fadeIn("slow");
				if(titulo=="")
				$("#no_titulo").fadeIn("slow");
				if(fileToUpload=="")
				$("#no_file").fadeIn("slow");
				if(!checked)
				$("#no_check").fadeIn("slow");				
				
			}
	}	
function ocultaComentarioVideo(){
	$("#no_alias").fadeOut("slow");
	$("#no_comentario").fadeOut("slow");	
	$("#mensaje_ok").fadeOut("slow");	
	}
function envia_comentario_video(){
	ocultaComentarioVideo();
	alias=document.getElementById("alias").value;
	id=document.getElementById("id_video").value;
	coment=document.getElementById("coment_video").value;
	if((alias !="")&&( coment !="")){
			
			$.ajax({
		   type: "POST",
		   url: "secciones/tumaremagnum/inserta_comentario_video.php",
		   data: "id="+id+"&comentario="+coment+"&alias="+alias,
		   success: function(msg){
			 ocultaComentarioVideo();
			$("#mensaje_ok").fadeIn("slow");
			document.forms.comentario_video.reset();

		   }
		 });	
	}else{
		 ocultaComentarioVideo();
		if(alias=="")		  
		$("#no_alias").fadeIn("slow");			
		if(coment=="")
		$("#no_comentario").fadeIn("slow");
				
		}
}

function envia_video(){
	
	
	

	
		
			var codigo= new String(document.getElementById("codigo").value)
			
			
			codigo = codigo.replace(/&/g,'[amper]');
			checked=document.getElementById("checkbox").checked;
			nombre=document.getElementById("nombre").value;
			uri=document.getElementById("uri").value;
			//comentario=document.getElementById("comentario").value;
			titulo=document.getElementById("titulo").value;
			if((codigo !="")&&( nombre !="")&&( titulo !="")&&( checked )){
		
			$.ajax({
				   type: "POST",
				   url: "secciones/tumaremagnum/inserta_video.php",
				   processData: true,
				   data: "codigo="+codigo+"&nombre="+nombre+"&uri="+uri+"&titulo="+titulo,
				   success: function(msg){
					   //alert(msg);
					   ocultaTodoVideo();
					$("#mensaje_ok").fadeIn("slow");
					document.forms.publica_video.reset();

					   }
			 });	

			}else{
				ocultaTodoVideo();
				if(nombre=="")
				$("#no_nombre").fadeIn("slow");
				if(codigo=="")
				$("#no_codigo").fadeIn("slow");
				if(titulo=="")
				$("#no_titulo").fadeIn("slow");
				if(!checked)
				$("#no_check").fadeIn("slow");
				
				}

	

}

function recomienda_video(){
	
	tunombre=document.getElementById("tunombre").value;
	tuemail=document.getElementById("tuemail").value;
	sunombre=document.getElementById("sunombre").value;
	suemail=document.getElementById("suemail").value;
	tucomentario=document.getElementById("tucomentario").value;
	id_video=document.getElementById("id_video").value;
			if((tunombre !="")&&( suemail !="")){
					$.ajax({
				   type: "POST",
				   url: "secciones/tumaremagnum/recomienda_video.php",
				   data: "tunombre="+tunombre+"&tuemail="+tuemail+"&sunombre="+sunombre+"&suemail="+suemail+"&tucomentario="+tucomentario+"&id_video="+id_video,
				   success: function(msg){
					ocultaRecomiendaFoto();
					document.forms.recomendar.reset();
					$("#mensaje_mail_ok").fadeIn("slow");

					$("#suemail").fadeIn("slow");
					$("#no_nombre").fadeOut("slow");
				   }
				 });	  
			}else{
				ocultaRecomiendaFoto();
				if(suemail=="")
				$("#no_email").fadeIn("slow");
				if(tunombre=="")
				$("#no_nombre").fadeIn("slow");		
		}
}