<?php 
set_time_limit(120);
if (!isset($_SESSION['FirstName'])) {
	session_start();
	//echo 'session id=' . session_id();
	//print_r($_SESSION);
}
if(isset($_GET['environment'])){
	$_SESSION['environment']=$_GET['environment'];
	
}
if(!isset($_SESSION['order_type'])){
	$_SESSION['order_type'] = "unknown";
}

$action = $_GET["a"];

if($action=="empty"){
	$_SESSION['order_type'] = "unknown";
}

//if($_SESSION['delivery_enabled']==0 || $_SESSION['delivery_open']==0){
//	$_SESSION['order_type'] = "carryout";
//}

$mobile = 0;
if($action=="logout"){
	session_start();
	session_destroy();
}

    //connect to site database
    include ('includes/db1config.php');
    include ('includes/mysql_connect.php');
	
	//lookup brand to determine admin folder for this site
	include ('includes/get_brand.php');
	
	//get site configuration parameters
	include ('cmsadmin/includes/admin-config.php');
	
	include ('includes/ssl_redirect.php');
	
	
	//######################  set timezone before checking hours of operation
	$query = "Select timezone, simple_reg_form, ordermenu_pics from storePrefs";
	$rt=mysql_query($query);          // query executed 
	while($nt=mysql_fetch_array($rt)){
		$timezone = $nt[timezone];
		$simple_reg_form = $nt[simple_reg_form];
		date_default_timezone_set($timezone);
		$_SESSION['ordermenu_pics'] = $nt['ordermenu_pics'];
	}
	//now check current time against hours
	$usertime = date('h:i:s a');
	$userdate = date('m/d/Y');
	$currenttime = strtotime($usertime);
	$daynumber = date('w', strtotime($userdate));
	//echo "daynum=" . $daynumber;
	//look up hours in database
	
	//get hours to determine if store is open
	$query =  "Select start_time, end_time from hours where day ='$daynumber' and delivery=0";
	$rt=mysql_query($query);  
	while($nt=mysql_fetch_array($rt)){
		//echo "date listed";
		$opentime = strtotime($nt[start_time]);
		$closetime = strtotime($nt[end_time]);
		if($currenttime > $opentime && $currenttime < $closetime){
			$store_status = "open";			
			//echo "we are open";
			break;
		}
	}
	
	
	$_SESSION['delivery_open']=0;
	//get delivery hours to determine if delivery is available
	$query =  "Select start_time, end_time from hours where day ='$daynumber' and delivery=1";
	$rt=mysql_query($query); 
	if(mysql_num_rows($rt)>0){ 
		while($nt=mysql_fetch_array($rt)){
			//echo "date listed";
			$delopentime = strtotime($nt[start_time]);
			$delclosetime = strtotime($nt[end_time]);
			if($currenttime > $delopentime && $currenttime < $delclosetime){			
				$_SESSION['delivery_open']=1;
				break;
			}
		}
	} else {
		if($store_status=="open"){
			$_SESSION['delivery_open']=1;
		} else {
			$_SESSION['delivery_open']=0;
		}
	}
	
	//########################## end of hours-of-operation testing
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?php include('title.php'); ?>
<meta name="description" content="<?php include('seodescr.php'); ?>" />
<meta name="keywords" content="<?php include('seokeywords.php'); ?>" />
<link href="css/cart-style.css" rel="stylesheet" type="text/css" media="screen" />

<?php include('includes/headlinks.php'); ?>

<link rel='stylesheet' media='screen and (min-device-width : 768px) and (max-device-width : 1024px)' href='custom/css/tablet-style.css' />
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>


<script type="text/javascript" src="/js/creditcard.js"></script>

<script type="text/javascript">
function openwin(url, width, height) {
var name = "popup"; // popup name
var width = width; // popup width
var height = height; // popup height
var left = (screen.width - width) / 2 ;
var top = (screen.height - height) / 2;
var windowproperties = "width="+ width +",height="+ height +",left="+ left +",top="+ top +",scrollbars=1";
window.open(url, name, windowproperties);
}

