function showJustContacts() {
	$("#contact-listing").toggle();
}
function showContacts() {
	$("#contact-listing").toggle();
	if($(".dd-contact-form").css("display")=="block"){ 
		$(".dd-contact-form").toggle();
	}
}
function showContactForm() {
	$(".dd-contact-form").toggle();
	$("#contact-listing").toggle();
}
/* SLIDER
*******************************/
var Slider = function(id, option) {
  this.create(id, option);
}
var SliderArray = new Array();

$.extend(Slider.prototype, {
	_id : '',
	_self : 0,
	_elem : '',
	/* Editable Options */
	_autoSlide : 2000,
	_moveCount : 1,
	_showArrows : true,
	_showNumbers : true,
	_leftDirection : true,
	_continuous : false,
	_effect : 'none', /*none,fade,slide,wipe*/
	_wipeImage : '',
	/* End Editable Options */
	_leftArrow : '',
	_rightArrow : '',
	_numbers : '',
	_numberList : '',
	_slides :'',
	_slidewidth : '',
	_slidecontainer : '',
	_current : 0,
	_timer : 0,
	
	create: function(id, option){
		this._id = id;
		this._self = SliderArray.length;
		this._elem = $(id)[0];
		this._slides = $('ul.slides>li',this._elem);
		this._slidecontainer = $('ul.slides',this._elem).first();
		this._slidewidth = $(this._slides).css('width').replace('px','');
		if(typeof(option)!="undefined"){
			if(typeof(option.moveCount)!="undefined"){this._moveCount = option.moveCount;}
			if(typeof(option.showArrows)!="undefined"){this._showArrows = option.showArrows;}
			if(typeof(option.showNumbers)!="undefined"){this._showNumbers = option.showNumbers;}
			if(typeof(option.autoSlide)!="undefined"){this._autoSlide = option.autoSlide;}
			if(typeof(option.effect)!="undefined"){this._effect = option.effect;}
			if(typeof(option.leftDirection)!="undefined"){this._leftDirection = option.leftDirection;}
			if(typeof(option.wipeImage)!="undefined"){this._wipeImage = option.wipeImage;}
			if(typeof(option.continuous)!="undefined"){this._continuous = option.continuous;}
		}
		if(this._showArrows){
			this._leftArrow = $('<div class="arrow-left">&lt;</div>').bind('click', {direction:(this._leftDirection?1:-1), obj:this}, this.moveSlides);
			this._rightArrow = $('<div class="arrow-right">&gt;</div>').bind('click', {direction:(!this._leftDirection?1:-1), obj:this}, this.moveSlides);
			$(this._elem).append(this._leftArrow);
			$(this._elem).append(this._rightArrow);
		}
		if(this._autoSlide != 0){
			this._timer = setTimeout('SliderArray['+this._self+'].autoMoveSlide('+this._self+');',this._autoSlide);
		}
		if(this._showNumbers){
			this._numbers = new Array();
			this._numberList = $(document.createElement('ul')).addClass('numbers');
			for(x=0;x<Math.ceil(this._slides.length / this._moveCount);x++){
				this._numbers[x] = $(document.createElement('li')).html(x+1).bind('click', {slide:x, obj:this}, this.selectSlide);
				this._numberList.append(this._numbers[x]);
			}
			$(this._elem).append(this._numberList);
		}
		
		if($('.grow', this._elem).length > 0){
			for(x=0;x<this._slides.length;x++){
				test1 = $('.grow', $(this._slides[x]))
				if(test1.length > 0){
					this._slides[x].grow = test1;
					for(y=0;y<this._slides[x].grow.length;y++){
						this._slides[x].grow[y].baseheight = $(this._slides[x].grow[y]).height();
						this._slides[x].grow[y].basewidth = $(this._slides[x].grow[y]).width();
						$(this._slides[x].grow[y]).height(this._slides[x].grow[y].baseheight * 0.8 + 'px');
						$(this._slides[x].grow[y]).width(this._slides[x].grow[y].basewidth * 0.8 + 'px');
						if(x==0){
							$(this._slides[x].grow[y]).animate({'width':this._slides[x].grow[y].basewidth,'height':this._slides[x].grow[y].baseheight},{'duration':1000,'easing':'linear','queue':false});
						}
					}
				}
			}
		}
		
		if($('.zoom', this._elem).length > 0){
			basesize = 0.85;
			for(x=0;x<this._slides.length;x++){
				test1 = $('.zoom img', $(this._slides[x]))
				if(test1.length > 0){
					this._slides[x].zoom = test1;
					$(this._slides[x]).css('position','absolute');
					for(y=0;y<this._slides[x].zoom.length;y++){
						this._slides[x].zoom[y].baseheight = $(this._slides[x].zoom[y]).height();
						this._slides[x].zoom[y].basewidth = $(this._slides[x].zoom[y]).width();
						$(this._slides[x].zoom[y]).height((this._slides[x].zoom[y].baseheight * basesize) + 'px');
						$(this._slides[x].zoom[y]).width((this._slides[x].zoom[y].basewidth * basesize) + 'px');
						off = $(this._slides[x].zoom[y]).position();
						if (navigator.appName == 'Microsoft Internet Explorer')
						{
							$(this._slides[x].zoom[y]).parent().parent().append($('<img style="visibility:hidden; width:'+this._slides[x].zoom[y].basewidth+'px; height:'+this._slides[x].zoom[y].baseheight+'px;" />'));
						}else{
							$(this._slides[x].zoom[y]).parent().parent().append($('<div style="display:inline-block; vertical-align:middle; width:'+this._slides[x].zoom[y].basewidth+'px; height:'+this._slides[x].zoom[y].baseheight+'px;" />'));							
						}
						
						this._slides[x].zoom[y].basesize = basesize;
						$(this._slides[x].zoom[y]).css(
							{
								'padding-top':(this._slides[x].zoom[y].baseheight * (1-basesize)/2) + 'px',
								'padding-bottom':(this._slides[x].zoom[y].baseheight * (1-basesize)/2) + 'px',
								'padding-left':(this._slides[x].zoom[y].basewidth * (1-basesize)/2) + 'px',
								'padding-right':(this._slides[x].zoom[y].basewidth * (1-basesize)/2) + 'px',
								'top':off.top,
								'left':off.left,
								'position':'absolute'
							});
						$(this._slides[x].zoom[y]).bind('mouseover', function(){
							$(this).animate(
								{
									'width':this.basewidth + 'px',
									'height':this.baseheight + 'px',
									'padding-top':0,
									'padding-bottom':0,
									'padding-left':0,
									'padding-right':0
								},
								{
									'duration':200,
									'easing':'linear'
								}
							);
						});
						$(this._slides[x].zoom[y]).bind('mouseout', function(){
							$(this).animate(
								{
									'width':this.basewidth*this.basesize + 'px',
									'height':this.baseheight*this.basesize + 'px',
									'padding-top':this.baseheight*(1-basesize)/2 + 'px',
									'padding-bottom':this.baseheight*(1-basesize)/2 + 'px',
									'padding-left':this.basewidth*(1-basesize)/2 + 'px',
									'padding-right':this.basewidth*(1-basesize)/2 + 'px'
								},
								{
									'duration':200,
									'easing':'linear'
								}
							);
						});
					}
				}
			}
		}
		if(this._effect == 'wipe'){
			co = this._moveCount;
			$(this._slides).css({'position':'absolute','top':0,
				'display':function(index){
					return(Math.floor(index / co) == 0? 'block':'none');
				},
				'left':0});
			this._wiperWidth = $(this._elem).css('width').replace('px','')*2;
			this._wiper = $(
			'<div style="'+
				'position:absolute; top:0; left:'+$(this._elem).css('width').replace('px','')*-2+'px;'+
				'width:'+this._wiperWidth+'px; '+
				'height:'+$(this._elem).css('height')+';'+
				'background:url('+this._wipeImage+');'+
				'">'+
			'</div>');
			$(this._elem).append(this._wiper);
		}else if(this._effect != 'fade'){
			$(this._slides).css({'position':'absolute','top':0,'left':function(index){jQuery.data(this,'left', $(this).css('width').replace('px','')*1); return index * $(this).css('width').replace('px',''); }});
		}else{
			co = this._moveCount;
			$(this._slides).css({'position':'absolute','top':0,
				'opacity':function(index){
					return(Math.floor(index / co) == 0? 1:0);
				},
				'display':function(index){
					return(Math.floor(index / co) == 0? 'block':'none');
				},
				'left':0});
		}
		if($('.navbar', this._elem).length > 0){
			nav = $('.navbar a', this._elem);
			for(x=0;x<nav.length;x++){
				$(nav[x]).bind('mouseover', {slide:x, obj:this}, this.pause).bind('mouseout', {slide:x, obj:this}, this.unpause);
			}
		}
		
		if($('.pause', this._elem).length > 0){
			$('.pause', this._elem).bind('mouseover', {slide:-1, obj:this}, this.pause).bind('mouseout', {slide:-1, obj:this}, this.unpause);
		}
		
	},
	moveSlides: function(eve){
		if(eve.data.obj._autoSlide != 0){clearTimeout(eve.data.obj._timer);}
		if($(':animated',eve.data.obj._elem).length == 0){
			if(eve.data.direction != 0){
				if(eve.data.obj._effect == 'none'){
					$(eve.data.obj._slides).css('left', 
						function(index){
							left = $(this).css('left').replace('px','')*1;
							movespace = eve.data.direction*eve.data.obj._slidewidth*eve.data.obj._moveCount;
							if(left + movespace < 0){
								move = left + movespace + ((eve.data.obj._slides.length % eve.data.obj._moveCount) + eve.data.obj._slides.length) * eve.data.obj._slidewidth;
							}else if(left + movespace >= ((eve.data.obj._slides.length % eve.data.obj._moveCount) + eve.data.obj._slides.length) * eve.data.obj._slidewidth){
								move = left + movespace - ((eve.data.obj._slides.length % eve.data.obj._moveCount) + eve.data.obj._slides.length) * eve.data.obj._slidewidth;
							}else{
								move = left + movespace;
							}
							return move;
						}
					);
				}else if(eve.data.obj._effect == 'slide'){
					
					for(x = 0; x<eve.data.obj._slides.length; x++){
						$(eve.data.obj._slides).css('left',
							function(index, value){
								left = $(this).css('left').replace('px','')*1;
								newleft = left;
								if(!(left >=0 && left < eve.data.obj._moveCount*eve.data.obj._slidewidth)){
									if(eve.data.direction > 0){
										if((left>=0)){
											newleft = (left - ((eve.data.obj._slides.length % eve.data.obj._moveCount != 0 && !eve.data.obj._continuous?(eve.data.obj._moveCount - (eve.data.obj._slides.length % eve.data.obj._moveCount)):0) + eve.data.obj._slides.length) * eve.data.obj._slidewidth);
									
									
										}
									}else if(eve.data.direction < 0){
										if((left<0)){
											newleft = (left + ((eve.data.obj._slides.length % eve.data.obj._moveCount != 0 && !eve.data.obj._continuous?(eve.data.obj._moveCount - (eve.data.obj._slides.length % eve.data.obj._moveCount)):0) + eve.data.obj._slides.length) * eve.data.obj._slidewidth);
										}
									}
								}
								return newleft;
							}					
						);
						movespace = eve.data.direction*eve.data.obj._slidewidth*eve.data.obj._moveCount;
						$(eve.data.obj._slides[x]).animate({'left':'+='+movespace},{'duration':'slow','queue':false});
					}
				}else if(eve.data.obj._effect == 'fade'){
					for(x=0;x<eve.data.obj._slides.length;x++){
						nextslide = eve.data.obj._current - eve.data.direction;
						if(nextslide < 0){
							nextslide += Math.ceil(eve.data.obj._slides.length / eve.data.obj._moveCount);
						}else if(nextslide >= Math.ceil(eve.data.obj._slides.length / eve.data.obj._moveCount)){
							nextslide -= Math.ceil(eve.data.obj._slides.length / eve.data.obj._moveCount);
						}
						if(Math.floor(x / eve.data.obj._moveCount) == nextslide){
							$(eve.data.obj._slides[x]).css('display','block');
							$(eve.data.obj._slides[x]).animate({'opacity':'1'},{'duration':'slow','queue':false});
						}else if(Math.floor(x / eve.data.obj._moveCount) == eve.data.obj._current){
							$(eve.data.obj._slides[x]).animate({'opacity':'0'},{'duration':'slow','queue':false,'complete':function(){$(this).css('display','none');}});
						}
					}
				}else if(eve.data.obj._effect == 'wipe'){
					eve.data.obj._wiper.eve = eve; 
					nextslide = eve.data.obj._current - eve.data.direction;
					if(nextslide < 0){
						nextslide += Math.ceil(eve.data.obj._slides.length / eve.data.obj._moveCount);
					}else if(nextslide >= Math.ceil(eve.data.obj._slides.length / eve.data.obj._moveCount)){
						nextslide -= Math.ceil(eve.data.obj._slides.length / eve.data.obj._moveCount);
					}
					
					ttimeout = "$(SliderArray['"+eve.data.obj._self+"']._slides["+eve.data.obj._current+"]).css('display','none'); "+
					"$(SliderArray['"+eve.data.obj._self+"']._slides["+nextslide+"]).css('display','block'); "
					
					
					if(eve.data.obj._slides[nextslide].grow){
						for(y=0; y < eve.data.obj._slides[nextslide].grow.length;y++){
							$(eve.data.obj._slides[nextslide].grow[y]).animate({'width': eve.data.obj._slides[nextslide].grow[y].basewidth,'height': eve.data.obj._slides[nextslide].grow[y].baseheight},3000, 'linear');
							
						}
					}
					
					if(eve.data.obj._slides[eve.data.obj._current].grow){
						for(y=0; y<eve.data.obj._slides[eve.data.obj._current].grow.length; y++){
							ttimeout +=	"$(SliderArray['"+eve.data.obj._self+"']._slides["+eve.data.obj._current+"].grow["+y+"]).height('" + eve.data.obj._slides[eve.data.obj._current].grow[y].baseheight * 0.8 + "px');";
							ttimeout +=	"$(SliderArray['"+eve.data.obj._self+"']._slides["+eve.data.obj._current+"].grow["+y+"]).width('" + eve.data.obj._slides[eve.data.obj._current].grow[y].basewidth * 0.8 + "px');";
						}
						
						//ttimeout +=	"$(SliderArray['"+eve.data.obj._self+"']._slides["+eve.data.obj._current+"].grow[y]).height(SliderArray['"+eve.data.obj._self+"']._slides["+eve.data.obj._current+"].grow[y].baseheight * 0.8 + 'px');$(SliderArray['"+eve.data.obj._self+"']._slides["+eve.data.obj._current+"].grow[y]).height(SliderArray['"+eve.data.obj._self+"']._slides["+eve.data.obj._current+"].grow[y].basewidth * 0.8 + 'px'); "	
					}
					
					setTimeout(ttimeout,2000);
					
					$(eve.data.obj._wiper).animate({'left':(eve.data.obj._wiperWidth)+'px'},{'duration':5000,'easing':'linear','queue':false,'complete':function(){$(eve.data.obj._wiper).css('left',eve.data.obj._wiperWidth*-1);}});
				}
				eve.data.obj._current -= eve.data.direction;
				if(eve.data.obj._current < 0){
					eve.data.obj._current += Math.ceil(eve.data.obj._slides.length / eve.data.obj._moveCount);
				}else if(eve.data.obj._current >= Math.ceil(eve.data.obj._slides.length / eve.data.obj._moveCount)){
					eve.data.obj._current -= Math.ceil(eve.data.obj._slides.length / eve.data.obj._moveCount);
				}
				
			}
		}
		if(eve.data.obj._autoSlide != 0){eve.data.obj._timer = setTimeout('SliderArray['+eve.data.obj._self+'].autoMoveSlide('+eve.data.obj._self+');',eve.data.obj._autoSlide);}
	},
	selectSlide: function(eve){
		if(eve.data.slide != eve.data.obj._current){
			eve.data.direction = (eve.data.slide - eve.data.obj._current) *-1;
			eve.data.obj.moveSlides(eve);
		}
	},
	autoMoveSlide: function(id){
		eve = {data:{}};
		eve.data.obj = SliderArray[id];
		eve.data.direction = (!this._leftDirection?1:-1);
		SliderArray[id].moveSlides(eve);
	},
	pause: function(eve){
		clearTimeout(eve.data.obj._timer);
		tmp = eve.data.obj._autoSlide;
		eve.data.obj._autoSlide = 0;
		if(eve.data.slide!=-1){
			eve.data.obj.selectSlide(eve);
		}
		eve.data.obj._autoSlide = tmp;
	},
	unpause: function(eve){
		tmp = eve.data.obj._autoSlide;
		eve.data.obj._autoSlide = 0;
		if(eve.data.slide!=-1){
			eve.data.obj.selectSlide(eve);
		}
		eve.data.obj._autoSlide = tmp;		
		eve.data.obj._timer = setTimeout('SliderArray['+eve.data.obj._self+'].autoMoveSlide('+eve.data.obj._self+');',eve.data.obj._autoSlide);
	}
});




