$(document).ready(function(){

	// add utility classes
	$('ul').each(function(){
		$(this).find('li:first-child').addClass('first-child');
		$(this).find('li:last-child').addClass('last-child');
	});
	
	$('a[rel="external"]').attr('target', '_blank');
	

	$('.pill').css('opacity', '.8');
	
	$('#social a').css('opacity', '.4').mouseover(function(){
		$(this).stop().animate({'opacity':'1'}, 400);
	}).mouseout(function(){
		$(this).stop().animate({'opacity':'.4'}, 400);
	});
	
	$('#top-subnav .pill').click(function(){
		$('#top-subnav .pill span').each(function(){
			var txt = $(this).text();
			// $(this).text(txt.replace(/\+/, ''));
			$(this).parent().removeClass('active');
			// $(this).parent().css('opacity','.8');
		});
		// $(this).find('span').prepend('+ ');
		$(this).addClass('active');
	})
	
});

$(window).load(function(){
	$('.panel').css('background-image', 'none');
});

function randOrd(){
	return (Math.round(Math.random())-0.5);
}


// Home Slide show
var med = 0;
var interupt = 0;
var callx = function() {timemove();};
var homecall = function() {slideHome();};
var callx2 = function() {interup0;};
function slideHome(){
	if (interupt == 0) {
        if (med == 0) {
			
            $('.project').fadeOut();
            $('#project-1').fadeIn(1500);
            $('#project-navigation a').removeClass('active');
            $('a[href="#project-1"]').addClass('active');
            med = 1;

        } else if (med == 1) {

            $('.project').fadeOut();
            $('#project-2').fadeIn(1500);
            $('#project-navigation a').removeClass('active');
            $('a[href="#project-2"]').addClass('active');

            med = 2;

        } else if (med == 2) {

            $('.project').fadeOut();
            $('#project-3').fadeIn(1500);
            $('#project-navigation a').removeClass('active');
            $('a[href="#project-3"]').addClass('active');

            med = 3;

        } else if (med == 3) {

            $('.project').fadeOut();
            $('#project-4').fadeIn(1500);
            $('#project-navigation a').removeClass('active');
            $('a[href="#project-4"]').addClass('active');
            med = 4;

        } else if (med == 4) {

            $('.project').fadeOut();
            $('#project-5').fadeIn(1500);
            $('#project-navigation a').removeClass('active');
            $('a[href="#project-5"]').addClass('active');
            med = 5;

        } else if (med == 5) {

            $('.project').fadeOut();
            $('#project-6').fadeIn(1500);
            $('#project-navigation a').removeClass('active');
            $('a[href="#project-6"]').addClass('active');
            med = 6;

        } else if (med == 6) {

            $('.project').fadeOut();
            $('#project-7').fadeIn(1500);
            $('#project-navigation a').removeClass('active');
            $('a[href="#project-7"]').addClass('active');
            med = 7;

        } else if (med == 7) {

            $('.project').fadeOut();
            $('#project-8').fadeIn(1500);
            $('#project-navigation a').removeClass('active');
            $('a[href="#project-8"]').addClass('active');
            med = 0;

        }
		setTimeout(homecall, 3000);
    }
}

// Work slideshows
var t;

var interuptAquilex = 0;
var callx3 = function() {interuptAquilex = 0;};
var callAquilex = function(){slideAquilex();}
function slideAquilex(){
	if (interuptAquilex == 0) {
        if (med == 0) {
	    	$('#aquilex .projects .inner').not('#comsys .inner').stop().animate({'left': '0px'}, 1000);
            $('#aquilex .project-nav a').removeClass('active');
            $('#aquilex .project1').addClass('active');
            med = 1;
        } else if (med == 1) {

	    	$('#aquilex .projects .inner').not('#comsys .inner').stop().animate({'left': '-620px'}, 1000);
            $('#aquilex .project-nav a').removeClass('active');
            $('#aquilex .project2').addClass('active');
            med = 2;

        } else if (med == 2) {
	    
	    	$('#aquilex .projects .inner').not('#comsys .inner').stop().animate({'left': '-1240px'}, 1000);
            $('#aquilex .project-nav a').removeClass('active');
            $('#aquilex .project3').addClass('active');

            med = 0;

        }
		setTimeout(callAquilex, 3000);
	}else{
		med=0;
		
	}
}

