<!--  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("sendemail.php",{ 
			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();
}

/* SIFR javascript */
var calibri = {
  src: 'sifr/calibrib.swf'//embedd calibri bold
  ,ratios: [8, 1.42, 11, 1.38, 17, 1.32, 21, 1.3, 22, 1.29, 30, 1.28, 35, 1.27, 44, 1.26, 67, 1.25, 70, 1.24, 71, 1.25, 74, 1.24, 75, 1.25, 1.24]
  ,wmode : 'transparent'
};

sIFR.activate(calibri);

sIFR.replace(calibri, {
	selector: 'h1,h2',
	filters: {
			  BevelFilter: {
				knockout: false
				,distance: -1
				,color: '#000000'
				,strength: 0.5
			  }
			},
	css: {'.sIFR-root': { 'color': sifrColor,'background-color': '#000000' } }
});
