// JavaScript Document
jQuery.noConflict();

jQuery(window).bind("load", function() {        
	var footerHeight = 0,
			footerTop = 0,
			jfooter = jQuery("#footer");
	positionFooter();     
	function positionFooter() {
		footerHeight = jfooter.height();
		footerTop = (jQuery(window).scrollTop()+jQuery(window).height()-footerHeight)+"px";
		
		if ( (jQuery(document.body).height()) < jQuery(window).height()) {
			jfooter.css({
				position: "absolute",
				top: footerTop})
		}else{
			jfooter.css({
				position: "static"
			})
		}
	}
	jQuery(window)
		.scroll(positionFooter)
		.resize(positionFooter)
});

jQuery(document).ready( function(){
	//jQuery(document).pngFix();
	
	var elementos = jQuery("#notas li").size();
	//alert("son " + elementos);
	var clase, el, num, tiempo, activo;
	
	tiempo = 10000;
	
	setInterval(function (){
		jQuery("#notas").children().each(function(){
      var children = jQuery(this);
			var sii = children.attr('style');
			var si = children.css('display');
			//alert(si)
			if(si == "" || si == undefined || si == 'block' || si == 'list-item' || sii == "" || sii == undefined){
				el = children.attr('id').split("nota");
				num = el[1];
				jQuery("#nota" + num).fadeOut('fast', function(){
					num = parseInt(num) + 1;
					if(num > elementos){
						num = 1;
						jQuery("#nota" + (num)).fadeIn('fast');
					}else{
						jQuery("#nota" + (num)).fadeIn('fast');
					}
				});
			}else{
				children.css('display','none');
			}
    });
	}, tiempo);
	
	jQuery(".btnder").click(function(){
		clase = jQuery(this).attr('class');
		el = clase.split("_");
		num = el[1];
		jQuery("#nota" + num).fadeOut('fast', function(){
			num = parseInt(num) + 1;
			if(num > elementos){
				num = 1;
				jQuery("#nota" + (num)).fadeIn('fast');
			}else{
				jQuery("#nota" + (num)).fadeIn('fast');
			}
		});
	});
	
	jQuery(".btnizq").click(function(){
		clase = jQuery(this).attr('class');
		el = clase.split("_");
		num = el[1];
		jQuery("#nota" + num).fadeOut('fast', function(){
			num = parseInt(num) - 1;
			if(num < 1){
				num = elementos;
				jQuery("#nota" + (num)).fadeIn('fast');
			}else{
				jQuery("#nota" + (num)).fadeIn('fast');
			}
		});
	});
	
	
	jQuery(".btnizq").hover(
	  function () {
		jQuery(this).attr('src','imagenes/arrow-before.png');//before-on
		
	  },
	  function () {
		jQuery(this).attr('src','imagenes/arrow-before.png');//before normal
		
	  }
	);
	
	jQuery(".btnder").hover(
	  function () {
		jQuery(this).attr('src','imagenes/arrow-after.png');//after on
		
	  },
	  function () {
		jQuery(this).attr('src','imagenes/arrow-after.png');//After normal
		
	  }
	);
	
	/*
	jQuery(".btnmore").hover(
	  function () {
		jQuery(this).attr('src','../images/more-on.png');
		
	  },
	  function () {
		jQuery(this).attr('src','../images/more.png');
		
	  }
	);
	*/
	
	jQuery(".contenidorayado").hover(
	  function () {
		jQuery(this).css('text-decoration','underline');
	  },
	  function () {
		jQuery(this).css('text-decoration','none');
		
	  }
	);
	
	jQuery(".titulorayado").hover(
	  function () {
		jQuery(this).css('text-decoration','underline');
	  },
	  function () {
		jQuery(this).css('text-decoration','none');
		
	  }
	);
	
	
});
