
// ****** start: misc ******

function printPage()
{
    if (window.print){window.print();}
}

function hide(element)
{
	document.getElementById(element).style.display = 'none';
	return;
}
function show(element)
{
	document.getElementById(element).style.display = 'block';
	return;		
}

// ****** end: misc ******


// *** start: popup links ***
// setamap pupuplinks
document.observe('dom:loaded', function(){
	$$('a.lnk_seatingchartpopup').invoke('observe', 'click', function(e){
		e.stop();
		var lnk = e.element();
		return(popuplink(lnk.href, lnk, 800, 800, true)
		);
	});
});


// start: popup window
// usage: popuplink(['js-only url',] this[, w[, h[, scroll[, extras]]]])
// basic usage: <a href="popup.html" target="_blank" onclick="return(popuplink(this));">new pop</a>
// advanced usage: <a href="popup_nojs.html" target="_blank" onclick="return(popuplink('popup_yesjs.html', this, 200, 100, false));">new pop</a>
// site-wide defaults:
popup_w = 400;
popup_h = 300;
popup_scroll = true;
popup_extras = 'location=0,statusbar=0,menubar=0,resizable=1';
function popuplink() {
	var undef, i=0, args=popuplink.arguments;
	var url = (typeof(args[i])=='string') ? args[i++] : args[i].getAttribute('href');
	var target = args[i++].getAttribute('target') || '_blank';
	var w = args[i++];
	var h = args[i++];
	var s = (args[i]===undef) ? popup_scroll : args[i++];
	var features = 'width=' + (w || popup_w)
				 + ',height=' + (h || popup_h)
				 + ',scrollbars=' + (s ? 'yes,' : 'no,')
				 + (args[i] || popup_extras);
	var win = window.open(url, target, features);
	win.focus();
	return false;
}




var popReveal = Class.create({
			initialize: function(aTabs, aContents) {
				this.tabs = aTabs;
				this.contents = aContents;				
				
				// Loop through each link and attach a click handler
				for(var i=0; i<this.tabs.length; i++) {
					Event.observe(this.tabs[i], 'click', this.__Click.bindAsEventListener(this));
				}
				
				// watch click on close button
				this.closeButton = $$('div.packages-tooltip-close a img');
				
				for(var i=0; i<this.closeButton.length; i++) {
                        var element = this.closeButton[i];
                        Event.observe(element, 'click', this.hideContents.bindAsEventListener(this)); 
                };


			},
			/**
			 * Show a specific content item
			 */
			show: function(iWhich) {
				for (var i=0; i<this.contents.length; i++) {
					if (i == iWhich) {					    
						this.contents[i].style.display = 'block';
					} else {
						this.contents[i].style.display = 'none';
					}
				}
			},
				
				
			hideContents: function(e) {
			    Event.stop(e);
			    var contentDivs = this.contents;
			    for (var i=0; i<contentDivs.length; i++) {
			        contentDivs[i].style.display = 'none';
			    }
			},
			
			/**
			 * Deal with a clicked link
			 */
			__Click: function(e) {
				var e = e || window.event;
				Event.stop(e);
				var element = Event.element(e);
				
				for (var i=0; i<this.tabs.length; i++) {
					if (this.tabs[i] == element) {
						this.show(i);									
					}
				}
			}
		});
		
		Event.observe(window, 'load', function()
        {
         // tab switch could be used on any page, so it's run on every page

         popshow = new popReveal($$('a.view_info'), $$('div.perf_popup'));

        });
        
        
        
        var closeRemoveDiv = Class.create({
			initialize: function(removeAnchor) {
				this.removeAnch = removeAnchor;
			
				
				// Loop through each link and attach a click handler
				for(var i=0; i<this.removeAnch.length; i++) {
					Event.observe(this.removeAnch[i], 'click', this.__Click.bindAsEventListener(this));
				}
			},
				
			/**
			 * Hide Remove Anchor Div
			 */
			__Click: function(e) {
			    var e = e || window.event;
				Event.stop(e);
				$$('div.removeDiv')[0].hide();
			}			
				
        });
        


// *** end: popup links ***
// *** start: text input default text ***
/* text input default text (stored in <label for="" title="default text"/>*/
var DefaultText = Class.create({
	initialize: function(label){
		var elLabel = $(label);
		
		if(!elLabel){return;}
		
		var clearHandler = this.clearDefaultText.bindAsEventListener(this);
		var replaceHandler = this.replaceDefaultText.bindAsEventListener(this);
		
		var txtInput = $(elLabel.readAttribute('for'));
		
		
		if(txtInput){
			// add default text to text input from label's title
			txtInput.defaultText = elLabel.readAttribute('title');
			txtInput.observe('focus', clearHandler);
			txtInput.observe('blur', replaceHandler);
			
			//set the initial default text
			if(txtInput.value == ''){
				txtInput.value = txtInput.defaultText;
			}
		}
	},
	
	clearDefaultText: function(e){
		var elTxtInput = Event.findElement(e, 'input');
		if (elTxtInput.value == elTxtInput.defaultText) {
			elTxtInput.value = '';
		}		
	},
	
	replaceDefaultText: function(e){
		var elTxtInput = Event.findElement(e, 'input');
		if (elTxtInput.value == '' && elTxtInput.defaultText) {
		  elTxtInput.value = elTxtInput.defaultText;
		}	
	}
});
// *** end: text input default text ***
