
function load_function(page){
	if(page == "submit.php"){
		if(document.theform != null && document.theform.name != null){
			document.theform.name.focus();
		}
	}
}

function nostatus(){
	window.status = company_name;
	return true
}

document.onmouseover = nostatus
document.onmouseout = nostatus
document.onmousedown = nostatus


function textCounter(area,maxlength){
	if(area.value.length >= maxlength){
		alert("You've reached the " + maxlength + " character limit.");
		area.value = area.value.substring(0, maxlength);
		event.returnValue = false;
	}
}

function promptLogin(){
	var x = confirm("This is a password protected area.\nWould you like to continue?");
	if(x){
		document.location.href = "admin/index.php";
	} else {
		return;
	}
}

function optionWindow(loc) {
	var x = 700;
	var y = 500;
	center_width = (screen.availWidth) ? (screen.availWidth-x)/2 : 0;
	center_height = (screen.availHeight) ? (screen.availHeight-y)/2 : 0;
	window.open(loc,'GotLunchMauiMenu','dependent=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+x+',height='+y+',top='+center_height+',left='+center_width);
}

function show_more_info(){
	document.getElementById("more_info_link").style.display = "none";
	document.getElementById("more_info").style.display = "";
}

function show_archives(){
	document.getElementById("view_archives").style.display = "none";
	document.getElementById("archived_polls").style.display = "";
}


//Submit Restaurant Form
function validate_submit_form(){
	var required = "";
	if (document.theform.name.value.length == 0) { required += "\n     - Name"; document.theform.name.className='textBoxRequired'; }
	if (document.theform.confirm1.value != document.theform.confirm2.value) { required += "\n     - Re-type Word"; document.theform.confirm2.className='textBoxRequired'; }
		
	if (required != "") {
		alert("Please fill in the required fields:" + required);
		return false;
	}
}

function reset_submit_form(){
	var x = confirm("Are you sure you want to erase all of your data and start over?");
	if(x){
		document.theform.name.className='textBox';
		document.theform.confirm2.className='textBox';
		document.theform.reset();
		document.theform.name.focus();
		
	} else {
		return;
	}
}


//Testimonials Page
function validate_testimonials_form(){
	var required = "";
	if (document.theform.name.value.length == 0) { required += "\n     - Name"; document.theform.name.className='textBoxRequired'; }
	if (document.theform.email.value.length == 0) { required += "\n     - Email"; document.theform.email.className='textBoxRequired'; }
	else if (document.theform.email.value.search(/(\w+[\w|\.|-]*\w+)(@\w+[\w|\.|-]*\w+\.\w{2,4})/) == -1) { required += "\n     - Please specify a valid email address"; document.theform.email.className='textBoxRequired'; }
	if (document.theform.comment.value.length == 0) { required += "\n     - Comment"; document.theform.comment.className='textBoxRequired'; }
	if (document.theform.confirm1.value != document.theform.confirm2.value) { required += "\n     - Re-type Word"; document.theform.confirm2.className='textBoxRequired'; }
	
	if (required != "") {
		alert("Please fill in the required fields:" + required);
		return false;
	}
}
		
function reset_testimonials_form(){
	var x = confirm("Are you sure you want to erase all of your data?");
	if(x){
		document.theform.name.focus();
		document.theform.name.className='textBox';
		document.theform.email.className='textBox';
		document.theform.comment.className='textBox';
		document.theform.confirm2.className='textBox';
		document.theform.reset();
	}
}

function show_form(){
	document.getElementById("comment_output").style.height = "132px";
	document.getElementById("comment_output").style.width = "475px";
	document.getElementById("comment_form").style.display = "";
	document.getElementById("comment_header").style.display = "none";
	document.theform.name.focus();
}



//Tooltip
/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip


//Fixed Tooltip
/***********************************************
* Fixed ToolTip script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="fixedtipdiv" style="visibility:hidden;" ></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden

// Added these next two lines to ensure that the div isn't larger than 300 pixels wide
dropmenuobj.style.width = "auto";
if(parseInt(dropmenuobj.offsetWidth) > 300){ dropmenuobj.style.width = "300px"; }
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
}
return edgeoffset
}

function fixedtooltip(menucontents, obj, e){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidetip()
dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv
dropmenuobj.innerHTML=menucontents

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
}

function hidetip(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidetip(){
if (ie4||ns6)
delayhide=setTimeout("hidetip()",disappeardelay)
}

function clearhidetip(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}