// scroll back to top
var $ = jQuery.noConflict(); 

//cufon
Cufon.replace('h1, h2, h3, h4, h5, h6, label');
Cufon.replace('.mainMenu> li > a',{
    hover: true						             
});
Cufon.replace('.postNextPrev > a',{
    hover: true						             
});

//back to top			
$(document).ready(function() {

    $(".mainMenu li:last-child").addClass("lastMenuChild");			   
						   
    $('.backToTop').click(function(e) {
        e.preventDefault();
        $('html, body').animate( {
            scrollTop : 0
        }
        , 800, 'easeOutCubic');
        return false;
    }
    ); 
   
   		
    $(".mainMenu li:last-child").addClass("lastMenuChild");			   
						   
    $('.backToTop').click(function(e) {
        e.preventDefault();
        $('html, body').animate( {
            scrollTop : 0
        }
        , 800, 'easeOutCubic');
        return false;
    }
    ); 
   
   
    //animate back to top btn
    $(".backToTop").hover(function() {
        $(".backToTopBtn").stop().animate({
            "height":"122px"
        },300, "easeOutCubic");
        $(this).stop().animate({ 
            "top": "0px"
        },300, "easeOutCubic");

    },function(){
        $(".backToTopBtn").stop().delay(200).animate({
            "height":"32px"
        },300, "easeOutCubic");
        $(this).stop().delay(200).animate({
            "top": "-90px"
        },300, "easeOutCubic");
    });
   
    //animate portfolio items and posts on load   
    var delayAni = 150;
    $(".portfolioItem1").css({
        opacity:0
    });
    $(".portfolioItem3").css({
        opacity:0
    });
    $(".smallPost").css({
        opacity:0
    });

    $(".portfolioItem1").each(function() {
														 
        $(this).delay(delayAni).animate({
            opacity:1
        }, 300);
        delayAni += 150;
    }
    ); 

    $(".portfolioItem3").each(function() {
														 
        $(this).delay(delayAni).animate({
            opacity:1
        }, 300);
        delayAni += 150;
    }
    );

    $(".smallPost").each(function() {
														 
        $(this).delay(delayAni).animate({
            opacity:1
        }, 300);
        delayAni += 150;
    }
    );
   
    //animate portfolio items and post image on hover
    $(".oneColumnImage").hover(function() {
        $(this).animate({ 
            opacity: 0.8
        },200, "easeOutCubic");

    },function(){
        $(this).animate({
            opacity: 1
        },200, "easeOutCubic");
    });
   
   
   
    $(".threeColumnsImage").hover(function() {
        $(this).animate({ 
            opacity: 0.8
        },200, "easeOutCubic");

    },function(){
        $(this).animate({
            opacity: 1
        },200, "easeOutCubic");
    });


    $(".smallPostImage").hover(function() {
        $(this).animate({ 
            opacity: 0.8
        },200, "easeOutCubic");

    },function(){
        $(this).animate({
            opacity: 1
        },200, "easeOutCubic");
    });


    $(".postLargeImage").hover(function() {
        $(this).animate({ 
            opacity: 0.8
        },200, "easeOutCubic");

    },function(){
        $(this).animate({
            opacity: 1
        },200, "easeOutCubic");
    });


    $(".widgetTabsThumb").hover(function() {
        $(this).animate({ 
            opacity: 0.8
        },200, "easeOutCubic");

    },function(){
        $(this).animate({
            opacity: 1
        },200, "easeOutCubic");
    });

    /* top menu */
    $(".mainMenu > li").hover(function() {   
        $(this).stop().find(".subMenu").animate({ 
            height: "show"
        },150);

    },function(){
        $(this).stop().find(".subMenu").delay(300).animate({
            height: "hide"
        },150);
    });

    // animate social links
    $('.socialDetails a').hover(
        function(){
			
            $(this).stop().animate({
                "margin-top": "-5px"
            }, 100);
		
        },
        function(){
		
            $(this).stop().animate({
                "margin-top": "0px"
            }, 100);
	
        });
    $('.postSocialIcon').hover(
        function(){
			
            $(this).stop().animate({
                opacity:0.7
            }, 200);
		
        },
        function(){
		
            $(this).stop().animate({
                opacity:1
            }, 200);
	
        });
   
    // cycle plugin
    $('#sliderOne').cycle({

        fx:     'fade',  // effect
        easing: 'linear', // set the easing you want , easeInElastic, easeOutBack  ...
        speed:  700,    // speed of transition
        timeout: 3200,    // timeout of the slide
        pause:       false,     // true to enable "pause on hover"
        pauseOnPagerHover: false, // true to pause when hovering over pager link
        pager:  '#sliderNavList',
        next:   '#nextSlide',
        prev:   '#prevSlide',
		   
        pagerAnchorBuilder: function(idx, slideModule) {
            // return sel string for existing anchor
            return '#sliderNavList li:eq(' + (idx) + ') a';
        },
        cleartypeNoBg: true,  // fix cleartype inside slides
        cleartype: true  // fix cleartype inside slides
    });
    // $('#sliderNavList li a').click(function() {   $('#sliderOne').cycle('pause');   });
    //$('.slideModule').click(function() {   $('#sliderOne').cycle('pause'); 	 });
		
    //jquery tabs	
    $("ul.widgetTabs").tabs(".widgetTabsLists > li",{
        effect: 'fade',
        fadeSpeed: 300
    });

    //pretty photo
    $("a[rel^='prettyPhoto']").prettyPhoto({
        theme: 'light_rounded'
    });
                  
    var selector = "a[href=\"" + window.location + "\"]";
    $(selector).parent().addClass('currentPage');
    
    $('#captcha').click(function() {
        $(this).attr('src', appURL + 'module/captcha/show?' + Math.random());
    });

}); 
