function loadGuide()
{
var text;
text="<br/><p>Welcome to DurangoMenu.com.</p><p>";
text+="The following questions will help you narrow down restaurants to match your criteria.<p/>--";

//check for checked options here and decide what question comes first
if(wasQuick())
{
text+="<p><b>Starting the Guided Search will clear your search criteria.</b> <br/><br/>Would you like to continue?<br/>";
text+="<input type='button' onclick='clearquick();' value='OK'/>";
text+="<input type='button' onclick='hidePage();' value='Cancel'/></p>";
}
else
{
text=currentquest(text);
}

document.getElementById('guidecontent').innerHTML = text;
}

function currentquest(text)
{
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var today = new Date();
var day = today.getDay();
var hours = today.getHours();
var time;

if(hours >= 5 && hours < 11){time="Morning";}
if(hours >= 11 && hours < 17){time="Lunch";}
if(hours >= 17 && hours < 21){time="Evening";}
if(hours >= 21 && hours < 25){time="Night";}
if(hours >= 0 && hours < 5){time="Night";}

text+="<br/><p>Do you want to see just the restaurants that are open right now?<br/><br/> ";
text+="<b>"+days[day]+" at "+time+"</b><br/>";
text+="<input type='button' onclick='dayquest(1);' value='Yes'/>";
text+="<input type='button' onclick='dayquest(0);' value='No'/></p>";
return text;
}

function dayquest(current)
{
var text="";

if(current)
{
 document.checkform.checkbox.checked=true;
 showdate=false;
 date();
 selectsome();
 searchIt();
 mealquest(0);
}
else
{
//specific day
text+="<br/><p>Do you want to see restaurants that are open on a specific day of the week?<br/><br/> ";
text+="<input type='button' onclick='whatday();' value='Yes'/>";
text+="<input type='button' onclick='timequest(0);' value='No'/></p>";
document.getElementById('guidecontent').innerHTML = text;
}
}

function whatday()
{
var text="";
text+="<br/><p>Pick a day of the week.<br/><br/> ";

text+="<a href='#' onclick='timequest(1);'>Sunday</a><br/>";
text+="<a href='#' onclick='timequest(2);'>Monday</a><br/>";
text+="<a href='#' onclick='timequest(3);'>Tuesday</a><br/>";
text+="<a href='#' onclick='timequest(4);'>Wednesday</a><br/>";
text+="<a href='#' onclick='timequest(5);'>Thursday</a><br/>";
text+="<a href='#' onclick='timequest(6);'>Friday</a><br/>";
text+="<a href='#' onclick='timequest(7);'>Saturday</a><br/>";

document.getElementById('guidecontent').innerHTML = text;
}

function timequest(day)
{
if(day!=0)
{

document.dateform.dateselect[day+1].selected=true;
selectsome();
uncheck();
searchIt();
}
var text="";
text+="<br/><p>Do you want to see restaurants that are open on a specific time of day?<br/><br/> ";
text+="<input type='button' onclick='whattime();' value='Yes'/>";
text+="<input type='button' onclick='mealquest(0);' value='No'/></p>";
document.getElementById('guidecontent').innerHTML = text;
}

function whattime()
{
var text="";
text+="<br/><p>Pick a time of day.<br/><br/> ";

text+="<a href='#' onclick='mealquest(1);'>Morning</a><br/>";
text+="<a href='#' onclick='mealquest(2);'>Lunch</a><br/>";
text+="<a href='#' onclick='mealquest(3);'>Evening</a><br/>";
text+="<a href='#' onclick='mealquest(4);'>Night</a><br/>";

document.getElementById('guidecontent').innerHTML = text;

}

function mealquest(time)
{
if(time!=0)
{
document.timeform.timeselect[time+1].selected=true;
selectsome();
uncheck();
searchIt();
}
var text="";
text+="<br/><p>Are you looking for a specific meal?<br/><br/> <b>Breakfast, Lunch, Dinner</b><br/> ";
text+="<input type='button' onclick='whatmeal();' value='Yes'/>";
text+="<input type='button' onclick='delivery(0);' value='No'/></p>";

document.getElementById('guidecontent').innerHTML = text;
}

function whatmeal()
{
var text="";
text+="<br/><p>Pick a meal.<br/><br/> ";

text+="<a href='#' onclick='delivery(1);'>Breakfast</a><br/>";
text+="<a href='#' onclick='delivery(2);'>Lunch</a><br/>";
text+="<a href='#' onclick='delivery(3);'>Dinner</a><br/>";

document.getElementById('guidecontent').innerHTML = text;

}


