(function($){

	$(document).ready(function(){

		var offset = 300;
	    var speed = 250;
	    var duration = 500;
        $(window).scroll(function(){
            if ($(this).scrollTop() < offset) {
                      $('.topbutton') .fadeOut(duration);
            } else {
                      $('.topbutton') .fadeIn(duration);
            }
        });
     	$('.topbutton').on('click', function(){
	        $('html, body').animate({scrollTop:0}, speed);
	        return false;
        });

		
		$('#mphtc').removeClass('fancybox');
		
		var iframe = $('#thecciframe').contents();
		iframe.find('#frmlogin input[type="submit"]').click(function(){
   			console.log("test");
		});

		
		$('.slider').bxSlider({
			mode: 'fade',
			auto: true,
			pause: 5000
		});

		$('.tslider').bxSlider({
			mode: 'fade',
			auto: true,
			pager: false
		});

		$('.bx-controls-direction a').text('');

		$('#project-gallery').bxSlider({
          pagerCustom: '#bx-pager',
          mode: 'fade',
          controls: false
        });

        $('.menu-button').click(function(){
        	$(this).next().slideToggle();
        });

        $('#menu-main-menu > .menu-item-has-children > a').each(function(){
        	// $('<span class="w-icon-dropdown-toggle project-down-arrow"></span>').insertAfter($(this));
        	$(this).append('<span class="w-icon-dropdown-toggle project-down-arrow"></span>');
        });

		fixTopText();
	});	

	$(window).load(function(){
		fixTopText();

		$('.tabs-detials-900 a').click(function(event){
			event.preventDefault();
        	$(this).addClass("w--current");
        	$(this).siblings().removeClass("w--current");
        	var tab = $(this).attr("href");
        	$(".w-tab-pane").not(tab).css("display", "none");
        	$(tab).fadeIn();
        });
	});

	$(window).resize(function(){
		fixTopText();
	});

	function fixTopText(){
		var $hHeight = $('#masthead').innerHeight();
		$('.intro-text').css('padding-top', $hHeight);
	}

})(jQuery);