$(document).ready(function(){ 
	//Sitespecific javascript here
	//Searchbox clear and fill
	function input_values()
	{	
		var inputBox = $('#newsletter input, #search input');
	
		
		inputBox.focus(function(){
			if ($(this).val() != "") {
				
				var theValue = $(this).val();
				$(this).attr('temp', theValue)
				$(this).val('');
			};
		
		});
		inputBox.blur(function(){
			if ($(this).val() == "") {
				var theValue = $(this).attr('temp');
				$(this).val(theValue);
			};
			
		});
	}
	input_values();
	
	//Even and odd rows in tables
	/* if Environment is NOT Editor */
		$("table tr").mouseover(function() {
			$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");
		});
		$("table tr:nth-child(even), table tr td:nth-child(even)").addClass("even");
		$("table tr:nth-child(odd), table tr td:nth-child(odd)").addClass("odd");
		$("table tr:first-child").removeClass('even').addClass("th");
		$('table tr td:first').addClass('first');
		$('table tr td:last').addClass('last');

	
	/*Accordion menu*/
	//Hide submenus
	$('#sub_nav li ul').hide();
	//If menu option is current, show sub menu
	if ($('#sub_nav li:first-child').hasClass('current'))
		{
			$('#sub_nav ul:first-child > li > ul').slideToggle('slow');
		};
	//When clicking the top level, show submenu, but not sub sub menus
	$('#sub_nav ul:first-child > li > a').click(function() {
		
			$(this).parent().toggleClass('current');
		
		$(this).next().slideToggle('slow');
		return false;
	});
	
	//Set height on subnav
    $col_l = $("#main").height();
    $col_r = $("#secondary").height();

    if($col_l > $col_r)
    {
        $("#secondary").css({height:$col_l});
    }
    else
    {
        $("#main").css({height:$col_r});
    }
    if($('.carousel').length)
    {
  /*Carousel - Theatre*/
	$('.carousel ul').theatre({
	  selector: 'img', 
	  effect: 'carousel', 		//horizontal or vertical or fade or show or slide or 3d or custome effect name or Effect . 
	  speed: 1000, 			//Animation speed
	  still: 4000, 			//Default time standing still
	  autoplay: true, 	//Start animations automatically.
	  controls: false, 	//Display default next/previous/play/stop controls. Values: horizontal or vertical or none. Default: horizontal
	  width: '100%', 		//Set the width of the Stage or false to leave the original size. Default: false
	  height: '210px' 		//Set the height of the Stage or false to leave the original size. Default: false
	  //itemWidth: false, //false - don't resize; 'max' - maximum size; arbitrary size ('100px', '50%', ...). Default: false
	  //itemHeight: false //false - don't resize; 'max' - maximum size; arbitrary size ('100px', '50%', ...). Default: false
	  //onMove: function(idx){ alert('Animate this')}//callback after animation
	});
	
	$('.carousel td').append('<span class="control"><a href=\"#\" title=\"previous\" class=\"control previous\">Previous</a> <a href=\"#\" title=\"stop\" class=\"control stop\">Stop</a> <a href=\"#\" title=\"play\" class=\"control play\">Play</a><a href=\"#\" title=\"next\" class=\"control next\">Next</a> </span>');

	$('.carousel a[title=next], .carousel a[title=previous], .carousel a[title=pause], .carousel a[title=stop], .carousel a[title=play]').click(function(event){
	  	event.preventDefault;
	  	switch($(this).attr('title'))
	  	{
	  		case "next":
			$('.carousel ul').theatre('next');
	  		break;
	  		case "previous":
	  		$('.carousel ul').theatre('prev');
	  		break;
	  		case "play":
	  		$('.carousel ul').theatre('play');
	  		break;
	  		case "pause":
	 		case "stop":
	  		$('.carousel ul').theatre('stop');
	  		break;
	  		default:
	  		$('.carousel ul').theatre('stop');
	 		break;
	  	}
	return false;
			  	
	});
}

});