// initiate modal popups
$(document).ready(function() {
	//$('#menu_modal').popup();

	// Initial credit card checker
	if ($('#card-number').length > 0) {
		$('#card-number').on('change', function() {
			var cardNumber = $('#card-number').val();
			var cardType = $('#card-type').val();
			if (checkCreditCard(cardNumber, cardType) == false) {
				alert('The credit card number is invalid.');
				$('#card-number').focus();
			}
		});
	}
});
</script>
<?php 

include('analytics.php'); 
include('includes/desktop_functions.php');

?>




<!--<script type="text/javascript" src="../js/ddaccordion.js">

/***********************************************
* Accordion Content script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit https://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

</script>-->



<style type="text/css" media="screen">

	@-webkit-keyframes glowing {
  0% { background-color: #fff; -webkit-box-shadow: 0 0 2px #FF0000; }
  50% { background-color: #fff; -webkit-box-shadow: 0 0 30px #FF0000; }
  100% { background-color: #fff; -webkit-box-shadow: 0 0 2px #FF0000; }
}

@-moz-keyframes glowing {
  0% { background-color: #fff; -moz-box-shadow: 0 0 2px #FF0000; }
  50% { background-color: #fff; -moz-box-shadow: 0 0 30px #FF0000; }
  100% { background-color: #fff; -moz-box-shadow: 0 0 2px #FF0000; }
}

@-o-keyframes glowing {
  0% { background-color: #fff; box-shadow: 0 0 2px #FF0000; }
  50% { background-color: #fff; box-shadow: 0 0 30px #FF0000; }
  100% { background-color: #fff; box-shadow: 0 0 2px #FF0000; }
}

@keyframes glowing {
  0% { background-color: #fff; box-shadow: 0 0 2px #FF0000; }
  50% { background-color: #fff; box-shadow: 0 0 30px #FF0000; }
  100% { background-color: #fff; box-shadow: 0 0 2px #FF0000; }
}

.ui-dialog{
  max-height: calc(100% - 100px);
  position: fixed;
    top: 50%;
    left: 50%;
  transform: translate(-50%, -50%);
  color:#fff;
  background:#f0f563;
    -webkit-animation: glowing 1500ms infinite;
  -moz-animation: glowing 1500ms infinite;
  -o-animation: glowing 1500ms infinite;
  animation: glowing 1500ms infinite;
	}
	#dialogItem{
		padding:30px;
	}



</style>

<script type="text/javascript">




/*ddaccordion.init({
	headerclass: "expandable", //Shared CSS class name of headers group that are expandable
	contentclass: "categoryitems", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", "openheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["prefix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
		//$('.categoryitems').hide();
		console.log($(".categoryitems").css("display")+" init");
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
		console.log($(".categoryitems").css("display")+" trigger");
		/*if($(".categoryitems").css("display") == "none"){
			$('.categoryitems').show();
		}else{
			$(".categoryitems").hide();
		}
	}
})

ddaccordion.init({ //2nd level headers initialization
	headerclass: "subexpandable", //Shared CSS class name of sub headers group that are expandable
	contentclass: "subcategoryitems", //Shared CSS class name of sub contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["opensubheader", "closedsubheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})*/



</script>
<style type="text/css">

.arrowlistmenu{
width:94%; /*width of accordion menu*/
max-width:94%;
}

.arrowlistmenu .menuheader{ /*CSS class for menu headers in general (expanding or not!)*/
font:1em; Verdana,Arial;
	font-weight:bold; margin-top:5px; cursor:pointer; 
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
    -webkit-transition-duration: 0.2s;
    -moz-transition-duration: 0.2s;
    transition-duration: 0.2s;
    -webkit-user-select:none;
    -moz-user-select:none;
    -ms-user-select:none;
    user-select:none;
	
	background:#48a3db;
	color:#fff;
	borderf: 1px solid #777777;
     -webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;
	padding:5px;
	margin-bottom:5px;
	margin-top:9px;
	background:url(../images/up-down-arrows.png) center right no-repeat #666;
	min-width: 150px;
}

