// (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;
		}
	},
	
	// Method adapted from Dan Pupius (pupius.co.uk):
	getElementsByClass : function(className,equal,node) {
		if(!node) node=document;
		var refTags = document.all ? document.all : node.getElementsByTagName("*");
		var retVal = new Array();
		for(var z=0;z<refTags.length;z++) {
			if((equal==1 && refTags[z].className == className) || (equal==0 && refTags[z].className.indexOf(className) != -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;
	}
}
