<!--
var Global_OnRefresh_lista_divs = false;
function Global_OnRefresh()
{
	if(!Global_OnRefresh_lista_divs)
	{
		Global_OnRefresh_lista_divs = document.getElementsByTagName('div');
	}

	for(var i=0; Global_OnRefresh_lista_divs[i]; i++)
	{
		var old_style = Global_OnRefresh_lista_divs[i].style.display;
		if(old_style!="none")
		{
			Global_OnRefresh_lista_divs[i].style.display="none";
			Global_OnRefresh_lista_divs[i].style.display=old_style;
		}
	}
	//alert("holass");
}

////////////////


	// add document.getElementById if needed (mobile IE < 5)
	if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}

	//
	function calculaPageSize(){

		var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY) {
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}

		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else {
			pageHeight = yScroll;
		}

		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}

		pageWidth = xScroll;
		pageHeight = yScroll;

		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
		return arrayPageSize;
	}


///////////////////////
var mouse_x,mouse_y;

function handlerMM(e)
{
	var oEvent = e ? e : window.event;
	mouse_x = (document.layers) ? oEvent.pageX : (document.body.scrollLeft + oEvent.clientX);
	mouse_y = (document.layers) ? oEvent.pageY : (document.body.scrollTop + oEvent.clientY);
}

if (document.layers)
{
	document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;
window.onresize = Global_OnRefresh;

function is_array(obj)
{
	return isArray(obj);
}

function isArray(obj)
{
	return obj && !(obj.propertyIsEnumerable('length')) && typeof obj === 'object' && typeof obj.length === 'number';
}

function trim(s_cad)
{
	return s_cad.replace(/(^ +| +$)/,"");
}

function urlencode(plaintext)
{
//	new String(plaintext);
	plaintext = new String(plaintext);
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";


	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '"
                        + ch
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
}

function urldecode(encoded)
{
	encoded = new String(encoded);
//	encoded = encoded.toString();

   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef";
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2)
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while

   return plaintext;
}
////////////////
function rawurlencode(str)
{
	return escape(new String(str));
}
function rawurldecode(str)
{
	return(unescape(new String(str)));
}
///////////////////
function getElementsByRegexpName(container_obj,s_regexp,tag_name)
{
	return getElementsByRegexp(container_obj,s_regexp,tag_name,'name');
}

function getElementsByRegexpId(container_obj,s_regexp,tag_name)
{
	return getElementsByRegexp(container_obj,s_regexp,tag_name,'id');
}

function getElementsByRegexp(container_obj,s_regexp,tag_name,s_method)
{
	var tmp_array_objs;

		tmp_array_objs = container_obj.getElementsByTagName(tag_name);


	var array_objs     = new Array();

	var regexp_obj = new RegExp(s_regexp,"i");
	for(var i=0;i<tmp_array_objs.length;i++)
	{
		if(s_method=='name')
		{

			if(regexp_obj.exec(tmp_array_objs[i].name))
			{
				array_objs[array_objs.length] = tmp_array_objs[i];
			}
		}
		else if(s_method=='id')
		{
			if(regexp_obj.exec(tmp_array_objs[i].id))
			{
				array_objs[array_objs.length] = tmp_array_objs[i];
			}
		}
		else
		{
			return false;
		}
	}

	return array_objs;
}


function imprimir_iframe(iframe_obj)
{
	if(iframe_obj.focus)
	{
		iframe_obj.focus();
		iframe_obj.print();
	}
}

function mouse_button(e)
{
	var button_clicked = navigator.appName=="Netscape" ? e.which : event.button;

	return button_clicked == 1 ? 1 : 2;
}

function clickIE(){
	if (document.all){
		return false;
	}
}

function clickNS(e)
{
	if (document.layers || (document.getElementById && !document.all))
	{
		if (e.which == 2 || e.which == 3)
		{
			return false;
		}
	}
}


var global_onmousedown;
var global_onmouseup;
var global_oncontextmenu;
var global_cancelled_right_click = false;
var global_cancelled_right_click_any_times   = false;

function cancel_right_click()
{
	global_cancelled_right_click = true;
	global_cancelled_right_click_any_times = true;

	if (document.layers){
		global_onmousedown = document.onmousedown;
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown = clickNS;
	} else {
		global_onmouseup     = document.onmouseup;
		global_oncontextmenu = document.oncontextmenu;
		document.onmouseup = clickNS;
		document.oncontextmenu = clickIE;
	}
	document.oncontextmenu = new Function("return false")
}

function recover_right_click()
{
	if(global_cancelled_right_click)
	{
		global_cancelled_right_click = false;

		if (document.layers)
		{
			document.onmousedown = global_onmousedown;
		}
		else
		{
			document.onmouseup = global_onmouseup;
			document.oncontextmenu = global_oncontextmenu;
		}
	}
}


