	
	var GalleryImages = 
	{
		showPopUpBackground : function()
		{
			var id = 'addPopUpBackground';
			var height = Number(GalleryImages.getWindowSize('h')) + Number(GalleryImages.getScrollXY()[1]);
			
			if ( document.getElementById(id) )
			{
				document.getElementById(id).style.display = 'block'; 
			}
			else
			{
				GalleryImages.addHTML('<div id="'+id+'" style="position:fixed;z-index:99;top:0px;left:0px;display:block;width:100%;height:'+height+'px; background-color:#000000;opacity: 0.75; filter: alpha(opacity = 75);">&nbsp;</div>');
			}
		},
		hidePopUpBackground : function()
		{
			var id = 'addPopUpBackground';
			if ( document.getElementById(id) )
			{
				document.getElementById(id).style.display = 'none'; 
			}
		},
		getWindowSize : function ( wh )
		{
			/* //////////////////////////////////////////
			Developer : Chayne Walsh
			Version Date : 2010 01 06 01
			////////////////////////////////////////// */

  			var myWidth = 0, myHeight = 0;
  			if( typeof( window.innerWidth ) == 'number' ) 
			{ //Non-IE
    			myWidth = window.innerWidth;
    			myHeight = window.innerHeight;
  			} 
			else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
			{ //IE 6+ in 'standards compliant mode'
    			myWidth = document.documentElement.clientWidth;
    			myHeight = document.documentElement.clientHeight;
  			} 
			else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
			{  //IE 4 compatible
    			myWidth = document.body.clientWidth;
    			myHeight = document.body.clientHeight;
  			}
  			if ( wh == 'w' ) return myWidth;
  			if ( wh == 'h' ) return myHeight;
		},
		addHTML : function (html) 
		{
			if (document.all)
				document.body.insertAdjacentHTML('beforeEnd', html);
			else if (document.createRange) 
			{
				var range = document.createRange();
				range.setStartAfter(document.body.lastChild);
				var cFrag = range.createContextualFragment(html);
				document.body.appendChild(cFrag);
			}
			else if (document.layers) 
			{
				var X = new Layer(window.innerWidth);
				X.document.open();
				X.document.write(html);
				X.document.close();
				X.top = document.height;
				document.height += X.document.height;
				X.visibility = 'show';
			}
		},
		IsImageOk : function (img) 
		{
			// During the onload event, IE correctly identifies any images that
			// weren’t downloaded as not complete. Others should too. Gecko-based
			// browsers act like NS4 in that they report this incorrectly.
			try { if (!img.complete) { return false; } } catch(e){}
	
			// However, they do have two very useful properties: naturalWidth and
			// naturalHeight. These give the true size of the image. If it failed
			// to load, either of these should be zero.
			try { if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) { return false; } } catch(e){}
	
			// No other way of checking: assume it’s ok.
			return true;
		},
		//Call this function onLoad of body tag
		checkImages : function () 
		{
			var imgToLoad = document.getElementById(GalleryImages.GalleryImageToLoad.id);
			var popUpViewerDiv = document.getElementById(GalleryImages.GalleryImageViewerPopup.id);
			var closeLink = document.getElementById(GalleryImages.GalleryCloseLink.id);
			if ( Number(GalleryImages.TimeOutSeconds) >= Number(GalleryImages.TimeOutSecondsCount) )
			{
				GalleryImages.TimeOutSecondsCount+=1;
				if ( !GalleryImages.IsImageOk(imgToLoad) ) 
				{
					GalleryImages.TimeOut = setTimeout("GalleryImages.checkImages();", 1000);
					//document.getElementById('testing').innerHTML += 'loading '+GalleryImages.GalleryImageToLoad.src+ '<br>';
				}
				else
				{
					window.clearTimeout(GalleryImages.TimeOut);
					GalleryImages.TimeOutSecondsCount = 0;
					popUpViewerDiv.style.width = '';
					popUpViewerDiv.style.height = '';
					GalleryImages.GalleryLoadingImage.style.display = 'none';
					imgToLoad.style.display = 'block';
					closeLink.style.display = 'block';
					
					popUpViewerDiv.style.top = GalleryImages.GetPopUpPositions(imgToLoad.width,imgToLoad.height)['top'] + 'px';
					popUpViewerDiv.style.left = GalleryImages.GetPopUpPositions(imgToLoad.width,imgToLoad.height)['left'] + 'px';
				}
			}
			else
			{
				Dom.remove(GalleryImages.GalleryImageToLoad.id);
				Dom.remove(GalleryImages.GalleryLoadingImage.id);
				GalleryImages.GalleryImageViewerPopup.innerHTML = 'Image loading timed out! <br><a href="javascript:GalleryImages.ClosePopUpImage();">Click here to Close</a>';
			}
		},
		TargetObject : null,
		GalleryImageToLoad : null,
		GalleryLoadingImage : null,
		GalleryImageViewerPopup : null,
		GalleryCloseLink : null,
		TimeOutSeconds : 5,
		TimeOutSecondsCount : 0,
		TimeOut : null,
		PopUpImage : function(imgSrc)
		{
			GalleryImages.TimeOutSeconds = 15;
			GalleryImages.TimeOutSecondsCount = 0;
		
			Dom.remove('GalleryImageViewerPopup');
		
			GalleryImages.GalleryLoadingImage = document.createElement('img');
			GalleryImages.GalleryLoadingImage.id = 'GalleryLoadingImage';
			GalleryImages.GalleryLoadingImage.src = './mm_files/images/loading/loading22.gif';	
			
			GalleryImages.GalleryImageToLoad = document.createElement('img');
			GalleryImages.GalleryImageToLoad.id = 'GalleryImageToLoads';
			GalleryImages.GalleryImageToLoad.style.display = 'none';
			GalleryImages.GalleryImageToLoad.src = imgSrc;	
			
			GalleryImages.GalleryCloseLink = document.createElement('a');
			GalleryImages.GalleryCloseLink.id = 'GalleryCloseLink';
			GalleryImages.GalleryCloseLink.innerHTML = 'Close';
			GalleryImages.GalleryCloseLink.href = '#';
			GalleryImages.GalleryCloseLink.style.textAlign = 'right';
			GalleryImages.GalleryCloseLink.style.display = 'none';
			GalleryImages.GalleryCloseLink.style.fontWeight = 'bold';
			GalleryImages.GalleryCloseLink.style.margin = '5px 0px 0px 0px';
			GalleryImages.GalleryCloseLink.style.padding = '2px';	
			Event.add(GalleryImages.GalleryCloseLink,'click',GalleryImages.ClosePopUpImage);
			
			GalleryImages.GalleryImageViewerPopup = document.createElement('div');
			GalleryImages.GalleryImageViewerPopup.id = 'GalleryImageViewerPopup';
			GalleryImages.GalleryImageViewerPopup.style.position = 'absolute';
			GalleryImages.GalleryImageViewerPopup.style.top = GalleryImages.GetPopUpPositions(300,300)['top'] + 'px';
			GalleryImages.GalleryImageViewerPopup.style.left = GalleryImages.GetPopUpPositions(300,300)['left'] + 'px';
			GalleryImages.GalleryImageViewerPopup.style.width = '300px';
			GalleryImages.GalleryImageViewerPopup.style.height = '300px'; 
			GalleryImages.GalleryImageViewerPopup.style.textAlign = 'center'; 
			GalleryImages.GalleryImageViewerPopup.style.verticalAlign = 'middle';
			
			GalleryImages.GalleryImageViewerPopup.style.zIndex = '10000';
			GalleryImages.GalleryImageViewerPopup.style.backgroundColor = '#ffffff';
			GalleryImages.GalleryImageViewerPopup.style.border = '1px solid #ededed';
			GalleryImages.GalleryImageViewerPopup.style.padding = '5px'; 
			
			
			GalleryImages.GalleryImageViewerPopup.appendChild(GalleryImages.GalleryLoadingImage);
			GalleryImages.GalleryImageViewerPopup.appendChild(GalleryImages.GalleryImageToLoad);
			GalleryImages.GalleryImageViewerPopup.appendChild(GalleryImages.GalleryCloseLink);
			
			document.body.appendChild(GalleryImages.GalleryImageViewerPopup);
			
			GalleryImages.showPopUpBackground();
			GalleryImages.checkImages();
		},
		GetPopUpPositions : function(w,h)
		{
			// set the width and position of the pop up loading window
			var t = 10;
			var l = 10;
			try { t = ( (GalleryImages.getWindowSize('h')/2) - (h/2) ); } catch(e){}
			try { l = ( (GalleryImages.getWindowSize('w')/2) - (w/2) ); } catch(e){}
			if ( t < 10 ) t = 10;
			if ( l < 10 ) l = 10;
			t = t + Number(GalleryImages.getScrollXY()[1]);
			l = l + Number(GalleryImages.getScrollXY()[0]);
			return {'top':t,'left':l};
		},
		ClosePopUpImage : function()
		{
			window.clearTimeout(GalleryImages.TimeOut);
			Dom.remove(GalleryImages.GalleryImageToLoad.id);
			Dom.remove(GalleryImages.GalleryLoadingImage.id);
			Dom.remove(GalleryImages.GalleryImageViewerPopup);
			GalleryImages.hidePopUpBackground();
		},
		ImageInflate : function(t)
		{
			var w = (t.width)?t.width:t.style.width.replace('px','');
			//t.imgWidth = w;
			
			t.zIndex = (t.zIndex)?t.zIndex:t.style.zIndex;
			t.style.zIndex = t.zIndex + 1;
			t.style.width=(Number(t.getAttribute('imgWidth'))+8)+'px';
			t.style.height=(Number(t.getAttribute('imgHeight'))+8)+'px';
			t.style.top=(Number(t.getAttribute('posTop'))-4)+'px';
			t.style.left=(Number(t.getAttribute('posLeft'))-4)+'px';
			
		},
		ImageDeflate : function(t)
		{
			t.style.width=t.getAttribute('imgWidth')+'px';
			t.style.height=t.getAttribute('imgHeight')+'px';
			t.style.top=t.getAttribute('posTop')+'px';
			t.style.left=t.getAttribute('posLeft')+'px';
			t.style.zIndex = t.zIndex;
		},
		getScrollXY : function () 
		{
  			var scrOfX = 0, scrOfY = 0;
  			if( typeof( window.pageYOffset ) == 'number' ) 
			{ //Netscape compliant
    			scrOfY = window.pageYOffset;
    			scrOfX = window.pageXOffset;
  			} 
			else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
			{ //DOM compliant
    			scrOfY = document.body.scrollTop;
    			scrOfX = document.body.scrollLeft;
  			} 
			else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
			{ //IE6 standards compliant mode
    			scrOfY = document.documentElement.scrollTop;
    			scrOfX = document.documentElement.scrollLeft;
  			}
 			 return [ scrOfX, scrOfY ];
		}
	}
	var Dom = 
	{
  		get: function(el) 
		{
    		if (typeof el === 'string') 
			{
      			return document.getElementById(el);
    		} else {
      			return el;
    		}
 		 },
  		add: function(el, dest) 
		{
			try{
    			var el = this.get(el);
    			var dest = this.get(dest);
    			dest.appendChild(el);
			}catch(e){}
  		},
  		remove: function(el) 
		{
			try{
    			var el = this.get(el);
    			el.parentNode.removeChild(el);
			}catch(e){}
  		}
  	};
	var Event = 
	{
  		add: function() 
		{
    		if (window.addEventListener) 
			{
      			return function(el, type, fn) 
				{
       				 Dom.get(el).addEventListener(type, fn, false);
      			};
    		} 
			else if (window.attachEvent) 
			{
      			return function(el, type, fn) 
				{
       				var f = function() 
					{
          				fn.call(Dom.get(el), window.event);
        			};
        			Dom.get(el).attachEvent('on' + type, f);
      			};
    		}
  		}()
 	};
