// navbar

var currencyCookieName = "currency";
var currency;

var initNav = function(){

	$(".navCatLabel").stop().animate({"opacity": "0"}, 0);
	
	$(".navCatBtn").hover(
		function() {
			$(".off", this).stop().animate({"opacity": "0"}, 100);
			$(".navCatLabel", this).stop().animate({"opacity": "1"}, 100);
		},
		function() {
			$(".off", this).stop().animate({"opacity": "1"}, 1000);
			$(".navCatLabel", this).stop().animate({"opacity": "0"}, 400);
		}
	);
	
	//eraseCookie(currencyCookieName);
	var currency = readCookie(currencyCookieName);
	if(currency == null)
	{
		createCookie(currencyCookieName, "gbp", 1);
		currency = "gbp";
	}

}

var setCurrency = function(newCurrency) {
	createCookie(currencyCookieName, newCurrency, 1);
	currency = newCurrency;
	window.location.reload();
}

var createCookie = function(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

var readCookie = function(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

var eraseCookie = function(name) {
	createCookie(name,"",-1);
}

var getPriceString = function(price, newCurrency)
{
	var priceMult = 1;
	var priceSymbol = "&pound;";
	
	switch(newCurrency)
	{
		case "usd":
			priceMult = fullXML.attr("usd");
			priceSymbol = "&#36;";
			break;
		case "eur":
			priceMult = fullXML.attr("eur");
			priceSymbol = "&euro;";
			break;
	}
	
	var price = (Math.ceil((priceMult * parseInt(price) * 100)) / 100);
	
	var priceString = "";
	priceString = priceSymbol + price;
	return(priceString);
}
