
// ###############################
// JavaScript - questions comments to rudy@digifx.tv
// ############################### 
var minTop = 0;
var minLeft = 0;
var TheMiddle = 0;
var TheLeftEdge = 0;
var theActualHeight = 0;
var idealWidth = 989;
var isIE = navigator.appName.indexOf("Microsoft") != -1;
var M_contentJax
var timer="";
var nextPic=0;
var initPos=new Array();
var nowDivPos=new Array();
var imageJax
if (origData) { var imgPlaces = origData.length-1; }
var imgWidth = 450; 
var imgHeight = 280; 
var imgSpacer = -2; 
var moz=document.getElementById&&!document.all
var speedTimer = "";
var speed=45;
var speedStep= 15;
var slowest = 150;
var nowSpd=7;
var lastTo =5;
var step=1;
var maxStep=3;
var dir=0;
var stopper = -1;
var timer="";
var noMove=0;
var lastDir=0;
var isLocked = 0;

function setup() {
}
// ###############################
// initial load and layout of Page
// ###############################

function preLoad() { 
	initAnims();				// subnav setup
	window.onresize = reBox; 	// IE size tracker
								// mouse tracker init
	if (!isIE) document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = getMousePosition;
	reBox(); 
}
function reBox() {
	var TheCheat = document.getElementById('cheater');
	var RealSizeH = TheCheat.offsetHeight;
	var RealSizeW = TheCheat.offsetWidth;
	TheMiddle = Math.round((RealSizeW / 2)-1.4);
	var widthOffset = 990;
	var bgModifier = 455; // (minus)
	var TheLeftEdge = (TheMiddle - (widthOffset / 2));
	//var TheTopEdge = (TheCentre - (heightOffset / 2));
	
	if (TheLeftEdge <= minLeft) {
		TheLeftEdge = minLeft;
		TheRightEdge = widthOffset;
		TheMiddle = widthOffset / 2;
	}

	document.getElementById('theImg').style.left = TheLeftEdge-bgModifier+"px";
	document.getElementById('theImg').style.top = 1+"px";
	document.getElementById('theImg').style.width = RealSizeW+bgModifier-TheLeftEdge+"px";
	if (RealSizeH < 770) {  document.getElementById('theImg').style.height = "770px";
	} else { document.getElementById('theImg').style.height = RealSizeH -1 +"px";
	}
	document.getElementById('bottomNav').style.left = TheLeftEdge+215+"px";
	document.getElementById('how2Find').style.left = TheLeftEdge+630+"px";
	document.getElementById('CFrame').style.left = TheLeftEdge+660+"px";
	
	document.getElementById('mapBox').style.left = TheLeftEdge+215+"px";
	document.getElementById('mapBoxB').style.left = TheLeftEdge+660+"px";
	
	document.getElementById('theLogo').style.left = TheLeftEdge+"px";
	
	document.getElementById('imagePane').style.left = 1+"px";
	document.getElementById('imagePane').style.width = TheLeftEdge+660+"px";
	
}

// ###############################
// initial load of Navigation - left alignment
// ###############################
function navLeft() {
	var TheCheat = document.getElementById('cheater');
	var RealSizeW = TheCheat.offsetWidth;
	var TheMiddle = Math.round((RealSizeW / 2)-1.4);
	var TheLeftEdge = (TheMiddle - (990 / 2));
	var TheRightEdge = (TheMiddle + (990 / 2));
	if (TheLeftEdge <= minLeft) {
		TheLeftEdge = minLeft;
		TheRightEdge = idealWidth;
		TheMiddle = idealWidth / 2;
	}
 	return TheLeftEdge*1+458;
}

// ###############################
// Flash interactivity
// ############################### 
 function getTextFromFlash(str) {
	 if (str == "Loaded") { makeMotion(250); } 
	 else if (str == "start") { moveIt(dir); } 
	 else if (str == "subNav") { doSubNav(); } 
	 else if (str == "showContent") { fadeContent('up'); } 
	 else if (str == "fadeContent") { fadeContent(); } 
 }
 
// Confirm Delete
function confirmdelete() { if (confirm("Are you sure you want to delete? - Delete is PERMANENT")) { return true; } else { return false;}}

// ###############################
// AJAX interactivity
// ###############################
function doM_Content(DocID) {  // engine for pulling Documents
	// doSubNav('up');
	fadeContent();
	M_contentJax=GetXmlHttpObject();
	var url="CMS/apps/_content.cfm";
	url=url+"?docid="+DocID;
	url=url+"&randInt="+Math.random();
	M_contentJax.onreadystatechange=doContentView;
	M_contentJax.open("GET",url,true);
	M_contentJax.send(null);
}
function doUpContent(DocID) {  // engine for pulling Documents from within Documents
	// doSubNav('up');
	fadeContent();
	M_contentJax=GetXmlHttpObject();
	var url="_content.cfm";
	url=url+"?docid="+DocID;
	url=url+"&randInt="+Math.random();
	M_contentJax.onreadystatechange=doContentView;
	M_contentJax.open("GET",url,true);
	M_contentJax.send(null);
}
function doM_FContent(FID) { // engine for pulling Folders
	doSubNav('up');
	fadeContent();
	M_contentJax=GetXmlHttpObject();
	var url="CMS/apps/_content.cfm";
	url=url+"?fid="+FID;
	url=url+"&randInt="+Math.random();
	M_contentJax.onreadystatechange=doContentView;
	M_contentJax.open("GET",url,true);
	M_contentJax.send(null);
}
 function doF_Content(DocID) { // engine for pulling a path from anywhere to the main content window.
	// doSubNav('up');
	fadeContent();
	M_contentJax=GetXmlHttpObject();
	if (DocID.indexOf('?') == -1){	var url=DocID+"?randInt="+Math.random(); } else { var url=DocID+"&randInt="+Math.random(); }
	M_contentJax.onreadystatechange=doContentView;
	M_contentJax.open("GET",url,true);
	M_contentJax.send(null);
}

