function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else
		begin += 2;
		var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

function open_window(page_url, page_title, params) {
	window.open(page_url, page_title, params);
	return false;
}

function win_opener(page_url, page_title, params) {
	window.open(page_url, page_title, params);
	return false;
}


function pagination_submit(url, page, form) {
	var frmObj = document.getElementById(form);
	var appendSign;
	if (frmObj == undefined) {
		window.location = url + page;
	
	} else {
		if (frmObj.action.indexOf('?') > 0) {
			appendSign = '&'
		} else {
			appendSign = '?'
		}
		frmObj.action = frmObj.action + appendSign + 'page=' + page;
		frmObj.submit();
	}
	
}



/*********************************************************************
Handle the swapping of navigation images
*********************************************************************/
topNavImages = {
	navRobson_on: "/images/general/tab_robson_on.gif",
	navRobson_off: "/images/general/tab_robson_off.gif",
	
	navPortico_on: "/images/general/tab_portico_on.gif",
	navPortico_off: "/images/general/tab_portico_off.gif",
	
	navPavilion_on: "/images/general/tab_pavilion_on.gif",
	navPavilion_off: "/images/general/tab_pavilion_off.gif",
	
	navNationalTrust_on: "/images/general/tab_national-trust_on.gif",
	navNationalTrust_off: "/images/general/tab_national-trust_off.gif",
	
	navConway_on: "/images/general/tab_conway_on.gif",
	navConway_off: "/images/general/tab_conway_off.gif",
	
	navCollinsBrown_on: "/images/general/tab_collinsandbrown_on.gif",
	navCollinsBrown_off: "/images/general/tab_collinsandbrown_off.gif",
	
	navBatsford_on: "/images/general/tab_batsford_on.gif",
	navBatsford_off: "/images/general/tab_batsford_off.gif",
	
	navHome_on: "/images/general/nav_home_on.gif",
	navHome_off: "/images/general/nav_home_off.gif",
	
	navAbout_on: "/images/general/nav_about_on.gif",
	navAbout_off: "/images/general/nav_about_off.gif",
	
	navCategories_on: "/images/general/nav_categories_on.gif",
	navCategories_off: "/images/general/nav_categories_off.gif",
	
	navAuthors_on: "/images/general/nav_ourauthors_on.gif",
	navAuthors_off: "/images/general/nav_ourauthors_off.gif",
	
	navContact_on: "/images/general/nav_contact_on.gif",
	navContact_off: "/images/general/nav_contact_off.gif",
	
	buttonSearch_on: "/images/buttons/button_search_on.gif",
	buttonSearch_off: "/images/buttons/button_search_off.gif",
	
	newsletterSubmit_on: "/images/buttons/button_red_submit_on.gif",
	newsletterSubmit_off: "/images/buttons/button_red_submit_off.gif",

	buttonMore_on: "/images/buttons/button_more_over.gif",
	buttonMore_off: "/images/buttons/button_more.gif",
	
	AddToBag_on: "/images/buttons/button_add-to-bag_over.gif",
	AddToBag_off: "/images/buttons/button_add-to-bag.gif",
	
	buttonEnlarge_on: "/images/buttons/button_enlarge-image_over.gif",
	buttonEnlarge_off: "/images/buttons/button_enlarge-image.gif",
	
	buttonEmail_on: "/images/buttons/button_email-a-friend_over.gif",
	buttonEmail_off: "/images/buttons/button_email-a-friend.gif",
	
	buttonSeries_on: "/images/buttons/button_rest-of-series_on.gif",
	buttonSeries_off: "/images/buttons/button_rest-of-series_off.gif",


	Q_on: "/images/keys/q_on.gif",
	Q_off: "/images/keys/q_off.gif",	
	
	W_on: "/images/keys/W_on.gif",
	W_off: "/images/keys/W_off.gif",	
	
	E_on: "/images/keys/E_on.gif",
	E_off: "/images/keys/E_off.gif",	
	
	R_on: "/images/keys/R_on.gif",
	R_off: "/images/keys/R_off.gif",	
	
	T_on: "/images/keys/t_on.gif",
	T_off: "/images/keys/t_off.gif",	
	
	Y_on: "/images/keys/y_on.gif",
	Y_off: "/images/keys/y_off.gif",	
	
	U_on: "/images/keys/u_on.gif",
	U_off: "/images/keys/u_off.gif",	
	
	I_on: "/images/keys/i_on.gif",
	I_off: "/images/keys/i_off.gif",	
	
	O_on: "/images/keys/o_on.gif",
	O_off: "/images/keys/O_off.gif",	
	
	P_on: "/images/keys/p_on.gif",
	P_off: "/images/keys/p_off.gif",	
	
	A_on: "/images/keys/a_on.gif",
	A_off: "/images/keys/a_off.gif",	
	
	S_on: "/images/keys/s_on.gif",
	S_off: "/images/keys/s_off.gif",
	
	D_on: "/images/keys/d_on.gif",
	D_off: "/images/keys/d_off.gif",	
	
	F_on: "/images/keys/f_on.gif",
	F_off: "/images/keys/f_off.gif",		
	
	G_on: "/images/keys/g_on.gif",
	G_off: "/images/keys/g_off.gif",
	
	H_on: "/images/keys/h_on.gif",
	H_off: "/images/keys/h_off.gif",	
	
	J_on: "/images/keys/j_on.gif",
	J_off: "/images/keys/j_off.gif",	
	
	K_on: "/images/keys/k_on.gif",
	K_off: "/images/keys/k_off.gif",
	
	L_on: "/images/keys/l_on.gif",
	L_off: "/images/keys/l_off.gif",	
	
	Z_on: "/images/keys/z_on.gif",
	Z_off: "/images/keys/z_off.gif",
	
	X_on: "/images/keys/x_on.gif",
	X_off: "/images/keys/x_off.gif",
	
	C_on: "/images/keys/c_on.gif",
	C_off: "/images/keys/c_off.gif",	
	
	V_on: "/images/keys/v_on.gif",
	V_off: "/images/keys/v_off.gif",
	
	B_on: "/images/keys/b_on.gif",	
	B_off: "/images/keys/b_off.gif",	
	
	N_off: "/images/keys/n_off.gif",
	N_on: "/images/keys/n_on.gif",
	
	M_off: "/images/keys/m_off.gif",	
	M_on: "/images/keys/m_on.gif",	


	buttonsign_in_off: "/images/buttons/button_grey_signin.gif",
	buttonsign_in_on: "/images/buttons/button_red_signin.gif",
	
	buttonregister_off: "/images/buttons/button_grey_signin.gif",
	buttonregister_on: "/images/buttons/button_red_signin.gif",
	
	editFrmSubmitBtn_off: "/images/buttons/button_red_next.gif",
	editFrmSubmitBtn_on: "/images/buttons/button_grey_next.gif",
	
	btnProceed_off: "/images/buttons/button_red_next.gif",
	btnProceed_on: "/images/buttons/button_grey_next.gif",
	
	btnAddress_off: "/images/buttons/button_grey_dispatch.gif",
	btnAddress_on: "/images/buttons/button_red_dispatch.gif",
	
	
	btnProcessPayment_off: "/images/buttons/button_grey_process-order.gif",
	btnProcessPayment_on: "/images/buttons/button_red_process-order.gif",
	
	btnEditItems_off: "/images/buttons/button_grey_update.gif",
	btnEditItems_on: "/images/buttons/button_red_update.gif",

	update_promocode_off: "/images/buttons/button_red_update.gif",
	update_promocode_on: "/images/buttons/button_grey_update.gif",
	
	btnEditCard_off: "/images/buttons/button_grey_update.gif",
	btnEditCard_on: "/images/buttons/button_red_update.gif",
	
	btnEditDelivery_off: "/images/buttons/button_grey_update.gif",
	btnEditDelivery_on: "/images/buttons/button_red_update.gif",
	
	btnEditBilling_off: "/images/buttons/button_grey_update.gif",
	btnEditBilling_on: "/images/buttons/button_red_update.gif",

	basketFrmSubBtn1_off: "/images/buttons/button_grey_update.gif",
	basketFrmSubBtn1_on: "/images/buttons/button_red_update.gif",
	
	basketFrmSubBtn2_off: "/images/buttons/button_grey_update.gif",
	basketFrmSubBtn2_on: "/images/buttons/button_red_update.gif",
	
	updateBtn_off: "/images/buttons/button_red_update.gif",
	updateBtn_on: "/images/buttons/button_grey_update.gif",
	
	remove_off: "/images/buttons/button_grey_remove.gif",
	remove_on: "/images/buttons/button_red_remove.gif",
	
	basketFrmCheckout_off: "/images/buttons/button_red_proceed.gif",
	basketFrmCheckout_on: "/images/buttons/button_grey_proceed.gif",
	
	btnContinue_off: "/images/buttons/button_grey_continue.gif",
	btnContinue_on: "/images/buttons/button_red_continue.gif",
	
	buttonPaf_off: "/images/buttons/button_grey_find-address.gif",
	buttonPaf_on: "/images/buttons/button_red_find-address.gif",
	
	show_paf_off: "/images/buttons/button_grey_find-address.gif",
	show_paf_on: "/images/buttons/button_red_find-address.gif",
	
	backBtn_off: "/images/buttons/button_grey_back.gif",
	backBtn_on: "/images/buttons/button_red_back.gif",
	
	accountDetailsSubBtn_off: "/images/buttons/button_red_save.gif",
	accountDetailsSubBtn_on: "/images/buttons/button_save_grey.gif",
	
	registerBtn_off: "/images/buttons/button_register_red.gif",
	registerBtn_on: "/images/buttons/button_register_grey.gif",
	
	viewOrderBtn_off: "/images/buttons/button_red_view-order.gif",
	viewOrderBtn_on: "/images/buttons/button_grey_view-order.gif",
	
	backBtn_off: "/images/buttons/button_grey_back.gif",
	backBtn_on: "/images/buttons/button_red_back.gif",
	
	newAddressBtn_off: "/images/buttons/button_red_add-new-address.gif",
	newAddressBtn_on: "/images/buttons/button_grey_add-new-address.gif",
	
	editBtn_off: "/images/buttons/button_red_edit.gif",
	editBtn_on: "/images/buttons/button_grey_edit.gif",
	
	amendSearchBtn_off: "/images/buttons/button_grey_amend-search.gif",
	amendSearchBtn_on: "/images/buttons/button_red_amend-search.gif",
	
	viewAllBtn_off: "/images/buttons/button_red_view-all.gif",
	viewAllBtn_on: "/images/buttons/button_grey_view-all.gif",
	
	XBtn_off: "/images/buttons/button_grey_X.gif",
	XBtn_on: "/images/buttons/button_red_X.gif",
	
	deleteBtn_off: "/images/buttons/button_grey_delete.gif",
	deleteBtn_on: "/images/buttons/button_red_delete.gif",

	buttonOOS_off: "/images/buttons/button_grey_notify-me.gif",
	buttonOOS_on: "/images/buttons/button_red_notify-me.gif",
	
	buttonregister_off: "/images/buttons/button_grey_register.gif",
	buttonregister_on: "/images/buttons/button_red_register.gif",
	
	buttonAddThis_off: "/images/buttons/button_share.gif",
	buttonAddThis_on: "/images/buttons/button_share_over.gif"
	
		
}	
	

