String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, "");    };
var regexjson = /<json>(.*?)<\/json>/m;

function parseJson(texto) {
	var json = "{}";
	var jsondata;
	if (regexjson.test(texto)) {
		aux = regexjson.exec(texto);
		json = aux[1];
		jsondata = eval("("+json+")");
		return jsondata;
	} else {
		return texto;
	}
}


function aleatorio(inferior,superior){ 
	numPosibilidades = superior - inferior 
	aleat = Math.random() * numPosibilidades 
	aleat = Math.round(aleat) 
	return parseInt(inferior) + aleat 
}


function ValidarCorreo(email){
   var formato = /^([\w-\.\+])+@([\w-]+\.)+([a-z]){2,4}$/;
   var comparacion = formato.test(email);
   return comparacion;
}

function Debug(texto) {
	document.getElementById("debug").innerHTML = texto;
}

function GetWinWidth() { 
   var w; 
   if (typeof window.innerWidth != 'undefined') { 
      w = window.innerWidth; 
   } else { 
      if (typeof document.documentElement != 'undefined' 
        && typeof document.documentElement.clientWidth !=  
        'undefined' && document.documentElement.clientWidth != 0) { 
         w = document.documentElement.clientWidth; 
      } else {    
         w = document.getElementsByTagName('body')[0].clientWidth; 
      } 
   } 
   return w; 
} 
function GetWinHeight() { 
   var h; 
   if (typeof window.innerHeight != 'undefined') { 
      h = window.innerHeight; 
   } else { 
      if (typeof document.documentElement != 'undefined' 
        && typeof document.documentElement.clientHeight !=  
        'undefined' && document.documentElement.clientHeight != 0) { 
         h = document.documentElement.clientHeight; 
      } else {    
         h = document.getElementsByTagName('body')[0].clientHeight; 
      } 
   } 
   return h; 
}

function GetKey(e) {
	var keynum;
	if(window.event) { keynum = e.keyCode; }
	else if(e.which) { keynum = e.which; }
	return keynum;
}