.arrowlistmenu .openheader{ /*CSS class to apply to expandable header when it's expanded*/
     -webkit-border-radius: 8px 8px 0px 0px;
    -moz-border-radius: 8px 8px 0px 0px;
    border-radius: 8px 8px 0px 0px;
	}

.arrowlistmenu ul{ /*CSS for UL of each sub menu*/
list-style-type: none;
margin: 0;
padding: 0;
margin-bottom: 0px; /*bottom spacing between each UL and rest of content*/
background: none;
}

.arrowlistmenu ul li{
padding-bottom: 0px; /*bottom spacing between menu items*/
}

.arrowlistmenu ul li .opensubheader{ /*Open state CSS for sub menu header*/
background: lightblue !important;
}

.arrowlistmenu ul li .closedsubheader{ /*Closed state CSS for sub menu header*/
background: lightgreen !important;
}

.arrowlistmenu ul li a{
color: #81BEF7;
display: block;
padding: 0px 0;
padding-left: 19px; /*link text is indented 19px*/
text-decoration: none;
font-weight: bold;
border-bottom: 1px solid #dadada;
font-size: 90%;
}


.arrowlistmenu ul li a:visited{
color: #81BEF7;
}

.arrowlistmenu ul li a:hover{ /*hover state CSS*/
color: #FA5858;
background-color: #FA5858;
}

.arrowlistmenu ul li a.subexpandable:hover{ /*hover state CSS for sub menu header*/
background: lightblue;
}
html {
    overflow-y: scroll;
}


#main-content .categoryitems {
list-style-type:inherit;
margin-left: 0; margin-right: 0;
padding:0;
}


.categoryitems {
	background-color:#fff;
		border-radius: 8px;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
width:100%;  margin-top:-.4em;
}

#expanded-area-inner-wrapper {
	padding: 0em .3em .5em .3em;
}



.btn-success {
  color: #ffffff;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  background-color: #000;
  *background-color: #000;
}

html.popup_open,
body.modal_open {
	overflow: hidden;
}

</style>


</head>
<body id="core" class="online" onload="hideLoadingGraphic();">



<div id="wrapper">


<!-- start page -->
<div id="page">
<div id="page-bgtop">
<div id="page-bgbtm">

<!-- start content -->
<?php
if($full_width_order_page=='1'){
	echo'<div id="content-full-width">';
	$full_width = true;
} else {
	echo'<div id="content">';
}
?>	
<script type="text/javascript">
//var message = "Do you want to start a war?";
//var type = "info_only";
var type = "yes_no";
//var type = "ok_cancel";
var action = "";
var response='';
popup_notice(message,type,action).then(function (answer) {
	if(answer==1){
	   response=answer;
	} else {
	   response=answer;
	}
	//alert(response);
});
</script>

<div id="main-content">

   
   <div id="online-order-logo">
   <a href="index.php"><img src="custom/images/header-logo_mobile.png" title="<?php include('seotitle.php'); ?>" alt="<?php include('seotitle.php'); ?>" border="none" /></a>
   <br />
   <p><?php include("city.php") ?> &bull; <?php include("phone.php") ?></p>
   </div>
   
    <div id="online-close-icon">
    <a href="index.php" title="Exit Online Ordering"><img src="images/closebox.png" alt="Exit Online Ordering" title="Exit Online Ordering" /></a>
   </div>
   
    <div id="online-exit-wrapper">
    <a href="index.php" title="Exit Online Ordering"><div id="exit-word">EXIT &nbsp;</div>
    </a></div>
   
   <div style="clear:both;"></div>
		<div class="post">
		  <div class="entry">
          
		  <div align="right">
          <?php
              //print_r($_SESSION);
			  //print_r($_POST);
              if($action=="logout" || $action=="register" || ($action=="login" && (!isset($_POST['username']) && $_SESSION['FirstName'] !="guest" ) ) ){
			  	//do not show offer box
			  } else {
              

              echo'<div id="offer-code-box">
          		<form action="order.php" method="POST"><p>Offer Code:</p>
          		<input type="text" name="ccode"><input id="offer-code-button" type="submit" value=" Submit "></form>
              </div>';
			  
			  }
          ?>    
              <div id="ssl"><img src="images/ssl-icon.png"></div>
			 
          </div><!-- end div align right -->
          
	<h1><!--Welcome to <?php include('seotitle.php'); ?><br />-->Online Ordering</h1>
	<style type="text/css" media="screen">
		.hoverBtn{
			color: #ffffff !important;
			background-color: #48a3db !important;
		}		
	</style>
	<form action="order.php" method="post" id="saveTopings" accept-charset="utf-8">
		<input type="hidden" name="toppingVal" id="toppingVal" value="">
		<input type="hidden" name="toppingQty" id="toppingQty" value="">
		<input type="hidden" name="toppingParent" id="toppingParent" value="">
		<input type="hidden" name="toppingItem" id="toppingItem" value="">
		<input type="hidden" name="toppingItem" id="toppingItemTemp" value="">
		<input type="submit" value="SubmitTopings" id="SubmitTopings" style="display:none;">
	</form>
