function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function virtualTour(){
	window.open('/assets/video/halfstreet.html','virtualTour','width=864,height=528');
}

function openPDF(filePath){
	window.open(filePath, filePath);
}


MM_preloadImages(
	'/images/live_on.jpg',
	'/images/work_on.jpg',
	'/images/shop_on.jpg',
	'/images/play_on.jpg',
	'/images/eat_on.jpg',
	'/images/stay_on.jpg',
	'/images/halfstreet_on.jpg',
	'/images/contact_on.jpg',
	'/images/gallery_on.jpg',
	'/images/tour_on.jpg',
	'/images/map_on.jpg',
	'/images/features_on.jpg',
	'/images/amenities_on.jpg',
	'/images/renderings_on.jpg',
	'/images/webcam_on.jpg',
	'/images/about_monument_on.jpg',
	'/images/btn_news_over.gif',
	'/images/btn-join-our-list-over.jpg');
	
	
	var Gallery = Class.create();

	Gallery.prototype = {
	  initialize: function(thumbContainer, ele) {

			var anchors = thumbContainer.getElementsBySelector('a');
			this.img_array = [];
			this.preloader_array = [];
			this.img_id = 0;
			this.ele = ele;
			this.thumb_container = thumbContainer;
			this.preloaded = [];
			this.caption_array = [];
			this._adding_events($(this.thumb_container));

			for (var i = 0; i < anchors.length; i++){
				this.img_array.push(anchors[i].href);
				this.preloader_array.push(anchors[i].href);
				this.caption_array.push(anchors[i].title);
			}

			this.imgPreloader = new ImagePreloader(this.preloader_array);

	 	},

		_adding_events: function(ele){
			var scope = this;		
			ele.immediateDescendants().each(function(s,index){
				Event.observe(s,'click',function(e){
					scope.show(index);
					Event.stop(e);
				});
				Event.observe(s,'mouseover',function(e){
					scope.imgPreloader.unshift(s);
					Event.stop(e);
				});

			});

		},
		
		show: function(int){
			this.img_id = parseInt(int);
			$(this.ele).src = this.img_array[this.img_id];
		}

	};

	var ImagePreloader = Class.create();
	ImagePreloader.prototype = {
	  initialize: function(urlArray) {
			this._loadedImages = {};
			this._queue = urlArray;
			this.load();
			this.oncomplete = function(){ return; };
	 	},

		unshift: function(url){
			return this._queue.unshift(url);
		},

		shift: function(url){
			return this._queue.shift(url);
		},

		load: function(){
			if (this._isLoading) return;
			this._isLoading = true;
			this._loadNext();
		},

		_loadNext: function(){
			var nextURL = this.shift().toString();
			var img_obj = new Image();
			img_obj.src = nextURL;
			var scope = this;

			img_obj.onload = function(){
				scope._loadedImages[nextURL] = this;
				if(scope._queue.length == 0){
					scope._isLoading = false;
					scope.oncomplete();
				}else{
					scope._loadNext();
				}
			}
		}

	};
	
	
	


	
	
	
