function createGallery()
{

}

var oImageWraps;
var iCurrIndex;
var sTourPath;


function galleryDoButtonLogin()
{
		var oLnkGalleryBack = document.getElementById("lnkGalleryBack");
		var oLnkGalleryNext = document.getElementById("lnkGalleryNext");
		if (iCurrIndex==0)
			oLnkGalleryBack.className = "n-active";
		else
			oLnkGalleryBack.className = "";
			
		if (iCurrIndex==(oImageWraps.length-1))
			oLnkGalleryNext.className = "n-active";
		else
			oLnkGalleryNext.className = "";
}


function showPrevImage()
{
		
	if (iCurrIndex>0)
	{		
		oImageWraps[iCurrIndex].style.display= "none";	
		oImageWraps[iCurrIndex-1].style.display= "block";	
		iCurrIndex -=1;
		galleryDoButtonLogin()
	}			
}

function showNextImage()
{	
	if (iCurrIndex<(oImageWraps.length-1))
	{
		oImageWraps[iCurrIndex].style.display= "none";	
		oImageWraps[iCurrIndex+1].style.display= "block";	
		iCurrIndex +=1;
		galleryDoButtonLogin()			
		
	}			
}

function showVirtual()
{
	window.open(sTourPath,'VirtualTour','resizable=yes,width=780,height=550');
}

function initGallery()
{
	var sQuery =document.location.search.toUpperCase();
	if(sQuery.indexOf('EDIT=TRUE')>0)return;
	var oGalleries = getElementsByClass("galleryWrapper",document,"DIV");
	var i;
	if (oGalleries.length >0)
	{
		var oGallery = oGalleries[0];
		oGallery.style.overflow = "visible";
		oGallery.style.left = "0px";
		oGallery.style.margin="0px";
		oGallery.style.width = "290px";				
		oImageWraps = getElementsByClass("visual-i",oGallery,"DIV");
		iCurrIndex = 0;
		if(oImageWraps.length > 0)
		{
			for (i=1;i<oImageWraps.length;i++)
			{		
				oImageWraps[i].style.display = "none";
			}				
		}
	}
	
	//Add navigation
	var odivGalleryNav = document.getElementById("divGalleryNav");
		
	var sVirtualTour ="";
	var arrTourAs = odivGalleryNav.getElementsByTagName("A")
		
	if (arrTourAs.length>0)
	{
		sTourPath = arrTourAs[0].href;
		sVirtualTour = "<li class=\"middle\"><a title=\"Virtual tour\" href=\"javascript:showVirtual()\">(Virtual tour)</a></li>";
	}
	//n-active
	if (oImageWraps.length >1) odivGalleryNav.innerHTML = "<ul ><li><a title=\"Back\" class=\"n-active\" href=\"javascript:showPrevImage()\" id=\"lnkGalleryBack\" >&laquo; Back</a></li>" + sVirtualTour + "<li class=\"next\"><a title=\"Next\" id=\"lnkGalleryNext\" href=\"javascript:showNextImage()\">Next &raquo;</a></li></ul>"
	else
		odivGalleryNav.innerHTML  = "<a title=\"Virtual tour\" href=\"javascript:showVirtual()\">(Virtual tour)</a>"
	
}