	

$(document).ready(function(){	
	var $container = $('div.spotlight');
	var total_features = $('div.feature').length;
	var curr_feature = 1;
	/*first feature is visible by default */
	var t = 0;	
	var pause;
	var showFeatureInProgress = false;
	
	
	var showFeature = function(){
	if (!showFeatureInProgress){
		
		showFeatureInProgress = true;
		pause = false;
			
		temp_id = "feature-" + curr_feature;
		$("div.feature:not(#" + temp_id + ")").css("display","none");
		$("div[id^=slide-" + curr_feature +"]").css("background-color","#bf7530");
		$("div.slide-link:not(#slide-" + curr_feature +")").css("background-color","#5fc0c0");
		$("div[id^=" + temp_id +"]").fadeIn(3000);
		showFeatureInProgress = false;
		
		curr_feature++;
		if (curr_feature > total_features){
			/*therefore reset if finished cycling through*/
			curr_feature = 1;		
		}
		if (!pause){	
			pause=setTimeout(showFeature,6000);
		}				
		}
	};
	
		if (!pause){	
			pause=setTimeout(showFeature,6000);
		}	
			
		$container.hover(function(){		
		clearTimeout(pause);
		pause=false;
		}, function(){
		if (!pause){	
			pause = setTimeout(showFeature, 250);
		}	
		});	
	
	$("div[id^=slide-]").click(function(){
		clearTimeout(pause);
		pause=false;		
		var temp_id = $(this).attr('id');	
		$(this).css("background-color","#bf7530");	
		myarr = temp_id.split("-");
		temp_id = "feature-" + myarr[1];			
		$("div.slide-link:not(#slide-" + myarr[1] +")").css("background-color","#5fc0c0");
		$("div[id^=" + temp_id +"]").fadeIn(2000);		
		$("div.feature:not(#" + temp_id + ")").css("display","none");
		clearTimeout(pause);
		pause=false;		
		if (!pause){	
			pause = setTimeout(showFeature, 8000);
		}		
	});

	$("ul#search .search_box").focus(function(){
	
		if (this.value == 'search...'){
			this.value='';			
		}
	});
	
	$("ul#search .search_box").blur(function(){
	
		if (this.value == ''){
		//	this.value='search...';			
		}
	});
	
	//if ($('div.spotlight').length){ 
		//this is the home page	
		//get height of div#content
		var page_height = $("div[id='content']").height();
		//now set height of sidebar to page_height		
		//page_height = page_height;		
		$("div[id='sidebar']").css("min-height", page_height + "px");
		//var sidebar_height = $("div[id='sidebar']").height();
		//$("div.ad-container").css("min-height", sidebar_height + "px");
		//$("div.ad-container").css("height", sidebar_height + "px");
	//}
	

    $('#date-input').calendar({
        parentElement: '#calendar-container',
        dateFormat: '%d.%m.%Y'
    });
 
 	//remove link for parent categories
 	$('ul.children').parent(['li']).find('a:first').removeAttr('href');


	$('#startDate').datepicker({ dateFormat: 'yy/mm/dd',navigationAsDateFormat: true, showAnim: 'slideDown', minDate: +1 });

	

 	$('#eventForm').validate({
	 rules: {
    fileupload: "accept"
  }
	 });
	 
	 $('#serviceForm').validate({
	 rules: {
    fileupload: "accept"
  }
	 });
 //alert(templateDir);
 $('#captcha').simpleCaptcha({  numImages: 6, scriptPath: templateDir + 'wp-content/themes/BlueSplash/scripts/captcha/simpleCaptcha.php'   });
 
//$('#fileupload').click(function(){
//	alert("changed");
//});
 
});



