var startValue	= 0; //400
var WHEREAMI	= startValue;
var Cposition	= 0;
var Nposition	= 0;
var ltMove;
var ltaMove;
var rtMove;
var rtaMove;
var trTime;
var hz_floater	= startValue;
var LFTposition;

if (document.layers) {
	self.onerror	= deal_with_error;
	self.onReload	= rEload_Doc;
	self.onResize	= rEload_Doc;
}

function deal_with_error(msg, url, line) {
    rEload_Doc();
    return true;
}

function CLRtimers() {
	moveitemVA = false;
	clearTimeout(ltMove);
	clearTimeout(rtMove);
	clearTimeout(trTime);
}
function strScroll() {
	if (document.layers) {
		winWidth	= window.innerWidth;
		LFTposition = parseInt((winWidth - 714)/2);
		document.popupCtr.left	= LFTposition + 20;
		document.eventCtr.left	= LFTposition + 20;
		document.imageLeft.left	= LFTposition;
		document.imageRight.left= LFTposition+714-20;
		}
	else if(document.all) {
		winWidth	= document.body.clientWidth;
		LFTposition = (winWidth - 714)/2;
		document.all.eventCtr.style.left	= LFTposition + 20;
		document.all.popupCtr.style.left	= LFTposition + 20;
		document.all.imageLeft.style.left	= LFTposition;
		document.all.imageRight.style.left	= LFTposition + 714-20;
		}
	else if(document.getElementById){
		winWidth = window.innerWidth;
		LFTposition = (winWidth - 714)/2;
		document.getElementById('eventCtr').style.left		= LFTposition + 20;
		document.getElementById('popupCtr').style.left		= LFTposition + 20;
		document.getElementById('imageLeft').style.left		= LFTposition;
		document.getElementById('imageRight').style.left	= LFTposition + 714-20;
		}
}
function hideDLY() {
	trTime = setTimeout("hidePopups()",popupHideDelay);
}
function hidePopups() {
	clearTimeout(trTime);
	if(document.layers){
		for (a=0; a<=popupCNT-1; a++,eval("document.popupCtr.document.LYR" + a + ".visibility='hidden'"));
		document.popupCtr.zIndex = 1;
		}
	else if(document.all) {
		for (a=0; a<=popupCNT-1; a++,eval("document.all.LYR" + a + ".style.visibility='hidden'"));
		document.all.popupCtr.style.zIndex = 1;
		}
	else if(document.getElementById) {
		for (a=0; a<=popupCNT-1; a++,eval("document.getElementById('LYR" + a + "').style.visibility ='hidden'"));
		document.getElementById('popupCtr').style.zIndex = 1;
		}
}
function generateScroller() {
	var pUpLyr		= "";
	var ImageLyr	= "";
	var sLyr		= "";
	for (a=1; a<=popupCNT;a++) {
			layerPositionValue = (RTend + (a*99)-99)
			if(layerPositionValue > 700) 
			{
				layerPositionValue = 700;
			}
			pUpLyr	= pUpLyr + " <DIV ID=\"LYR" + a + "\" STYLE=\"HEIGHT: 96px; LEFT: 0px; position: absolute; TOP: 0px; VISIBILITY: HIDDEN; WIDTH: 135px;z-index:99\">";
			pUpLyr	= pUpLyr + "\n  <TABLE WIDTH=\"135\" BGCOLOR=\"#ffffff\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\" HEIGHT=\"96\" BACKGROUND=\"thegarden/resources/images/popupBack.gif\">";
			pUpLyr	= pUpLyr + "\n   <TR>\n    <TD CLASS='whiteblack-10px'><A HREF=" + eventLINK[a] + "><IMG SRC=\"" + eventIMAGEOn[a] + "\" BORDER=\"0\"></a></TD>\n   </TR>\n  </TABLE>\n </DIV>\n";
			//pUpLyr	= pUpLyr + " <DIV ID=\"LYR" + a + "\" STYLE=\"HEIGHT: 58px; LEFT: 0px; position: absolute; TOP: 0px; VISIBILITY: HIDDEN; WIDTH: 150px;z-index:1\">";
			//pUpLyr	= pUpLyr + "\n  <TABLE WIDTH=\"150\" BGCOLOR=\"#ffffff\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"5\" HEIGHT=\"58\" BACKGROUND=\"thegarden/resources/images/popupBack.gif\">";
			//pUpLyr	= pUpLyr + "\n   <TR>\n    <TD CLASS='whiteblack-10px'>" + popupTEXT[a] + "</TD>\n   </TR>\n  </TABLE>\n </DIV>\n";
			
			ImageLyr = ImageLyr + " <DIV ID=\"IMG" + a + "\" STYLE=\"HEIGHT: 96px; LEFT:" + layerPositionValue + "px; position: absolute; TOP: 0px; VISIBILITY: HIDDEN; WIDTH: 135px;z-index:1\">";
			ImageLyr = ImageLyr + "\n  <A HREF=" + eventLINK[a] + " ONMOUSEOVER=\"MM_swapImage('Event" + a + "','','"+ eventIMAGEOn[a] + "',1);\" ONMOUSEOUT=\"MM_swapImgRestore();\"><IMG SRC=\"" + eventIMAGE[a] + "\" NAME=\"Event" + a + "\" BORDER=\"1\"></A>";
			//ImageLyr = ImageLyr + " <DIV ID=\"IMG" + a + "\" STYLE=\"HEIGHT: 58px; LEFT:" + layerPositionValue + "px; position: absolute; TOP: 0px; VISIBILITY: HIDDEN; WIDTH: 93px;z-index:1\">";
			//ImageLyr = ImageLyr + "\n  <A HREF=" + eventLINK[a] + " ONMOUSEOVER=\"showWindow('IMG" + a + "');\" ONMOUSEOUT=\"hideDLY();\"><IMG SRC=\"" + eventIMAGE[a] + "\" BORDER=\"1\"></A>";
			//ImageLyr = ImageLyr + "\n  <A HREF=\"javascript:openNewWin('" + eventLINK[a] + "');\" ONMOUSEOVER=\"showWindow('IMG" + a + "');\" ONMOUSEOUT=\"hideDLY();\"><IMG SRC=\"" + eventIMAGE[a] + "\" BORDER=\"1\"></A>";
			ImageLyr = ImageLyr + "\n </DIV>\n";
		}

		sLyr = sLyr + "\n<DIV ID=\"eventCtr\" STYLE=\"HEIGHT: 100px; LEFT: 0px; position: absolute; TOP: 325px; VISIBILITY: visible; WIDTH: 750px;z-index:8;CLIP:rect(0 667 100 5);\">\n";
		sLyr = sLyr + "\n" + ImageLyr + "\n";
		sLyr = sLyr + "</DIV>\n\n";
		
		sLyr = sLyr + "\n<DIV ID=\"popupCtr\" STYLE=\"HEIGHT: 100px; LEFT: 0px; position: absolute; TOP: 325px; VISIBILITY: visible; WIDTH: 750px;z-index:5;clip:rect(0 750 100 5);\">\n";
		sLyr = sLyr + "\n" + pUpLyr + "\n";
		sLyr = sLyr + "</DIV>\n\n";
		
		sLyr = sLyr + "<DIV ID=\"imageLeft\" STYLE=\"HEIGHT: 113px; LEFT: 0px; POSITION: absolute; TOP: 325px; vertical-align:middle; VISIBILITY: visible; WIDTH: 20px;z-index:8\">";
		sLyr = sLyr + "\n <A ONMOUSEOVER=\"javascript:moveItemRight();hidePopups(); selectImg(document.leftarrow,15)\" ONMOUSEOUT=\"javascript:CLRtimers(); selectImg(document.leftarrow,14)\" HREF=\"#\">";
		sLyr = sLyr + "<IMG SRC=\"images/Arrow_Left.gif\" WIDTH=\"18\" HEIGHT=\"96 \" BORDER=\"0\" NAME=\"leftarrow\"></A>\n</DIV>";
		sLyr = sLyr + "\n\n<DIV ID=\"imageRight\" STYLE=\"HEIGHT: 113px; LEFT: 725px; POSITION: absolute; TOP: 325px; VISIBILITY: visible; WIDTH: 20px;z-index:8\">";
		sLyr = sLyr + "\n <A ONMOUSEOVER=\"javascript:moveItemLeft();hidePopups(); selectImg(document.rightarrow,17)\" ONMOUSEOUT=\"javascript:CLRtimers(); selectImg(document.rightarrow,16)\" HREF=\"#\">";
		sLyr = sLyr + "<IMG SRC=\"images/Arrow_Right.gif\" WIDTH=\"18\" HEIGHT=\"96\" BORDER=\"0\" NAME=\"rightarrow\"></A><IMG SRC=\"images/spacer.gif\" WIDTH=\"20\" HEIGHT=\"60\">\n</DIV>";
	
		document.write(sLyr);
				
		LayerMoveTo(startValue);
		trTime = setTimeout("hidePopups()",popupHideDelay);
		strScroll();
}
function LayerMoveTo(xpos) {
	var layerID;
	var positionTrack=0;
	for (a=1; a<=popupCNT;a++) {
		layerID = "IMG" + a;
		// widht of images
		positionTrack = RTend + (a*143)-143;
		if(positionTrack + xpos-0 < 700) {
			if(document.all) {
				document.all[layerID].style.left = positionTrack+xpos-0;
				document.all[layerID].style.visibility = "visible";
			} 
			else if(document.layers) {
				document.eventCtr.document[layerID].left = parseInt(positionTrack + xpos);
				document.eventCtr.document[layerID].visibility = "visible";
			}
			else if(document.getElementById) {
				eval("document.getElementById('" + layerID + "').style.left = positionTrack+xpos-0");
				eval("document.getElementById('" + layerID + "').style.visibility='visible'");
	}
		}
			}

}
function moveItemLeft() {
	CLRtimers();
	if(hz_floater != LTend) {
		LayerMoveTo(hz_floater);
		hz_floater = hz_floater - 5;	
		ltMove = setTimeout("moveItemLeft('eventCtr')",TMRinterval);
	}
}
function moveItemRight() {
	CLRtimers();
	if(hz_floater != RTend) {
		LayerMoveTo(hz_floater);		
		hz_floater = hz_floater + 5-0;
		rtMove = setTimeout("moveItemRight('eventCtr')",TMRinterval);
	}
}

