﻿$(document).ready(function () {
	var carouselSpeed = 6000;

    $('#homepageCaro').css('overflow', 'hidden');

    //carousel
    $('#CaroCtrlsLst > li > a:not(#pause)').click(function () {
        var num = parseFloat($(this).attr('id'));
        $(this).parent().addClass('active').siblings('.active').removeClass('active');
        $('#homepageReel').stop().animate({ 'left': (num * -960) + 'px' }, 1000, 'easeInOutCubic');
		changeClientProject(num);
    });

    $('#pause').toggle(function () {
        clearInterval(caroInterval);
        $(this).parent().addClass('pauseActive');
    }, function () {
        moveCaro();
        caroInterval = setInterval(function () { moveCaro() }, carouselSpeed);
        $(this).parent().removeClass('pauseActive');
    });

    function moveCaro() {
        var num = parseFloat($('#CaroCtrlsLst > li.active').children('a').attr('id'));
		changeClientProject(num + 1);

        if (num == 5) {
            $('#homepageReel').stop().animate({ 'left': '0px' }, 1500, 'easeInOutCubic');			
            $('#CaroCtrlsLst > li.active').removeClass('active');
            $('#0caroCtrl').parent().addClass('active');
			changeClientProject(num - 5);
        } else {
            var e = (num + 1) * -960;
            $('#homepageReel').stop().animate({ 'left': e + 'px' }, 1000, 'easeInOutCubic');
            $('#CaroCtrlsLst > li.active').removeClass('active').next('li').addClass('active');
        }
    }
    var caroInterval = setInterval(function () { moveCaro() }, carouselSpeed);

function changeClientProject(currentIndex) {
	var currentLi = $('#homepageReel li').get(currentIndex);
	var currentImage = $(currentLi).children('a').children('img');
	
	$('#homepageCaroProjectInfo h3.projectName').html(currentImage.attr('alt'));
	$('#homepageCaroProjectInfo h4.clientName span').html(currentImage.attr('title'));
	Cufon.replace('h3.projectName', { hover: true, fontFamily: 'Rockwell' }); 
	Cufon.replace('h4.clientName', { hover: true, fontFamily: 'Rockwell' });	
}

	//clients show hide
//	function showClients() {
//	    if ($('#clientsLstCont').attr('title') == 'open') {
//	        $('#clientsLstCont').animate({'height': '0px' },800).attr({'title' : 'closed' , 'class' : 'hidden2'});
//	    } else {
//	        $('#clientsLstCont').animate({'height': $('#clientsLstCont').children('div').height() + 16 + 'px'},500).attr('title', 'open');
//	    }
//	}

//	$('#fltrClients').click(function(e) {
//	    showClients();
//	    e.preventDefault();
//	});

//archives show hide
function showArchives() {
    if ($('.archives').attr('title') == 'closed') {
		$('.archives').animate({'height': $('.archives').children('div').height()},500).attr('title', 'open');
		$('a#moreArchives span').html('Close');
		$('a#moreArchives span').css("background-position", "0px 4px"); 
    } else {
        $('.archives').animate({'height': '160px' },800).attr({'title' : 'closed' , 'class' : 'module archives hidden2'});
		$('a#moreArchives span').html('More...');
		$('a#moreArchives span').css("background-position", "0px -12px");  
    }
}

$('a#moreArchives').click(function(e) {
	showArchives();
    e.preventDefault();
	
});

//contact page submit button fix
	$('input.wpcf7-submit').val('Send message');

	//Cufon styles - Note: Rockwell Std = Rockwell light
	Cufon.replace('#homeIntro h2', { hover: true, fontFamily: 'Rockwell Std' });
	Cufon.replace('#homeIntro h1 a', { hover: true, fontFamily: 'Rockwell Std' });
	Cufon.replace('a.seeMore', { hover: true, fontFamily: 'Rockwell Std' });
	Cufon.replace('.readMore a', { hover: true, fontFamily: 'Rockwell Std' });
	Cufon.replace('a.socialMediaLink', { hover: true, fontFamily: 'Rockwell Std' });
	Cufon.replace('.projectInfo a.projectLink', { hover: true, fontFamily: 'Rockwell Std' }); 
	Cufon.replace('#whatsHapIntro p', { hover: true, fontFamily: 'Rockwell Std' }); 
	Cufon.replace('.theTeam p', { hover: true, fontFamily: 'Rockwell Std' });
	Cufon.replace('.favCamp a', { hover: true, fontFamily: 'Rockwell Std' });
	Cufon.replace('.favCamp a', { hover: true, fontFamily: 'Rockwell Std' });	
	Cufon.replace('h4.teamName', { hover: true, fontFamily: 'Rockwell Std' }); 
	Cufon.replace('h3.projectName', { hover: true, fontFamily: 'Rockwell' }); 
	Cufon.replace('h4.clientName', { hover: true, fontFamily: 'Rockwell' });
	Cufon.replace('.smallCol ul li', { hover: true, fontFamily: 'Rockwell Std' }); 
	Cufon.replace('.comment-reply-link', { hover: true, fontFamily: 'Rockwell Std' }); 
	Cufon.replace('#cancel-comment-reply-link', { hover: true, fontFamily: 'Rockwell Std' });
	Cufon.replace('#process-img p', { hover: true, fontFamily: 'Rockwell Std' });

});










