/******************************************************************************
 
	The Kimili (KML) Object 

 ******************************************************************************/

if (!KML) {var KML = new Object();};


/******************************************************************************

	KML.Screen Module - Version 1.0
	
	Dependencies:	None

 ******************************************************************************/

KML.Screen = {
		getWidth		: function() {
			return (self.screen.availWidth) ? self.screen.availWidth : self.screen.width;
		},
		getHeight		: function() {
			return (self.screen.availHeight) ? self.screen.availHeight : self.screen.height;
		}
	};
	
	

/******************************************************************************
 
	KML.Window Module - Version 1.0 
	
	Dependencies:	KML.Document,
					KML.Screen

 ******************************************************************************/

KML.Window = {
		getHeight		: function() {
			if (document.all) {  return (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight; }
			else { return window.innerHeight; }
		},		
		getWidth		: function() {
			if (document.all) {  return (document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth; }
			else { return window.innerWidth; }
		},
		getOuterHeight	: function() {
			return (self.outerHeight) ? self.outerHeight : null;
		},
		getOuterWidth	: function() {
			return (self.outerWidth) ? self.outerWidth : null;			
		},	
		popup			: function(url,title,width,height,config) {
			var args	= 'width=' + width + ',height=' + height + ',left=' + (screen.width / 2 - width / 2) + ', ' + config;
			var newwin	= window.open(url,title,args);			
			newwin.focus();
		},
		center			: function() {
			var ww	= (KML.Window.getOuterWidth()) ? KML.Window.getOuterWidth() : KML.Window.getWidth() + 64;
			var wh	= (KML.Window.getOuterHeight()) ? KML.Window.getOuterHeight() : KML.Window.getHeight() + 72;
			self.moveTo(((KML.Screen.getWidth() / 2) - (ww / 2)),((KML.Screen.getHeight() / 2) - (wh / 2)));
		},
		resizeToContent	: function() {
			var ho	= (KML.Window.getOuterWidth()) ? KML.Window.getOuterWidth() - KML.Window.getWidth() : 32;
			var vo	= (KML.Window.getOuterHeight()) ? KML.Window.getOuterHeight() - KML.Window.getHeight() : 72;
			var sh	= parseInt(KML.Screen.getHeight());
			var sw	= parseInt(KML.Screen.getWidth());
			var dh	= parseInt(KML.Document.getHeight());
			var dw	= parseInt(KML.Document.getWidth());
			if (dh > (sh - vo)) {
				if(dw > (sw - ho)) {
					self.resizeTo((sw - ho),(sh - parseInt(vo / 4)));
				} else {
					self.resizeTo((dw + ho),(sh - parseInt(vo / 4)));
				}				
			} else {
				if(dw > (sw - ho)) {
					self.resizeTo((sw - ho),(dh + vo));
				} else {
					self.resizeTo((dw + ho),(dh + vo));
				}
			}
			KML.Window.center();
		}
	};



/******************************************************************************

	KML.Document Module - Version 1.0 

	Adds extra Document Methods
	Includes code from Jonathan Snook (www.snook.ca) and 
	Cameron Adams (www.themaninblue.com)
	
	Dependencies:	None

 ******************************************************************************/

KML.Document = {

		loadFunctions			: new Array(),
		getElementsByClassName	: function(n,c) {
			var a	= [];
		    var re	= new RegExp('(^| )'+c+'( |$)');
		    var els	= n.getElementsByTagName("*");
		    for(var i = 0; i < els.length; i++) {
		        if(re.test(els[i].className)) {
					a.push(els[i]);
				}
			}
		    return a;
		},
		fireOnloads				: function() {
			for (var x = 0; x < KML.Document.loadFunctions.length; x++) {
				KML.Document.loadFunctions[x]();
			}
		},
		addLoadListener			: function(f) {
			if (typeof window.addEventListener != 'undefined') {
				window.addEventListener('load',f,false);
			} else if (typeof document.addEventListener != 'undefined') {
				document.addEventListener('load',f,false);
			} else if (typeof window.attachEvent != 'undefined') {
				window.attachEvent('onload', f);
			} else {
				return false;
			}
			return true;
		},
		addUnloadListener		: function(f) {
			if (typeof window.addEventListener != 'undefined') {
				window.addEventListener('unload',f,false);
			} else if (typeof document.addEventListener != 'undefined') {
				document.addEventListener('unload',f,false);
			} else if (typeof window.attachEvent != 'undefined') {
				window.attachEvent('onunload', f);
			} else {
				return false;
			}
			return true;
		},
		attachEventListener		: function(targ,type,fn,cap) {
		    if (typeof targ.addEventListener != "undefined") {
		        targ.addEventListener(type,fn,cap);
		    } else if (typeof targ.attachEvent != "undefined") {
		        targ.attachEvent("on"+type,fn);
		    } else {
		        return false;
		    }
			return true;
		},
		removeEventListener		: function(targ,type,fn,cap) {
		    if (typeof targ.removeEventListener != "undefined") {
		        targ.removeEventListener(type,fn,cap);
		    } else if (typeof targ.detatchEvent != "undefined") {
		        targ.detatchEvent("on"+type,fn);
		    } else {
		        return false;
		    }
			return true;
		},
		getHeight				: function() {
			return document.body.offsetHeight;
		},
		getWidth				: function() {
			return document.body.offsetWidth;
		},
		getScrollHeight			: function() {
			if (window.innerHeight && window.scrollMaxY) {	
				return window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				return document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				return document.body.offsetHeight;
			}
		},
		getScrollWidth			: function() {
			if (window.innerHeight && window.scrollMaxX) {	
				return window.innerHeight + window.scrollMaxX;
			} else if (document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
				return document.body.scrollWidth;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				return document.body.offsetWidth;
			}
		},
		getYScroll				: function() {
			if (document.all) { return (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop }
			else { return self.pageYOffset; }
		}

	};

	KML.Document.addLoadListener(KML.Document.fireOnloads);



/******************************************************************************

	KML.Element Module - Version 1.0
	
	Dependencies:	None

 ******************************************************************************/

KML.Element = {
		getHeight			: function(e) {
			if(e) {
				return e.offsetHeight;
			}
		},
		getWidth			: function(e) {
			if(e) {
				return e.offsetWidth;
			}
		},
		getAbsolutePosition	: function(obj) {
		    var result = [0, 0];
		    while (obj != null) {
		        result[0] += obj.offsetTop;
		        result[1] += obj.offsetLeft;
		        obj = obj.offsetParent;
		    }
		    return result;
		}
	};



/******************************************************************************

	KML.Utils Module - Version 1.0

	Dependencies:	None

 ******************************************************************************/

KML.Utils	= {

		getKeypress			: function(e) {
			if (!e) e = window.event;
			var keycode = (e.which) ? e.keyCode : e.which;
			return String.fromCharCode(keycode).toLowerCase();
		},
		getRequestParameter	: function(param) {
			var q = document.location.search || document.location.href.hash;
			if(q){
				var startIndex = q.indexOf(param +"=");
				var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
				if (q.length > 1 && startIndex > -1) {
					return q.substring(q.indexOf("=", startIndex)+1, endIndex);
				}
			}
			return "";
		}
	};



/******************************************************************************

	KML.XML Module - Version 1.0 

	Dependencies:	None

 ******************************************************************************/

KML.XML	= {
		stripWhitespace	: function(n) {
			for (var i = 0; i < n.childNodes.length; i++) {
				if(n.childNodes[i].nodeType == 3) {
					var j = 0;
					var emptyNode = true;
					for(j = 0;j < n.childNodes[i].nodeValue.length; j++) {
						if(n.childNodes[i].nodeValue.charCodeAt(j) > 32) {
							emptyNode = false;
							break;
						}
					}
					if(emptyNode) {
						var t = n.removeChild(n.childNodes[i]);
					}
				}
			}

			for(var k = 0; k < n.childNodes.length; k++) {
				KML.XML.stripWhitespace(n.childNodes[k]);
			}
		},
		removeChildren	: function(n) {
			if (n) {
				while (n.hasChildNodes()) n.removeChild(n.firstChild);
			}

		}
	}



/******************************************************************************

	KML.Lightbox Module - Version 1.0 
	
	Modified from Lokesh Dhakar's original code
	available from http://www.huddletogether.com/projects/lightbox/
	
	Dependencies:	KML.Window,
					KML.Document,
					KML.Element,
					KML.Flash,
					KML.Utils,
					KML.XML

 ******************************************************************************/

KML.Lightbox	= {
	
		scaledMessage	: 'scaled',
		viewFSMessage	: 'view full size',
		loadingImage	: 'images/loadingAnimation.gif',		
		closeButton		: 'images/close.gif',
		lightboxId		: 'lightbox',
		overlayId		: 'lb_overlay',
		lightboxImageId	: 'lb_image',
		closeButtonId	: 'lb_closebutton',
		captionId		: 'lb_caption',
		scaledId		: 'lb_scaledmessage',
		loadingImageId	: 'lb_loading',
		detailsId		: 'lb_details',
		validExts		: ['jpg','jpeg','gif','png','swf','flv'],
		fullImages		: new Array(),
			
		show			: function(l) {
			
			var ext					= l.href.substring(l.href.lastIndexOf(".") + 1,l.href.length).toLowerCase();
			var useLB				= false;
			
			for (var e = 0; e < KML.Lightbox.validExts.length; e++) {
				if (ext == KML.Lightbox.validExts[e]) {
					useLB = true;
					break;
				}
			}
			
			if (useLB) {
				var objOverlay 			= document.getElementById(KML.Lightbox.overlayId);
				var objLightbox			= document.getElementById(KML.Lightbox.lightboxId);
				var objCaption			= document.getElementById(KML.Lightbox.captionId);
				var objLoadingImage		= document.getElementById(KML.Lightbox.loadingImageId);
				var objLightboxDetails	= document.getElementById(KML.Lightbox.detailsId);
				var objCloseLink		= objLightbox.firstChild;

				// set height of Overlay to take up whole page and show
				objOverlay.style.display	= 'block';
				objOverlay.style.height		= KML.Document.getScrollHeight() + 500 + "px";
				
				// center loadingImage if it exists
				if (objLoadingImage) {
					objLoadingImage.style.display = 'block';
					KML.Lightbox.center(objLoadingImage);			
				}
			
				var preloaded = false;
				var full;
			
				for (var x = 0; x < KML.Lightbox.fullImages.length; x++) {
					full = KML.Lightbox.fullImages[x];
					if (l.href == full.uri) {
						preloaded = true;
						break;
					}
				}
				
				if (ext != "swf" && ext != "flv") {
			
					if (!preloaded) {
				
						full = new Object();
				
						full.uri			= l.href;
						full.capt			= l.getAttribute('title') ? l.getAttribute('title') : '';
						full.recall			= false;
						full.preload		= new Image();
						full.preload.onload	= function() {
						
							var img			= document.createElement("img");
							img.src			= full.uri;
							img.id			= KML.Lightbox.lightboxImageId;
					
							objCloseLink.appendChild(img);
					
							img.ow			= KML.Element.getWidth(img);
							img.oh			= KML.Element.getHeight(img);
							
							// Fixing some funky behaivor in Safari
							if (img.ow <= 2 || img.oh <= 2) {
								if (!full.recall) {
									full.recall = true;
									img.parentNode.removeChild(img);
									KML.Lightbox.show(l);
								}
							}
					
							KML.Lightbox.scale(img);
					
							if (img.scaled) {
								var scaled				= new Object();
								scaled.container		= document.createElement('em');
								scaled.container.id		= KML.Lightbox.scaledId;
								scaled.fullLnk			= document.createElement('a');
								scaled.fullLnk.href		= full.uri;
								scaled.fullLnk.onclick	= function() {
									var scale	= .8;
									var w = parseInt(KML.Screen.getWidth() * scale);
									var h = parseInt(KML.Screen.getHeight() * scale);
									KML.Window.popup(this.href,'fullImageWin',w,h,'scrollbars=yes,resizable=yes');
									KML.Lightbox.hide();
									return false;
								}
								scaled.fullLnk.appendChild(document.createTextNode(KML.Lightbox.viewFSMessage));
						
								scaled.container.appendChild(document.createTextNode('(' + KML.Lightbox.scaledMessage + ' - '));
								scaled.container.appendChild(scaled.fullLnk);
								scaled.container.appendChild(document.createTextNode(')'));
							}
					
							if(full.capt != '' || scaled) {
								objCaption.style.display = 'block';
								if (full.capt != '') {
									full.capt += ' ';
									objCaption.appendChild(document.createTextNode(full.capt));
								}
								if (scaled) {
									objCaption.appendChild(scaled.container);
								}
							} else {
								objCaption.style.display = 'none';
							}
					
							if (scaled) delete scaled;
					
							KML.Lightbox.center(objLightbox);

							if (objLoadingImage) objLoadingImage.style.display = 'none';

							// Hide select boxes as they will 'peek' through the image in IE
							if (document.all){
								selects = document.getElementsByTagName("select");
						        for (i = 0; i != selects.length; i++) {
						                selects[i].style.visibility = "hidden";
						        }
							}					

							KML.Document.attachEventListener(document,"keypress",KML.Lightbox.captureCloseKey,false);
							KML.Document.attachEventListener(window,"resize",KML.Lightbox.scaleImage,false);
							KML.Document.attachEventListener(window,"resize",KML.Lightbox.centerLb,false);
				
							delete img;
							objLightbox.style.visibility	= 'visible';

							return false;
					
						}
				
						i = KML.Lightbox.fullImages.length;
						KML.Lightbox.fullImages[i] = full;
				
					}

					full.preload.src = full.uri;
				
				} else if (ext != "flv") {	// Handle swf files
					
					// Create a container to drop the Flash into.
					var fw			= document.createElement("div");
					fw.id			= KML.Lightbox.lightboxImageId;			
					objCloseLink.appendChild(fw);
					
					// we don't know the width and height
					var w	= KML.Window.getWidth() * .8;
					var h	= KML.Window.getHeight() * .8;	

					var fo 	= new KML.Flash.object(l.href,'lb_flash',w,h,8,'#FFFFFF',true);
					fo.addParam("scale", "noscale");
					fo.write(KML.Lightbox.lightboxImageId);
					
					var capt	= l.getAttribute('title');
					
					if(capt != '' && capt !=null) {
						objCaption.style.display = 'block';
						objCaption.appendChild(document.createTextNode(capt));
					} else {
						objCaption.style.display = 'none';
					}
					
					KML.Lightbox.center(objLightbox);

					if (objLoadingImage) objLoadingImage.style.display = 'none';

					// Hide select boxes as they will 'peek' through the image in IE
					if (document.all){
						selects = document.getElementsByTagName("select");
				        for (i = 0; i != selects.length; i++) {
				                selects[i].style.visibility = "hidden";
				        }
					}					

					KML.Document.attachEventListener(document,"keypress",KML.Lightbox.captureCloseKey,false);
					KML.Document.attachEventListener(window,"resize",KML.Lightbox.centerLb,false);
					
					objLightbox.style.visibility	= 'visible';
					
				} else {	// Handle flv files
					// Create a container to drop the Flash into.
					var fw			= document.createElement("div");
					fw.id			= KML.Lightbox.lightboxImageId;			
					objCloseLink.appendChild(fw);
					
					// we don't know the width and height
					var w	= KML.Window.getWidth() * .8;
					var h	= KML.Window.getHeight() * .8;			
					
					var myloc = window.location.href;
					var locarray = myloc.split("/");
					delete locarray[(locarray.length-1)];
					var arraytext = locarray.join("/");
					
					newHref = arraytext + 'flash/video/flvPlayer.swf?videoLoc=' + l.href;
				
					var fo 	= new KML.Flash.object(newHref,'lb_flash',w,h,8,'#FFFFFF',true);
					fo.addParam("wmode", "transparent");
					fo.write(KML.Lightbox.lightboxImageId);
					
					var capt	= l.getAttribute('title');
					
					if(capt != '' && capt !=null) {
						objCaption.style.display = 'block';
						objCaption.appendChild(document.createTextNode(capt));
					} else {
						objCaption.style.display = 'none';
					}
					
					KML.Lightbox.center(objLightbox);

					if (objLoadingImage) objLoadingImage.style.display = 'none';

					// Hide select boxes as they will 'peek' through the image in IE
					if (document.all){
						selects = document.getElementsByTagName("select");
				        for (i = 0; i != selects.length; i++) {
				                selects[i].style.visibility = "hidden";
				        }
					}					

					KML.Document.attachEventListener(document,"keypress",KML.Lightbox.captureCloseKey,false);
					KML.Document.attachEventListener(window,"resize",KML.Lightbox.centerLb,false);
					
					objLightbox.style.visibility	= 'visible';
				}
				
				return false;
			}
			
			return true;

		},
		hide			: function() {
			var objOverlay 		= document.getElementById(KML.Lightbox.overlayId);
			var objLightbox 	= document.getElementById(KML.Lightbox.lightboxId);
			var objImage		= document.getElementById(KML.Lightbox.lightboxImageId);
			var objCaption		= document.getElementById(KML.Lightbox.captionId);
			
			KML.XML.removeChildren(objImage);
			objImage.parentNode.removeChild(objImage);
			KML.XML.removeChildren(objCaption);
			
			objLightbox.style.visibility	= 'hidden';
			objOverlay.style.display 		= 'none';

			// make select boxes visible in IE
			if (document.all) {
				selects = document.getElementsByTagName("select");
			    for (i = 0; i != selects.length; i++) {
					selects[i].style.visibility = "visible";
				}				
			}

			// disable keypress listener
			KML.Document.removeEventListener(document,"keypress",KML.Lightbox.captureCloseKey,false);
			KML.Document.removeEventListener(window,"resize",KML.Lightbox.scaleImage,false);
			KML.Document.removeEventListener(window,"resize",KML.Lightbox.centerLb,false);
		},		
		scale			: function(e) {
			if (e) {
				var shift	= .8;
				var wh		= KML.Window.getHeight();
				var ww		= KML.Window.getWidth();
				var eh		= e.offsetHeight;
				var ew		= e.offsetWidth;
				var oh		= (e.oh) ? e.oh	: eh;
				var ow		= (e.ow) ? e.ow	: ew;		
				if ((oh > wh) || (ow > ww)) {
					// Height based
					eh = wh * shift;
					ew = ow * (eh / oh);
					// Width based
					if (ew > (ww * shift)) {
						ew = ww * shift;
						eh = oh * (ew / ow);
					}
					e.style.width	= parseInt(ew) + "px";
					e.style.height	= parseInt(eh) + "px";
					e.scaled		= true;
				} else {
					e.style.width	= (e.ow) ? e.ow + "px" : "auto";
					e.style.height	= (e.oh) ? e.oh + "px" : "auto";
					e.scaled		= false;
				}
			}
		},		
		center			: function(e) {
			if (e) {
				var wh		= KML.Window.getHeight();
				var pw		= KML.Document.getWidth();
				var ys		= KML.Document.getYScroll();
				var eh		= KML.Element.getHeight(e);
				var ew		= KML.Element.getWidth(e);
				e.style.top = (ys + ((wh - eh) / 2) + 'px');
				e.style.left = (((pw - ew) / 2) + 'px');
			}
		},		
		scaleImage		: function() {
			KML.Lightbox.scale(document.getElementById(KML.Lightbox.lightboxImageId));
		},
		centerLb		: function() {
			KML.Lightbox.center(document.getElementById(KML.Lightbox.lightboxId));
		},
		captureCloseKey	: function() {
			var k	= KML.Utils.getKeypress();
			if (k == 'x') KML.Lightbox.hide();
		},
		resizeOverlay	: function() {
			document.getElementById(KML.Lightbox.overlayId).style.width = KML.Window.getWidth() + "px";
		},
		init			: function() {
			
			if (!document.getElementsByTagName){ return; }
			var links = document.getElementsByTagName("a");
			for (var i = 0; i < links.length; i++){
				var link = links[i];

				if (link.getAttribute("href") && (link.getAttribute("rel") == "lightbox")){
					link.onclick = function () {return KML.Lightbox.show(this);}
				}
			}
			
			var lb		= new Object();			
			var objBody = document.getElementsByTagName("body").item(0);

			// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
			lb.overlay 					= document.createElement("div");
			lb.overlay.id				= KML.Lightbox.overlayId;
			lb.overlay.onclick 			= function () {KML.Lightbox.hide(); return false;}
			lb.overlay.style.display	= 'none';
			lb.overlay.style.position	= 'absolute';
			lb.overlay.style.top		= '0';
			lb.overlay.style.left		= '0';
			lb.overlay.style.zIndex		= '1500';
			if (document.all) {
				// Some F'd up shit in IE
				lb.overlay.style.width		= KML.Window.getWidth() + "px";
				KML.Document.attachEventListener(window,"resize",KML.Lightbox.resizeOverlay,false);
			} else {
				lb.overlay.style.width		= "100%";
			}
		 	
		
			objBody.insertBefore(lb.overlay, objBody.firstChild);

			// preload and create loader image
			lb.loading			= new Image();

			// if loader image found, create link to hide lightbox and create loadingimage
			lb.loading.onload	= function(){
			
				lb.loading.lnk					= document.createElement("a");
				lb.loading.lnk.href				= '#';
				lb.loading.lnk.onclick			= function () {KML.Lightbox.hide(); return false;}
				lb.overlay.appendChild(lb.loading.lnk);

				lb.loading.img					= document.createElement("img");
				lb.loading.img.src				= KML.Lightbox.loadingImage;
				lb.loading.img.id				= KML.Lightbox.loadingImageId;
				lb.loading.img.style.position	= 'absolute';
				lb.loading.img.style.zIndex		= '1700';
				lb.loading.lnk.appendChild(lb.loading.img);

				lb.loading.onload=function(){};	//	clear onLoad, as IE will flip out w/animated gifs

				return false;
			}

			lb.loading.src = KML.Lightbox.loadingImage;

			// create lightbox div, same note about styles as above
			lb.lb					= document.createElement("div");
			lb.lb.id				= KML.Lightbox.lightboxId;
			lb.lb.style.visibility 	= 'hidden';
			lb.lb.style.position	= 'absolute';
			lb.lb.style.zIndex		= '1600';	
			objBody.insertBefore(lb.lb, lb.overlay.nextSibling);

			// create link
			lb.lb.lnk				= document.createElement("a");
			lb.lb.lnk.href			= '#';
			lb.lb.lnk.title			= 'Click to close';
			lb.lb.lnk.onclick 		= function () {KML.Lightbox.hide(); return false;}
			lb.lb.appendChild(lb.lb.lnk);

			// preload and create close button image
			lb.preloadClose				= new Image();

			// if close button image found, 
			lb.preloadClose.onload		= function(){

				lb.close				= document.createElement("img");
				lb.close.src 			= KML.Lightbox.closeButton;
				lb.close.id				= KML.Lightbox.closeButtonId;
				lb.close.style.position = 'absolute';
				lb.close.style.zIndex	= '2000';
				lb.lb.lnk.appendChild(lb.close);

				return false;
			}

			lb.preloadClose.src = KML.Lightbox.closeButton;
/*
			lb.details 			= document.createElement("div");
			lb.details.id		= KML.Lightbox.detailsId;
			lb.lb.appendChild(lb.details);
*/
			lb.capt					= document.createElement("div");
			lb.capt.id				= KML.Lightbox.captionId;
			lb.capt.style.display	= 'none';
			lb.lb.appendChild(lb.capt);
			
			delete lb;			

		}
		
	};
	
	KML.Document.loadFunctions.push(KML.Lightbox.init);


/******************************************************************************

	KML.Flash Module - Version 1.0 

	Based on Geoff Stearn's Flash Object code (v. 1.3)
	available at http://blog.deconcept.com/flashobject/

	Dependencies:	KML.Utils

******************************************************************************/

KML.Flash = {	
		object				: function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey) {
			if (!document.createElement || !document.getElementById) return;
			this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
			this.skipDetect = KML.Utils.getRequestParameter(this.DETECT_KEY);
			this.params = new Object();
			this.variables = new Object();
			this.attributes = new Array();
			this.useExpressInstall = useExpressInstall;

			if(swf) this.setAttribute('swf', swf);
			if(id) this.setAttribute('id', id);
			if(w) this.setAttribute('width', w);
			if(h) this.setAttribute('height', h);
			if(ver) this.setAttribute('version', new KML.Flash.playerVersion(ver.toString().split(".")));
			this.installedVer = KML.Flash.getVersion(this.getAttribute('version'), useExpressInstall);
			if(c) this.addParam('bgcolor', c);
			var q = quality ? quality : 'high';
			this.addParam('quality', q);
			var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
			this.setAttribute('xiRedirectUrl', xir);
			this.setAttribute('redirectUrl', '');
			if(redirectUrl) this.setAttribute('redirectUrl', redirectUrl);
		},
		getVersion			: function(reqVer, xiInstall){
			var PlayerVersion = new KML.Flash.playerVersion(0,0,0);
			if(navigator.plugins && navigator.mimeTypes.length) {
				var x = navigator.plugins["Shockwave Flash"];
				if(x && x.description) {
					PlayerVersion = new  KML.Flash.playerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
				}
			} else {
				try {
					var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
					for (var i=3; axo!=null; i++) {
						axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
						PlayerVersion = new KML.Flash.playerVersion([i,0,0]);
					}
				} catch(e) {}
				if (reqVer && reqVer.major > PlayerVersion.major) return PlayerVersion;
				if (!reqVer || ((reqVer.minor != 0 || reqVer.rev != 0) && PlayerVersion.major == reqVer.major) || PlayerVersion.major != 6 || xiInstall) {
					try {
					PlayerVersion = new KML.Flash.playerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
					} catch(e) {}
				}
			}
			return PlayerVersion;
		},	
		playerVersion		: function(arrVersion){
			this.major = parseInt(arrVersion[0]) || 0;
			this.minor = parseInt(arrVersion[1]) || 0;
			this.rev = parseInt(arrVersion[2]) || 0;
		}
	}

	KML.Flash.object.prototype 	= {
		setAttribute		: function(name, value){
			this.attributes[name] = value;
		},
		getAttribute		: function(name) {
			return this.attributes[name];
		},
		addParam			: function(name, value){
			this.params[name] = value;
		},
		getParams			: function(){
			return this.params;
		},
		addVariable			: function(name, value){
			this.variables[name] = value;
		},
		getVariable			: function(name){
			return this.variables[name];
		},
		getVariables		: function(){
			return this.variables;
		},
		createParamTag		: function(n, v){
			var p = document.createElement('param');
			p.setAttribute('name', n);
			p.setAttribute('value', v);
			return p;
		},
		getVariablePairs	: function(){
			var variablePairs = new Array();
			var key;
			var variables = this.getVariables();
			for(key in variables){
				variablePairs.push(key +"="+ variables[key]);
			}
			return variablePairs;
		},
		getFlashHTML		: function() {
			var flashNode = "";
			if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
				if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "PlugIn");
				flashNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
				flashNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
				var params = this.getParams();
				for(var key in params){ flashNode += [key] +'="'+ params[key] +'" ';
			}
			var pairs = this.getVariablePairs().join("&");
			if (pairs.length > 0) flashNode += 'flashvars="'+ pairs +'"';
			flashNode += '/>';
			} else { // PC IE
				if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "ActiveX");
				flashNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
				flashNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />"';
				var params = this.getParams();
				for(var key in params) {
					flashNode += '<param name="'+ key +'" value="'+ params[key] +'">';
				}
				var pairs = this.getVariablePairs().join("&");
				if(pairs.length > 0) flashNode += '<param name="flashvars" value="'+ pairs +'">';
			}
			return flashNode;
		},
		write				: function(elementId){
			if(this.useExpressInstall) {
				// check to see if we need to do an express install
				var expressInstallReqVer = new KML.Flash.playerVersion([6,0,65]);
				if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
					this.setAttribute('doExpressInstall', true);
					this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
					document.title = document.title.slice(0, 47) + " - Flash Player Installation";
					this.addVariable("MMdoctitle", document.title);
				}
			} else {
				this.setAttribute('doExpressInstall', false);
			}
			if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
				var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
				n.innerHTML = this.getFlashHTML();
			}else{
				if(this.getAttribute('redirectUrl') != "") {
					document.location.replace(this.getAttribute('redirectUrl'));
				}
			}
		}
	}

	KML.Flash.playerVersion.prototype.versionIsValid	= function(fv) {
		if(this.major < fv.major) return false;
		if(this.major > fv.major) return true;
		if(this.minor < fv.minor) return false;
		if(this.minor > fv.minor) return true;
		if(this.rev < fv.rev) return false;
		return true;
	}

	// For Universal Compatibility
	var FlashObject	= KML.Flash.object;
	

/******************************************************************************

	Add methods for older browser support if needed

 ******************************************************************************/

if (Array.prototype.push == null) {
	Array.prototype.push = function(item) {
		this[this.length] = item; return this.length;
	}
}

if (document.all && !document.getElementById) {
	document.getElementById= function(id) {
		return(document.all(id));
	}
	document.getElementsByTagName= function(id) {
		return(document.all.tags(id));
	}
}

if(document.layers) {
	document.getElementById= function(id) {
		return(document.layers[id]);
	}
}