var PopupGalleryPrints = Class.create();
Object.extend(Object.extend(PopupGalleryPrints.prototype, PopupGallery.prototype), {

 	initialize: function(trigger, content, itempos,swapitem,navscroll,itemslastpage) {
		this.popup = content;
		this.trigger = trigger;
		this.itempos = itempos;
		this.swap = swapitem;
		this.scroller = navscroll;
		this.itemsLastPage = itemslastpage; 
		//this.title = document.title;

		if (this.popup && this.trigger) {
			this.createPopup();
			this.setDefaults();
			this.setEvent();
		}
	},

 	createPopup: function() {
 		this.closeBtn = this.popup.down('a.close');
		Event.observe(this.closeBtn, 'click', this.close.bindAsEventListener(this), false);

 		this.popupshadow = this.popup.previous('.popupshadow');
 	},

 	setEvent: function() {
		Event.observe(this.trigger, 'click', this.onClick.bindAsEventListener(this, this.trigger), false);
	},

 	onClick: function(evt, item) {
 		// store the small size and position for later
		this.width = this.trigger.offsetWidth;
		this.left = evt.pageX || evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
		this.left -= this.width/2;
		this.left = this.left || document.body.getDimensions().width / 2;
		this.height = this.trigger.offsetHeight;
		this.top = evt.pageY || evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
		this.top -= this.height/2;
		// stop the default event
		Event.stop(evt);

		//document.title = this.title +' - '+this.popup.name;

		// do the image
		this.prepPop(evt);
 	},

 	swapContent: function() {
 	},

 	prepPop: function() {
		// call the effect
		//POPUP LADEN
		this.pop(this.defaultWidth, this.setPopPosition().top, this.defaultHeight, this.setPopPosition().left, this.trigger, this.trigger);
		//JUISTE ITEM TONEN		
		this.swap.showContent(null, this.itempos + this.itemsLastPage);
		//JUISTE PAGINANUMMER BEREKENEN EN ERHEEN SCROLLEN
		var toPos = this.itempos + this.itemsLastPage;
		var ItemsPerPage = 7;
		// +1 WANT BEGINT BIJ 0
		var toPage = Math.ceil((this.itempos +1) / ItemsPerPage);
		//alert('ToPos = '+toPos+' and itemsperpage = '+ItemsPerPage+' and toPage : '+toPage+' orig itempos = '+this.itempos);
		this.scroller.scrolltoPageNumber(toPage);
	},

 	beforeClose: function() {
		Element.addClassName(this.popup, 'isanim');
		Element.addClassName(this.popupshadow, 'isanim');
 		Element.removeClassName(this.popup, 'popped');
 		Element.removeClassName(this.popupshadow, 'popped');
 		
 		//document.title = this.title;
 	}

});