// check AJAX and define an AJAX object.
function GetXmlHttpObject() {
	var MyAjax=null;
	try {// Firefox, Opera 8.0+, Safari
  		MyAjax=new XMLHttpRequest();
  	}
	catch (e) {	// Internet Explorer
  		try { MyAjax=new ActiveXObject("Msxml2.XMLHTTP"); }
  		catch (e) { MyAjax=new ActiveXObject("Microsoft.XMLHTTP"); }
  	}
	return MyAjax;
} 
// content flipper
function doContentView() { 
	if (M_contentJax.readyState < 4) { document.getElementById('bigTit').innerHTML="loading...";
	} else if (M_contentJax.readyState == 4) { 
		if ( M_contentJax.responseText.indexOf('<!-- split -->') != -1 ) {
			theSplit = M_contentJax.responseText.split('<!-- split -->');
			if (theSplit.length > 2){
				document.getElementById("rightNav").innerHTML=theSplit[0];
				if (theSplit[1] == 0){ makeMotion(1); } else { makeMotion(250); }				
				document.getElementById("bigTit").innerHTML=theSplit[2];
				if (theSplit[3].indexOf('<!--imaOpenTable-->') > -1) {
					var otTimeA = setTimeout("setmyDate()", 3000);
					var otTimeB = setTimeout("ShowDay()", 3000);
				}
				document.getElementById("truC").innerHTML=theSplit[3];
				initRNav();
				doSubNav();
			} else {	
				document.getElementById("bigTit").innerHTML=theSplit[0];
				if (theSplit[1].indexOf('<!--imaOpenTable-->') > -1) {
					var otTimeA = setTimeout("setmyDate()", 3000);
					var otTimeB = setTimeout("ShowDay()", 3000);
				}
				document.getElementById("truC").innerHTML=theSplit[1];
			}
		} else {
			document.getElementById("truC").innerHTML = "an error occured with the request, please retry. If this problem persists, please contact a site administrator";
		//	getTextFromFlash('showContent');
		}
		fadeContent('up');
	}
}
// older and 'bit' rollover action
function doMe(myDiv,myID){
	if(myID == 1){ myDiv.style.background=overColor; myDiv.style.color=txtOnCol;  // might be unused....
	} else if (myID == 2){	myDiv.style.background="#65442C"; myDiv.style.color="#FFFFFF";	myDiv.style.cursor="pointer"	// Used for Calendar day overs.
	} else if (myID == 3){	myDiv.style.backgroundImage = "url('images/LnavItemOn.gif')"; undoFMe();						// Used for Left Navigation Buttons	
	} else if (myID == 4){	myDiv.style.color="#FF3399";	myDiv.style.cursor="pointer";									// Used for bottom of Calendar Buttons
	} else if (myID == 5){	myDiv.style.background="#ffffcd"; myDiv.style.color="#000000";									// Used for LeftNav Subs
	} else if (myID == 6){	myDiv.style.background="#ebe8c2"; myDiv.style.border="#FF3399 1px solid"; 						// Used for Folder View
	}
}
function undoMe(myDiv,myID){
	if(myID == 1){ myDiv.style.background=baseColor; myDiv.style.color=txtOffCol;
	} else if (myID == 2){	myDiv.style.background="#53301A"; myDiv.style.color="#FFFFFF";									// Used for Calendar day overs.
	} else if (myID == 3){	myDiv.style.backgroundImage = "url('images/LnavItemOff.gif')"; undoFMe();						// Used for Left Navigation Buttons
	} else if (myID == 4){	myDiv.style.color="#FFFFFF";																	// Used for bottom of Calendar Buttons
	} else if (myID == 5){	myDiv.style.background="#e7e3ad"; myDiv.style.color="#666666";									// Used for LeftNav Subs
	} else if (myID == 6){	myDiv.style.background="#ffffff"; myDiv.style.border="0px"; 																		// Used for Folder View
	}
}
// ##################################################
// OPEN TABLE SCRIPTS - supplied by opentable.com
// ##################################################
function addToArray(ar, str) {
	var l
	l = ar[0] + 1
	ar[l] = str
	ar[0] = l
}
function makeArray()
{
	array = new Object();
	array[0] = 0;
	return array;
}
var dayNames = makeArray()
addToArray(dayNames, " Sun")
addToArray(dayNames, " Mon")
addToArray(dayNames, " Tue")
addToArray(dayNames, " Wed")
addToArray(dayNames, " Thu")
addToArray(dayNames, " Fri")
addToArray(dayNames, " Sat")
function ShowDay() {
	var ryear = document.r.ResYear.selectedIndex;
	if(ryear < 0)
		ryear= 0;
	ryear= document.r.ResYear.options[ryear].value - 0;
	var rmonth = document.r.ResMonth.selectedIndex;
	var rdate = document.r.ResDate.selectedIndex + 1;
	var rnow = new Date(ryear,rmonth,rdate);
	var now = new Date();
	var rday = rnow.getDay() + 1;
	document.r.dayweek.value = dayNames[rday]
}
function setmyDate() { 	// extract date from literal..			
	var now = new Date();
	var closestTime = (now.getTime() + (30 * 60000)); //1/2 hour in advance...
	var nearest = new Date(closestTime)
	var nearmonth = nearest.getMonth();
	var neardate = nearest.getDate();
	var nearyear = nearest.getFullYear();
	document.r.ResMonth.selectedIndex = nearmonth
	document.r.ResDate.selectedIndex = neardate - 1
	document.r.ResYear.selectedIndex = nearyear-2005;
}
// ###############################
// MOUSE TRACKER
// ###############################
	function getMousePosition(mp) {
	  var _x;
	  var _y;
	  if (!isIE) {
		_x = mp.pageX;
		_y = mp.pageY;
	  }
	  if (isIE) {
		_x = event.clientX + document.body.scrollLeft;
		_y = event.clientY + document.body.scrollTop;
	  }
	  // if ((_y > 155) && (_y < 400) ){
	  if ((_y > 1) && (_y < 800) ){
	  	if (dir != 1 && _x-TheMiddle < 0){ cngDir();
		} else if (dir != 0 && _x-TheMiddle > 0){ cngDir();
		}
		theNum = Math.round((_x-TheMiddle) / (450/10));
		if (theNum <= 1 && theNum >= -1){ newSpd=1;
		} else if (theNum > 10 || theNum < -10){ newSpd=10;
		} else if (theNum < 0) { newSpd= -theNum;
		} else { newSpd = theNum;
		}
		cngSpd(newSpd);
	  } 
	  return true;
	}
