function PmodGallery(){
	this.id = '';
	this.arr = '';
	this.start = 0;
	this.stepSize = 2;
	this.current = 0;
	this.zoomopen = false;
	this.currentPicture = 0;
	this.arrows = false;
	this.arrowLeft = "img/arrow_left.gif";
	this.arrowRight = "img/arrow_right.gif";
	this.icoZoomIn = "img/ico-zoomin.gif";
	this.icoZoomOut = "img/ico-zoomout.gif";
	this.zoomText = 'Details';
	
	this.createGallery = function() {
		var arrSize = this.arr.length;

		Insertion.Top(this.id,'<div class="gallerythumbnails" id="' + this.id + '_gallerythumbnails"></div>');

		Insertion.Top(this.id + '_gallerythumbnails','<div style="display:none;" id="' + this.id + '_arrowleft" class="galleryarrow"><img src="' + this.arrowLeft + '"/></div>');
		$(this.id + '_arrowleft').observe('click', this.goBack.bind(this));

		for (i = this.start; i < arrSize; i++) {
			Insertion.Top(this.id + '_gallerythumbnails','<div class="gallerythumb" style="display:none;" id="' + this.id + '_gallerythumbnail' + i + '"><img counter="' + i + '" src="' + this.arr[i][0] + '"/></div>');
			$(this.id + '_gallerythumbnail' + i).observe('click', this.showPicture.bind(this));
			Insertion.Bottom(this.id,'<div class="gallerypicturecontainer" id="' + this.id + '_gallerypicturecontainer' + i + '"></div>');			
			Insertion.Bottom(this.id + '_gallerypicturecontainer' + i,'<div class="gallerypicture" style="display:none;" id="' + this.id + '_gallerypicture' + i + '"><img src="' + this.arr[i][1] + '"/></div>');
			Insertion.Bottom(this.id + '_gallerypicturecontainer' + i,'<div class="gallerypicturezoomin" style="display:none;" id="' + this.id + '_gallerypicturezoomin' + i + '"><img src="' + this.icoZoomIn + '" class="ico-zoomin"/></div>');
			$(this.id + '_gallerypicturezoomin' + i).observe('click', this.showZoom.bind(this));
 		}

		Insertion.Top(this.id + '_gallerythumbnails','<div style="display:none;" id="' + this.id + '_arrowright" class="galleryarrow"><img src="' + this.arrowRight + '"/></div>');
		$(this.id + '_arrowright').observe('click', this.goNext.bind(this));
		
		this.initNav();
	}
	
	this.initNav = function() {
		var arrSize = this.arr.length;
		if (arrSize > this.stepSize) {
			$(this.id + '_arrowleft').style.display = 'inline';
			$(this.id + '_arrowright').style.display = 'inline';
			this.arrows = true;
		}
		if (arrSize > 1) {
			for (i = this.start; i < this.stepSize; i++) {
				if(this.arr[i]) {
					$(this.id + '_gallerythumbnail' + i).style.display = 'inline';
				}
			}
		}
		$(this.id + '_gallerypicture' + this.current).style.display = 'inline';
		$(this.id + '_gallerypicturezoomin' + this.current).style.display = 'inline';
	}

	this.initNavZoom = function() {
		var arrSize = this.arr.length;
		if (this.arrows) {
			$(this.id + '_arrowleftzoom').style.display = 'inline';
			$(this.id + '_arrowrightzoom').style.display = 'inline';
		}
		if (arrSize > 1) {
			for (i = this.current;i < (this.current + this.stepSize);i++) {
				$(this.id + '_gallerythumbnailzoom' + i).style.display = 'inline';
			}
		}
	}

	this.showPicture = function(event) {
		this.clearPicture();
		var element = event.element();
		$(this.id + '_gallerypicture' + element.attributes['counter'].nodeValue).style.display = 'inline';
		$(this.id + '_gallerypicturezoomin' + element.attributes['counter'].nodeValue).style.display = 'inline';
		this.currentPicture = element.attributes['counter'].nodeValue;
	}

	this.showPictureZoom = function(event) {
		var element = event.element();
		$(this.id + '_zoomcontent').innerHTML = '<img src="' + this.arr[element.attributes['counter'].nodeValue][2] + '"/>';
		this.currentPicture = element.attributes['counter'].nodeValue;
	}
	
	this.showZoom = function() {
		var arrSize = this.arr.length;
		Insertion.Top(this.id,'<div class="zoomwindow" id="' + this.id + '_zoomwindow"><div class="contentbox"><h2>' + this.zoomText + '</h2></div><div class="galleryzoomcontent" id="' + this.id + '_zoomcontent"></div></div>');
		Insertion.Top(this.id + '_zoomwindow','<div class="gallerypicturezoomout" id="' + this.id + '_gallerypicturezoomout' + i + '"><img src="' + this.icoZoomOut + '" class="ico-zoomout"/></div>');
		$(this.id + '_gallerypicturezoomout' + i).observe('click', this.hideZoom.bind(this));
		Insertion.Top(this.id + '_zoomcontent','<img src="' + this.arr[this.currentPicture][2] + '"/>');
		sIFR.replace(corpoE, {
			selector: 'h2'
			,css: [
				'.sIFR-root { color:#88673C; background-color: #ffffff; letter-spacing:0.5; }'
			]
			,wmode: 'opaque'
		});

		Insertion.Top(this.id + '_zoomwindow','<div class="gallerythumbnailszoom" id="' + this.id + '_gallerythumbnailszoom"></div>');
		
		Insertion.Top(this.id + '_gallerythumbnailszoom','<div style="display:none;" id="' + this.id + '_arrowleftzoom" class="galleryarrow"><img src="' + this.arrowLeft + '"/></div>');
		$(this.id + '_arrowleftzoom').observe('click', this.goBackZoom.bind(this));

		for (i = this.start; i < arrSize; i++) {
			Insertion.Top(this.id + '_gallerythumbnailszoom','<div class="gallerythumb" style="display:none;" id="' + this.id + '_gallerythumbnailzoom' + i + '"><img counter="' + i + '" src="' + this.arr[i][0] + '"/></div>');
			$(this.id + '_gallerythumbnailzoom' + i).observe('click', this.showPictureZoom.bind(this));
 		}

		Insertion.Top(this.id + '_gallerythumbnailszoom','<div style="display:none;" id="' + this.id + '_arrowrightzoom" class="galleryarrow"><img src="' + this.arrowRight + '"/></div>');
		$(this.id + '_arrowrightzoom').observe('click', this.goNextZoom.bind(this));
		
		this.initNavZoom();
	}
	
	this.hideZoom = function() {
		var arrSize = this.arr.length;
		$(this.id).removeChild($(this.id + '_zoomwindow'));
		this.clearAll();
		if (arrSize > 1) {
			for (i = this.current;i < (this.current + this.stepSize);i++) {
				$(this.id + '_gallerythumbnail' + i).style.display = 'inline';
			}
		}
		this.clearPicture();
		$(this.id + '_gallerypicture' + this.currentPicture).style.display = 'inline';
		$(this.id + '_gallerypicturezoomin' + this.currentPicture).style.display = 'inline';
		
	}
	
	this.goNext = function() {
		var arrSize = this.arr.length;
		if ((this.current + 1) < (arrSize - 1)) {
			this.clearAll();
			this.current = this.current + 1;
			for (i = this.current;i < (this.current + this.stepSize);i++) {
				$(this.id + '_gallerythumbnail' + i).style.display = 'inline';
			}
		}
	}
	
	this.goNextZoom = function() {
		var arrSize = this.arr.length;
		if ((this.current + 1) < (arrSize - 1)) {
			this.clearAllZoom();
			this.current = this.current + 1;
			for (i = this.current;i < (this.current + this.stepSize);i++) {
				$(this.id + '_gallerythumbnailzoom' + i).style.display = 'inline';
			}
		}	
	}
	
	this.goBack = function() {
		if (this.current > 0) {
			this.clearAll();
			this.current = this.current - 1;
			for (i = this.current;i < (this.current + this.stepSize);i++) {
				$(this.id + '_gallerythumbnail' + i).style.display = 'inline';
			}
		}
	}

	this.goBackZoom = function() {
		if (this.current > 0) {
			this.clearAllZoom();
			this.current = this.current - 1;
			for (i = this.current;i < (this.current + this.stepSize);i++) {
				$(this.id + '_gallerythumbnailzoom' + i).style.display = 'inline';
			}
		}
	}

	
	this.clearAll = function() {
		var arrSize = this.arr.length;
		for (i = this.start; i < arrSize; i++) {
			$(this.id + '_gallerythumbnail' + i).style.display = 'none';
		}
	}

	this.clearAllZoom = function() {
		var arrSize = this.arr.length;
		for (i = this.start; i < arrSize; i++) {
			$(this.id + '_gallerythumbnailzoom' + i).style.display = 'none';
		}
	}
	
	this.clearPicture = function() {
		var arrSize = this.arr.length;
		for (i = this.start; i < arrSize; i++) {
			$(this.id + '_gallerypicture' + i).style.display = 'none';
			$(this.id + '_gallerypicturezoomin' + i).style.display = 'none';
		}
	} 
}