/**
 * rutinas.js: several utilities for data manipulation, etc.
 *
 * by Eduardo Hernando Izcara. Copyright 2008 agroGEX.
 */
// ------------------------------------------------------------------------

// Make sure we haven't already been loaded
var Rutinas;
if (Rutinas && (typeof Rutinas != "object" || Rutinas.NAME))
{
	throw new Error("Namespace 'Rutinas' already exists");
}

// Create our namespace, and specify some meta-information
Rutinas = {};
Rutinas.NAME = "Rutinas";    // The name of this namespace
Rutinas.VERSION = 1.0;       // The version of this namespace

// Algunas variables globales del namespace:

// ------------------------------------------------------------------------

/**
 * Obtine el ancho cliente (útil) de la ventana.
 * (Aún sin implementar).
 */
Rutinas.clientWidth = function()
{
	var w = 0;
	return w;
}
// ------------------------------------------------------------------------

/**
 * Obtine el alto cliente (útil) de la ventana.
 * (Aún sin implementar).
 */
Rutinas.clientHeight = function()
{
	var h = 0;
	return h;
}
// ------------------------------------------------------------------------

/**
 * Establece un par de 'cookies' con el ancho y el alto del mapa a
 * representar cuando se seleccione 'EXTENT' como tamaño de mapa.
 * Los parámetros resultantes dependerán de la geometría del navegador
 * cliente, lógicamente.
 */
Rutinas.setMapExtentCookies = function()
{
	var w = 0;
	var h = 0;

	// En función del navegador que estemos utilizando (IE, FF, Opera,...):
	if (window.innerWidth) {
		w = window.innerWidth;
		h = window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
	}
	else if (document.body.clientWidth) {
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	}

	document.cookie = "cliente_ancho=" + (w - 392);
	document.cookie = "cliente_alto=" + (h - 172);
}
// ------------------------------------------------------------------------

/**
 * Maximiza la ventana del navegador
 */
Rutinas.setMaxSizeWindow = function()
{
	if (!window.outerWidth || (window.outerWidth < screen.availWidth) || (window.outerHeight < screen.availHeight)) {
		window.moveTo(0,0);
		window.resizeTo(screen.availWidth,screen.availHeight)
	}
}
// ------------------------------------------------------------------------