// ##############################
//  START ANIMATIONS
// ##############################
function initRNav() {	/*
	var baseHeight = 20;
	// alert('boing');
	var animElements = document.getElementById("rightNav").getElementsByTagName("div");
	for(var i=0; i<animElements.length; i++) { 
			animElements[i].onmouseover = heightChange;
		 	animElements[i].onmouseout = heightRestore;
		}
	function heightChange() {
		if (!this.currentHeight) { this.currentHeight = baseHeight; } 
		if (this.heightChangeInt) { window.clearInterval(this.heightChangeInt);	 }
			var toHeight = 30;
			doSubNavOver(this,this.currentHeight,toHeight,10,1,1);
		}
	function heightRestore() {
		if (!this.currentHeight) { return; 
		} else { 
			var toHeight = 20; 
			doSubNavOver(this,this.currentHeight,toHeight,10,3,.3); } // (elem,startHeight,endHeight,steps,intervals,powr) (minValue,maxValue,totalSteps,actualStep,powr)
		}
		*/
}
function initAnims() {	
	var baseHeight = 20;
	 initRNav();
	// ######################## 
	// For the scroller 
	data=origData;
	containerEL=document.getElementById("imagePane")
	displayArea=document.getElementById("display_area")
	displayArea.innerHTML = "";
	for(var i=0;i<imgPlaces+1;i++){ // create image holders
		newImg=document.createElement("IMG");
		newImg.setAttribute("id","pic_"+i);
		newImg.setAttribute("src","");
		newImg.style.position="absolute";
		newImg.style.width=imgWidth+"px";
		newImg.style.marginTop="1px";
		newImg.style.height=imgHeight+"px";
		newImg.style.border=0;
		newImg.alt="";
		newImg.i=i;
		// newImg.onclick=function(){clikImg(data[this.i][2])}
		displayArea.appendChild(newImg);
	}
	pic0=document.getElementById("pic_0");
	containerWidth=(imgPlaces*imgWidth)+((imgPlaces-1)*imgSpacer)// 
	displayArea.style.width=containerWidth+"px"
	displayArea.style.clip=(!moz?"rect(0,"+containerWidth+","+imgHeight+",0)":"rect(0,"+containerWidth+","+imgHeight+",0)")
	// displayArea.onmouseover=function(){stopIt()}
	// displayArea.onmouseout=function(){moveIt(dir)}
	imgPos= -pic0.width
	for(var i=0;i<imgPlaces+1;i++){
		currentImage=document.getElementById("pic_"+i)
		if(dir==0){imgPos+=pic0.width+imgSpacer}
		initPos[i]=imgPos
		if(dir==0){currentImage.style.left=initPos[i]+"px"}
		if(dir==1){
			document.getElementById("pic_"+[(imgPlaces-i)]).style.left=initPos[i]+"px"
			imgPos+=pic0.width+imgSpacer
		}
		if(nextPic==data.length){nextPic=0;}
		currentImage.src=data[nextPic][0];
		currentImage.alt=data[nextPic][1];
		currentImage.idx=data[nextPic][3];
		currentImage.i=nextPic;
		// currentImage.onclick=function(){clikImg(data[this.i][2])} placePhoto
		currentImage.onclick=function(){placePhoto(this.idx)}
		nextPic++
	}
}
// ##############################
// Main & Content Frame Animation
// ##############################
function makeMotion(get2){
	var theObj = document.getElementById('imagePane');
	doChangeFrame(theObj.offsetHeight,get2,100,10,2);
}
function doChangeFrame(startHeight,endHeight,steps,intervals,powr) {
	var elem1 = document.getElementById('imagePane');
	var elem2 = document.getElementById('bigTit');
	var elem3 = document.getElementById('truC');
	SmImgr('off');
	if (elem1.heightChangeInt) { window.clearInterval(elem1.heightChangeInt); }
	var actStep = 0;
	elem1.heightChangeInt = window.setInterval(
		function() {
			document.getElementById('rightNav').style.top = document.getElementById('imagePane').offsetHeight+10+150+"px";
			document.getElementById('truC').style.height = theActualHeight-document.getElementById('imagePane').offsetHeight+15+"px";
			elem1.currentHeight = easeInOut(startHeight,endHeight,steps,actStep,powr);
			elem1.style.height = elem1.currentHeight+"px";
			elem2.style.top = elem1.currentHeight+50+"px";
			elem3.style.top = elem1.currentHeight+10+"px";
			actStep++;
			
			if ((startHeight-1 >= endHeight) && (actStep > steps)) {				// shrank and done
				SmImgr('on');
				window.clearInterval(elem1.heightChangeInt);
				reBox();
			} else if ((endHeight >= startHeight-1) && (actStep > steps)) {			//grew and done
				window.clearInterval(elem1.heightChangeInt);
				reBox();
			} else if (actStep > steps) { 
				window.clearInterval(elem1.heightChangeInt);
				reBox();
			}
		}
				,intervals)
}
function fadeContent(move) {
	elem = document.getElementById('truC');
	if (move == 'up') { 
		// alert('p');
		elem.currentAlpha = 0;
		toAlpha = 100; 
		fromAlpha=0; 
		elem.style.filter = "alpha(opacity=0"+fromAlpha+")";
		elem.style.KHTMLOpacity = fromAlpha/100;
		elem.style.MozOpacity = fromAlpha/100;
		elem.style.opacity = fromAlpha/100;
	} else { 
		toAlpha = 0; 
		fromAlpha=100;
	}	
	doAlphaChange(document.getElementById("truC"),fromAlpha,toAlpha,130,10,1);
}
// ##############################
// sub Nav Actions
// ##############################
function doSubNav(move) {
	if (move == 'up') { toHeight = 1;
		doHeightChange(document.getElementById("rightNav"),document.getElementById("rightNav").offsetHeight,1,30,10,1);
	} else { 
		doHeightChange(document.getElementById("rightNav"),document.getElementById("rightNav").offsetHeight,document.getElementById("rightNav").getElementsByTagName("div").length*20+30,130,10,1);
	}
}
function doSubNavOver(elem,startHeight,endHeight,steps,intervals,powr) {
	if (elem.heightChangeInt) window.clearInterval(elem.heightChangeInt);
	var actStep = 0;
	elem.heightChangeInt = window.setInterval(
		function() {
			elem.currentHeight = easeInOut(startHeight,endHeight,steps,actStep,powr);
			elem.style.height = elem.currentHeight+"px";
			elem.style.lineHeight = elem.currentHeight-2+"px";
			elem.style.fontSize = Math.round((elem.currentHeight-20)/3+15) +"px";
			// elem.innerHTML = elem.currentHeight;
			actStep++;
			if (actStep > steps) { window.clearInterval(elem.heightChangeInt); }
		},intervals)
}
// ##############################
// general Animation scripts
//###############################
function doAlphaChange(elem,startAlpha,endAlpha,steps,intervals,powr) {
	if (elem.alphaChangeInt) window.clearInterval(elem.alphaChangeInt);
	var actStep = 0;
	elem.alphaChangeInt = window.setInterval(
		function() {
			elem.currentAlpha = easeInOut(startAlpha,endAlpha,steps,actStep,powr);
			elem.style.filter = "alpha(opacity="+elem.currentAlpha+")";
			elem.style.KHTMLOpacity = elem.currentAlpha/100;
			elem.style.MozOpacity = elem.currentAlpha/100;
			elem.style.opacity = elem.currentAlpha/100;
			//elem.style.alpha = elem.currentAlpha+"px";
			actStep++;
			if (actStep > steps) { window.clearInterval(elem.alphaChangeInt); }
		},intervals)
}
function doHeightChange(elem,startHeight,endHeight,steps,intervals,powr) {
	if (elem.heightChangeInt) window.clearInterval(elem.heightChangeInt);
	var actStep = 0;
	elem.heightChangeInt = window.setInterval(
		function() {
			elem.currentHeight = easeInOut(startHeight,endHeight,steps,actStep,powr);
			elem.style.height = elem.currentHeight+"px";
			actStep++;
			if (actStep > steps) { window.clearInterval(elem.heightChangeInt); }
		},intervals)
}
function doWidthChange(elem,startHeight,endHeight,steps,intervals,powr) {
	if (elem.widthChangeInt) window.clearInterval(elem.widthChangeInt);
	var actStep = 0;
	elem.widthChangeInt = window.setInterval(
		function() {
			elem.currentWidth = easeInOut(startWidth,endWidth,steps,actStep,powr);
			elem.style.width = elem.currentWidth+"px";
			actStep++;
			if (actStep > steps) { window.clearInterval(elem.widthChangeInt); }
		},intervals)
}
function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) {
	var delta = maxValue - minValue;
	var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
	return Math.ceil(stepp)
}
// ############################################
// Photogallery large image open script.
// ############################################
function placePhoto(wut) {	
	var TheCheat = document.getElementById('cheater');
	var spareOne = document.getElementById('spareDiv1');
	var spareTwo = document.getElementById('spareDiv2');
	spareOne.style.width = document.getElementById('cheater').offsetWidth;
	spareTwo.style.width = document.getElementById('cheater').offsetWidth;
	spareOne.style.background = "#990000";
	// spareTwo.style.background = "#000000";
	spareOne.style.filter = "alpha(opacity=50)";
	spareOne.style.KHTMLOpacity = ".50";
	spareOne.style.MozOpacity = ".50";
	spareOne.style.opacity = ".50";
	spareOne.style.zIndex = "10001";
	spareTwo.style.zIndex = "10002";
	
	spareOne.style.top = 1+"px";
	spareOne.style.left = 1+"px";
	spareTwo.style.top = 1+"px";
	spareTwo.style.left = 1+"px";
	
	var toHeight = document.getElementById('cheater').offsetHeight-2 ;
	var toWidth = document.getElementById('cheater').offsetWidth-2 ;
	// alert(wut);
	 spareTwo.innerHTML = "<table border='0' cellspacing='0' cellpadding='0' style='padding-left: 10px; padding-right: 10px; height:"+toHeight+"px; width:"+toWidth+"px;' onClick='hidePhoto();'><tr><td align='right' style='color:#FFFFFF; font-size:10px; valign:top; height:12px;'><b>close image</b>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr><tr><td valign='middle' align='center'><img src='"+data[wut][2]+"' border='0'></td></tr></table>";
	//  height='"+parseInt(toHeight-200)+"'
	doHeightChange(spareOne,1,toHeight,70,1,1);
	doHeightChange(spareTwo,1,toHeight,130,1,1.333);
	
	// document.getElementById('spareDiv1').style.height = document.getElementById('CFrame').offsetHeight+3+"px";
	timeDeath = setTimeout("releaseBar()", 3000);
}
function releaseBar() {noMove=0; stopper = -1;} 
// Hide Photo.<div></div>
function hidePhoto() {	
	var spareOne = document.getElementById('spareDiv1');
	var spareTwo = document.getElementById('spareDiv2');
	doHeightChange(spareOne,spareOne.offsetHeight,1,130,1,1);
	doHeightChange(spareTwo,spareTwo.offsetHeight,1,70,1,1.333);
}
// #############################################
// Small Imager thingy
// #############################################
var curImg = 0;
var sideTime = "";
function SmImgr(wut) {
	if (wut != 'off') {
		if (curImg >= imgPlaces) { curImg = 0; }
		document.getElementById('imgBox').innerHTML="<img width='157' height='240' border='0' onClick='' src='"+data[curImg][0]+"'>";
		curImg++ ;
		sideTime = setTimeout("SmImgr()",5000);
	} else if (wut == 'off') {
		clearTimeout(sideTime);
		document.getElementById('imgBox').innerHTML="";
	}
}
// #############################################
// Banner Rotation & functions
// #############################################
function cngDir() {
	if (dir==1){ dir=0;	} else { dir=1; }
}
function cngSpd(to){ 
	if(to){lastTo=to;}
	clearTimeout(speedTimer);
	if (lastTo <= 1) {
		nowSpd=0;
		stopIt();
	} else if (nowSpd == 0) {
		nowSpd = 1
		speed = slowest - (speedStep*nowSpd);
		speedTimer = setTimeout("cngSpd()",100);
		moveIt();
	} else if (nowSpd < lastTo){
		nowSpd=nowSpd+1;
		speedTimer = setTimeout("cngSpd()",100);
		speed = slowest - (speedStep*nowSpd);
	} else if (nowSpd > lastTo) {
		nowSpd=nowSpd-1;
		speedTimer = setTimeout("cngSpd()",100);
		speed = slowest - (speedStep*nowSpd);
	} 
}
// Move the banner to
function stopAt(wut){ 
	// clearTimeout(timer);
	for(i=0;i<imgPlaces+1;i++){ 
		currentImage=document.getElementById("pic_"+i);
		nowDivPos[i]=parseInt(currentImage.style.left);
		 
		if ((nowDivPos[i] <= (idealWidth/2+imgWidth/2)) && (nowDivPos[i] >= (idealWidth/2-imgWidth/2))) {
			if ( (i-wut == 0) && nowDivPos[i] > (idealWidth/2) ) { dir=0; // alert('i made 1');		
			} else if ( (i-wut == 0) && nowDivPos[i] < (idealWidth/2) ) { dir=0;  // alert("i made 2    "+nowDivPos[i]+" < "+(idealWidth/2)); 				
			} else if ((i - wut > parseInt(imgPlaces)/2) || ( (i - wut < 0) && (i - wut > -(parseInt(imgPlaces)/2) ))  ){ dir = 0; } else { dir = 1; }
		}
	}
	cngSpd(10);
	noMove=0;
	stopper = wut;	
	timer=setTimeout("moveIt()",60);
}
// STOP function
function stopIt(){ 
	clearTimeout(speedTimer);
	clearTimeout(timer); 
	nowSpd=0;
	}
