$(document).ready(function() {						   
    window.client_carusel = true;
	//Tabs
    $('.b-tech-tabs ins').hide();
    $('.b-tech-tabs ins:first').show();
    $('.b-tech-tabs-head a:first').addClass('active');
    $('.b-tech-tabs-head a').hover(function () {
        $('.b-tech-tabs-head a').removeClass('active');
        $(this).addClass('active');
        var currentTab = $(this).attr('href');
        $('.b-tech-tabs ins').hide();
        $(currentTab).show();
        return false;
    });
	
	//what our clients say 
    $('.b-clientssay-tabs div').hide();
    $('.b-clientssay-tabs div:first').show();
    $('.b-clientssay-tabs-head a:first').addClass('active');
    $('.b-clientssay-tabs-head a').hover(function () {
        window.client_carusel = false;
        $('.b-clientssay-tabs-head a').removeClass('active');
        $(this).addClass('active');
        var currentTab = $(this).attr('href');
        $('.b-clientssay-tabs div').hide();
        $(currentTab).show();
        return false;
    }, function(){
        window.client_carusel = true;
    });
	
	//Modal Popup
	//select all the a tag with name equal to modal
    $('a[name=modal]').click(function(e) {	
        //Cancel the link behavior
        e.preventDefault();
        //Get the A tag
        var id = $(this).attr('href');		
     
        //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();
     
        //Set height and width to mask to fill up the whole screen
        $('#mask').css({'width':maskWidth,'height':maskHeight});
         
        //transition effect     
        $('#mask').fadeIn(1000);    
        $('#mask').fadeTo("slow",0.8);  
     
        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();
               
        //Set the popup window to center
        $(id).css('top',  winH/2-$(id).height()/2);
        $(id).css('left', winW/2-$(id).width()/2);
        $(id).css('position', 'fixed');
     
        //transition effect
        $(id).fadeIn(500); 		
    });
     
    //if close button is clicked
    $('.window .close').click(function (e) {
        //Cancel the link behavior
        e.preventDefault();
        $('#mask, .window').hide();
    });     
     
    //if mask is clicked
    $('#mask').click(function () {
        $(this).hide();
        $('.window').hide();
    });
	
	// add opacity
	$('body.home .l-3-cols .l-col, body.home .b-home-brands a').hover(function(){
		$(this).stop().animate({"opacity": 1}, 100);
		},
		function(){
		$(this).stop().animate({"opacity": 0.8}, 100);
		});
	
	
function clientSlider() {
        if(window.client_carusel == true){
            var id = $('.b-clientssay-tabs div:visible').attr('id');
            $('#'+id).fadeOut(1000, function(){ 
                $('.b-clientssay-tabs-head a[href="#'+id+'"]').removeClass('active');
                if($('#'+id).next().length) {
                    $('#'+id).next().fadeIn(1000);;
                    $('.b-clientssay-tabs-head a[href="#'+id+'"]').next().addClass('active');
                }
                else{
                    $('.b-clientssay-tabs div:first').fadeIn(1000);;
                    $('.b-clientssay-tabs-head a:first').addClass('active');
                }
            });
        }
    }
    setInterval(clientSlider, 15000);
});

