/* Preload Imagens */

$.fn.preload = function() {
    this.each(function(){ $('<img/>')[0].src = this; });
}
$(['Imgs/Layout/banner1.jpg','Imgs/Layout/banner2.jpg','Imgs/Layout/banner3.jpg','Imgs/Layout/banner4.jpg','Imgs/Layout/bg_men.png','Imgs/Layout/bg_sub.png']).preload(); // ../Imgs...

/* Slide Inicial - Menu */

/*jQuery(function() { slide(".blockeasing", 20, 4, 100, .7); });*/

/* Animação Caixas */

function fadecaixas() {
//if (!$.browser.msie) {
	$('.div-contents-int1').css({display:'none'});
	$('.scroll-pane h1').css({visibility:'hidden'});
	$('.scroll-pane p').css({visibility:'hidden'});
	$('.scroll-pane div').css({visibility:'hidden'});
	$('.scroll-pane img').css({visibility:'hidden'});
	//$('.div-contents-int1').stop().animate({height:'360px'},{queue:false, duration:500, easing: 'linear'})
	$('.div-contents-int1').fadeIn(1000, function() {
		$('.scroll-pane h1').css({display:'none'});
		$('.scroll-pane p').css({display:'none'});
		$('.scroll-pane h1').css({visibility:'visible'});
		$('.scroll-pane p').css({visibility:'visible'});
		$('.scroll-pane div').css({visibility:'visible'});
		$('.scroll-pane img').css({visibility:'visible'});
		$('.scroll-pane div').fadeIn(1000);	
		$('.scroll-pane img').fadeIn(1000);	
		$('.scroll-pane p').fadeIn(1000);	
		$('.scroll-pane h1').fadeIn(1000);		
	});
//}
//else { setTimeout(function(){ pictfunc(); },2000);}
}

/* Animação Menus */

//jQuery(function() {
$(document).ready(function() {
		
		//$('ul.blockeasing li.main ul.subnav li').css({display:'none'});
		if (!$.browser.msie) { 
			$('ul.blockeasing li.main ul.subnav li').css({display:'none'});
			$("ul.blockeasing li ul.subnav").fadeTo(0, 0); 
		}
		
		$("ul.blockeasing li.main").mouseover(function(){ //When mouse over ...
			 if ($.browser.msie) {
			  	$(this).find('.subnav').css({display:'block'});
				$(this).find('.subnav').stop().animate({height:'150px'},{queue:false, duration:500, easing: 'linear'})
			  }
			  else { 
			  	$('ul.blockeasing li.main ul.subnav li').css({display:'block'});
				$(this).find('.subnav').stop().animate({opacity:'1', height:'150px'},{queue:false, duration:500, easing: 'linear'}) 
				}
			 
		});
	    $("ul.blockeasing li.main").mouseout(function(){ //When mouse out ...
			   if ($.browser.msie) {  $(this).find('.subnav').stop().animate({height:'0px'},{queue:false, duration:300, easing: 'linear'}) }
			   else { 
			   		$('ul.blockeasing li.main ul.subnav li').css({display:'none'});
					$(this).find('.subnav').stop().animate({opacity:'0', height:'0px'},{queue:false, duration:300, easing: 'linear'}) 
				}
		});
        //menu itembackground color animation		
		$("ul.blockeasing li.main").css( {backgroundPosition: "0 -20px"} );
		$("ul.blockeasing li ul li").css( {backgroundPosition: "0 -22px"} );
		$("ul.blockeasing li.main").hover(function() {
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:200})
		},
        function() {
			$(this).stop().animate({backgroundPosition:"(0 -20px)"}, {duration:200})
        });
		//submenu itembackground color animation			
		$("ul.blockeasing li ul li").hover(function() {
			$(this).find('a').css({color: '#CF142B'});
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:200})
		},
        function() {
			$(this).find('a').css({color: '#fff'});
			$(this).stop().animate({backgroundPosition:"(0 -22px)"}, {duration:200})
        });
});

/* Scrollable images */

//$(function() { $("div#makeMeScrollable").smoothDivScroll(); });

/* ScrollPane */

$(function() { $('.scroll-pane').jScrollPane({hideFocus:true}); });

/* Grey to Color - Imgs*/

//jQuery(function() {
$(document).ready(function() {
	$("div.scrollableArea a").hover(function() {
		var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
		//Set a background image(thumbOver) on the &lt;a&gt; tag 
		$(this).css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
		//Fade the image to 0 
		$(this).find("span").stop().fadeTo('normal', 0 , function() {
			$(this).hide() //Hide the image after fade
		}); 
	} , function() { //on hover out...
		//Fade the image to 1 
		$(this).find("span").stop().fadeTo('normal', 1).show();
	});
});

/* Alterna Cor rows */
/*
function alternate(id){ 
	if(document.getElementsByTagName){  
		//var tabela = document.getElementById(id);   
		//var rows = tabela.getElementsByTagName("p"); 
		var rows = document.getElementsByTagName("p"); 
		for(i = 0; i < rows.length; i++){           
			if(i % 2 == 0){ rows[i].className = "par"; }
			else{ rows[i].className = "impar"; }
		} 
	}
}*/

/* Link externo */

function externalLinks() {   
 if (!document.getElementsByTagName) return;   
 var anchors = document.getElementsByTagName("a");   
 for (var i=0; i<anchors.length; i++) {   
   var anchor = anchors[i];   
   if (anchor.getAttribute("href") &&   
       anchor.getAttribute("rel") == "external")   
     anchor.target = "_blank";   
 }   
}   
window.onload = externalLinks;

/* Legenda Portfolio */

function legin(a) {
	document.getElementById('img-leg').innerHTML = a;
	document.getElementById('img-leg').style.padding = '0 10px';
	document.getElementById('img-leg').style.visibility = 'visible';
}
function legout() {
	document.getElementById('img-leg').innerHTML = '';
	document.getElementById('img-leg').style.padding = '0';
	document.getElementById('img-leg').style.visibility = 'hidden';
}