// GO function
function goIt(){ 
	clearTimeout(timer);
	noMove=0;
	stopper = -1;	
	timer=setTimeout("moveIt()",speed);
}
// Move the banners 
function moveIt(){
	nextPic=0;
	noMove=0;
	clearTimeout(timer);
	thisStep = step;	
	myDir=dir;
	if (isLocked != 1){
		isLocked = 1;
		for(var i=0;i<imgPlaces+1;i++){
			currentImage=document.getElementById("pic_"+i)
			nowDivPos[i]=parseInt(currentImage.style.left)
			if(myDir==0){nowDivPos[i]-=thisStep}
			if(myDir==1){nowDivPos[i]+=thisStep}
			if(myDir==0&&nowDivPos[i]<= -(pic0.width+imgSpacer) || myDir==1&&nowDivPos[i]>containerWidth){ 
				if(myDir==0){currentImage.style.left=containerWidth+(imgSpacer*2)+"px"} 
				if(myDir==1){currentImage.style.left= -pic0.width+(-imgSpacer*3)+"px"} 
				if(nextPic>data.length-1){nextPic=0;}
				nextPic++
			} else {
				currentImage.style.left=nowDivPos[i]+"px"
			}
			if ((stopper != -1) && (currentImage.idx == stopper)){ 
				if ((nowDivPos[i] <= (idealWidth/2-imgWidth/2+maxStep/2)) && (nowDivPos[i] >= (idealWidth/2-imgWidth/2-maxStep/2)) ){	// stopIt();	alert(currentImage.src); grow(currentImage.id);
					noMove=1;
					placePhoto(currentImage.i);
				}
			}
		}
		isLocked = 0;
	}
	if (noMove!=1){timer=setTimeout("moveIt()",speed)}
}