/* SOCIAL MEDIA ROOM TABS
*******************************/
var SocialMediaRoom = function(name_var) {
  this.create(name_var);
}
var SocialMediaRoomArray = new Array();

$.extend(SocialMediaRoom.prototype, {
	_id : '',
	_elem : '',
	_titles : new Array(),
	_contents : new Array(),
	create: function(id){
		this._id = id;
		this._elem = $(id)[0];
		this._titles = $('dt',this._elem);
		this._currentTab = -1;
		this._contents = $('dd',this._elem);
		step = 0;
		if(window.location.href.indexOf('#')!= -1){
			hash = window.location.href.split('#');
			hash = hash[1];
			window.scrollTo(0,0);
		}else{
			hash = '-1';	
		}
		for(x = 0; x < this._titles.length; x++){
			$(this._titles[x]).css({'top':x*36 +step+ 'px'});
			this._titles[x].classholder = this._titles[x].className;
			if(this._titles[x].id==hash){
				this._titles[x].id='dt-current';
			}else{
				$(this._titles[x]).removeAttr('id');	
			}
			if(this._titles[x].id=='dt-current'){
				this._currentTab = x;
				step = 12;
			}
			$(this._titles[x]).accessTabId = x;
			$(this._titles[x])._id = this._id;
			$(this._titles[x]).bind('click',{tabid:x, obj:this},this.switchTabTo);
		}
		if(this._currentTab != -1){
			this._contents[this._currentTab].id = 'dd-current';
			this._titles[this._currentTab].className += ' '+this._titles[this._currentTab].className+'-current'; 
			$(this._contents[this._currentTab]).addClass('dd-current');
		}else{
			for(x = 0; x < this._titles.length; x++){
				$(this._titles[x]).css({'top':x*36 +step+ 'px'});
				if(x==0){
					step = 12;
				}
			}		
			
			this._titles[0].className = this._titles[0].classholder + ' ' + this._titles[0].classholder + '-current';
			$(this._contents[0]).addClass('dd-current');
			this._currentTab = 0;	
		}
		return this;
	},
	clickSwitch:function(tab){
		eve = {data:{obj:this, tabid:tab}};
		this.switchTabTo(eve);
		window.scrollTo(0,0);
		//return false;
	},
	switchTabTo: function(eve){
		if(eve.data.obj._currentTab != eve.data.tabid){
			$(eve.data.obj._titles[eve.data.obj._currentTab]).removeClass(eve.data.obj._titles[eve.data.obj._currentTab].classholder + '-current');
			$(eve.data.obj._contents[eve.data.obj._currentTab]).removeClass('dd-current');
			step = 0;
			for(x = 0; x < eve.data.obj._titles.length; x++){
				$(eve.data.obj._titles[x]).css({'top':x*36 +step+ 'px'});
				if(x==eve.data.tabid){
					step = 12;
				}
			}		
			
			eve.data.obj._titles[eve.data.tabid].className = eve.data.obj._titles[eve.data.tabid].classholder + ' ' + eve.data.obj._titles[eve.data.tabid].classholder + '-current';
			$(eve.data.obj._contents[eve.data.tabid]).addClass('dd-current');
			eve.data.obj._currentTab = eve.data.tabid;
		}
	}
	
});



