/*
 * -------------------------------------------------------------- clases para los listados 
*/
function extendLists(scope) {
	var scope = scope || document;
	$('li:first-child', scope).addClass('first');
	$('li:last-child', scope).addClass('last');
}

/*
 * -------------------------------------------------------------- eventos especiales para los enlaces
*/
function extendLinks(scope) {
	var scope = scope || document;
	
	$('a.llegirMes').click(function() {
		var $c = $('#continguts')
		$c.children().css({
			width: $c.width() + 'px',
			marginRight: '-17px'
		});
		$c.css('overflow', 'auto');
		$('span.llegirMes').fadeIn();
		$('div.llegirMes').slideDown();
	});
	
	$('a[rel=external]', scope).attr({target: '_blank'});
}

/*
 * Plugin de jQuery para cambiar PNG's para IE6 dentro de un elemento 
 * Ej. uso: $('div.fulanito img').pngIE6()
 * El parametro 'blank' debe ser la ruta de un GIF transparente de 1x1
 * -------------------------------------------------------------- */
jQuery.fn.extend({
    pngIE6: function(blank) {
        if ($.support.opacity) return this;
        if (!blank) blank = 'img/blank.gif';
        return this.each( function() {
            this.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+ this.src +',sizingMethod=image)';
            this.src = blank;
        });
    }
});


/*
 * -------------------------------------------------------------- llamada global para las funciones del DOM
*/
function extendDOM(scope) {
	var scope = scope || document;
	$('img[id$=.png]', scope).pngIE6();
	extendLists(scope);
	extendLinks(scope);
}

// llamamos a distintas funciones al iniciar el DOM
$(function() {
	// extendemos el DOM a traves de las funciones definidas a tal efecto
	extendDOM(document);
});