var d_closed = true;
var f_closed = true;
var v_closed = true;
var pane;
var api;
$(document).ready(function(){
	scroll();
	$('#documentos_t').click(function(){
		if (d_closed){
			$('#documentos').addClass('d_open');$('#documentos').removeClass('d_closed');
			d_closed = false;
		}else{
			$('#documentos').addClass('d_closed');$('#documentos').removeClass('d_open'); 
			d_closed = true;
		}
		scroll();
		//api.scrollToY(70);
	});
	$('#fotos_t').click(function(){
		if (f_closed){
			$('#fotos').addClass('d_open');$('#fotos').removeClass('f_closed');
			f_closed = false;
		}else{
			$('#fotos').addClass('f_closed');$('#fotos').removeClass('d_open'); 
			f_closed = true;
		}
		scroll();
		api.scrollToY(parseInt($('#documentos').css('height'))+80);
	});
	$('#videos_t').click(function(){
		if (v_closed){
			$('#videos').addClass('d_open');$('#videos').removeClass('v_closed');
			v_closed = false;	
		}else{
			$('#videos').addClass('v_closed');$('#videos').removeClass('d_open'); 
			$('#preview').html('');
			v_closed = true;
		}
		scroll();
		api.scrollToY(parseInt($('#fotos').css('height'))+parseInt($('#documentos').css('height'))+85);
	});
	
	$('#vid1').click(function(){
		$('#vid1').addClass('sel');
		$('#vid2').removeClass('sel');
		$('#vid3').removeClass('sel');
		$('#vid4').removeClass('sel');
		$('#vm_if').html('<iframe src="http://player.vimeo.com/video/31957866?title=0&amp;byline=0&amp;portrait=0" width="374" height="266" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>');
	});
	$('#vid2').click(function(){
		$('#vid1').removeClass('sel');
		$('#vid2').addClass('sel');
		$('#vid3').removeClass('sel');
		$('#vid4').removeClass('sel');
		$('#vm_if').html('<iframe src="http://player.vimeo.com/video/32863084?title=0&amp;byline=0&amp;portrait=0" width="374" height="266" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>');
	});
	$('#vid3').click(function(){
		$('#vid1').removeClass('sel');
		$('#vid2').removeClass('sel');
		$('#vid3').addClass('sel');
		$('#vid4').removeClass('sel');
		$('#vm_if').html('<iframe src="http://player.vimeo.com/video/33726348?title=0&amp;byline=0&amp;portrait=0" width="374" height="266" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>');
	});
	$('#vid4').click(function(){
		$('#vid1').removeClass('sel');
		$('#vid2').removeClass('sel');
		$('#vid3').removeClass('sel');
		$('#vid4').addClass('sel');
		$('#vm_if').html('<iframe src="http://player.vimeo.com/video/35562828?title=0&amp;byline=0&amp;portrait=0" width="374" height="266" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>');
	});
});

/*
	$(iframe).load(function(){
		alert('2');
		$('#stream_content').attr("style", {height: "32px"});
	});
*/
function preview_vim(code){
	$('#preview').html('<iframe src="http://player.vimeo.com/video/'+code+'?title=0&amp;byline=0&amp;portrait=0" width="374" height="266" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>');
	$('#preview').show();
	$('#preview').ready(function(){
		scroll();
		api.scrollToY(parseInt($('#videos').css('height'))+parseInt($('#fotos').css('height'))+parseInt($('#documentos').css('height'))+85);
	});
}
function scroll() {
	pane = $('.scroll');
	api = pane.data('jsp');
	pane.jScrollPane({
		//showArrows: false,
		//animateScroll: true
		verticalDragMinHeight: 72,
		verticalDragMaxHeight: 70,
		horizontalDragMinWidth: 72,
		horizontalDragMaxWidth: 72
	});
}