/* TAB SWAP
*******************************/
var TabSwap = function(id) {
  this.create(id);
}
var TabSwapArray = new Array();

$.extend(TabSwap.prototype, {
	_id : '',
	_self : 0,
	_links : 0,
	_elem : '',
	_tabs : '',
	_contenttabs : '',
	_current : '',
	create : function(id){
		this._id = id;
		this._elem = $(id);
		this._tabs = $('dt',this._elem);
		currentset = false;
		if(window.location.href.indexOf('#')!= -1){
			hash = window.location.href.split('#');
			hash = hash[1];
		}else{
			hash = '';	
		}
		for(x=0;x<this._tabs.length;x++){
			$(this._tabs[x]).bind('click', {obj:this, tab:x}, this.switchTab);
			tmplinks = $('a[href*="#' + this._tabs[x].id + '"]');
			if(tmplinks.length>0){
				tmplinks.attr('href',"javascript:void(0);");
				tmplinks.bind('click', {obj:this, tab:x}, this.switchTab);
			}
			if(hash!='' && hash == this._tabs[x].id){
				this._tabs[x].id='current';
				$(this._tabs[x]).addClass('current-' + this._tabs[x].className);
				currentset = true;
				this._current = x;
			}
		}
		
		if(!currentset){
			this._tabs[0].id='current';
			this._current = 0;
			$(this._tabs[0]).addClass('current-' + this._tabs[0].className);
		}
		
		this._contenttabs = $('dd',this._elem);
		this._contenttabs.css('display', 'none');
		$(this._contenttabs[this._current]).css('display', 'block');
		
	},
	switchTab:function(eve){
		if(eve.data.obj._contenttabs[eve.data.tab] && eve.data.tab !=eve.data.obj._current){
				eve.data.obj._tabs[eve.data.obj._current].id = '';
				eve.data.obj._tabs[eve.data.tab].id = 'current';
				$(eve.data.obj._tabs[eve.data.obj._current]).removeClass('current-' + eve.data.obj._tabs[eve.data.obj._current].className);
				$(eve.data.obj._tabs[eve.data.tab]).addClass('current-' + eve.data.obj._tabs[eve.data.tab].className);
				$(eve.data.obj._contenttabs[eve.data.obj._current]).css('display','none');
				$(eve.data.obj._contenttabs[eve.data.tab]).css('display','block');
				eve.data.obj._current = eve.data.tab;
				if(eve.data.obj._id != '.enviro-tabs') {
					$(window).scrollTop(0);
				}
		}
	}
	
});

/* GREEN TAB SWAP
*******************************/
var GreenTabSwap = function(id) {
  this.create(id);
}
var GreenTabSwapArray = new Array();

$.extend(GreenTabSwap.prototype, {
	_id : '',
	_self : 0,
	_links : 0,
	_elem : '',
	_tabs : '',
	_contenttabs : '',
	_current : '',
	create : function(id){
		this._id = id;
		this._elem = $(id);
		this._tabs = $('dt',this._elem);
		currentset = false;
		if(window.location.href.indexOf('#')!= -1){
			hash = window.location.href.split('#');
			hash = hash[1];
		}else{
			hash = '';	
		}
		for(x=0;x<this._tabs.length;x++){
			$(this._tabs[x]).bind('click', {obj:this, tab:x}, this.switchTab);
			tmplinks = $('a[href*="#' + this._tabs[x].id + '"]');
			if(tmplinks.length>0){
				tmplinks.attr('href',"javascript:void(0);");
				tmplinks.bind('click', {obj:this, tab:x}, this.switchTab);
			}
			$(this._tabs[x]).append(' <span class="open-lodging"> + </span><span class="close-lodging"> - </span>');
			if(hash!='' && hash == this._tabs[x].id){
				this._tabs[x].id='current';
				$(this._tabs[x]).addClass('current-' + this._tabs[x].className);
				currentset = true;
				this._current = x;
			}
		}
		
		if(!currentset){
			this._tabs[0].id='current';
			this._current = 0;
			$(this._tabs[0]).addClass('current-' + this._tabs[0].className);
		}
		
		this._contenttabs = $('dd',this._elem);
		this._contenttabs.css('display', 'none');
		$(this._contenttabs[this._current]).css('display', 'block');
		
	},
	switchTab:function(eve){
		if(eve.data.obj._contenttabs[eve.data.tab] && eve.data.tab !=eve.data.obj._current){
				eve.data.obj._tabs[eve.data.tab].id = 'current';
				$(eve.data.obj._tabs[eve.data.tab]).addClass('current-' + eve.data.obj._tabs[eve.data.tab].className);
				$(eve.data.obj._contenttabs[eve.data.tab]).css('display','block');
				if(eve.data.obj._current != -1) {
					eve.data.obj._tabs[eve.data.obj._current].id = '';
					$(eve.data.obj._tabs[eve.data.obj._current]).removeClass('current-' + eve.data.obj._tabs[eve.data.obj._current].className);
					$(eve.data.obj._contenttabs[eve.data.obj._current]).css('display','none');
				}
				eve.data.obj._current = eve.data.tab;
		}
		else if(eve.data.obj._contenttabs[eve.data.tab]) {
			eve.data.obj._tabs[eve.data.obj._current].id = '';
			$(eve.data.obj._tabs[eve.data.obj._current]).removeClass('current-' + eve.data.obj._tabs[eve.data.obj._current].className);
			$(eve.data.obj._contenttabs[eve.data.obj._current]).css('display','none');
			eve.data.obj._current = -1;
		}
	}
	
});


/* RESIZE
*******************************/

window.resizeIframe = function(id, size){
	$('#'+id).height(size);
}


/* OVERLAY
*******************************/


var Overlay = function(elem) {
  this.create(elem);
}
var OverlayArray = new Array();

