//<![CDATA[
jQuery(document).ready(function() {  
   
   /*  Featured Slider  */ 
   jQuery('#slider').nivoSlider({
	    pauseTime:5,
	    directionNav:false,
	    effect:'fade',
	    startSlide:0,
	    directionNav:true,
	    captionOpacity:1,
	     	    manualAdvance: true,
	           
	    controlNav:false,
	    			pauseOnHover:false 
		,
	     
	    afterLoad: function(){
                var $slider = $('#slider img');
                $slider.css('opacity',0);
                $('#featured').css('opacity',0);
                $('#preloader').fadeOut(500, function(){
                   $slider.animate({'opacity':1}, 500); 
                   setTimeout(function() { $('#featured').animate({'opacity':1}, 500);  },1000);
                   
                   
                   
                });
            }
        });  
	                       
       
/*  Gallery Widget  */       
       jQuery('.widget-gallery').cycle('fade');
       
        
        
        	
/*  SuperFish  */
jQuery('ul.nav').superfish({ 
	delay:       200,                            // one second delay on mouseout 
	animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
	speed:       'fast',                          // faster animation speed 
	autoArrows:  true,                           // disable generation of arrow mark-up 
	dropShadows: false                            // disable drop shadows 
});


/*  Initialize Shadowbox  */
Shadowbox.init({
    
	overlayColor: "#FFFFFF",
    overlayOpacity: 0.9,
    autoplayMovies:     true,
    viewportPadding: 30
});



/*  Gallery  */
var $SingleItem = jQuery('.thumb');
jQuery('.zoom-icon').css('opacity','0');
$SingleItem.hover(function(){
	
	jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 1},200);
}, function(){
	jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 0},200);
	
});  

var $SingleGalItem = jQuery('.gallery-img');
jQuery('.zoom-icon, .link-icon').css('opacity','0');
$SingleGalItem.hover(function(){
	
	jQuery(this).find('.zoom-icon, .link-icon').stop(true, true).animate({opacity: 1},200);
}, function(){
	jQuery(this).find('.zoom-icon, .link-icon').stop(true, true).animate({opacity: 0},200);
	
}); 

jQuery(function(){

if (!((jQuery("#gallery.gallery-2col .gallery-item").length) == 0)) {
		jQuery("#gallery.gallery-2col .gallery-item").each(function (index, domEle) {
			// domEle == this
			if ((index+1)%2 == 0) jQuery(domEle).addClass("last").after("<div class='clear'></div>");
		});
	};

});

jQuery(function(){

if (!((jQuery("#gallery.gallery-3col .gallery-item").length) == 0)) {
		jQuery("#gallery.gallery-3col .gallery-item").each(function (index, domEle) {
			// domEle == this
			if ((index+1)%2 == 0) jQuery(domEle).addClass("last").after("<div class='clear'></div>");
		});
	};

});

});  
//]]>
		function maskIt(w,e,m,r,a){
        
        // Cancela se o evento for Backspace
        if (!e) var e = window.event
        if (e.keyCode) code = e.keyCode;
        else if (e.which) code = e.which;
        
        // Variáveis da funçao
        var txt  = (!r) ? w.value.replace(/[^\d]+/gi,'') : w.value.replace(/[^\d]+/gi,'').reverse();
        var mask = (!r) ? m : m.reverse();
        var pre  = (a ) ? a.pre : "";
        var pos  = (a ) ? a.pos : "";
        var ret  = "";

        if(code == 9 || code == 8 || txt.length == mask.replace(/[^#]+/g,'').length) return false;

        // Loop na máscara para aplicar os caracteres
        for(var x=0,y=0, z=mask.length;x<z && y<txt.length;){
                if(mask.charAt(x)!='#'){
                        ret += mask.charAt(x); x++;
                } else{
                        ret += txt.charAt(y); y++; x++;
                }
        }
        
				// Retorno da funçao
				ret = (!r) ? ret : ret.reverse()        
				w.value = pre+ret+pos;
		}
		
		// Novo método para o objeto 'String'
		String.prototype.reverse = function(){
				return this.split('').reverse().join('');
		};
function slideMenu (id)
{
	$('#'+id).animate({height: 'toggle'}, 700);
	
}
