var d = document, dE = d.Element;
var RJE = new Object();

/* Onload/unload
*******************************************************************************/

RJE = {
	init: function() {
		if (navigator.userAgent.indexOf("Opera") != -1) {
		}
		if (d.getElementById) {
			RJE.Widgets.ScrollToTop.init();
			RJE.Widgets.DropDownMenu.iniciar();
		}
	},
	end: function() {
	}
};

window.onload = RJE.init;
window.onunload = RJE.end;

/* Widgets
*******************************************************************************/

RJE.Widgets = {
	// Ayuda a que los Menús dEsplegables funcionen en IE
	DropDownMenu : {
		iniciar : function() {
			
			if (navigator.userAgent.indexOf("MSIE") != -1) {
			
				var elemento = d.getElementById("nav").getElementsByTagName("LI");
				
				for (var i = 0; i < elemento.length; i++) {
					elemento[i].onmouseover = function() {
						this.className += " over";
					}
					elemento[i].onmouseout = function() {
						this.className = this.className.replace(new RegExp(" over\\b"), "");
					}
				}
				
				var elemento = d.getElementById("utilidades").getElementsByTagName("LI");
				
				for (var i = 0; i < elemento.length; i++) {
					elemento[i].onmouseover = function() {
						this.className += " over";
					}
					elemento[i].onmouseout = function() {
						this.className = this.className.replace(new RegExp(" over\\b"), "");
					}
				}
				
			}	
		}
	},
	
	ScrollToTop: {
		button: null,
		x: null,
		y: null,
		timer: null,
		interval: 25,
		
		init: function() {
			var self = this;
			this.button = d.getElementById("backtotop").getElementsByTagName("a")[0];
			this.button.onclick = function() {
				clearTimeout(self.timer);
				this.blur();
				self.animate();
				return false;
			}
		},
		animate: function() {
			var x1 = x2 = x3 = 0;
			var y1 = y2 = y3 = 0;

			if (dE) {
				x1 = dE.scrollLeft || 0;
				y1 = dE.scrollTop || 0;
			}
			if (d.body) {
				x2 = d.body.scrollLeft || 0;
				y2 = d.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("RJE.Widgets.ScrollToTop.animate()",this.interval);
			} else {
				clearTimeout(this.timer);
			}
		}
	}
};


var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-11511077-1");
pageTracker._trackPageview();
} catch(err) {}</script>