var $ = jQuery;

$(function () {
	$('#sidebar li[title]').tooltip();
	$("#tabs").tabs("#panes > div");
	$(".tabs").tabs(".panes > div");

	$('#slideshow-items').anythingSlider({
		// Appearance
		width               : null,      // Override the default CSS width
		height              : null,      // Override the default CSS height
		resizeContents      : true,      // If true, solitary images/objects in the panel will expand to fit the viewport
		
		// Navigation
		startPanel          : 1,         // This sets the initial panel
		hashTags            : false,      // Should links change the hashtag in the URL?
		buildArrows         : false,      // If true, builds the forwards and backwards buttons
		buildNavigation     : true,      // If true, buildsa list of anchor links to link to each panel
		navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)
		
		// Slideshow options
		autoPlay            : true,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video has completed
		stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		playRtl             : false,     // If true, the slideshow will move right-to-left
		startText           : "Start",   // Start button text
		stopText            : "Stop",    // Stop button text
		delay               : 10000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		animationTime       : 1200,       // How long the slideshow transition takes (in milliseconds)
		easing              : "easeInOutExpo"    // Anything other than "linear" or "swing" requires the easing plugin
	});
	
	    $('#search').click(function(){
        if("search" === $(this).val()){
            $(this).val("");
        }
    });
    
    $.defaultText();
});


$(document).ready(function() {
	
	/* in order to center the buttons, we need to set the width of ul.thumbNav
	 * to the sum of the computed width of its children */
	if($('.thumbNav li')) {
		var len = 0;
		$('.thumbNav li').each(function(idx,elem) {
			len += $(elem).outerWidth()+3;
		})
		$('.thumbNav').width(len);
	}
		
	
	$('div.caption').each(function() {
		
		var hiddenPosition = '-' + ($(this).height() - $(this).find('h4').outerHeight()) + 'px';
		
		// hide all captions
		$(this).css('bottom',hiddenPosition);
		
		var caption = this;

		mousein = function() {
			$(caption).animate({
				bottom: '0px'
			},100);
		};
		
		mouseout = function() {
			$(caption).animate({
				bottom: hiddenPosition
			},100);
		};

		// show on hover
		//$(this).parent().hover(mousein,mouseout);
		$('.anythingSlider').hover(mousein,mouseout);
		
	});
	

	
});

function checkform ( form )
{
	if (form.theemail.value == "") {
		alert( "Your email is required." );
		form.theemail.focus();
		return false ;
		}
		if (form.message.value == "") {
		alert( "Message is required." );
		form.message.focus();
		return false ;
	}
	return true ;
} 

