function getObj(id){
	if(document.getElementById){
		this.nombre= document.getElementById(id);
		this.style= document.getElementById(id).style;
	}
	else if (document.all){
		this.nombre= document.all[id];
		this.style= document.all[id].style;
	}
	else if (document.layers){
		this.nombre= document.layers[id];
		this.style= document.layers[id];
	}
}


function resizeWindow(x,y){
// redimensiona la ventana actual al tamaño indicado, desde las coordenadas 0,0
window.moveTo(0,0);

	if(navigator.appName=='netscape'){
		window.outerWidth= x;
		window.outerHeight= y;
	}
	else{
//		alert("redim la  ventana");
		window.resizeTo(x,y);
	}

//return false;
}

function wOpen(url,wName,x,y){
// abre una ventana con nombre dado de un tamaño x,y, con top y left 0, y carga una url 
	window.open(url,wName,"width="+x+",height="+y+",top=0,left=0,scrollbars=no,menubar=no,toolbar=no");
	return false;
}

function jemail(nombre,dominio,traspunto){
// genera un mailto desde la direccion troceada especificada
// (nombre) '@' todo lo que haya antes del primer punto (dominio) '.' todo lo que va tras el primer punto (traspunto)
	location.href= nombre + "@" + dominio + "." + traspunto;
	return false;
}

function writeAddBookmarkLink(source, texto, url, titulo, blockTag){
	if(!window.external){ return; }		// no soporta el obj
	if (!source && !texto)	{ return; }	// debe haber definido o source o texto (para crear el link)
	if(!url){ url=window.location; }
	if(!titulo){ titulo=document.title; }
	if(!texto) { texto= ''; }
	
	var sTemp='';
	var sblockTagInit= '';
	var sblockTagEnd= '';
	var linkInit= '<a href="" onclick="return addBookmark(' + "'" + url + "','" + titulo + "'" + ');">';
	var linkEnd= '</a>';
	
	if(texto && !blockTag){ blockTag='div'; }	// blocktag debe tener valor (hay default) siempre que haya texto
	
	// si source, definir img con o sin class
	if(!blockTag && source){ sTemp= '<img class="addbookmarkimg" src="' + source + '" /> '; }
	else if(source) { sTemp= '<img src="' + source + '" /> '; }
	
	if(blockTag){ // definir valores del wrapper
		sblockTagInit= '<' + blockTag + ' class="addbookmarkblock"' + '>';
		sblockTagEnd= '</' + blockTag + '>';
	}
	
	// escribir todas las partes: envoltorio + img + texto + envoltorio
	document.write(sblockTagInit + linkInit + sTemp + texto + linkEnd + sblockTagEnd);
}

function addBookmark(url, titulo){
	if ((window.sidebar) && (window.sidebar.addPanel)){
		window.sidebar.addPanel(titulo, url, '');
	}
	else if (document.all){
		alert('document.all');
		window.external.AddFavorite(url, titulo);
	}
	else if (window.opera && window.print){
		return true;
	}
	else {
		alert('este navegador no está soportado.\n' +
			'por favor, añadelo tú manualmente.');
	}
	return false;
}


function externalLinks(){
	if(!document.getElementsByTagName) return;

	var anchors= document.getElementsByTagName("a");
	
	for (var i=0; i<anchors.length; i++) {
		var anchor= anchors[i];
		if (anchor.getAttribute("href") && 
				anchor.getAttribute("rel")== "external") {
			anchor.target="_blank";
		}
	}
}

function setHandler(obj, sEventName, sHandler){
// enlaza manejador a evento. Compatible DOM IE|W3C
// Fija problema de IE5+ con setAttribute cuando se establece propiedad de evento
	
	if(!document.all && document.getElementById){	obj.setAttribute(sEventName, sHandler); }
	else if(document.all){	obj[sEventName]= new Function(sHandler); }
}


