function externalLinks()
	{
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++)
		{
		var anchor = anchors[i];
		try 
			{
			if (anchor.getAttribute("href") && (anchor.getAttribute("rel").indexOf("external")>-1))
			anchor.target = "_blank";
			}
		catch(e)
			{
			}
		}
	}

Event.observe(window, 'load', externalLinks);


function featured(iShowId)
	{
	if($('featured'+iShowId))
		{
		new Effect.BlindUp('featured'+iShowId, { duration: 1.0 });
		if($('featured'+(iShowId+1)))
			{
			new Effect.BlindDown('featured'+(iShowId+1), { duration: 1.0, queue: 'end' });
			setTimeout('featured('+(iShowId+1)+');', 5000);
			}
		else
			{
			new Effect.BlindDown('featured1', { duration: 1.0, queue: 'end' });
			setTimeout('featured(1)', 5000);
			}
		}
	
	}

function SlideShow()
	{
	this.aImages = new Array();
	this.aLinks = new Array();
	this.oImgElement;
	this.oLinkElement;
	this.iId = 0;
	this.isPaused = false;
	this.Timer;
	this.add = function()
		{
		this.aImages[this.aImages.length] = arguments[0];
		this.aLinks[this.aLinks.length] = arguments[1];
		PreloadImage = new Image(); 
		PreloadImage.src = arguments[0];
		}

	this.startShow = function()
		{
		this.oImgElement = arguments[0];
		this.oLinkElement = arguments[1];
		this.oImgElement.src = this.aImages[0];
		this.oLinkElement.href = this.aLinks[0];
		this.resetTimer();
		}
	this.nextSlide = function()
		{
		this.iId++;
		if(!this.aImages[this.iId])
			this.iId=0;
		new Effect.Opacity(this.oImgElement, {duration:0.3, from:1.0, to:0.01});
		setTimeout('$("'+this.oImgElement.identify()+'").src = "'+this.aImages[this.iId]+'"', 300);
		setTimeout('$("'+this.oLinkElement.identify()+'").href = "'+this.aLinks[this.iId]+'"', 300);
		setTimeout('new Effect.Opacity("'+this.oImgElement.identify()+'", {duration:0.3, from:0.01, to:1.0})', 350);
		}
	this.previousSlide = function()
		{
		this.iId--;
		if(!this.aImages[this.iId])
			this.iId=this.aImages.length-1;
		new Effect.Opacity(this.oImgElement, {duration:0.3, from:1.0, to:0.01});
		setTimeout('$("'+this.oImgElement.identify()+'").src = "'+this.aImages[this.iId]+'"', 300);
		setTimeout('$("'+this.oLinkElement.identify()+'").href = "'+this.aLinks[this.iId]+'"', 300);
		setTimeout('new Effect.Opacity("'+this.oImgElement.identify()+'", {duration:0.3, from:0.01, to:1.0})', 350);
		}
		
	this.pause = function()
		{
		this.isPaused = true;
		}
	this.resume = function()
		{
		this.isPaused = false;
		}
	this.resetTimer = function()
		{
		if(this.Timer)
			this.Timer.stop();
		this.Timer = new PeriodicalExecuter(function(pe) {
		if(!this.isPaused)
			this.nextSlide();
		}.bindAsEventListener(this), 6);
		}
	
	}

