//ON PAGE LOAD
$(document).ready(function() {
	
	//STOCKISTS CLICKING
	$("p.stockistCounty").css({"cursor":"pointer"}).toggle(function() {
		$(this).css({"background":"#ebe3d9","fontWeight":"bold"}).next("ul").show();
	}, function() {
		$(this).css({"background":"","fontWeight":"normal"}).next("ul").hide();
	});
	$("p.stockistCounty + ul").css({"display": "none", "background":"#ebe3d9","marginTop":"-10px"});
	
	$("#menu-retail-yogurts:not(:has(.active)), #menu-foodservice:not(:has(.active)), #menu-about-our-business:not(:has(.active))").click(function() {
		$("ul", this).slideDown(300);
	}).mouseleave(function() {
		$("ul", this).slideUp(300);
	});
	
	$("#menu li.active").parents("#menu ul").css("display", "block");
	
	$("#panels .panel").each(function() {
		$("a:eq(0)", this).attr("href", $("a:eq(1)", this).attr("href"));
	});
	
	
	
});

//LOSE IE6 FLICKER BUG
//--------------------

try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

//POPUP
//-----

function popUp(URL, width, height) {

	var day = new Date();
	var id = day.getTime();
	
	var offsetWidth = (screen.width / 2) - (width / 2);
	var offsetHeight = (screen.height / 2) - (height / 2);

	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left = "+offsetWidth+",top = "+offsetHeight+"');");
	return false;
	
}

//FONT SIZE FUNCTIONALITY
//-----------------------

function fontSize(percentage) {

	document.getElementsByTagName("body")[0].style.fontSize = percentage+"%";
	
	if (!xmlHttp) {
		return false;
	};
	
	xmlHttp.open("get", "/inc/fontsize.php?percentage="+percentage, true);
	xmlHttp.send(null);
	
	xmlHttp.onreadystatechange = function() {		
		if (xmlHttp.readyState == 4 ) {
		 	//alert(xmlHttp.responseText);
		};
	};
	
	return false;

}