var logo_state = "red";
var s = scrollY;
var ps = scrollY;


$(document).ready(function(){
    $(".sep.ouvir > div")[0].style.height = $(".sep.ouvir > h1")[0].offsetHeight + "px";
});


document.body.onscroll = function() {
	

	$("#overlay")[0].style.height = scrollY*3.3+"px";
	if (scrollY*3.3 > $(".sep.dark")[0].offsetTop) {
		$("#overlay")[0].style.height = $(".sep.dark")[0].offsetTop+"px";
	}

	$(".splash > div")[0].style.marginTop = 100+scrollY/1.6+"px";
	$(".splash > div")[1].style.marginTop = 100+scrollY/1.6+"px";

	if (scrollY*3 > 60 & logo_state == "red") {
		toggleLogo();
	}

	if (scrollY > 70 & logo_state == "white") {
		$("#header")[0].style.background = "red";
	}

	if (scrollY*3.3 < 40 & logo_state == "white") {
		toggleLogo();
	}





	if (scrollY + (innerHeight/2) > $(".sep.ouvir")[0].offsetTop) {
		$(".sep.ouvir > div")[0].style.width = (scrollY + (innerHeight/2) - $(".sep.ouvir")[0].offsetTop)*3 + "px";
	} else {
		$(".sep.ouvir > div")[0].style.width = "0px";
	}
}

function toggleLogo() {

	if (logo_state == "red") {
		logo_state = "white";
	} else {
		logo_state = "red";
		$("#header")[0].style.background = "none";
	}
	menu = $("#header > div > a > h2");
	menu[0].style.color = logo_state;
	menu[1].style.color	= logo_state;
	menu[2].style.color	= logo_state;

	$("#header")[0].style.borderColor = logo_state;
	$("#header")[0].style.borderWidth = "0px";
	$("#header > a")[0].children[0].src = "/OMSL/img/logo_"+logo_state+".gif"
}

noise = [
	"chega!",
	"parvoíce",
	"sim, claro",
	"que estupidez",
	"LOL",
	"#%?$!#",
	"não quero saber",
	"ahah",
	"ignora-o",
	"RAIOS!!",
	"não sei",
	"OUVE-ME",
	"ouve-me já!",
	"não.",
	"nãooo!!!"
];

setInterval(function () {
		n = Math.round(Math.random() * noise.length-1);
		$(".splash > div:last-child")[0].children[0].innerHTML = noise[n];
}, 5000);

setInterval(function () {
		n = Math.round(Math.random() * noise.length);
		$(".splash > div:last-child")[0].children[1].innerHTML = noise[n];
}, 4000);

setInterval(function () {
		n = Math.round(Math.random() * noise.length);
		$(".splash > div:last-child")[0].children[0].innerHTML += "   "+noise[n];
}, 3000);

setInterval(function () {
		n = Math.round(Math.random() * noise.length);
		$(".splash > div:last-child")[0].children[1].innerHTML += "   "+noise[n];
}, 2000);