$(function(){
	$('a.navigation-item').each(function(){
		$(this).hover(
			function(){
				src=$(this).children('img').attr('src');
				$(this).children('img').attr('src',src.substr(0,src.length-4)+'_active.gif');
			}, 
			function(){
				src=$(this).children('img').attr('src');
				$(this).children('img').attr('src',src.substr(0,src.length-11)+'.gif');
			}
		);
	});
	$('a.navigation-item-active').each(function(){
		$(this).hover(
			function(){
				src=$(this).children('img').attr('src');
				$(this).children('img').attr('src',src.substr(0,src.length-11)+'.gif');
			}, 
			function(){
				src=$(this).children('img').attr('src');
				$(this).children('img').attr('src',src.substr(0,src.length-4)+'_active.gif');
			}
		);
	});
	$('li.navigation-left-item').each(function(){
		$(this).hover(
			function(){
				$(this).css('background-image','url(style/images/bg_navigation_left_active.gif)');
			}, 
			function(){
				$(this).css('background-image','url(style/images/bg_navigation_left.gif)');
			}
		);		
	})
	
	$('#quick-search').click(function(){
		this.form.submit();	
	});
	$('#quick-login-button').hover(
		function(){
			this.src='style/images/button_login_active.jpg';
		},
		function(){
			this.src='style/images/button_login.jpg';
		}
	).click(function(){
		this.form.submit();
	});
	
	$('#shoppingcart_box_img').hover(
		function(){
			this.src='style/images/bestelknop-active.gif';
		},
		function(){
			this.src='style/images/bestelknop-passive.gif';
		}
	);
	
	$('a.product_image').lightBox({containerResizeSpeed:100});
	$('.attribute').each(function(){
		switch(this.type){
			case 'select-one':
				value=parseFloat(attributes[this.id.substr(9)][this.value]);
				if(value!==0){
					$(this).attr('data',value);
				}
				$(this).change(function(){
					value=parseFloat(attributes[this.id.substr(9)][this.value]);
					if($(this).attr('data')!==undefined){
						basePrice=parseFloat(basePrice)-( parseFloat($(this).attr('data')) * product_quantity);
					}
					$(this).attr('data',value);
					basePrice=parseFloat(basePrice)+( parseFloat(value) * product_quantity);
					$("#price").html("&euro; "+CurrencyFormatted(basePrice));
				});
				break;
			case 'checkbox':
				$(this).click(function(a){
					if($(this).attr('checked')==false){
						basePrice=basePrice-( parseFloat(attributes[this.id.substr(9)][this.value]) * product_quantity);
					}else{
						basePrice=basePrice+( parseFloat(attributes[this.id.substr(9)][this.value]) * product_quantity);
					}
					$("#price").html("&euro; "+CurrencyFormatted(basePrice));
				});
				break;
		}
	});
	$('input.product_quantity').each(function(){
		basePrice=basePrice*$(this).val();	
		$("#price").html("&euro; "+CurrencyFormatted(basePrice));
	}).change(function(){
		basePrice=basePrice/product_quantity;
		basePrice=basePrice*$(this).val();
		product_quantity=$(this).val();
		$("#price").html("&euro; "+CurrencyFormatted(basePrice));		
	});
	$("form#productInfoAdd :input").each(function(){
		if(this.type=='select-one'){
			//TODO 
			//if($(this).text()=="Maak hier uw keuze.."){
			//	console.log($(this).text());
			//}
		}
	});
})