$(document).ready(function() {
	$('#gosearch').click(function() {
		$('#search form').submit();
	});

	$('#logolink').click(function() {
		location.href = 'index.php?id=home';
	});

	if ($('#menu').height() > $('#contentframe').height()) {
		$('#contentframe').css('height',$('#menu').height());
		$('#content').css('height',($('#menu').height()-187)+'px');
	}

	// Reset Font Size
	var originalFontSize = $('html').css('font-size');
		$(".resetFont").click(function(){
		$('html').css('font-size', originalFontSize);
	});
	// Increase Font Size
	$("#fs-big").click(function(){
		var currentFontSize = $('p.bodytext').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum+2;
		$('#contentframe p.bodytext, #contentframe li').css('font-size', newFontSize);
		return false;
	});
	// Decrease Font Size
	$("#fs-sml").click(function(){
		var currentFontSize = $('p.bodytext').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum-2;
		$('#contentframe p.bodytext, #contentframe li').css('font-size', newFontSize);
		return false;
	});

});


function startSlideshow(slides) { 
	/* server returns an array of slides which looks like this: 
	[ 
		'images/beach2.jpg', 
		'images/beach3.jpg', 
		'images/beach4.jpg', 
		'images/beach5.jpg', 
		'images/beach6.jpg', 
		'images/beach7.jpg', 
		'images/beach8.jpg' 
	] 
	 
	 
	var totalSlideCount = 1 + slides.length; 
	 
	var $slideshow = $('#slideshow'); 
	 
	// markup contains only a single slide; before starting the slideshow we  
	// append one slide and prepend one slide (to account for prev/next behavior) 
	$slideshow.prepend('<img src="'+slides.pop()+'" width="308" height="308" />'); 
	$slideshow.append('<img src="'+slides.shift()+'" width="308" height="308" />'); 
	*/

	var totalSlideCount = $('#slideshow').size(); 

	// start slideshow 
	$('#slideshow').cycle({ 
		fx: 'scrollHorz', 
		startingSlide: 1,  // start on the slide that was in the markup 
		timeout:  0, 
		speed:    500, 
		prev:    '.prev', 
		next:    '.next', 
		before:   onBefore 
	}); 
	 

	function onBefore(curr, next, opts, fwd) { 
		// on Before arguments: 
		//  curr == DOM element for the slide that is currently being displayed 
		//  next == DOM element for the slide that is about to be displayed 
		//  opts == slideshow options 
		//  fwd  == true if cycling forward, false if cycling backward 
			 
		// on the first pass, addSlide is undefined (plugin hasn't yet created the fn yet) 
		if (!opts.addSlide) 
			return; 
			 
		// have we added all our slides? 
		if (opts.slideCount == totalSlideCount) 
			return; 

		// shift or pop from our slide array  
		var nextSlideSrc = fwd ? slides.shift() : slides.pop(); 
		 
		// add our next slide 
		opts.addSlide('<img src="'+nextSlideSrc+'" />', fwd == false); 
	}; 
}; 