//Favoritos
$(document).ready(function(){
	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($("a.jqbookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
			$("a.jqbookmark").attr("rel","sidebar");
		}
	}

	$("a.jqbookmark").click(function(event){
		event.preventDefault(); // prevent the anchor tag from sending the user off to the link
		var url = this.href;
		var rel = this.rel;

		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(rel, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, rel);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing - the rel="sidebar" should do the trick
		} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}

	});
});

//Navegación
$(function(){
    $("ul.navegacion li").hover(function(){
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    }, function(){
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    });
    $("ul.navegacion li ul li:has(ul)").addClass("subnivel");
});

//Pestañas
$(function () {
	var tabContainers = $('div.pestanaContenido > div');
	tabContainers.hide().filter(':first').show();
		$('div.pestanasContenedor ul a').click(function () {
			tabContainers.hide();
			tabContainers.filter(this.hash).show();
			$('div.pestanasContenedor ul a').removeClass('seleccionada');
			$(this).addClass('seleccionada');
				return false;
		}).filter(':first').click();
});

//Iframes
function doIframe(){
	o = document.getElementsByTagName('iframe');
	for(i=0;i<o.length;i++){
		if (/\bautoHeight\b/.test(o[i].className)){
			setHeight(o[i]);
			addEvent(o[i],'load', doIframe);
		}
	}
}

function setHeight(e){
	if(e.contentDocument){
		e.height = e.contentDocument.body.offsetHeight + 5;
	} else {
		e.height = e.contentWindow.document.body.scrollHeight;
	}
}

function addEvent(obj, evType, fn){
	if(obj.addEventListener)
	{
	obj.addEventListener(evType, fn,false);
	return true;
	} else if (obj.attachEvent){
	var r = obj.attachEvent("on"+evType, fn);
	return r;
	} else {
	return false;
	}
}

if (document.getElementById && document.createTextNode){
 addEvent(window,'load', doIframe);	
}
