var navsection;
var subnavsection;

$(document).ready(function(){

	//apply the png fix for ie6
	pngFix();
	
	//show the pngs now they've been pngFix
	showpng();

	//expand/collapse given element
	showhideaccordion();

	//provide slider for product images
	initiateslider();

	//turn on the appropriate nav item
	setselected();

});


//show the pngs after the pngFix has been applied. stops nasty looking pngs being visible before they've been fixed.
//input: 
//notes: wrap any png imgs in a <span class="hidepng"> in order to make this work alongside pngFix
function showpng() {
	$(".hidepng").addClass("showpng");
	$(".hidepng").removeClass("hidepng");
}


//turn on the appropriate nav item based on the id passed in via global var stored here in global.js but set on each page
//input: id of element to add selected class to
function setselected() {
	if ($("#"+navsection).length != 0) {
		$("#"+navsection).addClass("selected");
	}


	if ($("#"+subnavsection).length != 0) {
		$("#"+subnavsection).addClass("selected");
	}
}


//rotate images in a div with the #rotator id
//input:
function initiateslider() {
	if($("#slider").length != 0) {
		var slideroptions = {
			auto: true,
			continuous: false,
			speed: 500,
			pause: 15000,
			controlsFade: true
		};
	
		$("#slider ul li").removeClass("hide");
		$(".rotator-content img").reflect(); //apply an image reflection. do here so easySlider calcs height of li element correctly (i.e. to include reflection)
		$("#slider").easySlider(slideroptions);
	}
}


//apply a png fix for ie6. done like this as conditional html (<!--[if lte IE 6]>...<![endif]-->) doesn't seem to work?
//input:
function pngFix() {
	$(document).pngFix(); 
}


//show/hide accordion elements
//input:
function showhideaccordion() {
	var accordionoptions = {
		collapsible: true,
		autoHeight: false
		};

	if ($('#accordion').length != 0) {
		$("#accordion").accordion(accordionoptions);
	}
}


//work out last modified date of page
//input:
function lastModified() {
	d = new Date(document.lastModified) ;
	dtDay = d.getDate();
	dtMonth = d.getMonth() + 1;
	dtYear = d.getFullYear();
	dtLastUpdated = dtDay + "/" + dtMonth + "/" + dtYear;
}




