// Search Function to make dynamic map work on the About --> Members Page (about_members.php)

function showMapMembers(pic, text, a) {
	document.getElementById('Members_TukwilaPic').style.visibility = "hidden";
	document.getElementById('Members_BellevuePic').style.visibility = "hidden";
	document.getElementById('Members_CovingtonPic').style.visibility = "hidden";
	document.getElementById('Members_IssaquahPic').style.visibility = "hidden";
	document.getElementById('Members_KirklandPic').style.visibility = "hidden";
	document.getElementById('Members_RedmondPic').style.visibility = "hidden";
	document.getElementById('Members_SammamishPic').style.visibility = "hidden";
	document.getElementById('Members_SkywayPic').style.visibility = "hidden";
		
	document.getElementById('Members_OverviewText').style.visibility = "hidden";
	document.getElementById('Members_TukwilaText').style.visibility = "hidden";
	document.getElementById('Members_BellevueText').style.visibility = "hidden";
	document.getElementById('Members_CovingtonText').style.visibility = "hidden";
	document.getElementById('Members_IssaquahText').style.visibility = "hidden";
	document.getElementById('Members_KirklandText').style.visibility = "hidden";
	document.getElementById('Members_RedmondText').style.visibility = "hidden";
	document.getElementById('Members_SammamishText').style.visibility = "hidden";
	document.getElementById('Members_SkywayText').style.visibility = "hidden";


	document.getElementById('link_overview').style.color = "#88a547";
	document.getElementById('link_tukwila').style.color = "#88a547";
	document.getElementById('link_bellevue').style.color = "#88a547";
	document.getElementById('link_covington').style.color = "#88a547";
	document.getElementById('link_issaquah').style.color = "#88a547";
	document.getElementById('link_kirkland').style.color = "#88a547";
	document.getElementById('link_redmond').style.color = "#88a547";
	document.getElementById('link_sammamish').style.color = "#88a547";
	document.getElementById('link_skyway').style.color = "#88a547";

	// Reveal Active Map Element
	document.getElementById(pic).style.visibility = "visible";
	document.getElementById(text).style.visibility = "visible";
	document.getElementById(a).style.color = "#007dc3";
}

// Search Function to make dynamic map work on the Community --> Serving Communities Page (serving_communities.php)

function showMapCommunity(pic, text, a) {
	document.getElementById('ServingCommunities_TukwilaPic').style.visibility = "hidden";
	document.getElementById('ServingCommunities_BellevuePic').style.visibility = "hidden";
	document.getElementById('ServingCommunities_CovingtonPic').style.visibility = "hidden";
	document.getElementById('ServingCommunities_IssaquahPic').style.visibility = "hidden";
	document.getElementById('ServingCommunities_KirklandPic').style.visibility = "hidden";
	document.getElementById('ServingCommunities_RedmondPic').style.visibility = "hidden";
	document.getElementById('ServingCommunities_SammamishPic').style.visibility = "hidden";
	document.getElementById('ServingCommunities_SkywayPic').style.visibility = "hidden";
		
	document.getElementById('ServingCommunities_OverviewText').style.visibility = "hidden";
	document.getElementById('ServingCommunities_TukwilaText').style.visibility = "hidden";
	document.getElementById('ServingCommunities_BellevueText').style.visibility = "hidden";
	document.getElementById('ServingCommunities_CovingtonText').style.visibility = "hidden";
	document.getElementById('ServingCommunities_IssaquahText').style.visibility = "hidden";
	document.getElementById('ServingCommunities_KirklandText').style.visibility = "hidden";
	document.getElementById('ServingCommunities_RedmondText').style.visibility = "hidden";
	document.getElementById('ServingCommunities_SammamishText').style.visibility = "hidden";
	document.getElementById('ServingCommunities_SkywayText').style.visibility = "hidden";

	document.getElementById('link2_tukwila').style.backgroundPosition = "0px 0px";
	document.getElementById('link2_bellevue').style.backgroundPosition = "0px 0px";
	document.getElementById('link2_covington').style.backgroundPosition = "0px 0px";
	document.getElementById('link2_issaquah').style.backgroundPosition = "0px 0px";
	document.getElementById('link2_kirkland').style.backgroundPosition = "0px 0px";
	document.getElementById('link2_redmond').style.backgroundPosition = "0px 0px";
	document.getElementById('link2_sammamish').style.backgroundPosition = "0px 0px";
	document.getElementById('link2_skyway').style.backgroundPosition = "0px 0px";

		
	// Reveal Active Map Element
	if(a == "link2_sammamish" || a == "link2_skyway"){
	document.getElementById(a).style.backgroundPosition = "0 -35px";
	} else {
	document.getElementById(a).style.backgroundPosition = "0 -15px";
	}
	document.getElementById(pic).style.visibility = "visible";
	document.getElementById(text).style.visibility = "visible";
}


