$(document).ready(function() {
	if (window.attachEvent) { 
		// IE does not do :hover on <li> ==> add a class onmouseover
		sfHover("headerNav");
		sfHover2("kalenderDagen");
	} 
	
	$.ajaxSetup ({
		// Disable caching of AJAX responses */
		cache: false
	});
	
	$(".target").change(function() {
	  updateBasket(this.name,this.value);
	});
	
	$(".checktarget").click(function() {
	  updateBasket(this.name,this.checked);
	});
	
	$(".showhide").click(function() {
		if (this.parentNode.className == "active") {
			this.parentNode.className = "";
		}
		else {
			this.parentNode.className = "active";
		}
		return false;
	});
	
	recountBlancoTotal();
	$(".blancoselect").change(function() {
		recountBlancoTotal();
	});
	
	$('#shopOverview').scrollFollow({
		speed: 1000
		
  	});
	
});

function recountBlancoTotal() {
	var total = 0;
	total = total + ($("#rittenkaart5").val() * $("#prijs_5rittenkaart").val());
	total = total + ($("#rittenkaart10").val() * $("#prijs_10rittenkaart").val());
	total = total + ($("#pass").val() * $("#prijs_pass").val());
	$("#totaalBlancoEuro").html(total.toFixed(2));
	$("#totaalEuro").html((parseFloat($("#subtotalEuro").html())+parseFloat($("#totaalBlancoEuro").html())).toFixed(2));
}

function updateBasket(name,value) {
	$.ajax({
	  url: '/basket_commands.dhtml?oper=updateBasket,name=' + name + ",value=" + value + ",session=" + $("#thisSession").val(),
	  success: function(data) {
		$('#shopBasket').load('/show_basket.dhtml?session=' + $("#thisSession").val() + ",language=" + $("#thisLanguage").val(), function() {
			recountBlancoTotal();
		});
	  }
	});
}

function sfHover(id) {
	var BUA = navigator.userAgent;
	var BIE = BUA.indexOf("MSIE");
	var BIsIE = BIE>=0;

	var ul = document.getElementById(id);
	if(ul) {
		var lis = ul.getElementsByTagName('li');
		for(i=0;i<lis.length;i++) {
			if(lis[i].parentNode.parentNode == ul) {
				lis[i].onmouseover=function() {this.className+=" hover";}
				lis[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" hover\\b"), "");}
			}
		}
	}
}

function sfHover2(id) {
	var BUA = navigator.userAgent;
	var BIE = BUA.indexOf("MSIE");
	var BIsIE = BIE>=0;

	var ul = document.getElementById(id);
	if(ul) {
		var lis = ul.getElementsByTagName('li');
		for(i=0;i<lis.length;i++) {
			if(lis[i].parentNode == ul) {
				lis[i].onmouseover=function() {this.className+=" hover";}
				lis[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" hover\\b"), "");}
			}
		}
	}
}