function stripslashes(str) {
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}
function del(id,program){
	$.ajax({
      type: "POST",
      dataType: "json",
      url: '/backend/comunidad/'+program+".php",
      data: "id="+ id,
	  timeout: 12000,
      success: function(json){
        if( json.status == true ) {
          	$('#friend'+id).hide("slow");
        } else {
			$("#ErrorMsj").html(json.error);
        }
      }
    })
}
function ajax_data(data,program,su,tipo){
	$('#loading').show();
	if(data == '') return;
	$.ajax({
      type: "POST",
      dataType: "json",
      url: '/backend/comunidad/'+program+".php?tip="+tipo,
      data: data,
	  timeout: 32000,
      success: procesado(su),
	  error: function(data){
        	$("#ErrorMsj").hide();
			$("#ErrorMsj").html('Se ha producido un error');
			$('#loading').hide("slow");
      }
    })
}
function borrar(id,program,div){
	$('#loading').show();
	$.ajax({
      type: "POST",
      dataType: "json",
      url: '/backend/comunidad/'+program+".php",
      data: "del="+ id,
	  timeout: 12000,
      success: function(json){
        if( json.status == true ) {
          	$('#'+div).hide();
			$('#loading').hide("slow");
        } else {
			$("#ErrorMsj").hide();
			$("#ErrorMsj").html(json.error).show("slow");
			$('#loading').hide("slow");
        }
      }
    })
}
function sendrequest(program,container,id,text,id2){
	$('#loading').show();
	$("#"+container).html('cargando...');
	$.ajax({
      type: "POST",
      dataType: "json",
      url: '/backend/comunidad/'+program+'.php',
      data: 'id='+id+'&text='+escapeURI(text)+'&id2='+id2,
	  timeout: 12000,
      success: function(json){
        if( json.status == true ) {
          	$("#"+container).html(stripslashes(json.error));
			$('#loading').hide("slow");
        } else {
			$("#"+container).html(stripslashes(json.error));
			$('#loading').hide("slow");
        }
      }
    })
}
function get_pag(program,container){
	$('#loading').show();
	$("#"+container).html('');
	$.ajax({
      type: "POST",
      dataType: "html",
      url: program,
	  timeout: 12000,
      success: function(data){
          	$("#"+container).html(data);
			$('#loading').hide();
      }
    })
}
function escapeURI(u){
	if(encodeURIComponent){
		return encodeURIComponent(u);
	}
	if(escape){
		return escape(u);
	}
}
function htmlspecialchars(text){
	if(typeof(text)=='undefined'||!text.toString){
		return'';
	}
	if(text===false){
		return'0';
	}else if(
		text===true
	){
		return'1';
	}
	return text.toString().replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/'/g,'&#039;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
}
function confirmReject(confirmMsg, rejectLink) { if(confirm(confirmMsg)) { self.location=rejectLink;}return true}
(function($) {
	$.fn.toggleVal = function(theOptions) {
		theOptions = $.extend({
			focusClass: "tv-focused",
			changedClass: "tv-changed",
			populateFrom: "default",
			removeLabels: false
		}, theOptions);
		return this.each(function() {
			var defText = "";
			switch(theOptions.populateFrom) {
				case "alt":
					defText = $(this).attr("alt");
					$(this).val(defText);
					break
				case "label":
					defText = $("label[for='" + $(this).attr("id") + "']").text();
					$(this).val(defText);
					break
				default:
					defText = $(this).val();
			}
			$(this).addClass("toggleval");
			if(theOptions.removeLabels == true) { $("label[for='" + $(this).attr("id") + "']").remove(); }
			$(this).focus(function() {
				if($(this).val() == defText) { $(this).val(""); }
				$(this).addClass(theOptions.focusClass).removeClass(theOptions.changedClass);
			}).blur(function() {
				if($(this).val() == "") { $(this).val(defText); }
				$(this).removeClass(theOptions.focusClass);
				if($(this).val() != defText) { $(this).addClass(theOptions.changedClass); }
					else { $(this).removeClass(theOptions.changedClass); }
			});
		});
	};
})(jQuery);
function mainmenu(){
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}
function myPopUp(url, myname, wd, ht){ 
	var PopUp;
	myleft = ((screen.width-wd)/2); 
	mytop = ((screen.height-ht)/2); 
	settings="width=" + wd + ",height=" + ht + ",top=" + mytop + ",left=" + myleft + ",menubar=no,toolbar=no,directories=no,location=no,status=no,scrollbars=no,rezizable=yes";
	PopUp = window.open(url, myname, settings); 
	PopUp.focus();
}
$(document).ready(function(){					
	mainmenu();
});
function SelectAll(id){ $('#'+id).focus(); $('#'+id).select();}
var loading_gif = "<div align=\"center\"><br /><img src='/images/load.gif' alt='cargando'> <br />Cargando Contenido...<br /><br /><br /></div>";
function sendData(program,container,data,loading){
	$(container).html(loading);
	$.ajax({
      type: "POST",
      dataType: "json",
      url: '/backend/'+program+'.php',
      data: data,
	  timeout: 12000,
      success: function(json){
        if( json.status == true ) {
          	$(container).html(json.error).removeClass("red");
        } else {
			$(container).html(json.error).addClass("red");
		}
      }
    })
}