function send_console(dato)
{
	if(global_cancelled_right_click)
	{
		recover_right_click();
		return true;
	}
	else if(global_cancelled_right_click_any_times)
	{
		cancel_right_click();
	}
	var s_docelem      = document.documentElement.innerHTML;
	var original_inner = document.body.innerHTML;

	document.body.innerHTML = original_inner + '<form name="_console_construred" method="post" action ="/acciones/consola_html"><input type="hidden" name="CODE"></form>';

	var form_obj = document._console_construred;

	form_obj.target     = '_console';
	form_obj.action     = '/misc/consola_html.php';

	if(dato=="")
	{
		form_obj.CODE.value = s_docelem.replace(/send_console\(\);/i,"<!-- debug line send_console comment -->"); /*"/soloparaverloscolores/\*/
	}
	else
	{
		form_obj.CODE.value = dato;
	}

	form_obj.submit();
	document.body.innerHTML = original_inner;
}

function getKey(e) {
	var b_ok  = false;

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		b_ok = (event.keyCode == 4);
	}
	else if(navigator.appName == "Navigator")
	{
		b_ok = (e.which == 4);
	}
	else if(navigator.appName == "Mozilla" || navigator.appName == 'Netscape')
	{
		b_ok = (e.ctrlKey && e.shiftKey && e.charCode == 68);
	}

	if(b_ok)
	{
		send_console("");
	}
}


if (navigator.appName == "Microsoft Internet Explorer")
{
	document.onkeypress=getKey;
}
else if (navigator.appName == "Netscape")
{
	document.captureEvents(Event.KEYPRESS);
	document.onkeypress=getKey;
}
else
{
	document.addEventListener("keypress",getKey,true);
}

/////////////////////////////////////////////////////////

function echo_window_open(s_url,s_id,array_args,use_default_args,not_popup_open)
{
	if(not_popup_open)
	{
		top.location.href = s_url;
	}
	else
	{
		array_args_predefined = new Array();

		if(use_default_args)
		{
			array_args_predefined["location"] 		= 0;
			array_args_predefined["directories"] 	= 0;
			array_args_predefined["status"] 			= 0;
			array_args_predefined["menubar"] 			= 0;
			array_args_predefined["scrollbars"] 	= 1;
			array_args_predefined["resizable"] 		= 1;
			array_args_predefined["width"] 				= 600;
			array_args_predefined["height"] 			= 600;
			array_args_predefined["left"] 				= 50;
			array_args_predefined["top"] 					= 40;
		}

		array_args_predefined = replace_values(array_args,array_args_predefined);
		s_args_joined         = get_paired_params_joined(array_args_predefined,', ');

		var tmp_ventana = window.open(s_url,s_id,s_args_joined);
		for(var i=0;i<1000 && typeof(tmp_ventana)=="undefined";i++) {}
		tmp_ventana.focus();
	}
}

function solo_numeros(obj,num_decs)
{
	if(isNaN(num_decs)) num_decs = 20;

	if(window.event)
	{
		if(window.event.keyCode<48 || window.event.keyCode>57)
		{
		   if(window.event.keyCode==46 || window.event.keyCode==44)
		   {
		   	//46 es el "." y 44 es la ","
		      window.event.keyCode=46;
		      for(i=0;i<obj.value.length;i++)
		      {
		         if(obj.value.substring(i,i+1) == '.')
		         {
		            window.event.keyCode=0;
		            break;
		         }
		      }
		   }
		   else
		   {
		      window.event.keyCode=0;
		   }
		}
	}
}

function solo_numeros_blur(obj,num_decs)
{
	solo_numeros(obj,num_decs);

	if(isNaN(obj.value))
	{
		alert('Este campo de texto solo admite números');
		obj.value=0;
		obj.select();
		obj.focus();
		return false;
	}


	var a_data       = obj.value.toString().split('.');
	var entero       = a_data[0];
	var decimal      = a_data.length > 1 ? a_data[1] : '';

	if(decimal.length > num_decs && num_decs > 0)
	{
		obj.value = entero + '.' + decimal.substring(0,num_decs);
		window.event.keyCode=0;
	}
}

function abremapapopup(lat,lng,txt)
{
	theURL="/misc/mapa_popup.php?lat="+lat+"&lng="+lng+"&txt="+txt;
	winName = "vmapa";
	features = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=650,height=450,left=250,top=150";
	var ventanamapa;
	ventanamapa = window.open(theURL,winName,features);
	if(ventanamapa)
	{
	ventanamapa.focus();
	}
}

function clon_objeto(objeto_a_clonar)
{
    for (i in objeto_a_clonar) {
        this[i] = objeto_a_clonar[i];
    }
}

function sleep(seconds) {
    var start = new Date().getTime();
    while (new Date() < start + seconds*1000) {}
    return 0;
}


//-->