function swapImg(elementId, state) {
	var tmpId = elementId;
	if (eval("topNavImages."+tmpId+'_off') == undefined) {
		tmpId = document.getElementById(elementId).name;
		
	}
	if (state == 0) {
		document.getElementById(elementId).src = eval("topNavImages."+tmpId+'_off');
	} else {
		document.getElementById(elementId).src = eval("topNavImages."+tmpId+'_on')
	}
}

/*********************************************************************
*********************************************************************/


var ForgottenPassword = {
	_this: this,
	addForm: function() {
		var _this = this;
		var url = '/myaccount/forgottenPassword.asp';
		$('#msgContainer .bg').load(url +' #forgottenContainer',  function() {
			$('#forgottenFrm').submit(function(){
				return false;
			});
			$('#forgottenFrmSubBtn').bind('click', _this, function(o) {
				var _url = '/myaccount/forgottenPassword_save.asp'
				var _data = $('#forgottenFrm').serialize();
			
				$.ajax({
					type: "POST",
					url: _url, 
					data: _data, 
					success: function(result) {
						MessageBox.strong();
						MessageBox.header('Newsletter sign-up');
						MessageBox.show(result);
					},
					failure: function(msg) {
						MessageBox.strong();
						MessageBox.header('Error');
						MessageBox.prepend('A problem occured while processing your \'Forgotten Password\' request');
					}
					
				});
					
			});

		});
		
	},
	init: function() {
		var _this = this;
		
		
		
		$('#forgottenPasswordLink').bind('click', _this, function(o) {
			MessageBox.width(500);
			MessageBox.header('Retrieve Forgotten Password');
			o.data.addForm();
			$('#msgContainer .bg').css('font-size','0.7em');

			MessageBox.show(null);
		    return false;
		});
	
	}
}