function delivery(meal)
{
if(meal==1)
{
document.foodcat1form.breakfast.checked=true;
selectsome();
searchIt();
}
else if(meal==2)
{
document.foodcat1form.lunch.checked=true;
selectsome();
searchIt();
}
else if(meal==3)
{
document.foodcat1form.dinner.checked=true;
selectsome();
searchIt();
}
var text="";
text+="<br/><p>Do you need the food delivered?<br/><br/> ";
text+="<input type='button' onclick='nationality(3);' value='Yes'/>";
text+="<input type='button' onclick='servicetype();' value='No'/></p>";

document.getElementById('guidecontent').innerHTML = text;
}

function servicetype()
{
var text="";
text+="<br/><p>Does service type matter? <br/><br/><b>fast food or sit down</b><br/> ";
text+="<input type='button' onclick='whatservice();' value='Yes'/>";
text+="<input type='button' onclick='nationality(0);' value='No'/></p>";

document.getElementById('guidecontent').innerHTML = text;
}

function whatservice()
{
var text="";
text+="<br/><p>Pick a service type. <br/><br/> ";
text+="<a href='#' onclick='nationality(1);'>fast food</a><br/>";
text+="<a href='#' onclick='nationality(2);'>sit down</a><br/>";

document.getElementById('guidecontent').innerHTML = text;
}

function nationality(type)
{
if(type==1)
{
document.foodcat1form.fastfood.checked=true;
selectsome();
searchIt();
}
else if(type==2)
{
document.foodcat1form.sitdown.checked=true;
selectsome();
searchIt();
}
else if(type==3)
{
document.foodcat1form.delivery.checked=true;
selectsome();
searchIt();
}
var text="";
text+="<br/><p>Would you like see restaurants that serve <b>mexican or oriental</b> food?<br/><br/> ";
text+="<input type='button' onclick='whichnation();' value='Yes'/>";
text+="<input type='button' onclick='american(0);' value='No'/></p>";

document.getElementById('guidecontent').innerHTML = text;
}

function whichnation()
{
var text="";
text+="<br/><p>Which one?<br/><br/> ";
text+="<a href='#' onclick='american(1);'>mexican</a><br/>";
text+="<a href='#' onclick='american(2);'>oriental</a><br/>";

document.getElementById('guidecontent').innerHTML = text;
}

function american(type)
{
if(type==1)
{
document.foodcat2form.mexican.checked=true;
selectsome();
searchIt();
}
else if(type==2)
{
document.foodcat2form.asian.checked=true;
selectsome();
searchIt();
}
var text="";
text+="<br/><p>Are you looking for any of the following foods?<br/><br/> <b>burgers, pizza, seafood, steak, or subs</b><br/> ";
text+="<input type='button' onclick='whichamerican();' value='Yes'/>";
text+="<input type='button' onclick='pricerange(0);' value='No'/></p>";
document.getElementById('guidecontent').innerHTML = text;
}

function whichamerican()
{
var text="";
text+="<br/><p>Pick one.<br/><br/>Use Quick Search later to add any extra selections. <br/><br/> ";

text+="<a href='#' onclick='pricerange(1);'>burgers</a><br/>";
text+="<a href='#' onclick='pricerange(2);'>pizza</a><br/>";
text+="<a href='#' onclick='pricerange(3);'>seafood</a><br/>";
text+="<a href='#' onclick='pricerange(4);'>steak</a><br/>";
text+="<a href='#' onclick='pricerange(5);'>subs</a><br/>";

document.getElementById('guidecontent').innerHTML = text;
}

function pricerange(type)
{
if(type==1)
{
document.foodcat2form.burgers.checked=true;
selectsome();
searchIt();
}
else if(type==2)
{
document.foodcat2form.pizza.checked=true;
selectsome();
searchIt();
}
else if(type==3)
{
document.foodcat2form.seafood.checked=true;
selectsome();
searchIt();
}
else if(type==4)
{
document.foodcat2form.steak.checked=true;
selectsome();
searchIt();
}
else if(type==5)
{
document.foodcat2form.subs.checked=true;
selectsome();
searchIt();
}
var text="";
text+="<br/><p>Are you looking for a specific price range? <br/><br/> ";
text+="<input type='button' onclick='whichprice();' value='Yes'/>";
text+="<input type='button' onclick='done(0);' value='No'/></p>";
document.getElementById('guidecontent').innerHTML = text;
}

function whichprice()
{
var text="";
text+="<br/><p>Pick a price range. <br/></br>These reflect per person charges for a meal and drink. The ranges do not include tax and tip. <br/><br/> ";

text+="<a href='#' onclick='done(1);'>4-8</a><br/>";
text+="<a href='#' onclick='done(2);'>9-15</a><br/>";
text+="<a href='#' onclick='done(3);'>16-25</a><br/>";
text+="<a href='#' onclick='done(4);'>25+</a><br/>";
document.getElementById('guidecontent').innerHTML = text;
}