$.extend(Overlay.prototype, {
	_id : '',
	_self : 0,
	_links : 0,
	_elem : '',
	_overlay : '',
	_controller : '',
	_closebtn : '',
	/* Editable Options */
	create : function(elem){
		this._id = elem.id;
		this._elem = elem;
		 
		if($('#jsOverlay').length == 0){
			this._overlay = document.createElement('div');
			this._overlay.id = 'jsOverlay';
			$(this._overlay).css({height:'100%', width:'100%', background:'#000','-ms-filter':"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)", 'filter':'alpha(opacity=25)', opacity:.25, position:'absolute', 'left':0, 'top':0, display:'none', zoom:1, zIndex:100});
			$(this._overlay).bind('click', {obj:this}, this.hide);
			$('body').append(this._overlay);
		}else{
			this._overlay = $('#jsOverlay')[0];	
		}
		
		this._controller = document.createElement('div');
		this._controller.className = 'jsOverlay';
		$(this._controller).css({height:$(this._elem).height(),width:$(this._elem).width(), position:'absolute', 'left':0, 'top':0, display:'none', zIndex:101});
		this._closebtn = document.createElement('div');
		this._closebtn.className = 'closebtn';
		$(this._closebtn).bind('click', {obj:this}, this.hide);
		$(this._controller).append(this._closebtn);
		$(this._controller).append(this._elem);
		$('body').append(this._controller);
		
		this._links = $('a[href="#' + this._id + '"]');
		this._links.attr('href','javascript:void(0);')
		this._links.bind('click', {obj:this}, this.display);
		
		$(window).bind('resize', {obj:this}, this.resetPosition);
	},
	showOverlay:function(){
			eve = {data:{obj:this}};
			this.display(eve);
		}
	,
	display : function(eve){
		$('object, select, input, textarea').css('visibility','hidden');
		$(eve.data.obj._overlay).css({'display':'block','height':$(document).height()});
		halfwidth = $(document).width()/2;
		halfwidth -= $(eve.data.obj._controller).width()/2;
		for(x in OverlayArray){
			$(OverlayArray[x]._controller).css('display','none');
		}
		$(eve.data.obj._controller).css({ 'display':'block', 'left':halfwidth, 'top':$(document).scrollTop()+40});
	},
	hide : function(eve){
		$('object, select, input, textarea').css('visibility','visible');
		$(eve.data.obj._overlay).css({'display':'none'});
		for(x in OverlayArray){
			$(OverlayArray[x]._controller).css('display','none');
		}
		if(document.getElementById("championship-video-1")){
			var div = document.getElementById("championship-video-1");
			div.innerHTML = div.innerHTML;
		}
		if(document.getElementById("championship-video-2")){
			var div = document.getElementById("championship-video-2");
			div.innerHTML = div.innerHTML;
		}
	},
	resetPosition : function(eve){
		for(x in OverlayArray){
			halfwidth = $(document).width()/2;
			halfwidth -= $(OverlayArray[x]._controller).width()/2;
			$(OverlayArray[x]._controller).css({'left':halfwidth, 'top':$(document).scrollTop()+40});
		}
	}
	
});



'use strict';

/*!
* AppleOfMyIframe
* github.com/premasagar/appleofmyiframe
*
*//*
JavaScript library for creating & manipulating iframe documents on-the-fly

by Premasagar Rose
dharmafly.com

license
opensource.org/licenses/mit-license.php


requires jQuery (best with jQuery v1.4+)
creates methods
jQuery.iframe()
jQuery(elem).intoIframe()
**
contributors
Alastair James: github.com/onewheelgood
Jonathan Lister: github.com/jayfresh
**
3KB minified & gzipped

*/

    /*
* Throttle
* github.com/premasagar/mishmash/tree/master/throttle/
*
*/
    (function($){
        function throttle(handler, interval, defer){
            var context = this;
            interval = interval || 250; // milliseconds
            // defer is false by default
            
            return function(){
                if (!handler.throttling){
                    handler.throttling = true;
                    
                    window.setTimeout(function(){
                        if (defer){
                            handler.call(context);
                        }
                        handler.throttling = false;
                    }, interval);
                    
                    if (!defer){
                        handler.call(context);
                    }
                }
                return context;
            };
        }

        // jQuery.throttle
        $.throttle = throttle;
        
        // jQuery(elem).throttle
        $.fn.throttle = function(eventType, handler, interval, defer){
            return $(this).bind(eventType, throttle(handler, interval, defer));
        };
    }(jQuery));


// **