var NewsletterSignUp = {
	init: function() {
	
		$('#newsletterFrm').submit(function(e) {
			$.post('/myaccount/newsletter_save.asp', {newsLetterEmailAddress: $('#newsLetterEmailAddress').val()}, function (res){
				var msg = '';
				var hdr = 'Error';
				switch (res) {
				case "success":
					msg = 'Thank you for registering';
					$('#newsLetterEmailAddress').val('');
					hdr = 'Thank You';
					break;
				case "empty":
					msg = 'Please enter an email address before pressing submit';
					break;
				case "invalid":
					msg = 'Please enter a valid email address before pressing submit';
					break;
				case "exists":
					msg = 'This email address has already been registered';
					break;
				default:
					msg = 'Unknown result';
					break;
				};

				//MessageBox.strong();
				MessageBox.header(hdr);
				MessageBox.show(msg);

			});
			
			return false;
		});
		
		$('#msgCloseLink').click(function() {MessageBox.hide(); return false;});



	}
};

var MessageBox = {
	_topOffset: 150,
	_strong: false,
	makeStrong: function(msg) {
		if (this._strong) {
			msg = '<strong>' + msg + '</strong>';
		}
		this._strong = false;
		return msg;
	},
	append: function(msg) {				
		//Assign message text
		if (msg != null) {
			msg = this.makeStrong(msg);
			$('#msgContainer .bg').append(msg + '<br/>');
		}
	},
	prepend: function(msg) {				
		//Assign message text
		if (msg != null) {
			msg = this.makeStrong(msg);
			$('#msgContainer .bg').prepend('<br/>' + msg);
		}
	},
	fadeBackground: function() {
		//$('#msgBackground').css('background-color', '#000');
		$('#msgBackground').css('opacity', 0.4);
		$('#msgBackground').css('width', $(document).width());
		$('#msgBackground').css('height', $(document).height()+100);
		
		$('#msgBackground').css('position','absolute').css('top','0px').css('left','0px');
		
		$('#msgBackground').show();

		//$('#msgContainer').css('opacity', 1);
		$('#msgContainer').css('z-index', 5);
	},
	showBackground: function() {
		$('#msgBackground').hide();
		//$('.main-container').fadeTo('slow', 1);
	},
	strong: function() {
		_strong = true;
	},
	show: function(msg) {
		
		this.reposition(null);
		this.fadeBackground();			
		//Assign message text
		if (msg != null) {
			msg = this.makeStrong(msg);
			
			$('#msgContainer .bg').html(msg);
		}
		//Show panel
		$('#msgContainer').fadeIn('slow', function() {

			$('#msgBackground').click(function() {
			    MessageBox.hide();
				return false;
			});
		
		
		});
		
		$('#msgContainer').focus();

		
	},
	image: function(imageFile) {				
		//Assign image tag
		var tmpBorder = $('#msgContainer').css('border-color');
		
		this.reposition(null);
		this.fadeBackground();		
		
		this.header($('.book-details_text h1').text());
		
		$('#msgContainer').css('border-color', '#fff');
		$('#msgContainer .bg').css('text-align', 'center');
		$('#msgContainer .bg').html('<img src=\"' + imageFile + '\" border=\"0\" />');
		
		//Show panel
		$('#msgContainer').fadeIn('slow', function() {
			$('#msgContainer').css('border-color', '#959595');
			
			$('#msgBackground').click(function() {
			    MessageBox.hide();
				return false;
			});
		//	MessageBox.width($('#msgContainer .bg img').width()+20);
		
		});
		$('#msgContainer').focus();

		
	},
	hide: function() {
		$('#msgContainer').fadeOut('slow', function() {
			//clear out content - dont want it to show again
			$('#msgContainer .bg').html('');
			$('#msgContainer .hd').html('');
		});
		this.showBackground();
		
		$('.main-container').unbind('click');	

		
	},
	header: function(msg) {
		$('#msgContainer .hd').html(msg);
	},
	width: function(w) {
		$('#msgContainer').css('width', w);
		this.reposition(this._topOffset);
	},
	height: function(h) {
		$('#msgContainer .bg').css('height', h);
	},
	reset: function() {
		this.width(300);
		this.height(100);
		this.resposition(150);
	},
	reposition: function(topOffset) {
		if (topOffset != undefined) {
			this._topOffset = topOffset;
		}
		
		//calculate centre position
		var totW = $('body').width();

		var w = $('#msgContainer').width();

//		var left = totW/2 - w/2;
//		var top = this._topOffset;
					
		var left = totW/2 - w/2;
		var top = this._topOffset + $(document).scrollTop();

					
		$('#msgContainer').css('position','absolute').css('top',top.toString() + 'px').css('left',left.toString() + 'px');
		
	
	},

	
	init: function() {	
		$('#msgCloseLink').click(function() {MessageBox.hide(); return false;});
		this.reposition(this._topOffset);
					
	}
}