// Change Tab BG on navigation so tab sticks by Mark

function changebg(el, px){
	var style = document.getElementById(el).style;
	style.backgroundPosition = "0px "+px+"px";		
}


//	---------------------------------------------------------------------------
//	Script: string.cnet.js
//	These are mootools authored extensions designed to allow prototype.lite libraries run in this environment.
//	
//	Dependancies:
//	mootools - <Moo.js>, <String.js>, <Array.js>
//	
//	Author:
//	Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>
//	
//	Class: String
//	This extends the <String> prototype.

String.implement({
	stripTags: function() {
		return this.replace(/<\/?[^>]+>/gi, '');
	},
	stripScripts: function() {
		return this.replace(/<script[^>]*?>.*?<\/script>/img, '');
	},
	evalScripts: function() {
		var scripts = this.match(/<script[^>]*?>.*?<\/script>/g);
		if(scripts) scripts.each(function(script){
			eval(script.replace(/^<script[^>]*?>/, '').replace(/<\/script>$/, ''));
		});
	},
	replaceAll: function(searchValue, replaceValue, regExOptions) {
		return this.replace(new RegExp(searchValue, $pick(regExOptions,'gi')), replaceValue);
	},
	urlEncode: function() {
		if (this.indexOf('%') > -1) return this;
		else return escape(this);
	},
	parseQuery: function() {
		var vars = this.split(/[&;]/);
		var rs = {};
		if (vars.length) vars.each(function(val) {
			var keys = val.split('=');
			if (keys.length && keys.length == 2) rs[encodeURIComponent(keys[0])] = encodeURIComponent(keys[1]);
		});
		return rs;
	},
	tidy: function() {
		var txt = this.toString();
		$each({
			"[\xa0\u2002\u2003\u2009]": " ",
			"\xb7": "*",
			"[\u2018\u2019]": "'",
			"[\u201c\u201d]": '"',
			"\u2026": "...",
			"\u2013": "-",
			"\u2014": "--"
		}, function(value, key){
			txt = txt.replace(new RegExp(key, 'g'), value);
		});
		return txt;
	}
});


//	---------------------------------------------------------------------------
//	FUNCTION:	fixHeight()
//	LAST MODIFIED: 09/28/07
//	AUTHOR:	Ryan J. Salva
//
//	Utility function designed to fix any layout using aboslute positioning for column
//
//	IMPLEMENTATION:
//	Add fixHeight(window,'load',fixHeight('Column1','Column2'... 'Column99') to any page
//	Most Capitol Media websites use the column ids: Left, Right, Middle and Canvas

function fixHeight() {
	var x = 0;
	for (i=0;i<arguments.length;i++) {
		if ($(arguments[i]) && $(arguments[i]).scrollHeight > x) x = $(arguments[i]).scrollHeight;
	}
	
	if (x < 375) x = 375;
	
	var wrapper;
	var right;
	var left;
	if (wrapper = $('Wrapper')) wrapper.setStyle('height',x);
	if (left = $('Left')) left.setStyle('height',x);
	if (right = $('Right')) right.setStyle('height',x);
}






//	---------------------------------------------------------------------------
//	CLASS:		Menu()
//	AUTHOR:		Ryan J. Salva
//	REVISED:	December 2007
//
//	Creates a drop-down menu for navigation. Also Corrects Windows IE support 
//	for LI:hover and adds an <IFRAME> behind drop-down menus to keep the 
//	menu above <SELECT> elements.
//
//	REQUIREMENTS:
//	Styles found in default.css
//	
//	TESTED IN:
//	Windows: IE 6, Firefox 1, Opera 8
//	Mac: IE 5.2, Firefox 1, Safari 1