var isDOM=document.getElementById?1:0,isIE=document.all?1:0,isNS4=navigator.appName=='Netscape'&&!isDOM?1:0,isIE4=isIE&&!isDOM?1:0,isOp=self.opera?1:0,isDyn=isDOM||isIE||isNS4;function getRef(i,p){p=!p?document:p.navigator?p.document:p;return isIE?p.all[i]:isDOM?(p.getElementById?p:p.ownerDocument).getElementById(i):isNS4?p.layers[i]:null};function getSty(i,p){var r=getRef(i,p);return r?isNS4?r:r.style:null};if(!self.LayerObj)var LayerObj=new Function('i','p','this.ref=getRef(i,p);this.sty=getSty(i,p);return this');function getLyr(i,p){return new LayerObj(i,p)};function LyrFn(n,f){LayerObj.prototype[n]=new Function('var a=arguments,p=a[0],px=isNS4||isOp?0:"px";with(this){'+f+'}')};LyrFn('x','if(!isNaN(p))sty.left=p+px;else return parseInt(sty.left)');LyrFn('y','if(!isNaN(p))sty.top=p+px;else return parseInt(sty.top)');LyrFn('vis','sty.visibility=p');LyrFn('bgColor','if(isNS4)sty.bgColor=p?p:null;else sty.background=p?p:"transparent"');LyrFn('bgImage','if(isNS4)sty.background.src=p?p:null;else sty.background=p?"url("+p+")":"transparent"');LyrFn('clip','if(isNS4)with(sty.clip){left=a[0];top=a[1];right=a[2];bottom=a[3]}else sty.clip="rect("+a[1]+"px "+a[2]+"px "+a[3]+"px "+a[0]+"px)" ');LyrFn('write','if(isNS4)with(ref.document){write(p);close()}else ref.innerHTML=p');LyrFn('alpha','var f=ref.filters,d=(p==null),o=d?"inherit":p/100;if(f){if(!d&&sty.filter.indexOf("alpha")==-1)sty.filter+=" alpha(opacity="+p+")";else if(f.length&&f.alpha)with(f.alpha){if(d)enabled=false;else{opacity=p;enabled=true}}}else if(isDOM)sty.opacity=sty.MozOpacity=o');function setLyr(v,dw,p){if(!setLyr.seq)setLyr.seq=0;if(!dw)dw=0;var o=!p?isNS4?self:document.body:!isNS4&&p.navigator?p.document.body:p,IA='insertAdjacentHTML',AC='appendChild',id='_sl_'+setLyr.seq++;if(o[IA])o[IA]('beforeEnd','<div id="'+id+'" style="position:absolute"></div>');else if(o[AC]){var n=document.createElement('div');o[AC](n);n.id=id;n.style.position='absolute'}else if(isNS4){var n=new Layer(dw,o);id=n.id}var l=getLyr(id,p);with(l)if(ref){vis(v);x(0);y(0);sty.width=dw+(isNS4?0:'px')}return l};if(!self.page)var page={win:self,minW:0,minH:0,MS:isIE&&!isOp};page.db=function(p){with(this.win.document)return(isDOM?documentElement[p]:0)||body[p]||0};page.winW=function(){with(this)return Math.max(minW,MS?db('clientWidth'):win.innerWidth)};page.winH=function(){with(this)return Math.max(minH,MS?db('clientHeight'):win.innerHeight)};page.scrollX=function(){with(this)return MS?db('scrollLeft'):win.pageXOffset};page.scrollY=function(){with(this)return MS?db('scrollTop'):win.pageYOffset};function addProps(obj,data,names,addNull){for(var i=0;i<names.length;i++)if(i<data.length||addNull)obj[names[i]]=data[i]};function PopupMenu(myName){this.myName=myName;this.showTimer=this.hideTimer=this.showDelay=0;this.hideDelay=500;this.menu={};this.litNow={};this.litOld={};this.overM='';this.overI=0;this.hideDocClick=0;this.actMenu=null;PopupMenu.list[myName]=this};PopupMenu.list={};var PmPt=PopupMenu.prototype;PmPt.callEvt=function(mN,iN,evt){var i=this.menu[mN][iN],r1=this[evt]?this[evt](mN,iN):0,r2;if(i[evt]){if(i[evt].substr)i[evt]=new Function('mN','iN',i[evt]);r2=i[evt](mN,iN)}return typeof r2=='boolean'?r2:r1};PmPt.over=function(mN,iN){with(this){clearTimeout(hideTimer);overM=mN;overI=iN;var evtRtn=iN?callEvt(mN,iN,'onmouseover'):0,rtn=evtRtn||false;litOld=litNow;litNow={};var litM=mN,litI=iN;if(mN)do{litNow[litM]=litI;litI=menu[litM][0].parentItem;litM=menu[litM][0].parentMenu}while(litM);var same=1;for(var z in menu)same&=(litNow[z]==litOld[z]);if(same)return rtn;clearTimeout(showTimer);for(var thisM in menu)with(menu[thisM][0]){if(!lyr)continue;lI=litNow[thisM];oI=litOld[thisM];if(lI!=oI){if(lI)changeCol(thisM,lI);if(oI)changeCol(thisM,oI)}if(!lI)clickDone=0;if(isRoot)continue;if(lI&&!visNow)doVis(thisM,1);if(!lI&&visNow)doVis(thisM,0)}nextMenu='';if(menu[mN]&&menu[mN][iN].sm&&(evtRtn+''!='false')){var m=menu[mN],t=m[iN].sm;if(!menu[t])return rtn;if(m[0].clickSubs&&!m[0].clickDone)return rtn;nextMenu=t;if(showDelay)showTimer=setTimeout(myName+'.doVis("'+t+'",1)',showDelay);else doVis(t,1)}return rtn}};PmPt.out=function(mN,iN){with(this){if(mN!=overM||iN!=overI)return;var thisI=menu[mN][iN],evtRtn=iN?callEvt(mN,iN,'onmouseout'):0;if(thisI.sm!=nextMenu){clearTimeout(showTimer);nextMenu=''}if(hideDelay&&(evtRtn+''!='false')){var delay=menu[mN][0].isRoot&&!thisI.sm?50:hideDelay;hideTimer=setTimeout(myName+'.over("",0)',delay)}overM='';overI=0}};PmPt.click=function(mN,iN){with(this){var m=menu[mN],evtRtn=callEvt(mN,iN,'onclick'),hm=1;if(evtRtn+''=='false')return false;with(m[iN]){if(type=='js:')eval(href);else{if(sm&&m[0].clickSubs){m[0].clickDone=1;doVis(sm,1);hm=0}if(href){type=type||'window';eval(type+'.location.href="'+href+'"')}}}if(hm)over('',0);return evtRtn||false}};PmPt.changeCol=function(mN,iN,fc){with(this.menu[mN][iN]){if(!lyr||!lyr.ref)return;var bgFn=outCol!=overCol?(outCol.indexOf('.')==-1?'bgColor':'bgImage'):0;var ovr=(this.litNow[mN]==iN)?1:0,doFX=(!fc&&this.litNow[mN]!=this.litOld[mN]);var col=ovr?overCol:outCol;if(fade[0]){clearTimeout(timer);col='#';count=Math.max(0,Math.min(count+(2*ovr-1)*parseInt(fade[ovr][0]),100));var oc,nc,hexD='0123456789ABCDEF';for(var i=1;i<4;i++){oc=parseInt('0x'+fade[0][i]);nc=parseInt(oc+(parseInt('0x'+fade[1][i])-oc)*(count/100));col+=hexD.charAt(Math.floor(nc/16)).toString()+hexD.charAt(nc%16)}if(count%100>0)timer=setTimeout(this.myName+'.changeCol("'+mN+'",'+iN+',1)',50)}if(bgFn&&isNS4)lyr[bgFn](col);var reCSS=(overClass!=outClass||outBorder!=overBorder);if(doFX)with(lyr){if(!this.noRW&&(overText||overInd||isNS4&&reCSS))write(this.getHTML(mN,iN,ovr));if(!isNS4&&reCSS){ref.className=(ovr?overBorder:outBorder);var chl=(isDOM?ref.childNodes:ref.children);if(chl&&!overText)for(var i=0;i<chl.length;i++)chl[i].className=ovr?overClass:outClass}}if(bgFn&&!isNS4)lyr[bgFn](col);if(doFX&&outAlpha!=overAlpha)lyr.alpha(ovr?overAlpha:outAlpha)}};PmPt.position=function(posMN){with(this){for(mN in menu)if(!posMN||posMN==mN)with(menu[mN][0]){if(!lyr||!lyr.ref||!visNow)continue;var pM,pI,newX=eval(offX),newY=eval(offY);if(!isRoot){pM=menu[parentMenu];pI=pM[parentItem].lyr;if(!pI)continue}var eP=eval(par),pW=(eP&&eP.navigator?eP:window);with(pW.page)var sX=scrollX(),wX=sX+winW()||9999,sY=scrollY(),wY=winH()+sY||9999;var sb=page.MS?5:20;if(pM&&typeof(offX)=='number')newX=Math.max(sX,Math.min(newX+pM[0].lyr.x()+pI.x(),wX-menuW-sb));if(pM&&typeof(offY)=='number')newY=Math.max(sY,Math.min(newY+pM[0].lyr.y()+pI.y(),wY-menuH-sb));lyr.x(newX);lyr.y(newY)}}};PmPt.doVis=function(mN,show){with(this){var m=menu[mN],sh=(show?'show':'hide'),mA=sh+'Menu',mE='on'+sh;m[0].visNow=show;if(m&&m[0].lyr&&m[0].lyr.ref){if(show)position(mN);var p=m[0].parentMenu;if(p)m[0].lyr.sty.zIndex=m[0].zIndex=menu[p][0].zIndex+2;if(this[mE])this[mE](mN);if(this[mA])this[mA](mN);else m[0].lyr.vis(show?'visible':'hidden')}}};function ItemStyle(){var names=['len','spacing','popInd','popPos','pad','outCol','overCol','outClass','overClass','outBorder','overBorder','outAlpha','overAlpha','normCursor','nullCursor'];addProps(this,arguments,names,1)};PmPt.startMenu=function(mName){with(this){if(!menu[mName])menu[mName]=[{}];actMenu=menu[mName];aM=actMenu[0];actMenu.length=1;var names=['name','isVert','offX','offY','width','itemSty','par','clickSubs','clickDone','visNow','parentMenu','parentItem','oncreate','isRoot'];addProps(aM,arguments,names,1);aM.extraHTML='';aM.menuW=aM.menuH=0;aM.zIndex=1000;if(!aM.lyr)aM.lyr=null;if(mName.substring(0,4)=='root'){aM.isRoot=1;aM.oncreate=new Function('obj','this.visNow=1;obj.position("'+mName+'");this.lyr.vis("visible")')}return aM}};PmPt.addItem=function(){with(this)with(actMenu[0]){var aI=actMenu[actMenu.length]={};var names=['text','href','type','itemSty','len','spacing','popInd','popPos','pad','outCol','overCol','outClass','overClass','outBorder','overBorder','outAlpha','overAlpha','normCursor','nullCursor','iX','iY','iW','iH','fW','fH','overText','overInd','sm','lyr','onclick','onmouseover','onmouseout'];addProps(aI,arguments,names,1);var iSty=arguments[3]?arguments[3]:actMenu[0].itemSty;for(prop in iSty)if(aI[prop]+''=='undefined')aI[prop]=iSty[prop];if(aI.type=='sm:'){aI.sm=aI.href;aI.href=''}var r=RegExp,re=/^SWAP:(.*)\^(.*)$/;if(aI.text.match(re)){aI.text=r.$1;aI.overText=r.$2}if(aI.popInd.match(re)){aI.popInd=r.$1;aI.overInd=r.$2}aI.timer=aI.count=0;aI.fade=[];for(var i=0;i<2;i++){var oC=i?'overCol':'outCol';if(aI[oC].match(/^(\d+)\#(..)(..)(..)$/)){aI[oC]='#'+r.$2+r.$3+r.$4;aI.fade[i]=[r.$1,r.$2,r.$3,r.$4]}}if(aI.outBorder&&isNS4)aI.pad++;if(!isIE){if(aI.normCursor=='hand')aI.normCursor='pointer';if(aI.nullCursor=='hand')aI.nullCursor='pointer'}aI.iW=isVert?width:aI.len;aI.iH=isVert?aI.len:width;var lastGap=actMenu.length>2?actMenu[actMenu.length-2].spacing:0;var spc=aI.outBorder&&actMenu.length>2?1:0;if(isVert){menuH+=lastGap-spc;aI.iX=0;aI.iY=menuH;menuW=width;menuH+=aI.iH}else{menuW+=lastGap-spc;aI.iX=menuW;aI.iY=0;menuW+=aI.iW;menuH=width}return aI}};PmPt.getHTML=function(mN,iN,isOver){with(this){var itemStr='';with(menu[mN][iN]){var tC=isOver?overClass:outClass,txt=isOver&&overText?overText:text,popI=isOver&&overInd?overInd:popInd,ln='<a href="'+(href&&type!='js:'?href:'#')+'" onclick="return false" onfocus="this.blur()" class="'+tC+(isNS4?'" onmouseover="'+myName+'.over(\''+mN+'\','+iN+')"':'"');if(popI&&sm){if(isNS4)itemStr+='<layer class="'+tC+'" left="'+((popPos+fW)%fW)+'" top="'+pad+'" height="'+(fH-2*pad)+'">'+popI+'</layer>';else itemStr+='<div class="'+tC+'" style="position:absolute;left:'+((popPos+fW)%fW)+'px;top:'+pad+'px;height:'+(fH-2*pad)+'px">'+popI+'</div>'}if(isNS4)itemStr+=(outBorder?'<span class="'+(isOver?overBorder:outBorder)+'"><spacer type="block" width="'+(fW-8)+'" height="'+(fH-8)+'"></span>':'')+'<layer left="'+pad+'" top="'+pad+'" width="'+(fW-2*pad)+'" height="'+(fH-2*pad)+'">'+ln+'>'+txt+'</a></layer>';else{itemStr+=(isIE4?'<div class="'+tC+'" ':ln)+' style="position:absolute;left:'+pad+'px;top:'+pad+'px;width:'+(fW-2*pad)+'px;height:'+(fH-2*pad)+'px;cursor:'+(href?normCursor:nullCursor)+'">'+txt+(isIE4?'</div>':'</a>')}}return itemStr}};PmPt.update=function(docWrite,upMN){with(this){if(!isDyn)return;for(mN in menu)with(menu[mN][0]){if(upMN&&upMN!=mN)continue;var str='',eP=eval(par);with(eP&&eP.navigator?eP:self)var dC=document.compatMode,dT=document.doctype;dFix=(dC&&dC.indexOf('CSS')>-1||isOp&&!dC||dT&&dT.name.indexOf('.dtd')>-1||isDOM&&!isIE)?2:0;for(var iN=1;iN<menu[mN].length;iN++)with(menu[mN][iN]){var tM=menu[sm],itemID=myName+'-'+mN+'-'+iN;if(sm&&tM){tM[0].parentMenu=mN;tM[0].parentItem=iN}if(outBorder){fW=iW-dFix;fH=iH-dFix}else{fW=iW;fH=iH}var isImg=(outCol.indexOf('.')!=-1);if(isDOM||isIE4){str+='<div id="'+itemID+'" '+(outBorder?'class="'+outBorder+'" ':'')+'style="position:absolute;left:'+iX+'px;top:'+iY+'px;width:'+fW+'px;height:'+fH+'px;z-index:'+zIndex+';'+(outCol?'background:'+(isImg?'url('+outCol+')':outCol):'')+(typeof(outAlpha)=='number'?';filter:alpha(opacity='+outAlpha+');-moz-opacity:'+outAlpha+'%;opacity:'+(outAlpha/100):'')+';cursor:'+(href?normCursor:nullCursor)+'" '}else if(isNS4){str+='<layer id="'+itemID+'" left="'+iX+'" top="'+iY+'" width="'+fW+'" height="'+fH+'" z-index="'+zIndex+'" '+(outCol?(isImg?'background="':'bgcolor="')+outCol+'" ':'')}var evtMN="('"+mN+"',"+iN+")";str+='onmouseover="return '+myName+'.over'+evtMN+'" onmouseout="'+myName+'.out'+evtMN+'" onclick="return '+myName+'.click'+evtMN+'">'+getHTML(mN,iN,0)+(isNS4?'</layer>':'</div>')}var sR=myName+'.setupRef('+(docWrite?1:0)+',"'+mN+'")';if(isOp)setTimeout(sR,1000);var mVis=isOp&&isRoot?'visible':'hidden';if(docWrite){var targFr=eP&&eP.navigator?eP:window;targFr.document.write('<div id="'+myName+'-'+mN+'" style="position:absolute;visibility:'+mVis+';left:'+(isOp?-1000:0)+'0px;top:0px;width:'+(menuW+2)+'px;height:'+(menuH+2)+'px;z-index:1000">'+str+extraHTML+'</div>')}else{if(!lyr||!lyr.ref)lyr=setLyr(mVis,menuW,eP);else if(isIE4)setTimeout(myName+'.menu.'+mN+'[0].lyr.sty.width='+(menuW+2),50);with(lyr){sty.zIndex=1000;write(str+extraHTML)}}if(!isOp)setTimeout(sR,100)}}};PmPt.setupRef=function(docWrite,mN){with(this)with(menu[mN][0]){var eP=eval(par);if(docWrite||!lyr||!lyr.ref)lyr=getLyr(myName+'-'+mN,eP);for(var i=1;i<menu[mN].length;i++)menu[mN][i].lyr=getLyr(myName+'-'+mN+'-'+i,isNS4?lyr.ref:eP);lyr.clip(0,0,menuW+2,menuH+2);if(oncreate)oncreate(this)}};