var SimpleSearch = {
	validate : function () {
		var validation = Validation;
		var valid;
		
		if (validation.s('searchTerm', 'Please enter a keyword to search for') ) {
		
			if (document.getElementById('searchTerm').value=='enter a keyword') {
				validation.alert('Please enter a keyword to search for');
				valid = false;
			} else {
				valid = true;
			}	
			
		} else {
			document.getElementById('searchTerm').value = 'enter a keyword';
			valid = false;
		}
		return valid;
	},
	init: function (){
		$('#searchFrm').submit(function(){return SimpleSearch.validate();})
	}
}
var AdvSearch = {
	validate : function () {
		var validation = Validation;
		var valid;
		if (!validation.s('productTitle', '') &&
			!validation.s('authorName', '') &&
			!validation.s('subject', '') &&
			!validation.s('isbn', '')  ) {
			validation.alert('Please fill in at least 1 search field');
			valid = false;
		} else {
			valid = true;		
		}
		return valid;
	},
	init: function (){
		if ($('#advSearchFrm').length != 0) {
			$('#advSearchFrm').submit(function(){return AdvSearch.validate();})
		}
	}
}
var SortResults = {
	init: function (){
		$('#sortResultsBtn').hide();
		$('#sortResultsFrm select').change(function(){$('#sortResultsFrm').submit();});
	}
}

