$(document).ready(function(){
	if ($('#prod_detail_add')){
		$('#prod_detail_add').nyroModal(
		{
			width:800, minWidth: 800,


			closeButton: '',

			endShowContent:function(elts, settings){
				publisher.notify('addToBasket');
			}

		}
		);
	}

	if ($('#emptyBasket')){
		$('#emptyBasket').nyroModal(
		{
			width:800, minWidth: 800,
			height:600, minHeight: 600,

			closeButton: ''
		}
		);
	}

	if ($('#checkout-notes')){
		$('#checkout-notes tr.input input').focus(function(){
			datePickerController.getDatePicker('nl_delivery_date').show();
			datePickerController.getDatePicker('nl_delivery_date').removeKeyboardEvents();
		}).change(function(e){
			//datePickerController.getDatePicker('nl_delivery_date').hide();
			//datePickerController.getDatePicker('nl_delivery_date').show();
			datePickerController.getDatePicker('nl_delivery_date').changeHandler();
		}).blur(function(e){
			datePickerController.getDatePicker('nl_delivery_date').addKeyboardEvents();
		});

		$('#nl_delivery_date').blur(function(){
			datePickerController.getDatePicker('nl_delivery_date').hide();
		});

	}

	new PostcodeAanvullen('zipcode', 'streetnumber', 'street', 'city');

});

function ShopPublisher(){
	this.subscribers = new Array();
}

ShopPublisher.prototype.add = function(s){
	this.subscribers.push(s);

	s.init(this);
}

ShopPublisher.prototype.notify = function(func, args){
	if (typeof args == 'undefined'){
		args = [];
	}
	for(var i=0; i<this.subscribers.length;i++){
		eval("this.subscribers[i]." + func + ".apply(this, args);");
	}
}


function BasketSubscriber(){
	this.publisher = null;
}

BasketSubscriber.prototype.init = function(publisher){
	this.publisher = publisher;
}

BasketSubscriber.prototype.addToBasket = function(){
	var count = 0;

//	alert('nof items added to basket: ' + count);
}


var publisher = new ShopPublisher();
var basketSubscriber = new BasketSubscriber();

publisher.add(basketSubscriber);
