$(document).ready( function (){
	$("#toolbar").hide()
	$("#header").css({ opacity:.5, height:"26px"}).animate({ height:"99px", opacity:1 }, 800, function(){ $("#toolbar").fadeIn(800); apareceImagen() });

	$("#mainMenu a").mouseover(dentroMM).click( function (){ return false });
	$("#submenu a").mouseover(dentroSM).mouseout(fueraSM).click(irSeccion);
	$("#accesoDirecto a").hover(dentroAD, fueraAD)
	$("#submenu ul").hide();
	
	
	// LIGHTBOX MODAL
	$(".modal").prettyPhoto({ theme: 'light_square', showTitle: false });

	
	// PNG FIX
	$(document).pngFix(); 
})


function apareceImagen(){
	$("#contenidos").append('<img />');
	var imagenAleatoria = '_img/portada'+Math.ceil(Math.random()*9)+'.jpg';
	$("#contenidos img").hide().attr("src", imagenAleatoria).load(function (){ $(this).fadeIn(800)})
}


function dentroMM(){
	$("#mainMenu a").css({ color: "#FFF" });
	$(this).css({ color: "#95c338" });
	$("#submenu ul").hide();
	$(String($(this).attr("href"))).fadeIn();
}
function fueraMM(){
	$(this).css({ color: "#FFF" });
}



function dentroSM(){
	$(this).css({ color: "#95c338" });
}
function fueraSM(){
	$(this).css({ color: "#ccc" });
}
function irSeccion(){
	$("#pageWrap").css({ background: "#FFF" });
	var url = $(this).attr("href")
	$("#contenidos").fadeOut(400, function (){ location = url; });
	return false;
}


function dentroAD(){
	$("#accesoDirecto a").css({ color: "#FFF" });
	$(this).css({ color: "#95c338" });
}

function fueraAD(){
	$(this).css({ color: "#FFF" });
}



