function ImageBrowser(imgId, listId, controlName, imageList) {
	this.imageList = imageList;
	this.imageTag = $(imgId);
	this.pagingList = $(listId);
	this.imageNumberControl = controlName;
//	alert(controlName);
//	alert(this.imageTag);
//	alert(this.pagingList);

    //var imageNumberID = controlName +"_lblImageNumber";
    
    //alert(imageNumberID);
    
    this.currentImage = 1;
	//Element.cleanWhitespace(this.pagingList);
	
	var imageNumber = document.getElementById(this.imageNumberControl);
	if (imageNumber != null)
	{
	    imageNumber.innerHTML = this.currentImage;
	}

	$A(this.pagingList.childNodes).each(function(el) {
		if (el.firstChild && el.firstChild.tagName && 'a' == el.firstChild.tagName.toLowerCase()) {
			Event.observe(el.firstChild, 'click', this.selectorClicked.bind(this));
		} else if (el.firstChild.nodeName == '#text' && el.firstChild.nodeValue.match(/^\d+$/)) {
			this.currentImage = parseInt(el.firstChild.nodeValue);
		}
	}.bind(this));
}

ImageBrowser.prototype = {
	selectorClicked: function(evt) {
		var el = Event.element(evt);
		var newImage = (el.textContent || el.innerText);

		if (["Previous","Next"].include(newImage)) {
			newImage = this.currentImage + (newImage == "Next" ? 1 : -1);

			newImage = Math.min(this.imageList.length, Math.max(1,newImage));
		}

		this.imageTag.src = this.imageList[newImage - 1];
		
		this.currentImage = parseInt(newImage);
		//alert(controlName);
        var imageNumber = document.getElementById(this.imageNumberControl);
	    imageNumber.innerHTML = this.currentImage;

		this.updateLinks();
        
		Event.stop(evt);
	},
	updateLinks: function() {
		$A(this.pagingList.childNodes).each(function(el) {
			var elText = (el.textContent || el.innerText).replace(/(^\s*|\s*$)/g, '');

			if (["Previous","Next"].include(elText)) {
				if (("Previous" == elText && this.currentImage > 1) || ("Next" == elText && this.currentImage < this.imageList.length)) {
					if (!el.firstChild.tagName || 'a' != el.firstChild.tagName.toLowerCase()) {
						el.replaceChild(this.createLink(elText), el.firstChild);
					} 
				} else {
					if (el.firstChild.tagName && 'a' == el.firstChild.tagName.toLowerCase()) {
						el.replaceChild(document.createTextNode(elText), el.firstChild);
					}
				}
			}	
			
//			} else {
//				if (this.currentImage == elText) {
//					if (el.firstChild.tagName && 'a' == el.firstChild.tagName.toLowerCase()) {
//						el.replaceChild(document.createTextNode(elText), el.firstChild);
//					}
//				} else {
//					if (!el.firstChild.tagName || 'a' != el.firstChild.tagName.toLowerCase()) {
//						el.replaceChild(this.createLink(elText), el.firstChild);
//					} 
//				}
//			}
		}.bind(this));
	},
	createLink: function(text) {
		var link = document.createElement("a");

		link.href = "#";
		link.appendChild(document.createTextNode(text));
		Event.observe(link, 'click', this.selectorClicked.bind(this));

		return link;
	}					
};


function WeddingsImageBrowser(imgId, listId, imageList) {

	this.imageList = imageList;
	this.imageTag = $(imgId);
	this.pagingList = $(listId);

    this.currentImage = 1;
	Element.cleanWhitespace(this.pagingList);

	$A(this.pagingList.childNodes).each(function(el) {
		if (el.firstChild && el.firstChild.tagName && 'a' == el.firstChild.tagName.toLowerCase()) {
			Event.observe(el.firstChild, 'click', this.selectorClicked.bind(this));
		} else if (el.firstChild.nodeName == '#text' && el.firstChild.nodeValue.match(/^\d+$/)) {
			this.currentImage = parseInt(el.firstChild.nodeValue);
		}
	}.bind(this));
}