(function($){
    // Anon and on
    function isUrl(str){
        return (/^https?:\/\/[\-\w]+\.\w[\-\w]+\S*$/).test(str);
    }
    function isElement(obj){
        return obj && obj.nodeType === 1;
    }
    function isJQuery(obj){
        return obj && !!obj.jquery;
    }
    // Utility class to create jquery extension class easily
    // Mixin the passed argument with a clone of the jQuery prototype
    function JqueryClass(proto){
        return $.extend(
            function(){
                this.init.apply(this, arguments);
            },
            {
                // deep clone of jQuery prototype and passed prototype
                prototype: $.extend(true, {}, $.fn, proto)
            }
        );
    }


    var
        // AOMI script version
        version = '0.25',
    
        // Namespace
        ns = 'aomi',
        
        // Environment
        win = window,
        
        // Browsers
        browser = $.browser,
        msie = browser.msie,
        ie6 = (msie && win.parseInt(browser.version, 10) === 6),
        
        // Browser behaviour booleans
        documentDestroyedOnIframeMove = !msie,
        externalIframesInvisibleOnAppend = ie6,
        
        // Shortcuts
        event = $.event,
        
        // Settings
        cssPlain = {
            margin:0,
            padding:0,
            borderWidth:0,
            borderStyle:'none',
            backgroundColor:'transparent'
        },
        
        defaultOptions = {
            attr:{
                scrolling:'no',
                frameBorder:0,
                allowTransparency:true
            },
            src:'about:blank', // don't include in attr object, or unexpected triggering of 'load' event may happen on applying attributes
            doctype:5, // html5 doctype
            target:'_parent', // which window to open links in, by default - set to '_self' or '_blank' if necessary
            autoheight:true, // shrink the iframe element to the height of its document body
            autowidth:false,
            resizeThrottle:250, // minimum delay between aomi.resize calls (milliseconds)
            css:$.extend(
                {width:'100%'}, // ensures that iframe element stretches to fill the containing width
                cssPlain
            ),
            title:'' // a title for the iframe document
        },
                
        // Main class
        AppleOfMyIframe = new JqueryClass(
            $.extend({
                init: function(){
                    var
                        aomi = this,
                        // Cache the constructor arguments, to enable later reloading
                        args = this._args($.makeArray(arguments))
                            ._args(), // retrieve the sorted arguments
                        options = this.options(),
                        autowidth = options.autowidth,
                        autoheight = options.autoheight,
                        firstResize, fromReload;
                    
                    // If a url supplied, add it as the iframe src, to load the page
                    // NOTE: iframes intented to display external documents must have the src passed as the bodyContents arg, rather than setting the src later - or expect weirdness
                    
                    // TODO: Possible change: don't accept url as bodyContents arg. Instead include src in options attribute. bodyContents and headContents are still optional in such a case - when those args are present, and the src attribute is html from a trusted domain, then the args will be used to append to the iframe document on load.
                    if (true){
                        options.src = args.bodyContents;
                        
                        // IE6 repaint - required a) for external iframes that are added to the doc while they are hidden, and b) for some external iframes that are moved in the DOM (e.g. google.co.uk)
                        if (externalIframesInvisibleOnAppend){
                            this.ready(this.repaint);
                        }
                    }
                    // If an injected iframe (i.e. without a document url set as the src)
                    else {
                        this
                            // When an iframe element is attached to the AOMI object, bind a handler function to the iframe's native 'load' event
                            .bind('attachElement', function(){
                                this._iframeLoad(function(){
                                    var handler = arguments.callee;
                                    
                                    // If the iframe has properly loaded
                                    if (aomi._okToLoad()){
                                        aomi
                                            // Unbind this handler
                                            ._iframeLoad(handler, true)
                                            
                                            // Write out the new document
                                            .document(true)
                                            
                                            // Bind an AOMI 'load' handler to the native 'load' event
                                            // NOTE: We do this after the document is written, because browsers differ in whether they trigger an iframe load event after the doc is written. So, we manually trigger the event for all browsers.
                                            ._iframeLoad(function(){
                                                aomi.trigger('load');
                                            });
                                    }
                                    else if (documentDestroyedOnIframeMove){
                                        aomi.reload();
                                    }
                                    // In IE, just replace the iframe element, as a reload would be unable to restore() the contents
                                    else {
                                        aomi.replace();
                                    }
                                });
                            });
                        
                        // Auto-resize behaviour
                        if (autowidth || autoheight){
                            if (autowidth){
                                options.css.width = 'auto';
                            }
                                                    
                            // When iframe first added to the DOM, resize it, and set up event listeners to resize later
                            this
                                .one('attachElement', function(){
                                    firstResize = true;
                                    this.css('visibility', 'hidden'); // hide iframe until it is resized
                                })
                            
                                .one('ready', function(){
                                    // Throttle the interval between iframe resize actions, and that between responses to the global window's 'resize' event
                                    var resize, parent, pollForVisibility;
                                    
                                    resize = $.throttle(function(){
                                        aomi.resize(autowidth, autoheight);
                                        
                                        if (firstResize){
                                            firstResize = false;
                                            aomi.css('visibility', 'visible'); // show iframe again
                                        }
                                    }, options.resizeThrottle, true);
                                    
                                    // iframe container is not yet displayed. If the container has display:none (e.g. it's in a non-selected tab), then resize() can't determine the height of the body contents, and the iframe will have a height set to zero. So, we poll for the iframe container to be displayed. Hack!
                                    // TODO: Does it matter that we stop polling once we're visible the first time? Are there practical situations where the body contents will be manipulated while the container is not displayed? Is that really our problem?
                                    if (!this.is(':visible')){
                                        pollForVisibility = win.setInterval(function(){
                                            if (aomi.parent().is(':visible')){ // re-check parent in case iframe is moved in DOM?
                                                resize();
                                                win.clearInterval(pollForVisibility);
                                            }
                                        }, 1000);
                                    }
                                    
                                    // Bind for later
                                    this
                                        .bind('manipulateHead', function(){ // TODO: For some reason (presumably related to the bind method), we need to pass this anonymous function, and not simply .bind('manipulateHead', resize) - else the callback won't fire
                                            return resize();
                                        })
                                        .bind('manipulateBody', function(){
                                            return resize();
                                        })
                                        .load(function(){ // NOTE: We resize on 'ready', so that the dimensions are in place for any custom 'ready' callbacks, and then on 'load', after any custom ready callbacks
                                            return resize();
                                        });
                                    
                                    // If we're not matching the iframe element's width to that of the iframe body's contents (instead we're letting the element stretch to fill its parent node, via css width:100%)
                                    if (!autowidth){
                                        // respond to browser window resizing
                                        $(win).resize(resize);
                                    }
                                    // TODO: Is it worth resizing the iframe whenever any of its contents is manipulated, e.g. by listening to DOM mutation events from within the document?
                                });
                        }
                        
                        // Setup iframe document caching
                        // Ridiculously, each time the iframe element is moved, or removed and re-inserted into the DOM, then the native onload event fires and the iframe's document is discarded. (This doesn't happen in IE, thought). So we need to bring back the contents from the discarded document, by caching it and restoring from the cache on each 'load' event.
                        if (documentDestroyedOnIframeMove){
                            this
                                // Track when an 'extreme' reload takes place
                                .bind('extremereloadstart', function(){
                                    fromReload = true;
                                })
                                .load(function(ev){
                                    // If an extreme reload, then don't restore from cached nodes - a) because the original constructor args are used, b) because probably the browser doesn't support adoptNode, etc, so we'll end up reloading again anyway during cache(), leading to an infinite loop
                                    if (fromReload){
                                        fromReload = false;
                                    }
                                    // Restore from cached nodes. Not restored if the body already has contents.
                                    // TODO: Could it be problematic to not restore when there is already body contents? Should we check if there's head contents too?
                                    else if (!this.body().children().length){
                                        this.restore();
                                    }
                                    this.cache();
                                });
                        }
                    }
                    
                    return this
                        // Attach the iframe element
                        ._attachElement()
                        
                        // Init complete
                        .trigger('init');
                },
            
                $: function(arg){
                    var doc = this.document();
                    return arg ? $(arg, doc[0]) : doc;
                },
                
                
                // doctype() examples:
                    // this.doctype(5);
                    // this.doctype(4.01, 'strict');
                    // this.doctype() // returns doctype object
                doctype: function(v){
                    var doctype;
                                    
                    if (v){
                        this.options().doctype = v;
                        return this;
                    }
                    v = this.options().doctype;
                    doctype = '<!DOCTYPE ';
                    if (v === 5){ // html5 doctype
                        doctype += 'html';
                    }
                    else if (v === 4.01){
                        doctype += 'HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"';
                    }
                    return doctype + '>';
                },
                
                // NOTE: We use $.event.trigger() instead of this.trigger(), because we want the callback to have the AOMI object as the 'this' keyword, rather than the iframe element itself
                trigger: function(type, data){
                    // DEBUG LOGGING
                    if ($.iframe.debug){
                        var debug = [this.attr('id') + ': *' + type + '*'];
                        if (typeof data !== 'undefined'){
                            debug.push(data);
                        }
                        //debug.push(arguments.callee.caller);
                        $.iframe.debug.apply(null, debug);
                    }
                    // end DEBUG LOGGING
                    
                    event.trigger(type + '.' + ns, data, this);
                    return this;
                },
                                
                bind: function(type, callback){
                    event.add(this, type + '.' + ns, callback);
                    return this;
                },
                
                unbind: function(type, callback){
                    event.remove(this, type + '.' + ns, callback);
                    return this;
                },
                
                one: function(type, callback){
                    return this.bind(type, function outerCallback(){
                        callback.apply(this, $.makeArray(arguments));
                        this.unbind(type, outerCallback);
                    });
                },
                
                
                // Avoid jQuery 1.4.2 bug, where it assumes that events are always bound to DOM nodes
                addEventListener: function(){},
                removeEventListener:function(){},
                
                
                /*
Ideas / Examples:
aomi.history(-1);
aomi.init(fn); // a function to do everything needed to initialise the widget; should be able to be re-run again at any time, to re-initialise the widget
aomi.load(0); // index number for screen history - e.g. url # fragments
aomi.load(fn); // bind callback for future 'load' events
=> aomi.document(head, body); // etc
$.iframe.doctypes = {
html5: '<!DOCTYPE html>'
};
aomi.doctype('html5') === $.iframe.doctypes['html5'];
*/
                
                // TODO: Should the iframe have visibility:hidden at first, then show it on load? - this may make the appearance and first rendering smoother
                document: function(){
                    var
                        args = $.makeArray(arguments),
                        doc;
                    
                    try {
                        doc = this.window().attr('document');
                    }
                    catch(e){}
                    
                    if (!args.length){
                        return $(doc || []);
                    }
                    // Cache the passed arguments
                    if (args[0] !== true){
                        this._args(args);
                    }
                    
                    // Doc is ready for manipulation
                    if (doc){
                        doc.open();
                        doc.write(
                            this.doctype() + '\n' +
                            '<head></head><body></body>'
                        );
                        doc.close();
                        this
                            ._trim()
                            // Apply the cached options & args
                            ._args(true)
                            // Trigger the 'ready' event, which is analogous to the $().ready() event for the global document
                            .trigger('ready')
                            .trigger('load');
                    }
                    // Doc not ready, so apply arguments at next load event
                    else {
                        this.one('load', function(){
                            this.document(true);
                        });
                    }
                    return this;
                },
                
                _args: function(){
                    var
                        aomi = this,
                        args = $.makeArray(arguments),
                        defaultArgs = {
                            headContents: '',
                            bodyContents: '',
                            callback: function(){}
                            // NOTE: options arg is handled by aomi.options()
                        },
                        argsCache = this._argsCache || defaultArgs,
                        found = {},
                        optionsFound;
                    
                    // Return cached args
                    if (!args.length){
                        return $.extend(true, argsCache, {
                            options:this.options()
                        });
                    }
                    
                    // An array of args was passed. Re-apply as arguments to this function.
                    if ($.isArray(args[0])){
                        return this._args.apply(this, args[0]);
                    }
                    if (args[0] === true){
                        // apply cached options and constructor arguments
                        this
                            .options(true)
                            // TODO: This will empty the head, overwriting the title option set on the previous line. Can the two lines be swapped?
                            // TODO: Do we need to call head() if headContents is blank? Should we empty the head, if there is no headContents?
                            .head(argsCache.headContents, true)
                            .body(argsCache.bodyContents, true)
                            // Call the callback on the next 'ready' event
                            .one('ready', argsCache.callback);
                    }
                    else {
                        // All arguments are optional. Determine which were supplied.
                        $.each(args.reverse(), function(i, arg){
                            if (!found.callback && $.isFunction(arg)){
                                found.callback = arg;
                            }
                            else if (!optionsFound && typeof arg === 'object' && !isJQuery(arg) && !isElement(arg)){
                                aomi.options(arg);
                                optionsFound = true;
                            }
                            // TODO: If the bodyContents or headContents is a DOM node or jQuery collection, does this throw an error in some browsers? Probably, since we have not used adoptNode, and the nodes have a different ownerDocument. Should the logic in reload for falling back from adoptNode be taken into a more generic function that is used here?
                            else if (!found.bodyContents && typeof arg !== 'undefined'){
                                found.bodyContents = arg;
                            }
                            // Once callback and options are assigned, any remaining args must be the headContents; then exit loop
                            else if (!found.headContents && typeof arg !== 'undefined'){
                                found.headContents = arg;
                            }
                        });
                        this._argsCache = $.extend(true, defaultArgs, found);
                    }
                    return this;
                },
                
                options: $.extend(
                    function(newOptions){
                        var
                            thisFn = this.options,
                            getDefaults = thisFn.defaultOptions,
                            options;
                        
                        if (newOptions){
                            // Cache new options
                            if (typeof newOptions === 'object'){
                                this._options = $.extend(true, getDefaults(), newOptions);
                            }
                            // Apply cached options to iframe
                            else if (newOptions === true){
                                options = this.options();
                                this
                                    // Re-apply cached title
                                    .title(true)
                                    
                                    // Let anchor links open pages in the default target
                                    .ready(function(){
                                        this.$('a').live('click', function(){
                                            if (!$(this).attr('target') && $(this).attr('href')){
                                                $(this).attr('target', options.target);
                                            }
                                        });
                                    });
                            }
                            return this;
                        }
                                                
                        // No args passed
                        if (!this._options){
                            this._options = getDefaults();
                        }
                        return this._options;
                    },
                    {
                        defaultOptions: function(){
                            return $.extend(true, {}, defaultOptions);
                        }
                    }
                ),
                
                load: function(callback){
                    return this.bind('load', callback);
                },
                
                ready: function(callback){
                    return this.bind('ready', callback);
                },
                
                reload: function(extreme){
                    // 'soft reload': re-apply src attribute
                    // NOTE: documentDestroyedOnIframeMove is included here, as only those browsers will have a 'soft' reload trigger the restore() method. Other browsers (that is, IE), should instead perform a hard reload
                    if ((!extreme && documentDestroyedOnIframeMove) || !this.hasBlankSrc()){
                        this.attr('src', this.attr('src'));
                    }
                    // 'hard reload': re-apply original constructor args
                    else {
                        this.trigger('extremereloadstart');
                        this.document(true);
                    }
                    return this.trigger('reload', !!extreme);
                },
                
                // Duplicate this AOMI object. This will essentially clone the iframe element, its document and all its settings, provided that they have only been manipulated via the AOMI API - e.g. by passing a function to the original constructor
                // TODO: should _args() be able to return as an array, so we can do an apply() on $.iframe?
                // TODO: Should this attempt to clone the current AOMI document's head and body elements?
                clone: function(){
                    var args = this._args();
                    return $.iframe(args.headContents, args.bodyContents, this.options(), args.callback);
                },
                
                // Replace the iframe element with the iframe element from a replica AOMI object
                replace: function(){
                    var newIframe = this.clone();
                    
                    this.replaceWith(newIframe);
                    this[0] = newIframe[0];
                    return this.trigger('replace');
                },
                
                // Trigger a repaint of the iframe - e.g. for external iframes in IE6, where the contents aren't always shown at first
                repaint: function(){
                    var className = ns + '-repaint';
                    this
                        .addClass(className)
                        .removeClass(className);
                    return this.trigger('repaint');
                },
            
                window: function(){
                    var win = this._windowObj();
                    if (win){ // For an injected iframe not yet in the DOM, then win is null
                        try { // For an external iframe, win is accessible, but $(win) will throw a permission denied error
                            return $(win);
                        }
                        catch(e){}
                    }
                    return $([]);
                },
                
                // TODO: Make this a read-write method
                location: function(){
                    var
                        win = this.window(),
                        loc = win.attr('location');
                        
                    if (loc){
                        try {
                            return loc.href; // location href is available, so iframe is in the DOM and is in the same domain
                        }
                        catch(e){}
                    }
                    return this._windowObj() ?
                        null : // iframe is in the DOM, but has a cross-domain document
                        this.attr('src'); // iframe is out of the DOM, so its window doesn't exist and it has no location
                },

                head: function(contents, emptyFirst){
                    var
                        head = this.$('head'),
                        method = 'append';
                    
                    if (typeof contents !== 'undefined' && contents !== false){
                        if (head.length){
                            if (emptyFirst){
                                head.empty();
                            }
                            if (contents){
                                head[method](contents);
                            }
                            this.trigger('manipulateHead', method);
                        }
                        // Document not active because iframe out of the DOM. Defer till the next 'load' event.
                        else {
                            this.one('load', function(){
                                this.head(contents, emptyFirst);
                            });
                        }
                        return this;
                    }
                    return head;
                },
                
                body: function(contents, emptyFirst){
                    var body = this.$('body');
                    if (typeof contents !== 'undefined' && contents !== false){
                        if (body.length){ // TODO: Perhaps this should also check if the 'ready' event has ever fired - e.g. in situations where iframe has just been added to the DOM, but has not yet loaded
                            if (emptyFirst){
                                this.empty();
                            }
                            if (contents){
                                this.append(contents);
                            }
                        }
                        // Document not active because iframe out of the DOM. Defer till the next 'load' event.
                        else {
                            this.one('load', function(){
                                this.body(contents, emptyFirst);
                            });
                        }
                        return this;
                    }
                    return body;
                },
                
                title: function(title){
                    if (title === true){
                        return this.title(this.options().title);
                    }
                    if (typeof title !== 'undefined'){
                        this.options().title = title;
                        this.$().attr('title', title);
                        return this;
                    }
                    return this.$().attr('title');
                },
                
                style: function(cssText){
                    return this.head('<style>' + cssText + '</style>');
                },
            
                // TODO: If bodyChildren is a block-level element (e.g. a div) then, unless specific css has been applied, its width will stretch to fill the body element which, by default, is a set size in iframe documents (e.g. 300px wide in Firefox 3.5). Is there a way to determine the width of the body contents, as they would be on their own? E.g. by temporarily setting the direct children to have display:inline (which feels hacky, but might just work).
                
                // NOTE: If the iframe element's parent node has position:absolute, then the options.css.width = '100%' won't succeed in having the iframe the same width as its parent. Instead, resize(true) will need to be called.
                resize: function(doWidth, doHeight){ // default is resize height only (as with other block-level elements)
                    var body, /*htmlDims,*/ bodyDims, childrenDims, width, height;
                    
                    doWidth = doWidth || false;
                    doHeight = doHeight !== false || true;
                
                    function getDimensions(selector){
                        var maxWidth = 0, totalHeight = 0;
                        
                        $(selector).each(function(){
                            var width;
                            
                            if (doWidth){
                                width = $(this).outerWidth(true);
                                if (width > maxWidth){
                                    maxWidth = width;
                                }
                            }
                            if (doHeight){
                                totalHeight += $(this).outerHeight(true);
                            }
                        });
                        return [maxWidth, totalHeight];
                    }
                    
                    body = this.body();
                    //htmlDims = getDimensions(this.$('html'));
                    bodyDims = getDimensions(body);
                    childrenDims = getDimensions(body.children());
                    
                    if (doWidth){
                        width = Math.max(bodyDims[0], childrenDims[0]);
                        this.width(width);
                    }
                    if (doHeight){
                        height = Math.max(bodyDims[1], childrenDims[1]);
                        this.height(height);
                    }
                    return this.trigger('resize', [width, height]);
                },
                
                // TODO: Currently, this will return true for an iframe that has a cross-domain src attribute and is not yet in the DOM. We should include a check to compare the domain of the host window with the domain of the iframe window - including checking document.domain property
                isSameDomain: function(){
                    return this.location() !== null;
                },
                
                hasExternalDocument: function(){
                    var loc = this.location();
                    return loc === null || (loc !== 'about:blank' && loc !== win.location.href);
                    // NOTE: the comparison with the host window href is because, in WebKit, an injected iframe may have a location set to that url. This would also match an iframe that has a src matching the host document url, though this seems unlikely to take place in practice.
                    // NOTE: this also returns true when the iframe src attribute is for an external document, but the iframe is out of the DOM and so doesn't actually contain a document at that time
                },
                
                hasBlankSrc: function(){
                    var src = this.attr('src');
                    return !src || src === 'about:blank';
                },
                
                cache: function(){
// iframe is not in the DOM
if (!this.$()[0]){
return this;
}

// Update the cached nodes
this._cachedNodes = this.head().add(this.body());
this.trigger('cache');
return this;
                },
                
                // TODO: It may be necessary to restore any possible cached events on the document and htmlElement, e.g. via .data('events') property
                // TODO: This needs to restore the originally set doctype. Currently, it won't do so, except when the append methods fail, and the reload() method is called (e.g. Opera 10.10). The function needs to re-write the document from scratch, but without disturbing any load() callbacks. Perhaps we need a stealth load - temporary turning off and turning on of the load event listener. It's fortunate that IE does not generally need to be restored when the iframe is moved in the DOM, because the loss of the doctype would be most obvious there, due to the Quirks mode box model.
                restore: function(){
                    // Methods to try, in order. If all fail, then the iframe will re-initialize.
                    var
                        methodsToTry = ['adoptNode', 'appendChild', 'importNode', 'cloneNode'],
                        appendMethod = $.iframe.appendMethod,
htmlElement = this.$('html').empty(),
                        doc = this.$()[0],
cachedNodes = this._cachedNodes;

if (!doc || !cachedNodes){
return this;
}

                    // If we don't yet know the append method to use, then cycle through the different options. This only needs to be determined the first time an iframe is moved in the DOM, and only once per page view.
                    if (!appendMethod){
                        appendMethod = this._findAppendMethod(doc, methodsToTry, htmlElement, cachedNodes) || 'reload';
                        $.iframe.appendMethod = appendMethod;
                    }
                    // If we've already determined the method to use, then use it
                    else if (appendMethod !== 'reload'){
                        this._appendWith(doc, appendMethod, htmlElement, cachedNodes);
                    }
                    // If the standard append methods don't work, then reload the iframe, using the original constructor arguments.
                    if (appendMethod === 'reload'){
                        // Remove the cached nodes, to prevent the reload triggering a new 'load' event => call to cache() => infinite loop
                        this._cachedNodes = null; // NOTE: In Opera 10.10, if we 'delete' the _cachedNodes property, weird stuff happens, so best to make null
                        this.reload(true);
                    }
                    // Re-apply the document title
                    // NOTE: We shouldn't need to re-apply any of the other options, such as CSS on the iframe element
                    else {
                        this.title(true);
                        
                        // TODO: TEMP HACK: why is this suddenly needed? The problem: in FF3.5 and WebKit, when the iframe element is moved in the DOM, the margin around the body contents is somehow not rendered as it should be. Not sure if there are problems with other CSS props.
                        this.body().contents().each(function(){
                            var el = $(this);
                            el.css('margin', el.css('marginTop') + ' ' + el.css('marginRight') + ' ' + el.css('marginBottom') + ' ' + el.css('marginLeft'));
                        });
                    }
                    
                    return this.trigger('restore', appendMethod);
                },
                
                // Advised not to use this API method externally
                // Proxy for iframe's native load event, with free jQuery event handling
                _iframeLoad: function(callback, unbind){
                    var aomi = this;
                    
                    if (!unbind){
                        $(this[0]).bind('load', callback);
                        
                        // Prevent IE having permission denied error, when relying on jQuery's built-in unload event handler removal
                        $(win).unload(function(){
                            aomi._iframeLoad(callback, true);
                        });
                    }
                    else {
                        $(this[0]).unbind('load', callback);
                    }
                    return this;
                },
                
                _attachElement: function(){
                    var options = this.options();
                    
                    // Absorb a jQuery-wrapped iframe element into the AOMI object
                    $.fn.init.call(this, '<iframe onload="taomi.resize()"></iframe>');
                    
                    // iframe element manipulation: apply attributes and styling
                    this
                        .css(options.css)
                        .attr(options.attr)
                        .addClass(ns)
                        .attr('src', options.src);
                    
                    return this
                        // iframe document and contents: apply options
                        .options(true)
                        .trigger('attachElement');
                },
                
                _windowObj: function(){
                    try { // Can cause "unspecified error" in IE if the window's not yet ready
                        return this[0].contentWindow;
                    }
                    catch(e){
                        return false;
                    }
                },
                
                _appendWith: function(doc, method, parentNode, childNodes){
                    if ($.isFunction(doc[method])){
                        try {
                            childNodes.each(
                                function(){
                                    var newNode;
                                    switch (method){
                                        case 'cloneNode':
                                        newNode = this[method](true);
                                        break;
                                        
                                        case 'appendChild':
                                        newNode = this;
                                        break;
                                        
                                        default: // adoptNode & importNode
                                        newNode = doc[method](this, true);
                                    }
                                    parentNode.append(newNode);
                                }
                            );
                            return true;
                        }
                        catch(e){}
                    }
                    return false;
                },
                
                _findAppendMethod: function(doc, methods, parentNode, childNodes){
                    var aomi = this, appendMethod;
                    
                    $.each(methods, function(i, method){
                        if (aomi._appendWith(doc, method, parentNode, childNodes)){
                            appendMethod = method;
                            return false;
                        }
                    });
                                    
                    return appendMethod;
                },
                
                _trim: function(){
                    this.body()
                        .css(cssPlain);
                    return this;
                },
                
                _hasSrcMismatch: function(){
                    return (this.hasBlankSrc() && this.hasExternalDocument());
                },
                
                // A check to prevent the situation where an iframe with an external src is on page, as well as an injected iframe; if the iframes are moved in the DOM and the page reloaded, then the contents of the external src iframe may be duplicated into the injected iframe (seen in FF3.5 and others). This function re-appplies the 'about:blank' src attribute of injected iframes, to force a reload of its content
                _okToLoad: function(){
                    var ok = true;
                    if (this._hasSrcMismatch()){ // add other tests here, if required
                        ok = false;
                    }
                    return ok;
                }
            },
            
            // Add modified jQuery methods to the prototype
            (function(){
                var
                    jQueryMethods = [
                        {
                            // Methods to manipulate the iframe element
                            fn: [
                                'appendTo',
                                'prependTo',
                                'insertBefore',
                                'insertAfter',
                                'replaceAll'
                            ],
                            
                            wrapper: function(method){
                                return function(){
                                    $.fn[method].apply(this, arguments);
                                    // Work around browser rendering quirks
                                    if (!this.hasBlankSrc()){
                                        this.reload();
                                    }
                                    return this.trigger('manipulateIframe', method);
                                };
                            }
                        },
                        
                        {
                            // Methods to manipulate the iframe's body contents
                            fn: [
                                'append',
                                'prepend',
                                'html',
                                'text',
                                'wrapInner',
                                'empty'
                            ],
                            
                            wrapper: function(method){
                                return function(){
                                    $.fn[method].apply(this.body(), arguments);
                                    return this.trigger('manipulateBody', method);
                                };
                            }
                        }
                    ],
                    methodsForPrototype = {};
                
                $.each(
                    jQueryMethods,
                    function(i, method){
                        var wrapper = method.wrapper;
                        $.each(
                            method.fn,
                            function(j, fn){
                                methodsForPrototype[fn] = wrapper(fn);
                            }
                        );
                    }
                );
                return methodsForPrototype;
            }())
        ));
        
    
    // Extend jQuery with jQuery.iframe() and jQuery(elem).intoIframe()
    $.extend(
        true,
        {
            iframe: $.extend(
                function(headContents, bodyContents, options, callback){
                    return new AppleOfMyIframe(headContents, bodyContents, options, callback);
                },
                {aomi: version} // script version number - for 3rd party scripts to verify that jQuery.iframe is created by AppleOfMyIframe, and to check the script version
            ),
            fn: {
                // TODO: Allow multiple elements in a collection to be replaced with iframes, e.g. $('.toReplace').intoIframe()
                // TODO: Where the element doesn't have an explicit width set, the iframe will not be able to resize to it. One hacky method to determine the width: display the element inline, measure its width, then return the display and then set the width of the iframe.
                intoIframe: function(headContents, options, callback){
                    return $.iframe(headContents, this, options, callback)
                        .replaceAll(this);
                }
            }
        }
    );
    
    // Expose AOMI prototype to $.iframe.fn
    $.iframe.fn = AppleOfMyIframe.prototype;
    
}(jQuery));


