var tabs_manager = Class.create({
		initialize: function(elem){
			this.elem = $(elem);
			this.containers = this.elem.select('.tab_content');
			this.triggers = this.elem.select('a.tabs_trigger');
			this.setListeners();
		},
		setListeners: function(){
			this.triggers.each(function(ele){
				ele.observe('click', this.handleClick.bind(this));
			}.bind(this));
		},
		handleClick: function(e){
			var tmp = Event.element(e);
			Event.stop(e);
			this.closeContainers();
			this.removeCurrent();
			tmp.up('li').addClassName('current');
			
			$(tmp.readAttribute('rel')).show();
			
				if (tmp.readAttribute('rel') == 'map_tab') {
					$(tmp.readAttribute('rel')).addClassName('reposition');
					$('tabs_content').addClassName('mapheight');
				}
				else {
					$('tabs_content').removeClassName('mapheight');
				}
			
			
			
			
			
		},
		removeCurrent: function(){
			this.elem.select('li.current')[0].removeClassName('current');
		},
		closeContainers: function(){
			this.containers.each(function(ele){
				ele.hide();
			});
		}
	});
	
	
	
	
	
	
	
	function popUp(URL) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=200,left = 440,top = 412');");
	}
	function expandBaths(){
		var expandDiv = $('expandBathBlock');
		var expandTrigger = $('bathDetailTrigger');
		if(expandDiv.visible()){
			new Effect.BlindUp(expandDiv,{duration:0.5,transition:Effect.Transitions.sinoidal});
			expandTrigger.innerHTML = '<img src="/images/ipwExpand.gif" alt="Expand" title="Expand" /> Expand';
		}else{
			new Effect.BlindDown(expandDiv,{duration:0.5,transition:Effect.Transitions.sinoidal});
			expandTrigger.innerHTML = '<img src="/images/ipwCollapse.gif" alt="Collapse" title="Collapse" /> Collapse';
		}
	}
	function showThumbElement(){
		var scrollingThumbs = $('galleryThumbs');
		var fullThumbs = $('expandPhotos');
		var triggerCont = $('photosTrigger');
		Effect.toggle(fullThumbs, 'appear',{duration:.3});
		Effect.toggle(scrollingThumbs, 'appear',{duration:.3, afterFinish:
			function(){
				if(fullThumbs.visible()){
					triggerCont.innerHTML = '<img src="/images/collapse_thumb.gif" alt="Collapse Thumbs" title="Collapse Thumbs" /> Collapse Thumbnails';
				}else{
					triggerCont.innerHTML = '<img src="/images/expan_thumbs.gif" alt="Expand Thumbs" title="Expand Thumbs" /> Expand Thumbnails';
				}
			}
		});
	}
	Event.observe(window, 'load', function(){
		if($('bathDetailTrigger')){$('bathDetailTrigger').observe('click', expandBaths.bindAsEventListener(this));}
		Object.extend(thumbImageSettings, {maxwidth:'450', maxheight:'300', matte:'!fff'});
		Object.extend(baseImageSettings, {maxwidth:'450', maxheight:'300', matte:'!fff'});
		lightBox = new Lightbox();
		lightBox.setMainImage('PhotoViewerMainImage');
		lightBox.setScrollDownButton('scrollLeftButton');
		lightBox.setScrollUpButton('scrollRightButton');
		lightBox.setNextButton('prevImgButton');
		lightBox.setPrevButton('nextImgButton');
		lightBox.setScrollPanel('belt');
		lightBox.setScrollUpSrc('/images/btn_gallery_next.gif','/images/btn_gallery_next_active.gif');
		lightBox.setScrollDownSrc('/images/btn_gallery_back.gif','/images/btn_gallery_back_active.gif');
		lightBox.setScrollDir(1);
		lightBox.setscrollInc(198);
		lightBox.setHasExpandJS();
		if($('photosTrigger')){$('photosTrigger').observe('click', showThumbElement.bindAsEventListener(this,'showThumbElement'));}
	});