function done(price)
{
if(price!=0)
{
document.priceform.priceselect[price+1].selected=true;
selectsome();
searchIt();
}
var text="";

if(displayed>0)
{
text+="<br/><p><b>Search Complete!</b><br/><br/>Restaurants matching all of the criteria selected are listed to the right. Choose one to view its details and menu.<br/><br/> ";
}
else
{
text+="<br/><p><b>No Results!</b><br/><br/>The criteria you chose were too narrow to match any restaurants.<br/> Remember that this is a subtractive search. You might try the Quick Search or start over.<br/><br/>";
}
text+="Start Over? ";
text+="<input type='button' onclick='showPage();' value='OK'/></p>";
document.getElementById('guidecontent').innerHTML = text;
}

function wasQuick()
{

if(document.checkform.checkbox.checked==true){return true;}

 for(var i=2; i< document.dateform.dateselect.length; i++)
 {
        if(document.dateform.dateselect[i].selected){return true;}
 }

for(var j=2; j<document.timeform.timeselect.length; j++)
 {
        if(document.timeform.timeselect[j].selected){return true;}
 }

  if (document.foodcat1form.breakfast.checked==true){return true;}
  if (document.foodcat1form.lunch.checked==true){return true;}
  if (document.foodcat1form.dinner.checked==true){return true;}
  if (document.foodcat2form.asian.checked==true){return true;}
  if (document.foodcat2form.mexican.checked==true){return true;}
  if (document.foodcat1form.delivery.checked==true){return true;}
  if (document.foodcat1form.fastfood.checked==true){return true;}
  if (document.foodcat1form.sitdown.checked==true){return true;}
  if (document.foodcat2form.burgers.checked==true){return true;}
  if (document.foodcat2form.pizza.checked==true){return true;}
  if (document.foodcat2form.seafood.checked==true){return true;}
  if (document.foodcat2form.steak.checked==true){return true;}
  if (document.foodcat2form.subs.checked==true){return true;}

  for (var i = 2; i < document.priceform.priceselect.length; i++)
  {
    if (document.priceform.priceselect[i].selected){return true;}
  }
  
  return false;

}

function showPage()
{
var objPage;
//if (objPage) objPage.style.display = 'none';

objPage=document.getElementById('guidecontent');
objPage.style.display = 'block';
objPage2=document.getElementById('day');
objPage2.style.display = 'none';
objPage=document.getElementById('time');
objPage.style.display = 'none';
objPage=document.getElementById('price');
objPage.style.display = 'none';

var text;
text="<div id='guidedtab'><a href='javascript:showPage()' target='_self'>";
text+="<img border='0' src='images/guidetab1.gif' alt=' '></a></div>";
text+="<div id='quicktab'><a href='javascript:hidePage()' target='_self'>";
text+="<img border='0' src='images/quicktab1.gif' alt=' '></a></div>";
document.getElementById('tabs').innerHTML = text;

loadGuide(); 
}

function hidePage()
{
var objPage = null;

if (objPage) objPage.style.display = 'block';
objPage=document.getElementById('guidecontent');
objPage.style.display = 'none';
objPage=document.getElementById('day');
objPage.style.display = 'block';
objPage=document.getElementById('time');
objPage.style.display = 'block';
objPage=document.getElementById('price');
objPage.style.display = 'block';

var text;
text="<div id='guidedtab'><a href='javascript:showPage()' target='_self'>";
text+="<img border='0' src='images/guidetab2.gif' alt=' '></a></div>";
text+="<div id='quicktab'><a href='javascript:hidePage()' target='_self'>";
text+="<img border='0' src='images/quicktab2.gif' alt=' '></a></div>";

document.getElementById('tabs').innerHTML = text;
}

function clearquick()
{
document.checkform.checkbox.checked=false;
document.timeform.timeselect.options[0].selected=true;
document.dateform.dateselect.options[0].selected=true;
document.priceform.priceselect.options[0].selected=true;
document.foodcat1form.breakfast.checked=false;
document.foodcat1form.lunch.checked=false;
document.foodcat1form.dinner.checked=false;
document.foodcat2form.asian.checked=false;
document.foodcat2form.mexican.checked=false;
document.foodcat1form.delivery.checked=false;
document.foodcat1form.fastfood.checked=false;
document.foodcat1form.sitdown.checked=false;
document.foodcat2form.burgers.checked=false;
document.foodcat2form.pizza.checked=false;
document.foodcat2form.seafood.checked=false;
document.foodcat2form.steak.checked=false;
document.foodcat2form.subs.checked=false;

selectsome();uncheck();searchIt();

var text="";
text=currentquest(text);
document.getElementById('guidecontent').innerHTML = text;

}

