window.movingFood = 'no'
window.numberFood = '';

document.observe("dom:loaded", function() {
	var numberPics = $$('.bannerPic');
	window.numberFood = numberPics.length;
	var newWidth = (window.numberFood * 287) + 'px';
	$('bannerRibbonBox').setStyle({ width: newWidth });
});

function slideFood(direction) {

	var maxLeft = (window.numberFood - 3) * -286;
	var maxRight = 0;
	var currentLeft = document.getElementById('bannerRibbonBox').offsetLeft;

	if ((direction == 'left') && (currentLeft > maxLeft) && (window.movingFood == 'no')) {
		window.movingFood = 'yes';
		new Effect.Move('bannerRibbonBox', { 
			x: -287, 
			transition: Effect.Transitions.sinoidal, 
			queue: 'end', 
			afterFinish: function() { 
				window.movingFood = 'no';
			}
		});
	}

	if ((direction == 'right') && (currentLeft < maxRight) && (window.movingFood == 'no')) {
		window.movingFood = 'yes';
		new Effect.Move('bannerRibbonBox', { 
			x: 287, 
			transition: Effect.Transitions.spring, 
			queue: 'end', 
			afterFinish: function() { 
				window.movingFood = 'no';
			}
		});
	}

}

// ANCIENT & VENERABLE IMAGE ROLL

function normRoll(imgname, imgsrc) {
	imgsrc = "imgTemplate/" + imgsrc;
	document.images[imgname].src = imgsrc;
	return true;
}

// MENU SYSTEM

sfHover = function() {
	var sfEls = document.getElementById("navTop").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


// FORM VALIDATION

function emailvalidation(entered, alertbox) {
	with (entered) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) {
			if (alertbox) {
				alert(alertbox);
			} 
			return false;
		} else {
			return true;
		}
	}
}

function emptyvalidation(entered, alertbox) {
	with (entered) {
		if (value==null || value=="" || value==0) {
			if (alertbox!="") {
				alert(alertbox);
			} return false;
		} else {
			return true;
		}
	}
}


function filevalidation(entered, alertbox) {
	docmarker = 0;
//	alert(whichmany);
	with (entered) {
		if (value == "") {
			value = none;
		}
//		alert(value);
		for (var i = 0; i <= whichmany; i++) {
			oppos=value.lastIndexOf(whichdocs[i]);
			xpos = value.length;
			markpos = xpos - 4;
//			alert(markpos + " " + oppos);
			if (markpos == oppos) {
				docmarker = 1;
			}
		}
		
		if (docmarker != 1) {
			if (alertbox) {
				alert(alertbox);
			}
			return false;
		} else {
			return true;
		}

	}
}

/* OPEN TABLE HACK */

function openTable() {
	var thisOne = document.openMe.whichOne.value;
	document.openMe.action="http://www.opentable.com/single.aspx?rid=" + thisOne + "&restref=" + thisOne + "&rtype=ism";
}

