
$(function(){
	var no_events_to_display = true;	   
	var arrayVariable = new Array;	   
	var arrayVariableMonth = new Array;
	var found_event = false;

	$(".event_box").each(function (i){
		 arrayVariable.push($(this).attr("id"));
	});
	
	$(".calendar .day_slot").each(function (i){
		 arrayVariableMonth.push($(this).attr("id"));
	});
	
	
	
	
	
	
							  
	$("#header_scheduled_events").html($("#navigation_month").html());	
	$("span#header_scheduled_events").html($("#navigation_month").html());	
	$(".event_box").css("display","none");
	
		
	
	$(".calendar .day_slot").each(function (i){
		//alert($(this).attr("id"));											   
											   
									   
		if($.inArray($(this).attr("id"), arrayVariable)!= -1){
			if( (getQueryVariable("event") != -1) && found_event == false ){
				$(("div#") + getQueryVariable("event")).addClass("okay_to_display").slideDown("slow");
				found_event = true;
			}
			else if(found_event == false)
				$(("div#") + $(this).attr("id")).addClass("okay_to_display").slideDown("slow");
				
			no_events_to_display = false;
			//alert($(this).attr("id"));
			$(this).css('font-weight','bold').addClass('event_day').click(function() {
			     window.location = "http://www.lasecfp.org/calendar.html?event=" + $(this).attr("id");
  		  		 /*$('.event_box').slideUp("fast");				
				 $(("div#") + $(this).attr("id")).slideDown("slow");*/
				 
				
					
				/*else {
				  $(("div#") + $(this).attr("id")).slideUp("fast");
				 $(".view_all_scheduled_events").html("Click to view all scheduled events");  
				}*/
			 });
			
		}
		
		
		//arrayVariable2[i]=$(this).attr("id");
	});
	
	
	//$(".event_box").slideDown("slow");
	//$(".view_all_scheduled_events").html("Click to hide events");	
	
	
	
	$(".calendar #822010").click(function() {
		
				alert($("#822010").attr("id"));
		 })
	
	
	
	if(no_events_to_display)
		$(".no_events_available").css('display', 'block')
		
								  
	 
	
	
	$(".view_all_scheduled_events").click(function() {  		
		$(".okay_to_display").slideDown("slow");
			
	
	});
	
	
	function getQueryVariable(variable) {
  		var query = window.location.search.substring(1);
  		var vars = query.split("&");
  		for (var i=0;i<vars.length;i++) {
			var pair = vars[i].split("=");
			if (pair[0] == variable) 
				return pair[1];
		}
		return -1;
    	
  	}//End of  function getQueryVariable(variable)
	
	
	
	
	$(".display_available_events > #events_container .event_box").css('display', 'block');
	//$(".display_available_events > #events_container").tsort( {"", {order:"desc"});

	
		   
 })
