
var RK_M = {};
var RK_V = {};
var RK_C = {};

// run scripts on load
$(function()
{
	// add JS class
	$('html').addClass('JS');
	
	// enable png support for IE6
	$('#sticker-voucher').supersleight();
	
	// shop form input buttons
	if($('.shop-form').length > 0)
	{
		// add the plus - minus buttons to the quantitiy boxes
		$('input.js-add-remove').each(function(i)
		{
			// create buttons
			var plus = $('<a href="#add-item" class="button-plus"></a>')
				.bind('click', function(event){ RK_C.Basket.add(event); return false; });
			var minus = $('<a href="#remove-item" class="button-minus"></a>')
				.bind('click', function(event){ RK_C.Basket.remove(event); return false; });
			
			// inject into the page
			$(this).wrap('<span></span>').parent().prepend(minus).append(plus);
		});
	}
	
	// check for paypal submission form
	if($('#paypal-submission').length > 0)
	{
		// JS enabled so remove button and auto-submit
		$('#redirection-message').hide();
		$('form').submit();
	}
	
	// load google map
	if($('#google-map').length > 0) {
		RK_C.GoogleMaps.draw('google-map');
	}
	
});




/* Google maps code - contact us page
****************************************************************************/
RK_C.GoogleMaps = {
	
	// draws the map to the page
	draw: function(id){
		if(GBrowserIsCompatible())
		{
			this.map = new GMap2(document.getElementById(id));
			this.map.addControl(new GSmallMapControl());
			var renskitchen = { x: 51.616875, y: -0.266081 };
			var point = new GLatLng(parseFloat(renskitchen.x), parseFloat(renskitchen.y));
			var center = new GLatLng(parseFloat(renskitchen.x+0.001), parseFloat(renskitchen.y));
			this.map.setCenter(center, 14);
			this.map.addOverlay(new GMarker(point));
		}
	}
}



RK_C.Basket = {
	
	// increases the item quantity by 1
	add: function(e)
	{
		// grab the data
		var input = $(e.target).prev();
		var quantity = input.val();
		
		// check that it is a number and add 1 to the total
		quantity = (quantity == parseFloat(quantity)) ? parseFloat(quantity)+1 : 1;
		input.val(quantity);
	},
	
	// reduces the item quantity by 1
	remove: function(e)
	{
		// grab the data
		var input = $(e.target).next();
		var quantity = input.val();
		
		// check that it is a number and it isn't less then 1
		quantity = (quantity == parseFloat(quantity) && parseFloat(quantity) > 1) ? parseFloat(quantity)-1 : '';
		input.val(quantity);
	}
}






