$(document).ready(function(){
    $("#main-nav > li").bind("mouseover", jsddm_open);
	$("#main-nav > li").bind("mouseout",  jsddm_timer);
	
	//If there are tabs then render them
	if($("#main-tabs.event-tabs").length) {
		//$("#main-tabs ul").tabs("#main-column > div.pane").history();
		$("#main-tabs ul").tabs("#main-column > div.pane");
	}

	//If there are thickbox tabs then render them
	if($("#thickbox-tabs ul").length) {
		//$("#main-tabs ul").tabs("#main-column > div.pane").history();
		$("#thickbox-tabs ul").tabs("div.pane");
	}

	if($("#header-images img").length > 1) {
		//Cycle the images
		$("#header-images").cycle('fade');
	} else {
		//If there is only one image the cycles script does not run. Just show the single image.
		$("#header-images img").show();
	}
	
	if($("#banner-ads img").length > 1) {
		//Cycle the images
		$("#banner-ads").cycle({
			fx: 'fade',
			pause: 1,
			timeout: 8000
		});
	} else {
		//If there is only one image the cycles script does not run. Just show the single image.
		$("#banner-ads img").show();
	}
	
	$("#did-you-know ul").cycle({
		fx: 'scrollHorz',
		pause: 1,
		timeout: 8000,
	    next:   '#next', 
	    prev:   '#prev'
	});
	
	// Header Pushdown Toggle Initialization
	$("#header-pushdown").css({position:"relative",visibility:"visible"}).hide();
	$("#pushdown-toggle a").click(function(){
		if ($(this).html() == "More"){
			$(this).html("Less");			
		} else {
			$(this).html("More");
		}
		$("#header-pushdown").animate({height:"toggle"},400);	
		return false;
	});
	
    $('a.target_new_window').click(function(){
        window.open(this.href);
        return false;
    });

	$("a.target_thickbox_iframe").each(function() {
		//this.href += 'thickbox/';
	});

	$("a.target_thickbox_iframe").colorbox({
		iframe:true,
		width:"80%",
		height:"80%"
	});

	$("a.target_thickbox_iframe_600x400").each(function() {
		this.href += 'thickbox/';
	});

	$("a.target_thickbox_iframe_600x400").colorbox({
		iframe:true,
		width:"600px",
		height:"400px"
	});
	
	$("a.target_thickbox_iframe_800x600").each(function() {
		this.href += 'thickbox/';
	});

	$("a.target_thickbox_iframe_800x600").colorbox({
		iframe:true,
		width:"800px",
		height:"600px"
	});
	
	$("a.target_thickbox_iframe_webcams").each(function() {
		this.href += 'thickbox/';
	});

	$("a.target_thickbox_iframe_webcams").colorbox({
		iframe:true,
		width:"710px",
		height:"710px"
	});

	if($(".widget_share").length) {
		var footerPosition = $("#footer").position();
		
		//$(".widget_share").css("bottom", footerPosition.top);
	}

});
