/*
	Copyright Code Computerlove Ltd 2007-2009
	Build: 1.0.0.127
	Date: 05/10/2009 10:52:21
*/

(function($j){

	Code.registerNamespace('Website.Pages');

	Website.Pages.ViewBasket = {
	
		init: function(){
			
			var _self = this;
			
			$j('body').addClass('jsEnabled');
			$j('div.js-rowdelivery').addClass('deliveryRow');
			
			//Hide Delivery Help
			//$j('div.js-deliveryhelp').hide();
			//Apply rollover event to delivery help link
			$j('a.js-deliveryhelplink').mouseover(function(){
				var row = $j(this).parents('div.js-rowdelivery');
				$j( 'div.js-deliveryhelp'  , row ).show();	
			});
			
			$j('a.js-deliveryhelplink').mouseout(function(){
				var row = $j(this).parents('div.js-rowdelivery');
				$j( 'div.js-deliveryhelp'  , row ).hide();	
			});
			
			$("div.js-deliveryhelp").each(function (i) {
			        $j(this).addClass("div.js-deliveryhelp" + i);
			});
			
			_self.hideCalendarTextBox();
			_self.calendarSetUp();
			_self.showDeliveryInformation();
			_self._hide();
			_self._accordion();
		
		},

		_hide: function(){
			var self = this;
			if($j('#tbxPromotionCode').val() == "" || $j('#tbxPromotionCode').val() == "undefined"){
				$j('.promotion-code .rowBodyPadding').hide();
			}
		},

		_accordion: function(){
			var self = this;
			$j('.promotion-code .rowHeader').toggle(function(){
				$j('.promotion-code .rowBodyPadding').slideDown();
			},function(){
				$j('.promotion-code .rowBodyPadding').slideUp();
			});
		},
		
		hideCalendarTextBox: function(){
			//$j('#DeliveryDateTbx').hide();
		},
		
		showDeliveryInformation: function() {
			$j('.js-delivery-information').click(function(){
				window.open("/deliveryInfoPopUp.aspx", "deliveryInfo", "menubar=1,resizable=1,width=650,height=400,scrollbars=1");
				return false;
			});
		},
		
		calendarSetUp: function(){
			
			var _self = this;
			
			if($j('#DeliveryDateTbx').length > 0)
			{
				Calendar.setup({
					inputField     :    "DeliveryDateTbx",
					ifFormat       :    "%d/%m/%Y",
					button         :    "f_trigger_c",
					align          :    "Tl",
					singleClick    :    true,
					firstDay       :    0,
					dateStatusFunc :   function (date , year, month, day )
					{ 
						return checkDate( date, year , month, day );
					},
					onUpdate				:	function(Calendar)
					{
						_self.onCalendarUpdate (Calendar)
					}
				});
			}		
		},
		
		onCalendarUpdate: function(cal){
			//alert('calendar update');
		},
	
		onReady: function(){
		
			var _self = this;
			_self.init();
			
		}
		

	};

	$j().ready(function(){
		Website.Pages.ViewBasket.onReady();
	});


})(jQuery);	


