if (!eRV) { var eRV = new Object(); };

eRV.hasRequired 	= function() { 
	if (document.getElementById && document.getElementsByTagName) {
		var html = document.getElementsByTagName('html')[0];
		html.className += ((html.className=='')?'':' ')+'has-dom';
		return true;
		};
	return false;
	}();

/******************************************************************************
 Modulo eRV.hasFlash
 Detector del plug-in Macromedia/Adobe Flash y su version 
 (se requiere la 7 + AS 2)

 ******************************************************************************/
eRV.hasFlash		= function() {
	var flashVersion = 0;
	var required = 7;
	var m = 16; // máxima version por la que testar
	var ua = navigator.userAgent.toLowerCase();
	if (navigator.plugins && navigator.plugins.length) {
		var p = navigator.plugins['Shockwave Flash'];
		if (typeof p == 'object') {
			for (var i = m;i >= 3; i--) {
				if (p.description && p.description.indexOf(i + '.') != -1) { flashVersion = i; break; };
				};
			};
		}
	else if (window.ActiveXObject && window.print) {
		var found = false;
		for (var i = m; i >= 3 && !found; i--) {
			try {
				found = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + i + "');");
				if(found) { flashVersion = i; };
				}
			catch(e) {};
			};
		};
	if (required <= flashVersion) {
		var html = document.getElementsByTagName('html')[0];
		html.className += ((html.className=='')?'':' ')+'has-flash';
		return true;
		};
	return false;
	}();
	
eRV.onbeforeload	= function() {
	if (this.hasRequired) {
		for (var module in this) { 
			if (this[module].onbeforeload) { 
				this[module].onbeforeload();
				};
			};
		};
	};
eRV.onload		= function() {if (this.hasRequired) { for (var module in this) { if (this[module].onload) 		{ this[module].onload(); };};};};


/******************************************************************************
 Modulo eRV.Fichas
 
 Permite utilizar un sistema de visualizacion del contenido basado en fichas
 
 ******************************************************************************/
