// JavaScript Document
function Cufon_replace() { 
	Cufon.replace('#menu li a', 'Tuffy');
}
var tel = 1;
var root = 'http://basrijs.forcez.nl/';
$(function(){
	
	//shoppingcart
	$('img.addtocart').click(function(){
		id = ($(this).attr('id')).split('_')[1];
		qty = $('#qty_'+id).val();
		$.post(root+'addtocart',{id:id,qty:qty},function(data){
			$('#smallcart').empty();
			$('#smallcart').html(data);
		});
	});
	
	$('#smallcart .plusone').live('click',function(){
		id = ($(this).attr('id')).split('_')[1];
		$.post(root+'cartplusone',{id:id},function(data){
			$('#smallcart').empty();
			$('#smallcart').html(data);
		});							  
	});
	
	$('#smallcart .removefromcart').live('click',function(){
		id = ($(this).attr('id')).split('_')[1];
		$.post(root+'removefromcart',{id:id},function(data){
			$('#smallcart').empty();
			$('#smallcart').html(data);
		});		
	});
	
	$("input[name='smallcartqty']").live('keyup',function(){
		id = ($(this).attr('id')).split('_')[1];
		qty = $(this).val();
		if(qty != ''){
			$.post(root+'cartchangeqty',{id:id,qty:qty},function(data){
				$('#smallcart').empty();
				$('#smallcart').html(data);
				$('#scqty_'+id).focus();
			});
		}
		
	});
	
	$('#smallcartorderbutton').live('click',function(){
		window.location= root+'orderoverview';												 
	});
	
	
	//** orderoverview **//
	$("input[name='payment_method']").click(function(){
		var method = $(this).val();
		var conditions = $("input[name='conditions']").attr('checked');
		if(conditions){
			$('#betalenknopideal').hide();
			$('#betalenknopfactuur').hide();
			$('#betalenknop'+method).show();
		}
	});
	
	$("input[name='conditions']").click(function(){
		$('#betalenknopideal').hide();
		$('#betalenknopfactuur').hide();
		var conditions = $("input[name='conditions']").attr('checked');
		if(conditions){
			var method = $("input[name='payment_method']:checked").val();
			if(method){
				$('#betalenknop'+method).show();
			}
		}											 
	});
	
	$('.betalenknop').click(function(){
		window.location = root+'checkout';								 
	});
	
	$(".text_small_img").click(function(){
		var id = $(this).attr('id').split('_')[1];
		$.post('getPageImage',{id:id},function(data){
			$('#img_host').empty();
			$('#img_host').html(data);
		});		
	});
	
	$(".news_small_img").click(function(){
		var id = $(this).attr('id').split('_')[1];
		$.post('getNewsImage',{id:id},function(data){
			$('#img_host').empty();
			$('#img_host').html(data);
		});		
	});
	
	$(".news_small_img_id").click(function(){
		var id = $(this).attr('id').split('_')[1];
		$.post('../getNewsImage',{id:id},function(data){
			$('#img_host').empty();
			$('#img_host').html(data);
		});		
	});
});