function ImageBrowser()
	{
		this.aImages = new Array();
		this.add = function()
			{
			ImageBrowser.aImages[ImageBrowser.aImages.length] = arguments;
			}
			
		this.fadeToBlack = function()
			{
			if(!$('fadeToBlack'))
				{
				var oBlind = new Element('div',{id:"fadeToBlack", style:"height:"+ImageBrowser.iScreenHeight+"px"});
				document.getElementsByTagName('body')[0].appendChild(oBlind);
				}
			}
		this.fadeUp = function()
			{
				Element.remove('fadeToBlack');
			}
			
		this.startShow = function()
			{
			var temp=navigator.appVersion.split('MSIE');
			var ieVer=parseInt(temp[1]);
			if(Prototype.Browser.IE && ieVer <= 6)
				scroll(0,0);

			var iScreenWidth;
			var iScreenHeight;
				
			if (window.innerWidth || window.innerHeight){ 
				ImageBrowser.iScreenWidth = window.innerWidth; 
				ImageBrowser.iScreenHeight = window.innerHeight; 
			}
			else if(document.documentElement.clientWidth) {
				ImageBrowser.iScreenWidth = document.documentElement.clientWidth;
				ImageBrowser.iScreenHeight = document.documentElement.clientHeight;
				}
			else
				{
				ImageBrowser.iScreenWidth = document.body.clientWidth;
				ImageBrowser.iScreenHeight = document.body.clientHeight;
				}

			ImageBrowser.iWidthLimit = ImageBrowser.iScreenWidth-90;		
			ImageBrowser.iHeightLimit= ImageBrowser.iScreenHeight-70;	
			
			ImageBrowser.fadeToBlack();
			setTimeout("ImageBrowser.openWindow("+arguments[0]+")", 200);
			}
		this.stopShow = function()
			{
			ImageBrowser.closeWindow();
			setTimeout("ImageBrowser.fadeUp();", 500);
			}
		this.closeWindow = function()
			{
			new Effect.Opacity('imagePreviewWindow', {duration:0.4, from:1.0, to:0.01});
			setTimeout("Element.remove('imagePreviewWindow');", 500);
			}
			
		this.buildNavigationbar = function()
			{
			var oNavigationBar = new Element('div', {id:"imageNavigationBar"});
			var oNaviPrevious = new Element('div', {id:"imageNavigationBarPrevious"}).update(ImageBrowser.iImagePosition<=0 ? "\u00A0" : "Previous");
			if(!(ImageBrowser.iImagePosition<=0))
				oNaviPrevious.observe('click', ImageBrowser.previousImage);
			var oNaviNext = new Element('div', {id:"imageNavigationBarNext"}).update(ImageBrowser.iImagePosition >=ImageBrowser.aImages.length-1 ? "\u00A0" : "Next");
			if(!(ImageBrowser.iImagePosition >=ImageBrowser.aImages.length-1))
				oNaviNext.observe('click', ImageBrowser.nextImage);
					
			var oNaviTitle = new Element('div', {id:"imageNavigationBarTitle"}).update(ImageBrowser.aImages[ImageBrowser.iImagePosition][3] == '' ? "\u00A0" : ImageBrowser.aImages[ImageBrowser.iImagePosition][3]);
			
			oNavigationBar.appendChild(oNaviNext);
			oNavigationBar.appendChild(oNaviPrevious);
			oNavigationBar.appendChild(oNaviTitle);
			
			return oNavigationBar;
			}
			
		this.naviPleaseWait = function()
			{
			$('imageNavigationBarNext').update("\u00A0");	
			$('imageNavigationBarPrevious').update("\u00A0");	
			$('imageNavigationBarTitle').update($('imageNavigationBarTitle').innerHTML == "Loading. Please wait |" ? "Loading. Please wait -" : "Loading. Please wait |");
			}
			
		this.nextImage = function()
			{
			ImageBrowser.iImagePosition = ImageBrowser.iImagePosition+1;
			ImageBrowser.iImageCache = new Element('img', {'src':ImageBrowser.aImages[ImageBrowser.iImagePosition][0], 'alt':""});
			setTimeout("ImageBrowser.showCached();", 400);
			ImageBrowser.naviPleaseWait();
			}
			
		this.previousImage = function()
			{
			ImageBrowser.iImagePosition = ImageBrowser.iImagePosition-1;
			ImageBrowser.iImageCache = new Element('img', {'src':ImageBrowser.aImages[ImageBrowser.iImagePosition][0], 'alt':""});
			setTimeout("ImageBrowser.showCached();", 400);
			ImageBrowser.naviPleaseWait();
			}	
		
		this.showCached = function()
			{
			if(!ImageBrowser.iImageCache.complete)
				{
				setTimeout("ImageBrowser.showCached();", 100);
				}
			else
				{
				/*var iPosX = Math.round((ImageBrowser.iScreenWidth - ImageBrowser.iCurrentWidth)/2);	
				new Effect.Morph('imagePreviewWindow',{style:'left:"+iPosX+"px; top:20px;height:"+(ImageBrowser.iCurrentHeight+20)+"px;width:"+ImageBrowser.iCurrentWidth+"px', duration:0.25);
				$('imagePreviewImage').setStyle({width:ImageBrowser.iCurrentWidth+"px", height:ImageBrowser.iCurrentHeight+"px"});
				$('imagePreviewImage').src = ImageBrowser.iImageCache.src;
				new Effect.Opacity('imagePreviewImage', {duration:0.3, from:0.01, to:1.0});
				$('imageNavigationBar').remove();
				var oNavigationBar = ImageBrowser.buildNavigationbar();
				$('imagePreviewWindow').appendChild(oNavigationBar);*/
				ImageBrowser.openWindow(ImageBrowser.iImagePosition);
				}
			}
		
		this.openWindow = function()
			{
			ImageBrowser.iImagePosition = arguments[0];
			ImageBrowser.iCurrentWidth = ImageBrowser.aImages[ImageBrowser.iImagePosition][1];
			ImageBrowser.iCurrentHeight = ImageBrowser.aImages[ImageBrowser.iImagePosition][2];			
			iRatio = (ImageBrowser.iCurrentWidth/ImageBrowser.iCurrentHeight);
			
			if(ImageBrowser.iCurrentWidth >= ImageBrowser.iWidthLimit)
				{
				ImageBrowser.iCurrentWidth =ImageBrowser.iWidthLimit;
				ImageBrowser.iCurrentHeight = Math.round(ImageBrowser.iCurrentWidth / iRatio);
				}

			if(ImageBrowser.iCurrentHeight >= ImageBrowser.iHeightLimit)
				{
				ImageBrowser.iCurrentHeight= ImageBrowser.iHeightLimit;
				ImageBrowser.iCurrentWidth = Math.round(ImageBrowser.iCurrentHeight*iRatio);
				}
			var iPosX = Math.round((ImageBrowser.iScreenWidth - ImageBrowser.iCurrentWidth)/2);
			if($('imagePreviewWindow')!=null)
				{
				$('imageNavigationBar').remove();
				$('imagePreviewImage').hide();
				$('imagePreviewImage').setStyle({width:ImageBrowser.iCurrentWidth+"px", height:ImageBrowser.iCurrentHeight+"px"});
				$('imagePreviewContent').setStyle({width:ImageBrowser.iCurrentWidth+"px", height:ImageBrowser.iCurrentHeight+"px"});
				$('imagePreviewImage').src = ImageBrowser.iImageCache.src;
				
				new Effect.Morph('imagePreviewWindow',{style:'left:'+iPosX+'px; top:20px;height:'+ImageBrowser.iCurrentHeight+'px;width:'+ImageBrowser.iCurrentWidth+'px', duration:0.25});
				$('imagePreviewImage').appear();
				oNavigationBar = this.buildNavigationbar();
				oNavigationBar.hide();
				$('imagePreviewWindow').appendChild(oNavigationBar);
				setTimeout("$('imageNavigationBarTitle').style.visibility = 'hidden'; $('imageNavigationBarNext').style.visibility = 'hidden'; $('imageNavigationBarPrevious').style.visibility = 'hidden'; $('imageNavigationBar').show(); new Effect.Morph('imagePreviewWindow', {style:'height:'+("+ImageBrowser.iCurrentHeight+"+$('imageNavigationBar').getHeight())+'px;background-color:#8EACAC'});", 500);
				setTimeout("$('imageNavigationBarTitle').style.visibility = 'visible';$('imageNavigationBarNext').style.height = $('imageNavigationBar').getHeight()+'px'; $('imageNavigationBarNext').style.visibility = 'visible'; $('imageNavigationBarPrevious').style.height = $('imageNavigationBar').getHeight()+'px'; $('imageNavigationBarPrevious').style.visibility = 'visible'; if(Prototype.Browser.IE) $('imageExitButton').style.bottom = ($('imageNavigationBar').getHeight()+30)+'px'; ", 1100);
				}
			else
				{
				var oWindow = new Element('div',{id:"imagePreviewWindow", style:"background-color:#000; height:1px; width:1px; left:"+iPosX+"px;display:block"});
				var oContent = new Element('div',{id:"imagePreviewContent"});
				var oImage = new Element('img',{id:"imagePreviewImage", src:ImageBrowser.aImages[ImageBrowser.iImagePosition][0], alt:"", style:"display:block; visiblity:visible; width:"+ImageBrowser.iCurrentWidth+"px; height:"+ImageBrowser.iCurrentHeight+"px;"});
				
				var oNavigationBar = ImageBrowser.buildNavigationbar();
				
				var oExit = new Element('div', {id:"imageExitButton", style:"cursor:pointer", onclick:"ImageBrowser.stopShow();"}).update('Exit');
				oExit.observe('click', ImageBrowser.stopShow);

				oExit.hide();
				oWindow.appendChild(oExit);
				oContent.appendChild(oImage);
				oContent.hide();
				oWindow.appendChild(oContent);
				oNavigationBar.hide();
				oWindow.appendChild(oNavigationBar);
				$('fadeToBlack').appendChild(oWindow);
				$('imagePreviewWindow').style.top=Math.round(ImageBrowser.iScreenHeight/2)+"px";
				new Effect.Morph('imagePreviewWindow',{style:'width:'+ImageBrowser.iCurrentWidth+'px', duration:0.5});
				setTimeout("new Effect.Morph('imagePreviewWindow',{style:'top:20px;height:"+ImageBrowser.iCurrentHeight+"px', duration:0.7});", 500);
				setTimeout("$('imagePreviewContent').show();", 1200);
				setTimeout("$('imageNavigationBarTitle').style.visibility = 'hidden'; $('imageNavigationBarNext').style.visibility = 'hidden'; $('imageNavigationBarPrevious').style.visibility = 'hidden'; $('imageNavigationBar').show(); new Effect.Morph('imagePreviewWindow', {style:'height:'+("+ImageBrowser.iCurrentHeight+"+$('imageNavigationBar').getHeight())+'px;background-color:#8EACAC'});", 1200);
				setTimeout("$('imageNavigationBarTitle').style.visibility = 'visible';$('imageNavigationBarNext').style.height = $('imageNavigationBar').getHeight()+'px'; $('imageNavigationBarNext').style.visibility = 'visible'; $('imageNavigationBarPrevious').style.height = $('imageNavigationBar').getHeight()+'px'; $('imageNavigationBarPrevious').style.visibility = 'visible'; if(Prototype.Browser.IE) $('imageExitButton').style.bottom = ($('imageNavigationBar').getHeight()+30)+'px';", 2000);
				setTimeout("$('imageExitButton').show();", 1200);
				$('imagePreviewWindow').appendChild(oContent);
				$('imagePreviewWindow').appendChild(oNavigationBar);
				}
			}
	}

ImageBrowser = new ImageBrowser();