eRV.Fichas = {
	className 		: 'tabs',
	container		: 'div',
	onbeforeload	: function() {
		var elems	= document.getElementsByTagName(this.container);
		for (var i = 0; i < elems.length; i++) {
			var e = elems[i];
			if (e.className == this.className) {
				var tabs = e.getElementsByTagName('a');
				for (var j = 0; j < tabs.length; j++) {
					var lnk		= tabs[j];
					lnk.tabs	= tabs;
					lnk.tab		= document.getElementById(lnk.href.replace(/^([^#]*#)/,''));
					// Oculta los vínculos
					if (lnk.className != 'active') { lnk.tab.style.display = 'none'; }
					else {
						};
					lnk.onclick = function() {
						// Desactiva todos los vínculos
						
						for (var i = 0; i < this.tabs.length; i++) {
							var lnk = this.tabs[i];
							lnk.className = '';
							lnk.tab.style.display = 'none';
							};
						this.className = 'active';
						this.tab.style.display = 'block';
						 eRV.SmoothScroll.start();
						 eRV.Clear.init();
						//this.blur();
						var theIframe = document.getElementById('doUpdate');
						if(theIframe) theIframe.setAttribute('src','blank.html');
						return false;
						};
					};
				};
			};
		}
	};
/******************************************************************************
 Modulo eRV.SmoothScroll

 ******************************************************************************/
eRV.SmoothScroll = {
	button		: null,
	x			: null,
	y			: null,
	timer		: null,
	interval	: 25,
	start		: function() {
		this.timer = window.setTimeout("eRV.SmoothScroll.animate()",500);
		},
	onload			: function() {
		//window.scroll(0,0);
		},
	onbeforeload	: function() {
		var self = this;
		if(document.getElementById("backtotop2")) {
			this.button02 = document.getElementById("backtotop2").getElementsByTagName("a")[0];

			this.button02.onclick = function() {
				clearTimeout(self.timer);
				this.blur();
				self.animate();
				return false;
				};
			};
		},
	animate		: function() {
		var x1 = x2 = x3 = 0;
		var y1 = y2 = y3 = 0;

		if (document.documentElement) {
			x1 = document.documentElement.scrollLeft || 0;
			y1 = document.documentElement.scrollTop || 0;
			};
		if (document.body) {
			x2 = document.body.scrollLeft || 0;
			y2 = document.body.scrollTop || 0;
			};

		x3 = window.scrollX || 0;
		y3 = window.scrollY || 0;

		var x = Math.max(x1, Math.max(x2, x3));
		var y = Math.max(y1, Math.max(y2, y3));

		window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

		if (x > 0 || y > 0) {
			this.timer = window.setTimeout("eRV.SmoothScroll.animate()",this.interval);
		} else {
			clearTimeout(this.timer);
			};
		}
	};	

/******************************************************************************
 Modulo eRV.Clear

 ******************************************************************************/
eRV.Clear = {
	id01		: 'sidebar',
	id02		: 'main-content',
	ci			: null,
	onbeforeload: function() {
		this.init();
		},
	init		: function() {
		if($(this.id01)) {
			var h2 = $(this.id02).offsetHeight;
			var h1 = $(this.id01).offsetHeight;
			//alert("main-content: " + h2 + ', sidebar: ' + h1);
			if(h2 < h1) {
				$(this.id02).setStyle('height', h1 + 'px'); 
				}
			//alert("main-content: " + $(this.id02).offsetHeight + ', sidebar: ' + $(this.id01).offsetHeight);
			}
		},
	interval	: function() {
		this.ci = window.setInterval("eRV.Clear.onbeforeload()", 1000);
		}
	};
	
eRV.Clear02 = {
	id01		: 'skybox1',
	id02		: 'skybox2',
	ci			: null,
	onbeforeload: function() {
		this.init();
		},
	init		: function() {
		if($(this.id01)) {
			var h2 = $(this.id02).offsetHeight;
			var h1 = $(this.id01).offsetHeight;
			//alert("main-content: " + h2 + ', sidebar: ' + h1);
			if(h2 < h1) {
				$(this.id02).setStyle('height', h1 + 'px'); 
				}
			//alert("main-content: " + $(this.id02).offsetHeight + ', sidebar: ' + $(this.id01).offsetHeight);
			}
		},
	interval	: function() {
		this.ci = window.setInterval("eRV.Clear02.onbeforeload()", 1000);
		}
	};

/******************************************************************************
 window.onload
 ******************************************************************************/
window.onload	= function() { eRV.onload(); eRV.Clear.interval(); eRV.Clear02.interval(); };
window.onunload = function() { window.clearInterval(eRV.Clear.ci); window.clearInterval(eRV.Clear02.ci); };

/*
var Task = new Object({

	create: function() {
		if (this.initialise)
			window.addEventListener("load", this.initialise, false);
	},
	
	makeNew: function() {
		var instance = this.identify && this.identify.apply(this, arguments) || {};

		for (var property in this) {
			if (property in Task.reserved) continue;

			instance[property] = Task.bind(this[property], instance);
		}

		return this.create && this.create.apply(instance, arguments) || instance;
	},

	extend: function(basis) {
		basis.extend = function() {
			return Task.extend.apply(basis, arguments);
		}

		Task.define.call(basis, this, true);

		return Task.makeNew.apply(basis);
	},

	define: function(source, preserve) {
		for (var property in source) {
			if (preserve && this[property]) continue;

			this[property] = source[property];
		}
	},
	
	reserved: { create: null, identify: null },
	
	bind: function(method, owner) {
		if (typeof method != "function") return method;

		return function() {
			return method.apply(owner, arguments);
		}
	}

});

// Animation

var Animation = Task.extend( {

	start: function(action, guide, limit) {
		var current = Math.round(guide += (limit - guide) / 3);

		return action(current, limit) && current != limit
			&& window.setTimeout(this.start, 32, action, guide, limit);
	}

} );

var Configure = Task.extend({

	initialise: function() {
		this.config = document.getElementById("options");
		if (!this.config) return;

		this.wrapper = document.createElement("div");
		this.wrapper.appendChild(this.config);

		this.hideMe = (window.navigator.vendor != "Apple Computer, Inc.") ? null : "block";

		this.wrapper.style.display = "block";
		this.wrapper.style.overflow = "hidden";
		this.wrapper.style.height = "auto";

		h2 = document.getElementsByTagName("address")[0];
		h2.parentNode.insertBefore(this.wrapper, h2.nextSibling);

		this.link = h2.getElementsByTagName("a")[0];
		this.link.addEventListener("click", this.toggle, false);

		this.link.addEventListener("click", this.cancel, false);
		this.link.addEventListener("mousedown", this.cancel, false);
	},

	toggle: function() {
		this.link.removeEventListener("click", this.toggle, false);

		if (this.wrapper.style.height != "auto") {
			this.wrapper.style.display = "block";
			Animation.start(this.update, 0, this.config.offsetHeight);

		} else Animation.start(this.update, this.config.offsetHeight, 0);
	},

	update: function(position, destination) {
		this.wrapper.style.height = position + "px";

		if (position == destination) {
			if (this.wrapper.offsetHeight > 0) {
				this.wrapper.style.height = "auto";
			} else {
				this.wrapper.style.display = this.hideMe || "none";
			}

			this.link.addEventListener("click", this.toggle, false);

			return false;
		}

		return true;
	}

});
*/