var Menu = new Class({
	Implements: Options,
	options: {
		iframe: false,
		onComplete: Class.empty,
		onStart: Class.empty
	},
	initialize: function(el,options){
		this.el = $(el);
		if (!$defined(this.el)) return false;
		this.setOptions(options);
		
		this.el.getElements('li').each(function(li,index) {
			li.addEvent('mouseenter',function() {
				this.addClass('hover');
			});
			li.addEvent('mouseleave',function() {
				this.removeClass('hover');
			});
		});
		if (this.options.iframe) this.addIframe();
	},
	addIframe: function() {
		this.el.getElements('ul').each(function(ul,index) {
			var coord = ul.getCoordinates();
			var iframe = new Element('iframe',{'src':'about:blank','styles':{
				overflow:'hidden',
				border:0,
				width: coord.width,
				height: coord.height,
				left: 0,
				top: 0,
				zIndex: -10,
				opacity: 0
			}});
			iframe.injectTop(ul);
			ul.setStyle('z-index',99);
		});
	}
});



//	---------------------------------------------------------------------------
//	CLASS:		FormTip(selector,options)
//	AUTHOR:		Ryan J. Salva
//	REVISED:	December 2008

var FormTip = new Class({
	Implements: Options,
	options: {
		className: 'FormTip',
		onComplete: Class.empty,
		onStart: Class.empty
	},
	initialize: function(selector,options){
		this.setOptions(options);
		this.els = $$(selector);
		this.els.each(function(el,index){
			el.addEvent('focus',this.show.bindWithEvent(this));
			el.addEvent('blur',this.hide.bindWithEvent(this));
		}.bind(this));
	},
	show: function(e) {
		var e = new Event(e);
		var el = e.target;
		if ($type(el) != 'element') return false;
		var title = el.getAttribute('title');
		if (!$defined(title)) return false;
		var pos = el.getPosition(el.getOffsetParent());
		var width = el.getWidth();
		this.tip = new Element('div',{'class':this.options.className,'styles':{
			opacity: 0,
			position: 'absolute',
			left: pos.x + width,
			top: pos.y
		}}).setText(title);
		this.tip.inject(el.getParent(),'inside');
		this.tip.tween('opacity',1); 
	},
	hide: function() {
		this.tip.remove();
	}
});




//	---------------------------------------------------------------------------
//	CLASS:		Modal();
//	OPTIONS:	speed: the transition speed (default:500)
//				maskColor: the background color of the mask (default: black)
//				width: default width of the dialog box (default:400px)
//				height: default height of the dialog box (default: auto)
//				classPrefix: used to define unique classes for each dialog box (default: "Modal")
//				onHide: event
//				onShow: event
//				onStart: event
//	AUTHOR:		Ryan J. Salva, http://www.capitolmedia.com
//	REVISED:	January 2008

