//  Jquery style 
$(document).ready(function() {
	// initialize scrollable
	$("div.scrollable").scrollable({
		circular: true,
		mousewheel: false
	}).autoscroll({
		interval: 8000,
		autoplay: true,
		autopause: true
	});
	// fix for circular jQuery tools addon
	$("div.items").css("left", "0");

	// Clear Search input field after click
	$("input.search_box").click(function() {
		$("input.search_box").attr("value","");
	});

	/* DropDown menu START */
	$("ul.top_menu li a").hover(function() { //When trigger is clicked...
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.children").slideDown('fast').show(); //Drop down the subnav on click
		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.children").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
		});
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

	// Wrap last H2 word in <span> =)
	$('h2.single, div.box h3, div.page h3').each(function(index, element) {
		var heading = $(element), word_array, last_word, first_part;
		word_array = heading.html().split(/\s+/); // split on spaces
		last_word = word_array.pop();			  // pop the last word
		first_part = word_array.join(' ');		  // rejoin the first words together
		heading.html([first_part, ' <span>', last_word, '</span>'].join(''));
	});

});

