function mediaMnd(nrol, action, property, lang, media, parent, url){
	
    if(action == "delete"){
    	var val = "";
		if (!confirm('Desea eliminar definitivamente este objeto?')){ 
			return false;
		}else{
			

		    $.ajax({
		        type: "POST",
		        dataType: "xml",
		        url: WWW_ROOT+"/admin/media.php",
		        data: {value: val, action: action, property: val, lang: val, media: media, parent: parent},
		        error: function(objeto,error){
		            alert("Error: "+error);
		        },
		        success: function(xml){
		        	 if($(xml).find("result").text() == true){
		        		 alert("La operación ha sido realizada correctamente.");
		        		 var page = WWW_ROOT+"/"+url;
		        		 location.href=page;
		        		 setTimeout ("", 1000);
		        		 //$("#crntNew"+id).remove();
		             }else{
		                 alert($(xml).find("result").text());
		             }	
		     	}
			  });
		}
		
    
    }else{
    
	    $.ajax({
	        type: "POST",
	        dataType: "xml",
	        url: WWW_ROOT+"/admin/media.php",
	        data: {value: nrol.value, action: action, property: property, lang: lang, media: media, parent: parent},
	        error: function(objeto,error){
	            alert("Error: "+error);
	        },
	        success: function(xml){
	        	 if($(xml).find("result").text() == true){
	        		 alert("La operación ha sido realizada correctamente.");
	        		 //$("#crntNew"+id).remove();
	             }else{
	                 alert($(xml).find("result").text());
	             }	
	     	}
		  });
    }
      
}

function showInterface(divToShow){
	if($("#"+divToShow).is(":hidden")){
		$("#"+divToShow).css("opacity", 0).slideDown("slow").animate({opacity:1});
	}else{
		$("#"+divToShow).fadeOut('slow').slideUp("slow").animate({opacity:1}); 
	}
}

function resetPw(ln){
	  var message = "Debe introducir el correo electronico!";
	  if(ln == "en"){ message = "Please introduce your email!"; }
	  if($("#mail").val() == ""){
		  alert(message);
		  return false;
	  }
	  $.ajax({
	        type: "POST",
	        dataType: "xml",
	        url: WWW_ROOT+"/admin/pw.php",
	        data: {mail: $("#mail").val()},
	        error: function(objeto,error){
	            alert("Error: "+error);
	        },
	        success: function(xml){
	        	alert($(xml).find("result").text());	
	     	}
		  });
}

function writeComment(work){
	window.open("commentWindow.php?work="+work, "comment", "width=650,height=500");		
}

function showTemplate(section, object){
	 window.open(WWW_ROOT+"/"+section+"-"+$("#"+object).val()+"-"+section, section) ;
}

function deleteItem(id, type, translate, url){
	if(!type){type = "def";}
	if (!confirm("Are you sure you want to delete this "+translate+" permanetly?")){ 
		return false;
	}else{
	   $.ajax({
        type: "POST",
        dataType: "xml",
        url: WWW_ROOT+"/admin/deleteItem.php",
        data: {id: id, type: type},
        error: function(objeto,error){
            alert("Error: "+error);
        },
        success: function(xml){
        	 if($(xml).find("result").text() == "" || $(xml).find("result").text() == true){
        		 alert("La operación ha sido realizada correctamente.");
        		 if(url){
        			 var page = WWW_ROOT+"/"+url;
	        		 location.href=page;
	        		 setTimeout ("", 1000);
        		 }else{
        			 $("#crnt_"+id).remove();
        		 }
             }else{
                 alert($(xml).find("result").text());
             }	
     	}
	   });
      
	}
}
function getList(action, val){
	$.ajax({
        type: "POST",
        dataType: "xml",
        url: WWW_ROOT+"/admin/lists.php",
        data: {action: action, value: val.value},
        beforeSend: function(objeto){
            $("#loading").append("<img src='"+WWW_ROOT+"/images/site/ajax-loader.gif' />");
        },
        error: function(objeto,error){
            alert("Error: "+error);
        },
        success: function(xml){
        	$("#list").empty();
        	$("#loading").empty();
        	if($(xml).find('error').text()){
        		$("#list").append('<li>'+$(xml).find('error').text()+'</li>');	
        	}else{
        		$("#list").append('<li><strong>'+$(xml).find('count').text()+'</strong></li>');	
        		$(xml).find("user").each(function(){
					var currentWork = "<li id = \""+$(this).find('id').text()+"\">"+$(this).find('firstname').text()+" "+$(this).find('lastname').text()+" | "+$(this).find('mail').text()+"</li>";
					$("#list").append(currentWork);	
				});
        	}
     	}
	   });
}

function red(event, user, url){
	$.ajax({
        type: "POST",
        dataType: "xml",
        url: WWW_ROOT+"/admin/activity.php",
        data: {id_user: user, dato: event.value},
        error: function(objeto,error){
            alert("Error: "+error);
        },
        success: function(xml){
        	 if($(xml).find("result").text() == 1 || $(xml).find("result").text() == true){
        		 alert("La operación ha sido realizada correctamente.");
        		 if(url){
        			 var page = WWW_ROOT+"/"+url;
	        		 location.href=page;
	        		 setTimeout ("", 1000);
        		 }
             }else{
                 alert($(xml).find("result").text());
             }	
     	}
	   });

}