Modal = new Class({
	Implements: [Events, Options],
	options: {
		speed: 500,
		maskColor: '#000000',
		width: 400,
		height: 'auto',
		classPrefix: 'Modal',
		onHide: Class.empty,
		onShow: Class.empty,
		onStart: Class.empty
	},
	initialize: function(options) {
		this.setOptions(options);
		this.isShowing = false;
		var classPrefix = this.options.classPrefix;
		this.mask = new Element('div', {
			'styles':{
				'position':'absolute',
				'top': 0,
				'left': 0,
				'opacity': 0,
				'height': (window.getHeight() > window.getScrollHeight()) ? window.getHeight() : window.getScrollHeight(),
				'width': '100%',
				'background':this.options.maskColor,
				'z-index': 9999
			},
			'class':classPrefix+'Mask'
		});
		this.pop = new Element('div',{
			'styles':{
				'position': 'absolute',
				'visibility': 'hidden',
				'width': '100%',
				'margin': 0,
				'z-index': 10000
			},
			'class':classPrefix+'Pop'
		});
		this.container = new Element('div',{
			'styles':{
				'margin':'0 auto'
			},
			'class':classPrefix+'Container'
		});
		this.close = new Element('div',{'class':classPrefix+'Close'}).adopt(new Element('a', {'href':'#', 'text':'Close'}));

		this.fade = new Fx.Tween(this.mask, {duration:this.options.speed});
		this.slide = new Fx.Tween(this.pop, {duration: this.options.speed});
		
		this.fireEvent('onStart');
	},
	show: function(el, title) {
		var classPrefix = this.options.classPrefix;
		switch($type(el)) {
			case 'element':
				this.el = new Element('div',{'styles':{'height':this.options.height}}).adopt(el.clone().cloneEvents(el));
				break;
			case 'string':
				this.el = new Element('div',{'styles':{'height':this.options.height},'html':el});
				break;
			default:
				return false;
				break;
		}
		var message = new Element('div').addClass(classPrefix+'Message').adopt(this.el);
		if(title) var title = new Element('div',{'text':title,'class':classPrefix+'Title'});
		
		if(this.isShowing) {
			this.container.adopt(title, message);
		} else {
			this.close.getElement('a').addEvent('click', function(event) {
				event.stop();
				this.hide();
			}.bind(this));
			window.addEvent('keydown', function(event) {
				if(event.key == 'esc') this.hide();
			}.bind(this));
			
			$$('object', 'select').setStyle('visibility', 'hidden');
			
			$$('body').adopt(this.mask, this.pop);
			this.container.adopt(this.close, title, message);
			this.container.inject(this.pop, 'inside').setStyle('width', this.options.width);
		}
		
		this.pop.setStyles({
			'top': window.getScroll().y - this.pop.getSize().y,
			'visibility':'visible'
		});

		this.fade.start('opacity',0.8);
		var slideTo = ((window.getSize().y - this.container.getSize().y) / 2 + window.getScroll().y);
		this.slide.start('top',slideTo);
		this.periodical = this.update.periodical(100, this);
		this.isShowing = true;
		this.fireEvent('onShow');
	},
	update: function() {
		var slideTo = ((window.getSize().y - this.container.getSize().y) / 2 + window.getScroll().y);
		this.slide.start('top',slideTo);
		var h = (window.getSize().y > window.getScrollSize().y) ? window.getSize().y : window.getScrollSize().y;
		this.mask.setStyle('height', h);
	},
	hide: function() {
		$$('object', 'select').setStyle('visibility', 'visible');
		$clear(this.periodical);
		this.slide.cancel();
		var slideTo = window.getScroll().y - this.pop.getSize().y;
		this.slide.start('top',slideTo).chain(function() {
			this.pop.destroy();
			this.fade.start('opacity',0).chain(function() {
				this.mask.destroy();
				this.isShowing = false;
				this.fireEvent('onHide');
			}.bind(this));
		}.bind(this));
	}
});

/*	---------------------------------------------------------------------------
	CLASS:		Layout(el[,columns])
	AUTHOR:		Ryan J. Salva, http://www.capitolmedia.com
	LICENSE:	MIT License, <http://en.wikipedia.org/wiki/MIT_License>	
	REVISED:	January 2008
	EXAMPLE:	<div id="Wrapper"><div id="Left">Foo</div><div id="Right">Bar</div></div>
				var x = new Layout('Wrapper',['Left','Right']);
	ABOUT:		Utility function designed to fix any layout using aboslute positioning for each column
				Adjusts the page to make wrapper as tall as the highest column (left, right, etc.)
				Most Capitol Media websites use the column ids: Left, Right, Middle and Canvas	
*/

var Layout = new Class({
	initialize: function(el,columns){
		this.columns = columns;
		this.el = $(el);
		if (!$defined(this.el)) return false;
		
		// this.el.setStyle('overflow','hidden');
		this.columns.each(function(col,index) {
			this.columns[index] = $(col);
		}.bind(this));
		this.columns = this.columns.clean();
		this.periodical = this.update.bind(this).periodical(200);
	},
	update: function() {
		var y = 0;
		this.columns.each(function(col,index) {
			var h = col.getCoordinates().height;
			if (h<375){ h = 375;}
			if(h > y) y = h;
		});
		this.el.get('tween',{property:'height',duration:100}).start(y);
	}
});

/* OPEN WINDOW */

function openWindow(url){
	my_window= window.open (url,"mywindow","status=0,scrollbars=0,width=600,height=530"); 
}

function openMovie(url){
	my_window= window.open (url,"mywindow","status=0,scrollbars=0,width=812,height=889"); 
}