
	var slideSpeed = 5;	
	var slideSteps = 10;	
	var columnsThumb = false;
	
	var mp_largeimg = false;
	var mp_imageToShow = false;
	var mp_slideHeight = false;
	var mp_thumbTotalHeight = false;
	var mp_viewableHeight = false;
	
	var mp_currentActiveImage = false;
	var mp_thumbDiv = false;
	var mp_thumbSlideInProgress = false;
	
	var oUpArrow;
	var oDownArrow;
	var thumbsColIndex = 1;
	var thumbstopPos = false;
	var mp_isOpened = false;
	var mp_thumbsRef;
	var mp_activeThumb = 0;
	var mp_header;
	var mp_text;
	
	var mp_closeEvent = null;
	var mp_openEvent = null;
	
	function initGallery()
	{
		mp_mpWindow = document.getElementById('mediaplayer');
		mp_header = document.getElementById('mp_header');
		mp_text = document.getElementById('mp_text');
		oUpArrow = document.getElementById('mp_uparrow');				
		oUpArrow.style.visibility='hidden';
		oDownArrow = document.getElementById('mp_downarrow');
		oDownArrow.style.visibility='hidden';	
		oUpArrow.style.cursor = 'pointer';
		oDownArrow.style.cursor = 'pointer';
		oUpArrow.onclick = moveThumbnails;
		oDownArrow.onclick = moveThumbnails;		
		
		oNextArrow = document.getElementById('mp_rightarrow');	
		oPreviousArrow = document.getElementById('mp_leftarrow');		
		oNextArrow.style.cursor = 'pointer';
		oPreviousArrow.style.cursor = 'pointer';
		oNextArrow.onclick = viewNextThumb;
		oPreviousArrow.onclick = viewPreviousThumb;	

		mp_largeimg = document.getElementById('mp_largeimg');
		
		mp_thumbDiv = document.getElementById('mp_smallimgs_inner');
		mp_thumbDiv.style.top = '0px';		
		
		mp_currentActiveImage = mp_thumbDiv.getElementsByTagName('A')[0].getElementsByTagName('IMG')[0];
		mp_currentActiveImage.parentNode.parentNode.className='mp_activeimg';
		
	}
	
	
	function setIntialHeights(){
		
		mp_thumbsRef = new Array();
		var innerDiv = document.getElementById('mp_smallimgs_inner');
		mp_slideHeight = innerDiv.getElementsByTagName('DIV')[0].offsetHeight;
		var subDivs = mp_thumbDiv.getElementsByTagName('DIV');

		mp_thumbTotalHeight = 0;
		var tmpTop = 0;
		for(var no=0;no<subDivs.length;no++){
			if(subDivs[no].className=='mp_strip'){
				mp_thumbTotalHeight = mp_thumbTotalHeight + mp_slideHeight;
				subDivs[no].style.left = '0px';
				tmpTop = tmpTop + subDivs[no].offsetHeight;				
			}
			if(subDivs[no].className=='mp_thumb'){
				mp_thumbsRef[mp_thumbsRef.length] = subDivs[no].getElementsByTagName('IMG')[0];	
			}
		}
		mp_viewableHeight = document.getElementById('mp_smallimgs').offsetHeight;	
	}
	
	
	function moveThumbnails(){
		var innerDiv = document.getElementById('mp_smallimgs_inner');
		var mp_slideHeight = innerDiv.getElementsByTagName('DIV')[0].offsetHeight;

		if(mp_thumbSlideInProgress)return;
		mp_thumbSlideInProgress = true;
		if(this.id=='mp_uparrow'){
			thumbsColIndex--;
			oDownArrow.style.visibility='visible';
			if(mp_thumbDiv.style.top.replace('px','')/1==(-1*mp_slideHeight)){
				oUpArrow.style.visibility='hidden';				
				mp_thumbSlideInProgress = false;
				slideThumbs(slideSteps,0);
				return;
			}			
			slideThumbs(slideSteps,0);
			
		}else{
			thumbsColIndex++;

			oUpArrow.style.visibility='visible';
			//var left = mp_thumbDiv.style.top.replace('px','')/1;	
			var showArrow = true;
			if(mp_thumbTotalHeight + mp_thumbDiv.style.top.replace('px','') - mp_slideHeight <= mp_viewableHeight)showArrow = false;
			if(columnsThumb)showArrow = true;
			
			if(!showArrow){
				mp_thumbSlideInProgress = false;				
				return;
			}	
			
			slideThumbs((slideSteps*-1),0);
		}	
		
	}
	
	function slideThumbs(speed,currentPos){
		
		var topPos;
		if(thumbstopPos){
			topPos= thumbstopPos;
		}else{
			var topPos = mp_thumbDiv.style.top.replace('px','')/1;
			thumbstopPos = topPos;
		}
		currentPos = currentPos + Math.abs(speed);		
		var tmptopPos = topPos;
		topPos = topPos + speed;
		thumbstopPos = topPos;
		mp_thumbDiv.style.top = topPos + 'px';

		if(currentPos<mp_slideHeight)setTimeout('slideThumbs(' + speed + ',' + currentPos + ')',slideSpeed);else{
			if(tmptopPos>=0 || (columnsThumb && thumbsColIndex==1)){
				document.getElementById('mp_uparrow').style.visibility='hidden';
			}	
			var top = tmptopPos;		
			var showArrow = true;
			
			if(mp_thumbTotalHeight + top - mp_slideHeight <= mp_viewableHeight){
				showArrow=false;
			}
			
			if(columnsThumb){
				if((thumbsColIndex+1)<columnsThumb){
					showArrow=true;
				}else{
					showArrow = false;
				}				
			}			
			if(!showArrow){
				document.getElementById('mp_downarrow').style.visibility='hidden';
			}					
			mp_thumbSlideInProgress = false;
		}
	}
	
	function showPreview(inObj)
	{	
		//mp_thumbsRef[mp_activeThumb].className='mp_thumbimg';
		//mp_thumbsRef[inObj].className='mp_activeimg';
		mp_thumbsRef[mp_activeThumb].parentNode.parentNode.className="mp_thumbdiv";
		mp_thumbsRef[inObj].parentNode.parentNode.className='mp_thumb_active';
		
		mp_header.innerHTML = thumbsLink[inObj].title;
		mp_text.innerHTML = thumbsLink[inObj].teaser;

		mp_activeThumb = inObj;		
		mp_imageToShow = thumbsLink[inObj].path;
		
		while(mp_largeimg.hasChildNodes()){
			mp_largeimg.removeChild(mp_largeimg.childNodes[0]);
		}
		
		if(thumbsLink[inObj].type == 'image'){
			var tmpImage = new Image();
			tmpImage.src = mp_imageToShow;
            tmpImage.className = "mp_image";
			mp_largeimg.appendChild(tmpImage);
		}else{
			createThumb(mp_activeThumb);
		}		
	}


	function closeMediaplayer()
	{
		mp_mpWindow.style.display='none';
		document.getElementById('mp_downarrow').style.visibility='hidden';
		document.getElementById('mp_uparrow').style.visibility='hidden';
		mp_thumbDiv = document.getElementById('mp_smallimgs_inner');
		mp_thumbDiv.style.top = '0px';
		while(mp_largeimg.hasChildNodes()){
			mp_largeimg.removeChild(mp_largeimg.childNodes[0]);
		}
		if(mp_closeEvent != null)mp_closeEvent();
	}

	
	function openMediaplayer(nr)
	{	
		if(mp_openEvent != null)mp_openEvent();
		
		try {
			mp_mpWindow.style.display='block';
			document.getElementById('mp_downarrow').style.visibility='hidden';
			document.getElementById('mp_uparrow').style.visibility='hidden';

			if(!mp_isOpened){
				setIntialHeights();
				mp_isOpened = true;
			}
			showPreview(nr);
			var x = document.getElementById('mp_smallimgs');					
			if(mp_thumbTotalHeight>x.offsetHeight){
				document.getElementById('mp_downarrow').style.visibility='visible';	
			}
        } catch (exception) {
            // mp_mpWindow probably not available yet
        }
	}
	
	
	function createThumb(inObj){		
		var path = thumbsLink[inObj].path;
		var type = thumbsLink[inObj].type;
		var element, src, conf, fullscreen;		
		var str= "";
				
		if (type == "flash") {
			conf = "config={videoFile: \'" + path + "\', autoPlay: false, showFullScreenButton: false ,showMenu:false, loop:false, bufferLength:15}";
			src ="/furniture/swf/FlowPlayerWhite";
			fullscreen = "false";
			
			if(hasRightVersion) {  // if we've detected an acceptable version
				// embed the flash movie
	
				str = AC_FL_RunContent(
				'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0',
				'width', '393',	
				'height', '295',
				'src', src,
				'quality', 'high',
				'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
				'align', 'middle',
				'id', 'movie',
				'bgcolor', '#fff',
				'name', 'movie',
				'menu', 'true',
				'allowScriptAccess','always',
				'allowFullScreen',fullscreen,
				'movie', src,
				'flashvars', conf 
			); //end AC code
			
			}else{
				"<p>No flash player...</p>"
			}
			
			
		}else{
			str="<iframe src='"+path+"' height='100%' width='100%' frameborder='0' marginheight='0' marginwidth='0' ></iframe>";
		}
		mp_largeimg.innerHTML=str;
	}	
	
	function viewNextThumb(){		
		if(mp_activeThumb == (mp_thumbsRef.length -1)) return;
		showPreview(mp_activeThumb +1);
	}
	
	function viewPreviousThumb(){
		if(mp_activeThumb == 0) return;
		showPreview(mp_activeThumb -1);
	}