
// JavaScript Document

//FUCIONES

	// PHP AJAX
	function phpajax(id,path,vars,funciones) 
	{
		 $.ajax({
		   type: "POST",
		   url: path,
		   data: vars,
		   success: function(html){
			$(id).html(html);
			tb_init('a.thickbox, area.thickbox, input.thickbox');
		   }
		 });
	}
	
	function ajaxBoolean(path, vars){
		
		var html = $.ajax({
		type: "POST",
		url: path,
		data: vars,
		cache: false,
		async: false
		}).responseText;	
	
		return html;
	}
	
	function in_array(needle, haystack)
	{
		for (var i = 0; i < haystack.length; i++) {
			if (haystack[i] == needle) {
				return true;
			}
		}
		return false;
	}
	
	function numbersonly(e)
	{
		var unicode=e.charCode? e.charCode : e.keyCode
		var caracteresEspeciales = new Array('8','46','37','38','39','40');
		
		if (in_array(unicode,caracteresEspeciales) == false)
		{
			if (unicode<48||unicode>57)
			{
				return false;
			}
		}
	}
	
	function textOnly(char)
	{	
		if(char.length>0)
		{
			for(var i=0; i < char.length; i++){
				txt = char.substr(i,i+1);
				if(!txt.match(/\w/)){
					return false;
				}
			}
		}
		else
		{
			return false;
		}
		return true;
	}
	
	function popUp(url, alto, ancho, atributos){
		
		var ops = "top=" + ((screen.height - alto) / 2);
		ops += ",left=" + ((screen.width - ancho) / 2);
		ops += ",height="+ alto;
		ops += ",width="+ancho;
		
		if(atributos != ""){
			ops+= ','+atributos;
		}
		
		window.open(url, "popup", ops);
	}
	

	// Redireccion
	function goUrl(url){
		
		if(url == ""){
			url = location.href;
		}
		location.href = url;
	}