function myRand(a,b) {return Math.round(Math.random()*(b-a)+a);}

function toggleImage( i ) {
	var obj = $( '#service_menu ul li:eq(' + i + ')' ).children( 'span' );
	if ( obj.css( 'display' ) == 'none' )
		obj.fadeIn( 500 );
	else
		obj.fadeOut( 500 );
}

function setImgInterval( i ) {
	setInterval( function() { toggleImage(i); }, 5000 );
}

$(document).ready(function() {
	// Carga las imagenes en los <li>
	$( '#service_menu ul li' ).each( function( i ) {
		i++;
		$( this ).css( 'background-image', 'url(\'http://www.espacioriesco.cl/wp-content/themes/riesco-11/img/service_menu/btn0'+ i + 'A_M.jpg\')');
		$( this ).children( 'span' ).css( 'background-image', 'url(\'http://www.espacioriesco.cl/wp-content/themes/riesco-11/img/service_menu/btn0'+ i + 'B_M.jpg\')' );
	});
	$( '#service_menu ul li' ).each( function( i ) {
		setTimeout( function() { setImgInterval(i); }, myRand(1000, 8000) );
	});
});

$(document).ready(function(){
$("#pagemenu ul li span").hover(
function( x ) {
$(this).stop().animate({"opacity": "0"}, "slow");
},
function( x ) {
$(this).stop().animate({"opacity": "1"}, "slow");
});
 
});

$(document).ready(function() {
	// Carga las imagenes en los <li>
	$( '#pagemenu ul li' ).each( function( x ) {
		x++;
		$( this ).css( 'background-image', 'url(\'http://www.espacioriesco.cl/wp-content/themes/riesco-11/img/pagemenu/btn_'+ x + 'A.jpg\')');
		$( this ).children( 'span' ).css( 'background-image', 'url(\'http://www.espacioriesco.cl/wp-content/themes/riesco-11/img/pagemenu/btn_'+ x + 'B.jpg\')');
	});
	$("#pagemenu ul li").hover(
		function( x ) {
		$(this).stop().animate({"opacity": "0"}, "slow");
		},
		function( x ) {
		$(this).stop().animate({"opacity": "1"}, "slow");
		});
	});
	
$(document).ready(function() {
	// Carga las imagenes en los <li>
	$( '#pagemenu2 ul li' ).each( function( y ) {
		y++;
		$( this ).css( 'background-image', 'url(\'http://www.espacioriesco.cl/wp-content/themes/riesco-11/img/pagemenu2/btn_'+ y + 'A.jpg\')');
		$( this ).children( 'span' ).css( 'background-image', 'url(\'http://www.espacioriesco.cl/wp-content/themes/riesco-11/img/pagemenu2/btn_'+ y + 'B.jpg\')');
	});
	$("#pagemenu2 ul li").hover(
		function( y ) {
		$(this).stop().animate({"opacity": "0"}, "slow");
		},
		function( y ) {
		$(this).stop().animate({"opacity": "1"}, "slow");
		});
	});



$(document).ready(function() {
        $('#slider').nivoSlider();
    });
