// JavaScript Document



$(document).ready( function() {

	

	//grab total number of slides (only 3 shown at a time)

	var slides = $('#latest ul li').size();

	

	//disable arrows by default

	$('#latest #prev, #latest #next').addClass('dead');



	//more than 3 slides? show the next button

	if (slides>3) {

		$('#latest #next').removeClass('dead');

	}



	//keep count of the position of the carousel

	var carousel = 3;



	//when next is clicked

	$('#latest #next').click( function() {

		if (!$(this).hasClass('dead')) {

			//show the next slide by moving the UL over by 240px

			$('#latest ul').animate({left:'-=720'}, 1000, 'easeInOutExpo')

		

			//show the prev button

			$('#latest #prev').removeClass('dead');

	

			//increment the counter

			++carousel

	

			//if we're on the last slide, disable the next button

			if (carousel>=6) {

				$('#latest #next').addClass('dead');

			}

		}

		return false;

	});



	//when prev is clicked

	$('#latest #prev').click( function() {

		if (!$(this).hasClass('dead')) {

			//show the prev slide by moving the UL over by 240px

			$('#latest ul').animate({left:'+=720'}, 1000, 'easeInOutExpo')

	

			//show the next button

			$('#latest #next').removeClass('dead');

	

			//increment the counter

			--carousel

	

			//if we're on the first slide, disable the prev button

			if (carousel<=3) {

				$('#latest #prev').addClass('dead');

			}

		}

		return false;

	});



	//top button

	$('a.top').click( function() {

		$('html, body').animate({scrollTop:0}, 600);

		return false;

	});



	//sidebar defaults

	//grab the ID of the category

	var cat = 999;
	cat = $('input.cats').eq(0).attr('name')*1;
	if (cat!=999) {

		 $('#links li a').eq(cat).addClass('active')

	}	



	// form inputs

	$('#contact-form input, #contact-form textarea').each( function() {

		$(this).attr('value',$(this).parent('span').parent('div').attr('title'))

	})



	// full-list hover

	$('#wrapper .full-list').hover(

		function() {	$(this).html('Browse the full list of Services &raquo;') },
		function() {	$(this).html('Browse the full list of Services') }

	);



	// medium hover
	$('#wrapper #contact-med').html('contact');

	$('#wrapper #contact-med').hover(

		function() {	$(this).html('contact &raquo;') },

		function() {	$(this).html('contact') }

	);


	var location = $('#url').attr('class');
	if (location == 'home') {
		$('#home li').addClass('active');
	}
	if (location == 'portfolio') {
		$('#menu li').eq(0).addClass('active');
	}
	if (location == 'services') {
		$('#menu li').eq(1).addClass('active');
	}


});