
$(document).ready(function() { 

	// featured
	cmd = "featured_slide_next()";
	featured_timer = setTimeout(cmd, featured_delay);
	
	$("#style1_featured1").click(function() {
		location.href='get_around-maps.php';	
	
	});
	
	$("#style1_featured3").click(function () {
		location.href='have_fun-first_final_friday.php';
	
	});
	
	$("#style1_featured5").click(function () {
		location.href='have_fun-first_final_friday.php';
	
	});


	// tabs
	$("#tabbed_tab_click_momentum").click(function () {
		tabbed_tab_go('momentum');
		
	});

	$("#tabbed_tab_click_news").click(function () {
		tabbed_tab_go('news');
	
	});
	
	$("#tabbed_tab_click_events").click(function () {
		tabbed_tab_go('events');
	
	});
	
	$("#tabbed_tab_click_resources").click(function () {
		tabbed_tab_go('resources');


	});

	cmd = "tabbed_tab_switch()";
	tab_timer = setTimeout(cmd, tab_delay);

	$("#style1_tabbed").mouseover(function() {
		clearTimeout(tab_timer);
		
		$(".widget_day_events_overlay").hide();
		
	});
	
	$("#style1_tabbed").mouseout(function() {
		cmd = "tabbed_tab_switch()";
		tab_timer = setTimeout(cmd, tab_restart_delay);
		
	});
	

	
	// calendar
	$("#style1_calendar_div").load("listener_calendar.php");

	$(".style1_calendar_dropoff").mouseover(function () {
		$(".widget_day_events_overlay").hide();
	
	});


	// ad
/*
	$("#style1_ad").mouseover(function () {
		$("#style1_ad").css("background-image", "url(images/style1_ad_over.gif)");
		
	});
	
	$("#style1_ad").mouseout(function () {
		$("#style1_ad").css("background-image", "url(images/style1_ad.gif)");
	
	});
*/

	$("#style1_content1").mouseover(function () {
		dropoff();
	});

	$("#style1_content2").mouseover(function () {
		$(".widget_day_events_overlay").hide();
	});

	$("#style1_featured").mouseover(function () {
		$(".widget_day_events_overlay").hide();
	//	dropoff();
	});
	
	$("#style1_nav_dropoff").mouseover(function () {
		dropoff();
	});


	//map panels
	map_slide_timer = setTimeout(function() {
		map_slide_go();
		
	}, map_slide_delay);
	
	$("#style1_map").mouseover(function() {
		clearTimeout(map_slide_timer);
	});
	
	$("#style1_map").mouseout(function() {
		map_slide_timer = setTimeout(function() {
			map_slide_go();
		
		}, (map_slide_delay / 3));
	});

});

var featured_current = 1;
var featured_delay = 7000;

function featured_slide_next() {
	featured_next = (featured_current * 1) + 1;
	
	if (featured_next > 6) {
		featured_next = 1;
	}
	
	featured_current_id = "style1_featured" + featured_current;
	featured_next_id = "style1_featured" + featured_next;
	
	//$("#" + featured_current_id).hide();
	$("#" + featured_current_id).fadeOut(1000);
	//$("#" + featured_next_id).show();
	$("#" + featured_next_id).fadeIn(1000);
	
	featured_current = featured_next;

	cmd = "featured_slide_next()";
	featured_timer = setTimeout(cmd, featured_delay);
}


var tab_current = "momentum";
var tab_delay = "7000";
var tab_restart_delay = "12000";

var tabs = Array();
tabs[0] = "momentum";
tabs[1] = "news";
tabs[2] = "events";
tabs[3] = "resources";

var resources_number = 0;

function tabbed_tab_go(tab_name) {
	new_tab = "tabbed_tab_" + tab_name;
	new_box = "tabbed_box_" + tab_name;
	
	current_tab = "tabbed_tab_" + tab_current;
	current_box = "tabbed_box_" + tab_current;
	
	$("#" + current_tab).hide();
	$("#" + current_box).hide();
	
	$("#" + new_tab).show();
	$("#" + new_box).show();
	
	tab_current = tab_name;

	if (tab_name=="resources") {
		if (resources_number > 5) {
			col1_id = "resourceitem_5"
		} else {
			col1_id = "resourceitem_" + resources_number;
		}

		col1 = $("#" + col1_id).position();
		$("#tabbed_box_resources_col1_line").height( col1.top + "px");

		if (resources_number > 5) {		
			col2_id = "resourceitem_" + resources_number;

			col2 = $("#" + col2_id).position();	
			$("#tabbed_box_resources_col2_line").height( col2.top + "px");


		}

	}
}

function tabbed_tab_switch() {
	tab_current_id = tabbed_tab_id(tab_current);
	
	new_tab = (tab_current_id * 1) + 1;
	
	if (new_tab > 3) {
		new_tab = 0;
	}

	tabbed_tab_go(tabs[new_tab]);
	
	cmd = "tabbed_tab_switch()";
	tab_timer = setTimeout(cmd, tab_delay);
	
}

function tabbed_tab_id(tab_name) {
	for(i=0; i < tabs.length; i++) {
		if (tabs[i]==tab_name) {
			return i;
		
		}
	
	}
}


var style1_media_current = 1;

function style1_media_click(media_id) {
	media_file = media_files[media_id];
	media_preview = media_previews[media_id];

	var so = new SWFObject("flash/mediaplayer/player.swf", "player-swf", "256", "212", "9.0.124.0", "");
	so.addParam("wmode", "transparent");
	so.addParam("flashvars", "&file=../../user/media/" + media_file + "&skin=flash/mediaplayer/skins/nacht/nacht.swf&usefullscreen=false&image=user/media/" + media_preview);
	so.write("style1_media_player");

	thumb_active_current = "style1_media_thumb_active" + style1_media_current;
	caption_current = "style1_media_caption" + style1_media_current;
	
	$("#" + thumb_active_current).hide();
	$("#" + caption_current).hide();
	
	
	thumb_active = "style1_media_thumb_active" + media_id;
	caption = "style1_media_caption" + media_id;
	
	$("#" + thumb_active).show();
	$("#" + caption).show();
	
	
	style1_media_current = media_id;

}


function widget_show_month(show_month, show_year) {
	$("#widget_grid").fadeOut("normal");

	$("#style1_calendar_div").load("listener_calendar.php", { 'show_month': show_month, 'show_year': show_year });

}


var map_slide_current = 1;
var map_slide_max = 5;
var map_slide_delay = 5500;

function map_slide_go() {
	map_slide_next = map_slide_current + 1;
	
	if (map_slide_next > map_slide_max) {
		map_slide_next = 1;
	}

	$("#style1_map_panel" + map_slide_current).hide();
	$("#style1_map_panel" + map_slide_next).show();
	
	map_slide_current = map_slide_next;
	
	map_slide_timer = setTimeout(function() {
		map_slide_go();	
		
	}, map_slide_delay);

}