<!--  initialize the slideshow when the DOM is ready -->

$(document).ready(function() {

	$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) { 
		$(pager).find('li').removeClass('active') 
			.filter('li:eq('+currSlideIndex+')').addClass('active'); 
	}; 

	$('#slides').css({'overflow' : 'hidden'}); //set overflow to hidden

	$('#pager').children().remove();//remove filler li(for validation) in the list

	$('#slides').cycle({
		fx: 'scrollVert',
		speed:   500,
		startingSlide: 0,
        timeout: 0,
		prev:   '.up', 
	    next:   '.down',
		prevNextClick: testLocation,
		pagerClick: testLocation2,
		pager:  '#pager', 
		pagerAnchorBuilder: function(idx, slide) {
			return '<li><a href="#">' + slide.title + '</a></li>'; 
		}, 
		nowrap: true //prevents from wrapping back to first slide again
	});
	
	$('.up').hide();//hide scroll up button when page loads
	$('.down').show();//show scroll down button when page loads that way it won't show is user has js disabled

	//initialize portfolio images
	$("a.fancybox").fancybox({
		'titleShow' : false
	});

	$('#emailSent').hide();//hide form sent confirmation message

	//submit form
	$("#submit").click(function(){
		$(this).val('Sending..');
		$(this).attr("disabled", true); 

		$.post("aspmailform.asp",{ 
			strEmail: $("#strEmail").val(), strName: $("#strName").val(), strMessage: $("#strComments").val() },
			function(data){
				$("#sendEmail").slideUp("normal", function() {
					$("#emailSent").show();
				});
		});

		return false;
	});

	$('.follow a').hover(function(){
		$(this).animate({left:'10px'},{queue:false,duration:250});
	}, function(){
		$(this).animate({left:'0px'},{queue:false,duration:250});
	});

});

//test to see if we are on last or first slide and if we need to hide buttons
function testLocation(val,slideNum)
{
	if(slideNum==$('#slides').children().size()-1)//last slide
		$('.down').hide();
	else
		$('.down').show();


	if(slideNum==0)//first slide
		$('.up').hide();
	else
		$('.up').show();
}
function testLocation2(slideNum)//test same as above but when we click to navigate straight to a page
{
	if(slideNum==$('#slides').children().size()-1)//last slide
		$('.down').hide();
	else
		$('.down').show();


	if(slideNum==0)//first slide
		$('.up').hide();
	else
		$('.up').show();
}