var interuptAutotrader = 0;
var callAutotrader = function(){slideAutotrader();}
function slideAutotrader(){
	if (interuptAutotrader == 0) {
        if (med == 0) {
	    	$('#autotrader .projects .inner').not('#comsys .inner').stop().animate({'left': '0px'}, 1000);
            $('#autotrader .project-nav a').removeClass('active');
            $('#autotrader .project1').addClass('active');
            med = 1;

        } else if (med == 1) {

	    	$('#autotrader .projects .inner').not('#comsys .inner').stop().animate({'left': '-620px'}, 1000);
            $('#autotrader .project-nav a').removeClass('active');
            $('#autotrader .project2').addClass('active');
            med = 2;

        } else if (med == 2) {
	    
	    	$('#autotrader .projects .inner').not('#comsys .inner').stop().animate({'left': '-1240px'}, 1000);
            $('#autotrader .project-nav a').removeClass('active');
            $('#autotrader .project3').addClass('active');

            med = 3;

        } else if (med == 3) {
	    
	    	$('#autotrader .projects .inner').not('#comsys .inner').stop().animate({'left': '-1860px'}, 1000);
            $('#autotrader .project-nav a').removeClass('active');
            $('#autotrader .project4').addClass('active');

            med = 0;

        } else if (med == 4) {
	    
	    	$('#autotrader .projects .inner').not('#comsys .inner').stop().animate({'left': '-2520px'}, 1000);
            $('#autotrader .project-nav a').removeClass('active');
            $('#autotrader .project5').addClass('active');

            med = 0;

        }
		setTimeout(callAutotrader, 3000);
	}else{
		med=0;
		
	}
}

var interuptAvivia = 0;
var callAvivia = function(){slideAvivia();}
function slideAvivia(){
	if (interuptAvivia == 0) {
        if (med == 0) {
	    	$('#avivia .projects .inner').not('#comsys .inner').stop().animate({'left': '0px'}, 1000);
            $('#avivia .project-nav a').removeClass('active');
            $('#avivia .project1').addClass('active');
            med = 1;

        } else if (med == 1) {

	    	$('#avivia .projects .inner').not('#comsys .inner').stop().animate({'left': '-620px'}, 1000);
            $('#avivia .project-nav a').removeClass('active');
            $('#avivia .project2').addClass('active');
            med = 2;

        } else if (med == 2) {
	    
	    	$('#avivia .projects .inner').not('#comsys .inner').stop().animate({'left': '-1240px'}, 1000);
            $('#avivia .project-nav a').removeClass('active');
            $('#avivia .project3').addClass('active');

            med = 3;

        } else if (med == 3) {
	    
	    	$('#avivia .projects .inner').not('#comsys .inner').not('#comsys .inner').stop().animate({'left': '-1860px'}, 1000);
            $('#avivia .project-nav a').removeClass('active');
            $('#avivia .project4').addClass('active');

            med = 4;

        } else if (med == 4) {
	    
	    	$('#avivia .projects .inner').not('#comsys .inner').stop().animate({'left': '-2520px'}, 1000);
            $('#avivia .project-nav a').removeClass('active');
            $('#avivia .project5').addClass('active');

            med = 5;

        } else if (med == 5) {

	    	$('#avivia .projects .inner').not('#comsys .inner').stop().animate({'left': '-3160px'}, 1000);
            $('#avivia .project-nav a').removeClass('active');
            $('#avivia .project6').addClass('active');

            med = 0;

        }
		setTimeout(callAvivia, 3000);

	}else{
		med=0;
		
	}
}

