// funciones globales para todo el sitio


/*
Suckerfish Shoal
http://www.htmldog.com/articles/suckerfish/shoal/
*/
	/*
	Streamlined Timer class, for object-oriented timeouts @ http://www.codingforums.com/showpost.php?p=50902&postcount=1
	Part of the solution suggested @ http://www.htmldog.com/ptg/archives/000050.php#comment470
	*/
	function Timer(){
		this.obj = (arguments.length)?arguments[0]:window;
		return this;
	}
	Timer.prototype.setTimeout = function(func, msec){
		var i = Timer.getNew();
		Timer.buildCall(this.obj, i, arguments);
		Timer.set[i].timer = window.setTimeout("Timer.callOnce("+i+");",msec);
		return i;
	}
	Timer.set = new Array();
	Timer.buildCall = function(obj, i, args){
		var t = "";
		Timer.set[i] = new Array();
		if(obj != window){
			Timer.set[i].obj = obj;
			t = "Timer.set["+i+"].obj.";
		}
		t += args[0]+"(";
		if(args.length > 2){
			Timer.set[i][0] = args[2];
			t += "Timer.set["+i+"][0]";
			for(var j=1; (j+2)<args.length; j++){
				Timer.set[i][j] = args[j+2];
				t += ", Timer.set["+i+"]["+j+"]";
		}}
		t += ");";
		Timer.set[i].call = t;
		return t;
	}
	Timer.callOnce = function(i){
		if(!Timer.set[i]) return;
		eval(Timer.set[i].call);
		Timer.set[i] = null;
	}
	Timer.getNew = function(){
		var i = 0;
		while(Timer.set[i]) i++;
		return i;
	}


function suckerfish(type, tag, parentId) {
	if (window.attachEvent) { // only loads on IE
		window.attachEvent("onload", function() {
			var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag);
			type(sfEls);
		});
	}
}

sfHover = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" IEhover";
		}
		sfEls[i].onmouseout=function() {
			this.timer = new Timer(this);
			this.timer.setTimeout("delay",200);
		}
		sfEls[i].delay=function() {
			this.className=this.className.replace(new RegExp(" IEhover\\b"), "");
		}
	}
}

sfFocus = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" IEfocus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" IEfocus\\b"), "");
		}
	}
}

suckerfish(sfHover, "LI", "nav"); // menu de nav principal, ver layout-nav.css
//if (document.getElementById("lbOverlay")) { suckerfish(sfHover, "span", "lbOverlay"); } // slimbox 
//suckerfish(sfFocus, "INPUT");
//suckerfish(sfFocus, "TEXTAREA");

// ======================================================== //