// (c)2004 Sergi Meseguer http://zigotica.com/, 07/2004
 
var  CSS = {
	setStyle : function(node,rule,value){
		if(typeof(node)=="string")  node = document.getElementById(node);
		node.style[rule] = value;
	},
	
	getStyle : function(node,rule){
		if(typeof(node)=="string")  node = document.getElementById(node);
		if(rule=="width") return CSS.getW(node);
		else if(rule=="height") return CSS.getH(node);
		else {
			if (window.getComputedStyle) return window.getComputedStyle(node, null)[rule];
			else return node.currentStyle[rule];
		}
	},

	getH : function(node){
		if(typeof(node)=="string")  node = document.getElementById(node);
		return node.offsetHeight;
	},

	getW : function(node){
		if(typeof(node)=="string")  node = document.getElementById(node);
		return node.offsetWidth;
	}
}


EXTRAS = {
	// Event listener by Scott Andrew (www.scottandrew.com):
	addEvent : function(obj, evType, fn, useCapture){
		if (obj.addEventListener){
			obj.addEventListener(evType, fn, useCapture);
			return true;
		} 
		else if (obj.attachEvent){
			var r = obj.attachEvent("on"+evType, fn);
			return r;
		} 
		else {
			return false;
		}
	}, 
	
	popup : function(where,w,h,t,l) {
		if (!t) t=0;
		if (!l) l=0;
		window.open( where, 'popupwindow', 'width='+w+', height='+h+', top='+t+', left='+l+', scrollbars=no, resizable=no'); 
	},

	reTarget : function(){ 
		var external = document.getElementsByTagName("a"); 
		for (var k=0; k<external.length; k++){
			if (external[k].href) {
			var url = external[k].href; 
				if (url.indexOf(document.domain) == -1 && url.indexOf("javascript:") == -1 && url.indexOf("mailto:") == -1) 
				{
					var ExternalTxt = "(Enlace externo)";
					external[k].target = "_blank";
					external[k].title += " " + ExternalTxt;
				}
			}
		}
	},
	
	blurAll : function(){ 
		var lincs = document.getElementsByTagName("a"); 
		function doBlur(e)  { this.blur(); } 
		for (var k=0; k<lincs.length; k++){
			lincs[k].onfocus = doBlur;
		}
	},
	
	addClass : function(elm, cn){ 
		elm.className += " " + cn;
	},
	
	removeClass : function(elm, cn){ 
		var s = elm.className.split(" ");
		for (var k=0; k<s.length; k++) if(s[k]== cn) s[k]="";
		elm.className = s.join(" ");
	},
	
	// Method adapted from Dan Pupius ( pupius.co.uk):
	getElementsByClass : function(className,node,equal,except) {
			if(!node) node=document;
			// follows UGLY hack to fix IE5
			if(navigator.appVersion.indexOf("MSIE 5")>-1) var refTags = document.all;
			else var refTags = node.getElementsByTagName("*") ? node.getElementsByTagName("*") : document.all;
		 
			var retVal = new Array();
			for(var z=0;z< refTags.length;z++) {
					if(
					(equal==1 && refTags[z].className == className)
					|| (equal==0 && !except && refTags[z].className.indexOf(className) != -1)
					|| (equal==0 && refTags[z].className.indexOf(className) != -1 && refTags[z].className.indexOf(except) == -1)
					)
					retVal.push(refTags[z]);
			}
			return retVal;
	}
}
// adds 1 or more elements to an array (IE only)
if(!Array.prototype.push)
{
	Array.prototype.push =  function()
	{
		var i;
		for(i=0; j=arguments[i]; i++) this[this.length] = j;
		return this.length;
	}
}