var interuptKodak = 0;
var callKodak = function(){slideKodak();}
function slideKodak(){
	if (interuptKodak == 0) {
        if (med == 0) {
	    	$('#kodak-dental-systems .projects .inner').not('#comsys .inner').stop().animate({'left': '0px'}, 1000);
            $('#kodak-dental-systems .project-nav a').removeClass('active');
            $('#kodak-dental-systems .project1').addClass('active');
            med = 1;

        } else if (med == 1) {

	    	$('#kodak-dental-systems .projects .inner').not('#comsys .inner').stop().animate({'left': '-620px'}, 1000);
            $('#kodak-dental-systems .project-nav a').removeClass('active');
            $('#kodak-dental-systems .project2').addClass('active');
            med = 0;
			
        } 
		setTimeout(callKodak, 3000);
	}else{
		med=0;
		
	}
}

var interuptMistubishi = 0;
var callMistubishi = function(){slideMistubishi();}
function slideMistubishi(){
	if (interuptMistubishi == 0) {
        if (med == 0) {
	    	$('#mitsubishi .projects .inner').not('#comsys .inner').stop().animate({'left': '0px'}, 1000);
            $('#mitsubishi .project-nav a').removeClass('active');
            $('#mitsubishi .project1').addClass('active');
            med = 1;

        } else if (med == 1) {

	    	$('#mitsubishi .projects .inner').not('#comsys .inner').stop().animate({'left': '-620px'}, 1000);
            $('#mitsubishi .project-nav a').removeClass('active');
            $('#mitsubishi .project2').addClass('active');
            med =2;

        } else if (med == 2) {

	    	$('#mitsubishi .projects .inner').not('#comsys .inner').stop().animate({'left': '-1240px'}, 1000);
            $('#mitsubishi .project-nav a').removeClass('active');
            $('#mitsubishi .project3').addClass('active');
            med = 0;

        }

		setTimeout(callMistubishi, 3000);
	}else{
		med=0;
		
	}
}

var interuptMovius = 0;
var callMovius = function(){slideMovius();}
function slideMovius(){
	if (interuptMovius == 0) {
        if (med == 0) {
	    	$('#movius .projects .inner').not('#comsys .inner').stop().animate({'left': '0px'}, 1000);
            $('#movius .project-nav a').removeClass('active');
            $('#movius .project1').addClass('active');
            med = 1;

        } else if (med == 1) {

	    	$('#movius .projects .inner').not('#comsys .inner').stop().animate({'left': '-620px'}, 1000);
            $('#movius .project-nav a').removeClass('active');
            $('#movius .project2').addClass('active');
            med =2;

        } else if (med == 2) {

	    	$('#movius .projects .inner').not('#comsys .inner').stop().animate({'left': '-1240px'}, 1000);
            $('#movius .project-nav a').removeClass('active');
            $('#movius .project3').addClass('active');
            med = 3;

        } else if (med == 3) {

	    	$('#movius .projects .inner').not('#comsys .inner').stop().animate({'left': '-1860px'}, 1000);
            $('#movius .project-nav a').removeClass('active');
            $('#movius .project4').addClass('active');
            med = 0;

        }
		setTimeout(callMovius, 3000);
	}else{
		med=0;
		callMovius();
	}
}

var interuptPorsche = 0;
var callPorsche = function(){slidePorsche();}
function slidePorsche(){
	if (interuptPorsche == 0) {
        if (med == 0) {
	    	$('#porsche .projects .inner').not('#comsys .inner').stop().animate({'left': '0px'}, 1000);
            $('#porsche .project-nav a').removeClass('active');
            $('#porsche .project1').addClass('active');
            med = 1;

        } else if (med == 1) {

	    	$('#porsche .projects .inner').not('#comsys .inner').stop().animate({'left': '-620px'}, 1000);
            $('#porsche .project-nav a').removeClass('active');
            $('#porsche .project2').addClass('active');
            med =2;

        } else if (med == 2) {

	    	$('#porsche .projects .inner').not('#comsys .inner').stop().animate({'left': '-1240px'}, 1000);
            $('#porsche .project-nav a').removeClass('active');
            $('#porsche .project3').addClass('active');
            med = 0;

        }
		setTimeout(callPorsche, 3000);
	}else{
		med=0;
		
	}
}