function showWindow(eventLayerID) {
	//CLRtimers();
	var parentLayer;
	parentLayer = "LYR" + replace(eventLayerID,"IMG","")
	//hidePopups(); 
    if(document.layers) {
    //alert("1 - " + eventLayerID);
		parentYpos = parseInt(eval("document.eventCtr.document." + eventLayerID + ".left"));
		if(parentYpos < 565){
			document.popupCtr.clip.left		= parseInt(parentYpos + 80);
			document.popupCtr.clip.width	= 250; 
			document.popupCtr.zIndex		= 10;
			document.popupCtr.document[parentLayer].left		= parentYpos + 80;
			document.popupCtr.document[parentLayer].top			= -10;
			document.popupCtr.document[parentLayer].visibility	= "visible";
		}
	}
	else if(document.all) {
	//alert("2 - " + eventLayerID);
		parentYpos = parseInt(document.all[eventLayerID].style.left);
		//alert("parentYpos - " + parentYpos);
		if(parentYpos < 565){
				document.all.popupCtr.style.clip			= "rect(-30 " + parseInt(parentYpos + 250) + " 96 " + parseInt(parentYpos + 0) + ")";
				document.all.popupCtr.style.zIndex			= 10;
				document.all[parentLayer].style.left		= parentYpos;
				document.all[parentLayer].style.top			= 0;
				document.all[parentLayer].style.visibility	= "visible";
				//document.all.popupCtr.style.clip			= "rect(-30 " + parseInt(parentYpos + 250) + " 60 " + parseInt(parentYpos + 80) + ")";
				//document.all.popupCtr.style.zIndex			= 10;
				//document.all[parentLayer].style.left		= parentYpos + 80;
				//document.all[parentLayer].style.top			= -10;
				//document.all[parentLayer].style.visibility	= "visible";
			}
	}
	else if(document.getElementById) {
	//alert("3 - " + eventLayerID);
		parentYpos = parseInt(eval("document.getElementById('" + eventLayerID + "').style.left"));
		if(parentYpos < 565){
		        document.all.popupCtr.style.clip			= "rect(0)";
				document.all.popupCtr.style.zIndex			= 10;
				document.all[parentLayer].style.left		= parentYpos + 1;
				document.all[parentLayer].style.top			= 1;
				document.all[parentLayer].style.visibility	= "visible";
		        //document.all.popupCtr.style.clip			= "rect(-30 " + parseInt(parentYpos + 250) + " 60 " + parseInt(parentYpos + 80) + ")";
				//document.all.popupCtr.style.zIndex			= 10;
				//document.all[parentLayer].style.left		= parentYpos + 80;
				//document.all[parentLayer].style.top			= -10;
				//document.all[parentLayer].style.visibility	= "visible";
				//document.getElementById('popupCtr').style.clip = "rect(-30px " + parseInt(parentYpos + 250) + "px 60px " + parseInt(parentYpos + 80) + "px)";
				//document.getElementById('popupCtr').style.zIndex = 10;
				//eval("document.getElementById('" + parentLayer + "').style.left=parentYpos + 80");
				//eval("document.getElementById('" + parentLayer + "').style.top=-10");
				//eval("document.getElementById('" + parentLayer + "').style.visibility='visible'");
			}
	}
}
function replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;
    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;
    var newstr = string.substring(0,i) + by;
    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);
    return newstr;
}
function openNewWin(url) {
    NewWin = window.open(url, 'popupWin', 'scrollbars,resizable,dependent,width=475,height=475,left=yes,top=yes');
    NewWin.focus();
}   

function rEload_Doc() {
	location.reload(true);
}

function resize_Doc() {
	strScroll();
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}