$(document).ready(function() {
	scrollFunction();
	menusHoverFunction();
	$(window).resize(function() {
		scrollFunction();
	});
	$('h1').click(function(){
	    GoTo("/"+model.page.GetLanguage());
	});
	$('#homeBtn').click(function(){
		GoTo("/"+model.page.GetLanguage());
	});
	$('.small-input input:last-child').css('margin-right', '0px');			
	$('.block > div:nth-child(2n)').css('margin-right', '0px');
	$('.news-block ul > li:nth-child(3n)').css('margin-right', '0px');
	Cufon.replace('.menu.small .title', { fontFamily: 'Gill Light SSi' });
});

function scrollFunction() {
	scrollFunctionLeft();	
	scrollFunctionRight();
	$(".jScrollPaneDrag").hover(function(){$(this).css("backgroundColor","#663333");},
	function(){$(this).css("backgroundColor","#000000");}
	);
	destqPos();
}

function scrollFunctionLeft() {
	paiLeft = $('#scrollerLeft').parent();
	if(paiLeft.hasClass('jScrollPaneContainer')){
		paiLeft.parent().removeClass('scrollNoPadd');	
		$('#scrollerLeft').jScrollPaneRemove();
		$('.scrollValLeft').unwrap('<div id="scrollerLeft" />');
	}
	if (($(".scrollValLeft").height())>($('#main-container').height()-180)) {
		$('.scrollValLeft').parent().addClass('scrollNoPadd');
		$('.scrollValLeft').wrap('<div id="scrollerLeft" />');
		alturaScroll = $('#main-container').height() - 40;
		$('#scrollerLeft').css('height', alturaScroll);	
		$('#scrollerLeft').jScrollPane({scrollbarWidth:19, scrollbarMargin:10, dragMaxHeight:100});	
		if($(".scrollValLeft").css("margin-left")=='40px') $('.scrollValLeft').css('margin-left', '0px');
		$('.jScrollPaneContainer').css('margin-left', '40px');
	} else {
		$('.scrollValLeft').parent().removeClass('scrollNoPadd');
		$('.scrollValLeft').css('margin-left', '40px');
	}
	/*if ($('#cv').length>0) {
	alert("ok");
		$(':file').si_files({
		button: {
			src: 'http://n0nick.net/jquery/file_choose.gif',
			width: 79,
			height: 22
		}
});
	}*/
}
function scrollFunctionRight() {
	paiRight = $('#scrollerRight').parent();
	
	if(paiRight.hasClass('jScrollPaneContainer')){
		paiRight.parent().removeClass('scrollNoPadd');	
		$('#scrollerRight').jScrollPaneRemove();
		$('.scrollValRight').unwrap('<div id="scrollerRight" />');
	}
	if (($(".scrollValRight").height())>($('#main-container').height()-180)) {
		$('.scrollValRight').parent().addClass('scrollNoPadd');
		$('.scrollValRight').wrap('<div id="scrollerRight" />');
		alturaScroll = $('#main-container').height() - 40;
		$('#scrollerRight').css('height', alturaScroll);	
		$('#scrollerRight').jScrollPane({scrollbarWidth:19, scrollbarMargin:10, dragMaxHeight:100});
		if($(".scrollValRight").css("margin-left")=='40px') $('.scrollValRight').css('margin-left', '0px');
		$('.jScrollPaneContainer').css('margin-left', '40px');
	} else {
		$('.scrollValRight').parent().removeClass('scrollNoPadd');
		$('.scrollValRight').css('margin-left', '40px');		
	}
}

function menusHoverFunction() {
	$('.menu.preto li').each(function() {
		$(this).css( {backgroundPosition: "-150 bottom"} )
		$(this).mouseenter(function(){		
			$(this).stop().animate(
				{backgroundPosition:"(0 bottom)"}, 
				{duration:300}
			);
		});
		$(this).mouseleave(function(){
			$(this).stop().animate(
				{backgroundPosition:"(-150 bottom)"}, 
				{duration:300}
			);
		});		
	});
	$('.menu.cinza li').each(function() {
		$(this).css( {backgroundPosition: "-150 bottom"} )
		$(this).mouseenter(function(){		
			$(this).stop().animate(
				{backgroundPosition:"(0 bottom)"}, 
				{duration:300}
			);
		});
		$(this).mouseleave(function(){
			$(this).stop().animate(
				{backgroundPosition:"(-150 bottom)"}, 
				{duration:300}
			);
		});		
	});	
}	
function videoInspiracoes() {
	//var oFlash = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='360' height='196' id='jaPlayer' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='/video/jaPlayer.swf' /><param name='loop' value='false' /><param name='quality' value='high' /><param name='scale' value='noscale' /><param name='wmode' value='opaque' /><param name='bgcolor' value='#000000' /><embed src='/video/jaPlayer.swf' loop='false' quality='high' scale='noscale' wmode='opaque' bgcolor='#000000' width='360' height='196' name='jaPlayer' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/go/getflashplayer' /></object>";
//	var flashInspiracoes = function() { $('.video-js-box').css('display','none');$('.video-js-box').html(oFlash);$('.video-js-box').css('display','block'); }	
	var flashInspiracoes = function() { flowplayer("player", "/video/flowplayer.commercial-3.2.7.swf", { key: '#@674074cb9e95d77cf7e', clip: { autoPlay: false, autoBuffering: true }}); }	

	if ($.browser.msie) {
		setTimeout(flashInspiracoes, 3000);
	} else {
		setTimeout(flashInspiracoes, 2500);
	}
}

function destqPos() {
	altJan = $(window).height();
	largJan = $(window).width();
	if (altJan>578) {
		$('#destq').css('top',Number(altJan/2)-124);
	} else {
		$('#destq').css('top',164);
	}
	if (largJan<990) {
		$('#destq').css('right',-Number(990-largJan));
	} else {
		$('#destq').css('right',0);
	}
}