/*Stay Connected Form
*******************************/

function submitStayConnectedForm(){
	okay = true;
	var email = document.getElementById('stay-conn-email');
	var emailPattern = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;
	errmsg = new Array();
	
	if($('.stay-connected-email')[0].value == ''){
		okay = false;
		errmsg['email_missing'] = 'Please enter an email address.';
	}else{
		if(emailPattern.test(email.value)) { 
			okay = true;
		}else {
			okay = false;
			errmsg['email_bad'] = 'Please enter a valid email address.';
		}
	}
	
	
	if(okay){
		form.submit();
		
	}else{
		if($('.form-area-stay-connected .alert').length > 0){
			alertarea = $('.form-area-stay-connected .alert')[0];
		}else{
			alertarea = $('<div class="alert"><p>There is an issue with the submission:</p><ul></ul></div>');	
			$('.form-area-stay-connected').prepend(alertarea);
		}
		$('ul li', alertarea).remove();
		for(x in errmsg){
			$('ul', alertarea).append($('<li>'+errmsg[x]+'</li>'));
		}
	}
	
return false;
	
}

function greenInnovationOverlay(url, w, h) {
	var a = document.createElement('a');
	a.href = url;
	a.rel = 'lyteframe';
	a.rev = 'width: '+w+'px; height: '+h+'px; scrolling: no;';
	myLytebox.start(a, false, true);
}