var ProductDetails = {
	init: function() {
		if ($('#buttonEnlargeLink') != undefined) {
			$('#buttonEnlargeLink').hide();
			$('#thumb').click(function(){
				MessageBox.width(420);
				MessageBox.image($('#buttonEnlargeLink').attr('href'));
				
				MessageBox.show();
			});
			$('#buttonEnlarge').click(function(){
				MessageBox.width(420);
				MessageBox.image($('#buttonEnlargeLink').attr('href'));
				
				MessageBox.show();
			});

			
		}	
	}

}

var EmailAFriend = {
	_catId: null,
	_subCatId: null,
	_id: null,
	_this: this,
	addForm: function(catId, subCatId, id) {
		var _this = this;
		var url = '/products/emailafriend.asp?catid=' + catId + '&subcatId=' + subCatId + '&id=' + id;
		$('#msgContainer .bg').load(url +' #emailAFriendContainer', _this, function(o) {
			var _this = o.data;
			$('#emailFrm').submit(function(){
				return false;
			});
			$('#emailFrmSubBtn').bind('click', _this, function(o) {
/*				var yourEmail = $('#yourEmailAddress').val();
				var yourName = $('#yourName').val();
				var recipientsEmail = $('#recipientsEmailAddress').val();
				var recipientsName = $('#recipientsName').val();
				var yourMessage = $('#yourMessage').val();
				var productid = $('#productid').val();
*/				
				var _url = '/products/emailafriend_save.asp'
				var _data = $('#emailFrm').serialize();
			
				$.ajax({
					type: "POST",
					url: _url, 
					data: _data, 
					success: function(result) {
						if (result == 'Success') {
							MessageBox.strong();
							MessageBox.show('Your friend will soon receive an email notifying them about the item');
						} else {
							MessageBox.strong();
							MessageBox.prepend('The following information was not found:<br/>' + result);
						}
					},
					failure: function(msg) {
						MessageBox.strong();
						MessageBox.prepend('A problem occured while processing your \'Email A Friend\' request');
					}
					
				});
					
			});

		});
		
	},
	init: function(catId, subCatId, id) {
		this._catId = catId;
		this._subCatId = subCatId;
		this._id = id;
		var _this = this;
		
		
		$('#buttonEmail').parent().click(function() {
			return false;	
		});
		
		$('#buttonEmail').bind('click', _this, function(o) {
			MessageBox.width(500);
			MessageBox.header('Email A Friend');
			o.data.addForm(o.data._catId, o.data._subCatId, o.data._id);
			$('#msgContainer .bg').css('font-size','0.7em');

			MessageBox.show(null);
		    return false;
		});
	
	}
}

