function init(){
	test_bottom();
}

function slide_left(){
	if($("#box_bottom").is(":hidden")){
		bottom_show()
	}
	var div = document.getElementById("box_left");
	if(div.style.marginLeft == "-285px"){
		$("#box_left").animate({marginLeft: "0px"}, 1500 );
		$("#box_left_fundo").animate({marginLeft: "0px"}, 1500 );
	} else {
		$("#box_left").animate({marginLeft: "-285px"}, 1500 );
		$("#box_left_fundo").animate({marginLeft: "-285px"}, 1500 );
	}
	video_on = 0;
}

function slide_rigth(){
	var div = document.getElementById("box_right");
	if(div.style.marginRight == "-700px"){
		$("#box_right").animate({marginRight: "0px"}, 1500 );
		$("#box_right_fundo").animate({marginRight: "0px"}, 1500 );
	} else {
		$("#box_right").animate({marginRight: "-700px"}, 1500 );
		$("#box_right_fundo").animate({marginRight: "-700px"}, 1500 );
	}
}

function open_page(page){
	var iframe = document.getElementById("iframe");
	var link_page = "page/" + page + ".htm";
	iframe.src = link_page;
	var div = document.getElementById("box_right");
	if(div.style.marginRight == "-700px"){
		slide_rigth()
	}
}

function play_video(){
	bottom_hide()
	div_cont = document.getElementById("btn_play");
	div_cont.setAttribute("onclick", "mute_video()");
	div_cont.innerHTML = "Desativar áudio";
	ytplayer.seekTo(0,false);
	ytplayer.unMute();
	var div1 = document.getElementById("box_right");
	var div2 = document.getElementById("box_left");
	if(div1.style.marginRight != "-700px"){
		slide_rigth()
	}
	if(div2.style.marginLeft != "-285px"){
		slide_left()
	}
}

function mute_video(){	
	ytplayer.mute();
	div_cont = document.getElementById("btn_play");
	div_cont.setAttribute("onclick", "play_video()");
	div_cont.innerHTML = "Assistir vídeo com áudio";
}

function stop_video(){
	ytplayer.stopVideo();
	div_cont = document.getElementById("btn_stop");
	div_cont.setAttribute("onclick", "play2_video()");
	div_cont.innerHTML = "Reproduzir vídeo";
}

function play2_video(){
	ytplayer.playVideo();
	div_cont = document.getElementById("btn_stop");
	div_cont.setAttribute("onclick", "stop_video()");
	div_cont.innerHTML = "Parar vídeo";
}

function bottom_hide(){
	$("#box_bottom").fadeOut("slow");
	$("#box_bottom_fundo").fadeOut("slow");
}

function bottom_show(){
	$("#box_bottom").fadeIn("slow");
	$("#box_bottom_fundo").fadeIn("slow");
}

var video_on = 0
function load_video(div){
	var id = div.id;
	ytplayer.loadVideoById(id, 0, "small");
	play_video();
	video_on = 1;
}

function test_bottom(){
	var bottom = document.getElementById("box_bottom_fundo");
	if(bottom.offsetTop < 520){
		$("#box_bottom").remove();
		$("#box_bottom_fundo").remove();
	}
}
