(function($) {
	$(function() {
	
		$('ul.tabs').each(function() {
			$(this).find('li').each(function(i) {
				$(this).click(function(){
					$(this).addClass('current').siblings().removeClass('current')
						.parents('div.section').find('div.box').hide().end().find('div.box:eq('+i+')').fadeIn(150);
						window.mode = 'stop';
				});
			});
		});
	
	});
})(jQuery);

function Ajax(file, data, div)
{
	$.ajax({
	   type: "GET",
	   url: file,
	   data: data,
	   cache: false,
	   success: function(html){
	     $("#"+div).html(html);
	   }
	});
}


function slideshow() {
	if (window.mode == 'run') {
		
		var i = $("#slideshowNumber").val();
		
		$("#slideshow li").removeClass('current')
		$("#curr_" + i).addClass('current')
					  .parents('div.section').find('div.box').hide().end().find('div.box:eq('+i+')').fadeIn(150);
		
		
		
		if (i > 2) {
			i =  0;
			$("#slideshowNumber").val(i);
		} else {
			i =  parseInt(i) + 1;
			$("#slideshowNumber").val(i);
		}
		
		
		setTimeout('slideshow()', 5000);
	}
}




//// DatePicker

	$(function() {
		var dates = $( "#from, #to" ).datepicker({
			changeMonth: true,
			numberOfMonths: 2,
			onSelect: function( selectedDate ) {
				var option = this.id == "from" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" );
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});
	});
	