var OOS = {
	_catId: null,
	_subCatId: null,
	_id: null,
	_this: this,
	addForm: function(catId, subCatId, id) {
		var _this = this;
		var url = '/products/OOS.asp?catid=' + catId + '&subcatId=' + subCatId + '&id=' + id;
		$('#msgContainer .bg').load(url +' #emailAFriendContainer', _this, function(o) {
			var _this = o.data;
			$('#oosFrm').submit(function(){
				return false;
			});
			$('#oosFrmSubBtn').bind('click', _this, function(o) {

				var _url = '/products/OOS.asp?func=save'
				var _data = $('#oosFrm').serialize();
			
				$.ajax({
					type: "POST",
					url: _url, 
					data: _data, 
					success: function(result) {
						if (result == 'Success') {
							MessageBox.strong();
							MessageBox.show('Thankyou we will notify you when this item comes into stock');
						} else {
							MessageBox.strong();
							MessageBox.prepend('The following information was not found:<br/>' + result);
						}
					},
					failure: function(msg) {
						MessageBox.strong();
						MessageBox.prepend('A problem occured while processing your request');
					}
					
				});
					
			});

		});
		
	},
	init: function(catId, subCatId, id) {
		this._catId = catId;
		this._subCatId = subCatId;
		this._id = id;
		var _this = this;
		
		
		$('#buttonOOS').parent().click(function() {
			return false;	
		});
		
		$('#buttonOOS').bind('click', _this, function(o) {
			MessageBox.width(500);
			MessageBox.header('Email me when back in stock');
			o.data.addForm(o.data._catId, o.data._subCatId, o.data._id);
			$('#msgContainer .bg').css('font-size','0.7em');

			MessageBox.show(null);
		    return false;
		});
	
	}
}

var Basket = {
	numbersOnly: function() {
		Validation.numbersOnly($('.basket-row input.quantity'));
	},
	updateDelivery: function() {
		$('#deliveryOption').bind('change', function() {
			var _url = '/checkout/order_charge.asp';
			var _data = $('#basketFrm').serialize();
			$.ajax({
				type: "POST",
				url: _url, 
				data: _data, 
				success: function(result) {
					var obj = eval('(' + result + ')');
					if (obj.error != null) {
						//failed
						$('#itemsTotal').text(obj.items_value);
						$('#taxTotal').text(obj.tax);
						$('#deliveryTotal').text(obj.delivery_value);
						$('#grandTotal').text(obj.total);
						
					} else {
						//success - so update displayed charges
						$('#itemsTotal').text(obj.items_value);
						$('#taxTotal').text(obj.tax);
						$('#deliveryTotal').text(obj.delivery_value);
						$('#grandTotal').text(obj.total);
						
					}
					
				},
				failure: function(msg) {
					MessageBox.strong();
					MessageBox.prepend('A problem occured while updating your delivery option');
				}
					
			});

			
		
		});
	},
	updatePromo: function()
	{
		$('#update_promocode').bind('click', function(e)
		{
			e.preventDefault();
			var _url = '/checkout/order_charge.asp';
			var _data = $('#basketFrm').serialize();
			$.ajax(
			{
				type: "POST",
				url: _url, 
				data: _data, 
				success: function(result) 
				{
					var obj = eval('(' + result + ')');
					if (obj.error != null) 
					{
						//failed
						$('#itemsTotal').text(obj.items_value);
						$('#taxTotal').text(obj.tax);
						$('#deliveryTotal').text(obj.delivery_value);
						$('#grandTotal').text(obj.total);
						$('#discountTotal').text(obj.discount);
						
					} else {
						//success - so update displayed charges
						$('#itemsTotal').text(obj.items_value);
						$('#taxTotal').text(obj.tax);
						$('#deliveryTotal').text(obj.delivery_value);
						$('#grandTotal').text(obj.total);
						$('#discountTotal').text(obj.discount);
					}
				},
				failure: function(msg) 
				{
					MessageBox.strong();
					MessageBox.prepend('A problem occured while updating your delivery option');
				}
					
			});
			
		});
		
	},
	init: function() {
		if ($('#basket') != undefined) {
			this.numbersOnly();
			this.updateDelivery();
			this.updatePromo();
		}	
	
	}

}

$(document).ready(function() {
//		NewsletterSignUp.init();	
		SimpleSearch.init()
		AdvSearch.init();
		MessageBox.init();
		SortResults.init();
		ProductDetails.init();
		Basket.init();
	}
);