var slideshow;
var slideshowIsRunning=true;

function startSlideshow() {
	slideshowIsRunning=true;
	$(".pause").css("backgroundPosition", "top left");
	slideshow = setTimeout("$('.arrow_next').click()",4000);
}	

function stopSlideshow() {
	slideshowIsRunning=false;
	$(".pause").css("backgroundPosition", "bottom left");
	clearTimeout(slideshow);
}	


$(function() {

	var showMessage = true;
	
	if ($.cookie('noMessage') == 'true') {
		showMessage = false;
	}

	if (showMessage) {
		$('#maintenanceMessage').fadeIn(600);
	}

	$('#closeMaintenanceMessage').click(function(e) {
		e.preventDefault();
		$('#maintenanceMessage').fadeOut(600);
	});
	
	$('#killMaintenanceMessage').click(function(e) {
		e.preventDefault();
		$('#maintenanceMessage').fadeOut(600);
		$.cookie('noMessage', true, { expires: 14 });
	});

	$('#footer_logo').click(function(e) {
		e.preventDefault();
		$('#flagSelector').slideToggle(600);
	});

	
	// Add Niecon logo instead of home link
	if (window.location.hostname != 'www.niecon.com.au') {
		var homeLink = $('#firstLevelNav>.menu>ul>li:first-child>a');
		homeLink.html('');
		homeLink.css('background-image','url(/images/niecon-home-nav-small-lifespaces.jpg)');
		homeLink.css('background-repeat','no-repeat');
		homeLink.css('background-position','center');
		homeLink.css('width','50px');
	}

	
	$("#content_wslide").wslide({
		width: 200,
		height: 255,
		pos: 1,
		horiz: true
	});
	
	$("#resources_wslide").wslide({
		width: 200,
		height: 255,
		pos: 1,
		horiz: true
	});

	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 22, /* padding for each side of the picture */
		opacity: 0.80, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: ' / ', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'dark_rounded' /* light_rounded / dark_rounded / niecon1_rounded / light_square / dark_square */
	});
	
	$("a[rel^='prettyPopin']").prettyPopin({
		modal : false, /* true/false */
		width : 800, /* false/integer */
		height: 630, /* false/integer */
		opacity: 0.5, /* value from 0 to 1 */
		animationSpeed: 'fast', /* slow/medium/fast/integer */
		followScroll: true, /* true/false */
		loader_path: '/images/prettyPopin/loader.gif', /* path to your loading image */
		callback: function(){} /* callback called when closing the popin */
	});
	
	$("a[rel^='video_prettyPopin']").prettyPopin({
		modal : false, /* true/false */
		width : 664, /* false/integer */
		height: 500, /* false/integer */
		opacity: 0.5, /* value from 0 to 1 */
		animationSpeed: 'fast', /* slow/medium/fast/integer */
		followScroll: true, /* true/false */
		loader_path: '/images/prettyPopin/loader.gif', /* path to your loading image */
		callback: function(){} /* callback called when closing the popin */
	});

	$("#thirdLevelNav").slideDown(1000);

	$('#thirdLevelNav a[href="' + window.location.href + '"]').addClass('selected');
	

	$("a[rel^='prettyPhoto']").click(function() {
		//startSlideshow();
	});

	$(".pause").live("click", function(e) {
		e.preventDefault();
		/*
		if (slideshowIsRunning)
			stopSlideshow();
		else
			startSlideshow();
		*/
	});

});