<?php
   
   include('orderonline.php');
   
   if(!empty($order_notice)){
	echo "<div class='order-notice-message'>$order_notice</div>";
   }

   


   if(($orderonline==1 && $store_status == "open")||($_SESSION['environment']=="test")){  



   //site uses online ordering
                   /* if (($action=="logout")||($action=="login")||($action=="register")){  //user has just logged out - show login screen to re-login if needed
                        include('login.php');
                    } elseif($storeaddress==$_SESSION['storeID']){     //logged in, show menu
                        if($action=="submit"){   //not logged in, but trying to submit order - must login now
                           include('login.php');
                         } else{
                        include('orderengine.php');
                        }
                    } else {	//not logged in - create temporary cart based on session ID, then proceed as if logged in
                        //echo 'action=' . $action ;

                        include('templogin.php');
                        include('orderengine.php');

                    }*/
			   if (($action=="logout")||($action=="login")||($action=="register")){  //user has clicked login or has just logged out - show login screen
                        //echo "scenario1<br />";
			   	

					include('login.php');
					
                   // } elseif($storeaddress==$_SESSION['storeID']){     //logged in, show menu
			    } elseif((!empty($_SESSION['UserID']))&&($_SESSION['UserID']!="9999")){     //user is logged in
                        //if($action=="submit"){   
                           //echo "scenario2<br />";
						  // include('login.php');
                         //} else{
							//echo "scenario3<br />";
							if($action=="history"){
								include('history.php');
							} else {

								include('orderengine.php');
							}
                       // }
                    } else {	//not logged in - create temporary cart based on session ID, then proceed as if logged in
						if(($action=="submit")&&($_SESSION['UserID']=="9999")){   //not logged in, but trying to submit order - must login now
							
							include('login.php');
						} else{	
							


						//not logged in, but not trying to check out
						//echo "scenario4<br />";
						//echo "using temporary guest login...<br />";
                        include('templogin.php');
                        include('orderengine.php');
                        
                        //include('login.php');
						}
                    }
                } elseif ($store_status != "open") {
					echo '<div style="clear:both;"></div><div align="center"><font color="red">We are currently closed and cannot accept orders. <br /><br />Online Ordering
				             We apologize for the inconvenience.</div></font>';
			    } else {      //site does not utilize online ordering
                     echo '<div style="clear:both;"></div><div align="center"><font color="red">Online ordering not currently offered at this location. <br /><br />
				             We apologize for the inconvenience.</div></font>';
                }



?>


    </div><!-- end post div -->

<div style="clear: both;"></div>

</div><!-- end entry div -->
</div><!-- end main-content-->
	<!-- end content -->
    
    

	
	<div style="clear: both;">&nbsp;</div>
</div>
</div>
</div>

</div><!-- end wrapper div-->

<!-- end page -->
</div>




</body>
<script>
	$(document).ready(function() {
	$( "#dialogItem" ).dialog();
	$(".ui-dialog").css({'z-index':'11111'});
});

</script>
</html>