/* ONLOAD
*******************************/
var taomi;

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function greenContact() {
	if(window.location.pathname=='/contact-us') {
		if(window.location.search=='?content=green'){
			$('.dd-contact-form').css('display','block');
			$('#dnn_ctr687_View_ddlCategory').val(26);
		}
	}
}

/* Fisheye Menu
************************************/
var fisheyemenu = {
	startSize : 50,
	endSize : 75,
	imgType : ".gif",
	init : function () {
		var animElements = document.getElementById("fisheye_menu").getElementsByTagName("img");
		var titleElements = document.getElementById("fisheye_menu").getElementsByTagName("span");
		for(var j=0; j<titleElements.length; j++) {
			titleElements[j].style.display = 'none';
		}
		for(var i=0; i<animElements.length; i++) {
			var y = animElements[i];
			y.style.width = fisheyemenu.startSize+'px';
			y.style.height = fisheyemenu.startSize+'px';
			fisheyemenu.imgSmall(y);
			animElements[i].onmouseover = changeSize;
			animElements[i].onmouseout = restoreSize;
		}
		function changeSize() {
			fisheyemenu.imgLarge(this);
			var x = this.parentNode.getElementsByTagName("span");
			x[0].style.display = 'block';
			if (!this.currentWidth) this.currentWidth = fisheyemenu.startSize;
			fisheyemenu.resizeAnimation(this,this.currentWidth,fisheyemenu.endSize,15,10,0.333);
		}
		function restoreSize() {
			var x = this.parentNode.getElementsByTagName("span");
			x[0].style.display = 'none';
			if (!this.currentWidth) return;
			fisheyemenu.resizeAnimation(this,this.currentWidth,fisheyemenu.startSize,15,10,0.5);
			fisheyemenu.imgSmall(this);
		}
	},
	resizeAnimation : function (elem,startWidth,endWidth,steps,intervals,powr) {
		if (elem.widthChangeMemInt) window.clearInterval(elem.widthChangeMemInt);
		var actStep = 0;
		elem.widthChangeMemInt = window.setInterval(
			function() {
				elem.currentWidth = fisheyemenu.easeInOut(startWidth,endWidth,steps,actStep,powr);
				elem.style.width = elem.currentWidth+"px";
				elem.style.height = elem.currentWidth+"px";
				actStep++;
				if (actStep > steps) window.clearInterval(elem.widthChangeMemInt);
			}
			,intervals)
	},
	easeInOut : function (minValue,maxValue,totalSteps,actualStep,powr) {
	//Generic Animation Step Value Generator By www.hesido.com
		var delta = maxValue - minValue;
		var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
		return Math.ceil(stepp)
	},
	imgSmall : function (obj) {
		imgSrc = obj.getAttribute("src");
		var typePos = imgSrc.indexOf(fisheyemenu.imgType, 0);
		var imgName = imgSrc.substr(0, typePos);
		obj.setAttribute("src", imgName+"_small"+fisheyemenu.imgType);
	},
	imgLarge : function (obj) {
		imgSrc = obj.getAttribute("src");
		var typePos = imgSrc.indexOf("_small", 0);
		var imgName = imgSrc.substr(0, typePos);
		obj.setAttribute("src", imgName+fisheyemenu.imgType);
	}
}
/* End of Fisheye menu
************************************************/

