var _datesClicked=[];

function MultiDimArray(iRows,iCols) {
	var i,j;
	var arr = new Array(iRows);

	for (i=0; i < iRows; i++)
	{
		arr[i] = new Array(iCols);
		for (j=0; j < iCols; j++)
		{
			arr[i][j] = "";
		}
	}

	return(arr);
}

function fProcessMouseClick(id,t,date) {
	t.className='dayMouseClick';
  	var indx=fArraySearch(_datesClicked,date);

	if(indx == -1) {
		_datesClicked.push(date);
	}
	else {
		_datesClicked.splice(indx,1);
		t.className=_elemClassName[id];
	}

	_datesClicked.sort();
}

function fMouseOver(id,t,date) {
	_datesClicked.sort();
	if(fArraySearch(_datesClicked,date) == -1) {
		t.className='dayMouseOver';
	}
}

function fMouseOut(id,classArr,t,date) {
	_datesClicked.sort();
	if(fArraySearch(_datesClicked,date) == -1) {
		t.className=classArr[id];
	}
}

function fArraySearch(vArray,vValue){
	var iStartIndex, iEndIndex, iMiddleIndex;
	iStartIndex = 0;
	iMiddleIndex = -1;
	iEndIndex = vArray.length - 1;

	while (true)
	{
		iMiddleIndex = iStartIndex + Math.ceil((iEndIndex - iStartIndex) / 2);
		switch(vValue)
		{
		case vArray[iStartIndex]: return iStartIndex;
		case vArray[iMiddleIndex]: return iMiddleIndex;
		case vArray[iEndIndex]: return iEndIndex;
		}
		if (iStartIndex == iMiddleIndex || iEndIndex == iMiddleIndex) return -1;
		if (vValue > vArray[iMiddleIndex])
		{
			iStartIndex = iMiddleIndex + 1;
		}
		else if (vValue < vArray[iMiddleIndex])
		{
			iEndIndex = iMiddleIndex - 1;
		}
	}

	return -1;
}

function checkBox(box,id,dates) {
	if(!box.checked) {
		// box was checked and now it will be unchecked
  		box.checked=false;
  		var idx=0;
  		_datesClicked.sort();
  		for(var i=id+1;i<id+8;i++) {
  			idx=fArraySearch(_datesClicked,dates[i]);
  			if(idx != -1) _datesClicked.splice(idx,1);
  			document.getElementById(i).className=_elemClassName[i];
  		}
 	}
 	else {
 		// box not checked
 		_datesClicked.sort();
 		for(var i=id+1;i<id+8;i++) {
 			//_elemClassName[i]=document.getElementById(i).className;
 			document.getElementById(i).className='dayMouseClick';
 			if(fArraySearch(_datesClicked,dates[i]) == -1) {
 				_datesClicked.push(dates[i]);
 			}
 		}
 	}
 }

var temp=document.monthandyear.year;

function go(elem) {
	monthIndex=document.monthandyear.month.selectedIndex+1;
	year=temp.options[temp.selectedIndex].value;
	elem.href='reservation.php?mo='+monthIndex+'&yr='+year;
}

function book(elem) {
	if(_datesClicked=='') {
		alert('Please mark dates on a calendar in order to continue with your booking.');
		return;
	}
  	elem.href='confirmation.php?dt='+_datesClicked;
}

function getImg(im){
	var i=new Image();
	i.src='../images/bt'+im;
	return i;
}

function buttonAction(id,name){
	x=id.substring(0,id.length-1);
	document[name+x].src=eval(name+id+'.src');
	if(id.indexOf('e')!=-1)document[name+x+'e'].src=eval(name+id+'e.src');
}

goButton0n=getImg('0_1.gif');
goButton0f=getImg('0_0.gif');
goButton0c=getImg('0_2.gif');

bookButton0n=getImg('1_1.gif');
bookButton0f=getImg('1_0.gif');
bookButton0c=getImg('1_2.gif');

function qanda(ev,w,h) {
	var winl=(screen.width-w) / 2;
	var wint=(screen.height-h) / 2;

	win=window.open("escalEV.php?ev="+ev+"&readFile=0&readSQL=0","ESCalendar","scrollbars=yes,status=no,location=no,toolbar=no,menubar=no,directories=no,resizable=no,width="+w+",height="+h+",top="+wint+",left="+winl+"");

	if (parseInt(navigator.appVersion) >=4) {
		win.window.focus();
	};
}

// Menu engine
function JSFX_FloatTopLeft()
{
	var startX = 10, startY = 134;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	var px = document.layers ? "" : "px";
	function ml(id)
	{
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
		el.x = startX; el.y = startY;
		return el;
	}
	window.stayTopLeft=function()
	{
		var pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
		var dY = (pY > startY) ? pY : startY;
		ftlObj.y += (dY - ftlObj.y)/8;
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 20);
	}
	ftlObj = ml("divFoldCont");
	stayTopLeft();
}
JSFX_FloatTopLeft();