WeddingsImageBrowser.prototype = {
	selectorClicked: function(evt) {
		var el = Event.element(evt);
		var newImage = (el.textContent || el.innerText);

		if (["Previous","Next"].include(newImage)) {
			newImage = this.currentImage + (newImage == "Next" ? 1 : -1);

			newImage = Math.min(this.imageList.length, Math.max(1,newImage));
		}

		this.imageTag.src = this.imageList[newImage - 1];

		this.currentImage = parseInt(newImage);




		this.updateLinks();

		Event.stop(evt);
	},
	updateLinks: function() {
		$A(this.pagingList.childNodes).each(function(el) {
			var elText = (el.textContent || el.innerText).replace(/(^\s*|\s*$)/g, '');

			if (["Previous","Next"].include(elText)) {
				if (("Previous" == elText && this.currentImage > 1) || ("Next" == elText && this.currentImage < this.imageList.length)) {
					if (!el.firstChild.tagName || 'a' != el.firstChild.tagName.toLowerCase()) {
						el.replaceChild(this.createLink(elText), el.firstChild);
					} 
				} else {
					if (el.firstChild.tagName && 'a' == el.firstChild.tagName.toLowerCase()) {
						el.replaceChild(document.createTextNode(elText), el.firstChild);
					}
				}
			} else {
				if (this.currentImage == elText) {
					if (el.firstChild.tagName && 'a' == el.firstChild.tagName.toLowerCase()) {
						el.replaceChild(document.createTextNode(elText), el.firstChild);
					}
				} else {
					if (!el.firstChild.tagName || 'a' != el.firstChild.tagName.toLowerCase()) {
						el.replaceChild(this.createLink(elText), el.firstChild);
					} 
				}
			}


		}.bind(this));
	},
	createLink: function(text) {
		var link = document.createElement("a");

		link.href = "#";
		link.appendChild(document.createTextNode(text));
		Event.observe(link, 'click', this.selectorClicked.bind(this));

		return link;
	}					
};

function photoGallery(propno)
{    
    window.open("/hotels/Photo-Gallery/Popup.aspx?PropertyNumber="+ propno+"","PhotoGallery","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=400, height=490");
}
//back up
//function ImageBrowser(imgId, listId, imageList) {
//	this.imageList = imageList;
//	this.imageTag = $(imgId);
//	this.pagingList = $(listId);
//	
//	alert(this.imageList);
//	alert(this.imageTag);
//	alert(this.pagingList);
//    this.currentImage = 1;
//	Element.cleanWhitespace(this.pagingList);
//	
//	ctl00_ctl00_Content_ContentMain_PartialPagesHotelInfoControl_WebImagesControl_lblImageNumber.innerText = this.currentImage;

//	$A(this.pagingList.childNodes).each(function(el) {
//		if (el.firstChild && el.firstChild.tagName && 'a' == el.firstChild.tagName.toLowerCase()) {
//			Event.observe(el.firstChild, 'click', this.selectorClicked.bind(this));
//		} else if (el.firstChild.nodeName == '#text' && el.firstChild.nodeValue.match(/^\d+$/)) {
//			this.currentImage = parseInt(el.firstChild.nodeValue);
//		}
//	}.bind(this));
//}

//ImageBrowser.prototype = {
//	selectorClicked: function(evt) {
//		var el = Event.element(evt);
//		var newImage = (el.textContent || el.innerText);

//		if (["Previous","Next"].include(newImage)) {
//			newImage = this.currentImage + (newImage == "Next" ? 1 : -1);

//			newImage = Math.min(this.imageList.length, Math.max(1,newImage));
//		}

//		this.imageTag.src = this.imageList[newImage - 1];
//		this.currentImage = parseInt(newImage);
//        ctl00_ctl00_Content_ContentMain_PartialPagesHotelInfoControl_WebImagesControl_lblImageNumber.innerText = this.currentImage;
//		this.updateLinks();
//        
//		Event.stop(evt);
//	},
//	updateLinks: function() {
//		$A(this.pagingList.childNodes).each(function(el) {
//			var elText = (el.textContent || el.innerText).replace(/(^\s*|\s*$)/g, '');

//			if (["Previous","Next"].include(elText)) {
//				if (("Previous" == elText && this.currentImage > 1) || ("Next" == elText && this.currentImage < this.imageList.length)) {
//					if (!el.firstChild.tagName || 'a' != el.firstChild.tagName.toLowerCase()) {
//						el.replaceChild(this.createLink(elText), el.firstChild);
//					} 
//				} else {
//					if (el.firstChild.tagName && 'a' == el.firstChild.tagName.toLowerCase()) {
//						el.replaceChild(document.createTextNode(elText), el.firstChild);
//					}
//				}
//			} else {
//				if (this.currentImage == elText) {
//					if (el.firstChild.tagName && 'a' == el.firstChild.tagName.toLowerCase()) {
//						el.replaceChild(document.createTextNode(elText), el.firstChild);
//					}
//				} else {
//					if (!el.firstChild.tagName || 'a' != el.firstChild.tagName.toLowerCase()) {
//						el.replaceChild(this.createLink(elText), el.firstChild);
//					} 
//				}
//			}
//		}.bind(this));
//	},
//	createLink: function(text) {
//		var link = document.createElement("a");

//		link.href = "#";
//		link.appendChild(document.createTextNode(text));
//		Event.observe(link, 'click', this.selectorClicked.bind(this));

//		return link;
//	}					
//};