var interuptRaymondJames = 0;
var callRaymondJames = function(){slideRaymondJames();}
function slideRaymondJames(){
	if (interuptRaymondJames == 0) {
        if (med == 0) {
	    	$('#raymond-james .projects .inner').not('#comsys .inner').stop().animate({'left': '0px'}, 1000);
            $('#raymond-james .project-nav a').removeClass('active');
            $('#raymond-james .project1').addClass('active');
            med = 1;

        } else if (med == 1) {

	    	$('#raymond-james .projects .inner').not('#comsys .inner').stop().animate({'left': '-620px'}, 1000);
            $('#raymond-james .project-nav a').removeClass('active');
            $('#raymond-james .project2').addClass('active');
            med =2;

        } else if (med == 2) {

	    	$('#raymond-james .projects .inner').not('#comsys .inner').stop().animate({'left': '-1240px'}, 1000);
            $('#raymond-james .project-nav a').removeClass('active');
            $('#raymond-james .project3').addClass('active');
            med = 3;

        }else if (med == 3) {

	    	$('#raymond-james .projects .inner').not('#comsys .inner').stop().animate({'left': '-1860px'}, 1000);
            $('#raymond-james .project-nav a').removeClass('active');
            $('#raymond-james .project4').addClass('active');
            med = 0;

        }
		setTimeout(callRaymondJames, 3000);
	}else{
		med=0;
		
	}
}


// 
// function timemove(num) {
// 
//     if (interupt == 0) {
//         if (med == 0) {
// 
//             $('.projects .inner').stop().animate({
//                 'left': '-0'
//             },
//             1000);
//             $('.project-nav a').removeClass('active');
//             $('.project1').addClass('active');
//             med = 1;
// 
//         } else if (med == 1) {
//             $('.projects .inner').stop().animate({
//                 'left': '-620px'
//             },
//             1000);
//             $('.project').fadeOut();
//             $('#project-2').fadeIn(1500);
//             $('.project-nav a').removeClass('active');
//             $('.project2').addClass('active');
// 
//             med = 2;
// 			
// 			if(num == 2) med = 0;
// 
//         } else if (med == 2) {
//             $('.projects .inner').stop().animate({
//                 'left': '-1240px'
//             },
//             1000);
//             $('.project').fadeOut();
//             $('#project-3').fadeIn(1500);
//             $('.project-nav a').removeClass('active');
//             $('.project3').addClass('active');
// 
//             med = 3;
// 			if(num == 3) med = 0;
// 
//         } else if (med == 3) {
//             $('.projects .inner').stop().animate({
//                 'left': '-1860px'
//             },
//             2000);
//             $('.project').fadeOut();
//             $('#project-4').fadeIn(1500);
//             $('.project-nav a').removeClass('active');
//             $('.project4').addClass('active');
//             med = 4;
// 
//         } else if (med == 4) {
//             $('.projects .inner').stop().animate({
//                 'left': '-2520px'
//             },
//             2000);
//             $('.project').fadeOut();
//             $('#project-5').fadeIn(1500);
//             $('.project-nav a').removeClass('active');
//             $('.project5').addClass('active');
//             med = 5;
// 
//         } else if (med == 5) {
//             $('.projects .inner').stop().animate({
//                 'left': '-3160px'
//             },
//             2000);
// 
//             $('.project').fadeOut();
//             $('#project-6').fadeIn(1500);
//             $('.project-nav a').removeClass('active');
//             $('.project6').addClass('active');
//             med = 0;
// 
//         }
//         // else if (med == 6) {
//         // 		$('.projects .inner').stop().animate({'left':'-3700px'}, 2000);
//         // 		med = 7;
//         //
//         // }else if (med == 7) {
//         // 		$('.projects .inner').stop().animate({'left':'-4240px'}, 2000);
//         // 		med = 0;
//         //
//         // }
//     } else {}
// 
//     setTimeout(callx, 5000);
// 
// }