// JavaScript Document

function number_format( number, decimals, dec_point, thousands_sep ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://crestidg.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)    
    // *     example 1: number_format(1234.5678, 2, '.', '');
    // *     returns 1: 1234.57     
 
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "," : dec_point;
    var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}

$(document).ready(function(){


	var active = $('#activeCat').attr("class");
	

	$(".spinner_down").click(function() {
		var aantal = parseInt($("#aantal").val());
		if (aantal > 1){
			var new_aantal = aantal-1;
		}else{
			var new_aantal = 1;
		}
		var price 	= $("#products_price").val();
		var tot = new_aantal * price;
		var tot_formatted = number_format(tot,2,',','.');
		//alert(tot);
		$("#aantal").val(new_aantal);
		$("#tot").html(tot_formatted);
	});

	$(".spinner_up").click(function() {
										
		var aantal = parseInt($("#aantal").val());
		if (aantal > 0){
			var new_aantal = aantal+1;
		}else{
			var new_aantal = 1;
		}
		var price 	= $("#products_price").val();
		var tot = new_aantal * price;
		var tot_formatted = number_format(tot,2,',','.');
		//alert(tot);
		$("#aantal").val(new_aantal);
		$("#tot").html(tot_formatted);
	});
	
	$("#aantal").blur(function() {
		var aantal = parseInt($("#aantal").val())+1;
		var price 	= $("#products_price").val();
		var tot = aantal * price;
		//alert(tot);
		$("#aantal").val(aantal);
		$("#tot").html(tot);
	});


	//alert('x');
	
	for (var x = 1; x <= 50; x++){
		var overid = '#over' + x;
		
		//var overid = '#over' + x;
		
		if (x == active){
			var activeid = '#' + active;
			$(overid).show();
			//alert(activeid);
			$(activeid).attr("class", "linkitemactive");	
//					(hfdImg).attr("class", $(hfdImg).attr("src").replace("_r.png", "_g.png"));	
		}else{
			$(overid).hide();
		}
	}			

	$("#items div.linkitem").mouseover(function() {
		var id = $(this).attr("id");	
		var overid = '#over' + id;
		//alert (overid);
		$(overid).show();	
	});
	
	$("#items div.linkitem").mouseout(function() {
		var id = $(this).attr("id");	

		var overid = '#over' + id;
		//alert (id + ' / ' + active);
		if (id != active) $(overid).hide();	

	});			


	$(".news_detail_toggle").click(function(evt) {
		$(this).parents('.news_item').toggleClass("listed");
		$(this).parents('.news_item').children('.news_details').is(":hidden")      
		
			if ($(this).parents('.news_item').children('.news_details').is(":hidden")) {
				$(this).parents('.news_item').children('.news_details').slideDown("slow");
		  } else {
			$(this).parents('.news_item').children('.news_details').slideUp("slow");
		  }
		  evt.preventDefault();


	});
	
	$(".press_detail_toggle").click(function(evt) {
		$(this).parents('.press_item').toggleClass("listed");
		$(this).parents('.press_item').children('.press_details').is(":hidden")      
		
			if ($(this).parents('.press_item').children('.press_details').is(":hidden")) {
				$(this).parents('.press_item').children('.press_details').slideDown("slow");
		  } else {
			$(this).parents('.press_item').children('.press_details').slideUp("slow");
		  }
		  evt.preventDefault();

	});
			
	$(".job_detail_toggle").click(function() {
		$(this).parents('.job_item').toggleClass("listed");
		$(this).parents('.job_item').children('.job_details').is(":hidden")      
		
			if ($(this).parents('.job_item').children('.job_details').is(":hidden")) {
				$(this).parents('.job_item').children('.job_details').slideDown("slow");
		  } else {
			$(this).parents('.job_item').children('.job_details').slideUp("slow");
		  }

	});
	
});
	
	
 
 
 
 
