// Apply :hover effect to menu (ie6 hack)
$(document).ready(function(){

	// dropdown :hover for ie
	$('#pagina #cuerpo #menu ul li').mouseover(function(){
		// hide all opened 'submenus'
		$('#pagina #cuerpo #menu ul li').removeClass('hovered');
		// set LI's class
		$(this).addClass('hovered');
	});
	$('#pagina #cuerpo #menu ul li ul').mouseout(function(){
		// remove LI's class
		$(this).parent().removeClass('hovered');
	});

	// main page image slideshow (with preloading)
	pic1= new Image(520,120);
	pic1.src='http://www.guiallongueras.com/imagenes/degradados/degradado1.png';
	pic2= new Image(520,120);
	pic2.src='http://www.guiallongueras.com/imagenes/degradados/degradado2.png';
	pic4= new Image(520,120);
	pic4.src='http://www.guiallongueras.com/imagenes/degradados/degradado4.png';
	// slideshow's fading effect
	timer = 3000;
	imatge = 0;
	setTimeout('degradar(timer)', timer);

	// replace antispam in emails
	$("a[href*='(ELIMINAR)']").each(function(i) {
		omg = $(this).attr('href');
		omg2 = $(this).text();
		$(this).attr('href', omg.split('(ELIMINAR)').join(''));
		$(this).text(omg2.split('(ELIMINAR)').join(''));
	});
	$("a[href*='(DELETE)']").each(function(i) {
		omg = $(this).attr('href');
		omg2 = $(this).text();
		$(this).attr('href', omg.split('(DELETE)').join(''));
		$(this).text(omg2.split('(DELETE)').join(''));
	});

});

// slideshow fading effect
function degradar(timer) {
	$('p.degradado img').each(function(i) {
		if(imatge == 0) {
			$(this).fadeOut('slow', function() { this.src = 'http://www.guiallongueras.com/imagenes/degradados/degradado1.png'; });
			$(this).fadeIn('slow');
			imatge = 1;
		}
		else if(imatge == 1) {
			$(this).fadeOut('slow', function() { this.src = 'http://www.guiallongueras.com/imagenes/degradados/degradado4.png'; });
			$(this).fadeIn('slow');
			imatge = 2;
		}
		else if(imatge == 2) {
			$(this).fadeOut('slow', function() { this.src = 'http://www.guiallongueras.com/imagenes/degradados/degradado2.png'; });
			$(this).fadeIn('slow');
			imatge = 3;
		}
		else if(imatge == 3) {
			$(this).fadeOut('slow', function() { this.src = 'http://www.guiallongueras.com/imagenes/degradados/degradado3.png'; });
			$(this).fadeIn('slow');
			imatge = 0;
		}
	});
	timer += 2500;
	setTimeout('degradar(timer)', timer);
}