$(document).ready(function(){
	if($('.form-area-stay-connected').length > 0) {
		$($('#dnn_ctr677_View_btnSubmit')[0]).bind('click', function(){
			submitStayConnectedForm();
		});
	}	
	if($('.mini-slider').length > 0){
		SliderArray[SliderArray.length] = new Slider('.mini-slider', {moveCount:2, showNumbers:false, showArrows:true, autoSlide:4000, effect:'slide'});
		$('body').addClass('slider-loaded');
	}
	if($('.awards-hdr-slider').length > 0){
		SliderArray[SliderArray.length] = new Slider('.awards-hdr-slider', {moveCount:3, showNumbers:false, showArrows:true, autoSlide:4000, effect:'slide'});
		$('body').addClass('slider-loaded');
	}
	if($('.booking-slider').length > 0){
		SliderArray[SliderArray.length] = new Slider('.booking-slider', {moveCount:7, showNumbers:false, showArrows:true, autoSlide:4000, effect:'slide', continuous:true});
		$('body').addClass('slider-loaded');
	}
	if($('.home-slider').length > 0){
		SliderArray[SliderArray.length] = new Slider('.home-slider', {showNumbers:false, showArrows:true, autoSlide:4000, effect:'fade'});
		$('body').addClass('home-slider-loaded');
	}
	if($('.full-slider').length > 0){
		SliderArray[SliderArray.length] = new Slider('.full-slider', {showNumbers:false, showArrows:true, autoSlide:4000, effect:'fade'});
		$('body').addClass('full-slider-loaded');
	}	
	
	if($('.media-slider').length > 0){
		SliderArray[SliderArray.length] = new Slider('.media-slider', {showNumbers:false, showArrows:true, autoSlide:4000, effect:'fade'});
		$('body').addClass('media-slider-loaded');
	}
	if($('.social-media-room').length > 0){
		SocialMediaRoomArray['social-media-room'] = new SocialMediaRoom('.social-media-room');
		$('body').addClass('dl-tabs-loaded');
	}
	if($('#stay-connected-close-account').length > 0){
		OverlayArray[$('#stay-connected-close-account')[0].id] = new Overlay($('#stay-connected-close-account')[0]);
	}
	
	if($('#dnn_Overlay').length > 0 && $('.ControlPanel').length == 0){
		overlays = $('#dnn_Overlay .overlay');
		for(x = 0; x<overlays.length; x++){
			OverlayArray[overlays[x].id] = new Overlay(overlays[x]);
		}
		$('#dnn_Overlay').remove();
	}
	if($('.imageliboverlay').length > 0){
		overlays = $('.imageliboverlay');
		for(x = 0; x<overlays.length; x++){
			OverlayArray[overlays[x].id] = new Overlay(overlays[x]);
		}
		//overlays.remove();
		
	}
	if($('.irpressoverlay').length > 0){
		overlays = $('.irpressoverlay');
		for(x = 0; x<overlays.length; x++){
			OverlayArray[overlays[x].id] = new Overlay(overlays[x]);
		}
		//overlays.remove();
		
	}
	if($('.PressReleaseDetails').length > 0){
		overlays = $('.PressReleaseDetails');
		holder = $('<div id="pressoverlay" class="overlay"></div>').append($(overlays[0]).clone()).append($('<div class="printopt-top"><a href="javascript:window.print();">Print</a></div><div class="printopt-bottom"><a href="javascript:window.print();">Print</a></div>'));
		$('body').append(holder);		
		OverlayArray['pressoverlay'] = new Overlay(holder);		
	}
	if($('.contact-form').length > 0){
		TabSwapArray[TabSwapArray.length] = new TabSwap('.contact-form');
		$('body').addClass('dl-tabswap');
	}
	
	if($('.dl-book-your-vacation').length > 0){
		TabSwapArray[TabSwapArray.length] = new TabSwap('.dl-book-your-vacation');
		$('body').addClass('dl-tabswap');
	}
	if($('.dl-investor-tabs').length > 0){
		TabSwapArray[TabSwapArray.length] = new TabSwap('.dl-investor-tabs');
		$('body').addClass('dl-tabswap');
	}
	if($('.enviro-tabs').length > 0){
		TabSwapArray[TabSwapArray.length] = new TabSwap('.enviro-tabs');
		$('body').addClass('dl-tabswap');
	}
	else if($('.dl-tabs').length > 0){
		TabSwapArray[TabSwapArray.length] = new TabSwap('.dl-tabs');
		$('body').addClass('dl-tabswap');
	}
	if($('.green-lodging').length > 0){
		GreenTabSwapArray[GreenTabSwapArray.length] = new GreenTabSwap('.green-lodging');
		$('body').addClass('dl-tabswap');
	}
	
	if($('#investorreliframe').length > 0){
		/*tmp = $('#investorreliframe');
		
		taomi = $.iframe($($('#investorreliframe')[0]).attr('src'));
		tmp.after(taomi);
		tmp.remove();*/
	}
	
	if($('#fisheye_menu').length > 0){
		fisheyemenu.init();
	}
	
	if($('.tab-wyndham-worldwide').length > 0){
		greenContact();
	}
	
	if($('#investorsnewsletter').length > 0){
		$('input', $('#investorsnewsletter')).keypress(function(event) {
			if (event.keyCode == '13') {
				event.preventDefault();
			}
		});
		$('#stay-connected-submit', $('#investorsnewsletter')).bind('click',
			function(){
				okay = true;
				errmsg = new Array();
				if($('#stay-connected-email')[0].value == ''){
					okay = false;
					errmsg['home_resv_city'] = 'Please enter a city.';
				}
				
				if(okay){
					
					form = $('form')[0];
					form.action = 'http://phx.corporate-ir.net/preview/phoenix.zhtml?c=200690&p=irol-alertsLong&t=AlertPost&control_ws_active_alert_list=&control_ir-pvvolumeexceeds=&control_ir-pvrecentclosingvolume=&control_ir-pvpricefalls=&control_ir-pvpriceexceeds=&control_ir-pvpercentagepricefalls=&control_ir-pvpercentagepriceexceeds=&control_ir-pvpercentagemaxmin=&control_ir-pvisinpage=&control_ir-pvcurrentstockprice=&control_ir-pvabsvolume=&control_ir-pvabsmaxmin=&control_ir-wksumradioon=&control_ir-wksumradiooff=&control_ir-wksumdescr=&control_ir-pvradioon=&control_ir-pvradiooff=&control_ir-pvdescr=&control_ir-regulatorynewsradioon=&control_ir-regulatorynewsradiooff=&control_ir-regulatorynewsdescr=&control_ir-financialnewsradioon=&control_ir-financialnewsradiooff=&control_ir-financialnewshidden=&control_ir-financialnewsdescr=&control_ir-financialnewscheckbox=&control_ir-debtradioon=&control_ir-debtradioof';
					form.method = 'post';
					form.submit();
					return false;
				}
			}
		);
	}
});
