function openLightbox(x,y,obj)
	{
		var objBody = document.getElementsByTagName("body").item(0);

		hideSelectBoxes();
		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 15) + 20;

		var lightBoxBg = document.createElement("div");
		lightBoxBg.setAttribute('id','overlayMap');
		lightBoxBg.style.width = arrayPageSize[0];
		lightBoxBg.style.height = arrayPageSize[1];
		lightBoxBg.onclick = function() { closeLightbox(); return false; }
		objBody.appendChild(lightBoxBg);
		
		var winCont = document.createElement("div");
		winCont.setAttribute('id','windowContainer');
		objBody.appendChild(winCont);
		
		var innerWindow = document.createElement("div");
		innerWindow.setAttribute('id','innerwindowMap');
		innerWindow.style.left = (arrayPageSize[0] / 2) - 220 + "px";
		innerWindow.style.top = lightboxTop + "px";
		winCont.appendChild(innerWindow);
		
		var googleMap = document.createElement('div');
		googleMap.setAttribute('id','hmap');
		innerWindow.appendChild(googleMap);
		
		var mapTitle = document.createElement('div');
		mapTitle.setAttribute('id','mapTitle');
		mapTitle.innerHTML = "<b>" + obj.title + "</b>";
		innerWindow.appendChild(mapTitle);

		var closeMap = document.createElement('img');
		closeMap.setAttribute('id','closeMap');
		closeMap.src = "closelabel.gif";
		closeMap.style.width = 66;
		closeMap.style.height = 22;
		closeMap.style.cursor = "pointer";
		closeMap.onclick = closeLightbox;
		innerWindow.appendChild(closeMap);

		setTimeout("setMap(" + x + "," + y + ",'" + obj.rel + "')",500);
	}

function setMap(x,y,obj)
	{
		var hmap = new GMap2(document.getElementById("hmap"));
		var point = new GLatLng(x, y);
		hmap.setCenter(point, 14);
		hmap.addControl(new GSmallMapControl());
		var title = stringFormat(obj);
		var marker = createCustomMarker(point,title);
		hmap.addOverlay(marker);
	}

function closeLightbox()
	{
		var myDivs = new Array();
		myDivs[0] = document.getElementById("closeMap");
		myDivs[1] = document.getElementById("mapTitle");
		myDivs[2] = document.getElementById("hmap");
		myDivs[3] = document.getElementById("windowContainer");
		myDivs[4] = document.getElementById("innerwindowMap");
		myDivs[5] = document.getElementById("overlayMap");
		for (var i = 0; i < myDivs.length; i++)
			{
				myDivs[i].parentNode.removeChild(myDivs[i]);
			}
		showSelectBoxes();
	}


// ---------------------------------------------------

function setOpacity(x,obj)
	{
		obj.style.opacity = x; 
		obj.style.MozOpacity = (x/100); 
    	obj.style.KhtmlOpacity = (x/100); 
	  	obj.style.filter = "alpha(opacity=" + x + ")"; 
		obj.filters.alpha.opacity = (x/100);
	}

function stringFormat(myVar)
	{
		var myArray = myVar.split(",");
		var myVar2 = "";
		for (var i = 0; i < myArray.length; i++)
			{
				if (i == 0)
					{
						myVar2 = myVar2 + "<em>" + myArray[i] + "</em><br />";
					}
				else
					{
						myVar2 = myVar2 + myArray[i] + "<br />";
					}
			}
		return myVar2;
	}

// ---------------------------------------------------

function createCustomMarker(point,title)
		{

			var mark = new GMarker(point);
			GEvent.addListener(mark, "mouseover", function() {mark.openInfoWindowHtml(title);});
			return mark;
    	}

// ---------------------------------------------------

function getPageSize()
	{
		var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY)
			{
				xScroll = document.body.scrollWidth;
				yScroll = window.innerHeight + window.scrollMaxY;
			}
		else if (document.body.scrollHeight > document.body.offsetHeight)
			{ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			}
		else
			{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}

		var windowWidth, windowHeight;
		if (self.innerHeight)
			{ // all except Explorer
				windowWidth = self.innerWidth;
				windowHeight = self.innerHeight;
			}
		else if (document.documentElement && document.documentElement.clientHeight)
			{ // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			}
		else if (document.body)
			{ // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}

		// for small pages with total height less then height of the viewport
		if (yScroll < windowHeight)
			{
				pageHeight = windowHeight;
			}
		else
			{
				pageHeight = yScroll;
			}

		// for small pages with total width less then width of the viewport
		if (xScroll < windowWidth)
			{
				pageWidth = windowWidth;
			}
		else
			{
				pageWidth = xScroll;
			}


		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
		return arrayPageSize;
	}

// ---------------------------------------------------

function getPageScroll()
	{
		var yScroll;
		
		if (self.pageYOffset)
			{
				yScroll = self.pageYOffset;
			}
		else if (document.documentElement && document.documentElement.scrollTop)
			{ // Explorer 6 Strict
				yScroll = document.documentElement.scrollTop;
			}
		else if (document.body)
			{ // all other Explorers
				yScroll = document.body.scrollTop;
			}

		arrayPageScroll = new Array('',yScroll)
		return arrayPageScroll;
	}

// ---------------------------------------------------

function showSelectBoxes()
	{
		selects = document.getElementsByTagName("select");
		for (i = 0; i != selects.length; i++)
			{
				selects[i].style.visibility = "visible";
			}
		objects = document.getElementsByTagName("object");
		for (i = 0; i != objects.length; i++)
			{
				objects[i].style.visibility = "visible";
			}
	}

// ---------------------------------------------------

function hideSelectBoxes()
	{
		selects = document.getElementsByTagName("select");
		for (i = 0; i != selects.length; i++)
			{
				selects[i].style.visibility = "hidden";
			}
		objects = document.getElementsByTagName("object");
		for (i = 0; i != objects.length; i++)
			{
				objects[i].style.visibility = "hidden";
			}
	}

// ---------------------------------------------------

function Left(str, n)
	{
    	if (n <= 0)
			{
	        	return "";
			}
	    else if (n > String(str).length)
			{
		    	return str;
			}
	    else
			{
		    	return String(str).substring(0,n);
			}
	}

// ---------------------------------------------------

function Right(str, n)
	{
	    if (n <= 0)
			{
				return "";
			}
		else if (n > String(str).length)
			{
				return str;
			}
		else
			{
				var iLen = String(str).length;
				return String(str).substring(iLen, iLen - n);
			}
	}
