<?php
//print_r($_POST);
if ($_SESSION['FirstName'] == "") {
	echo 'You are not authorized to view this page. <br><br>You may <a href="index.php"><font color="blue">log in here.</font></a>';
	exit;
	}
 if($_SESSION['roladmin'] ==1){$roladmin=1;}
 if($_SESSION['masterAdmin']==1){$masteradmin=1;}
 if($_SESSION['admin']==1){$admin=1;}
//require_once ('mysql_connect.php');
$action          = $_GET["a"];
include ('includes/admin-config.php');

?>

<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<?php
if ($action == "update") {
		$query = "UPDATE storePrefs SET ";
			//update specific fields depending on which section is being updated
			$update = $_REQUEST["section"];
			
			if($update=="general"){
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", title='" . mysql_real_escape_string($_POST['title']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " title='" . mysql_real_escape_string($_POST['title']) . "'";
				}

				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", address1='" . mysql_real_escape_string($_POST['address1']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " address1='" . mysql_real_escape_string($_POST['address1']) . "'";
				}
			
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", address2='" . mysql_real_escape_string($_POST['address2']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " address2='" . mysql_real_escape_string($_POST['address2']) . "'";
				}
				
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", city='" . mysql_real_escape_string($_POST['city']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " city='" . mysql_real_escape_string($_POST['city']) . "'";
				}
			
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", state='" . mysql_real_escape_string($_POST['state']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " state='" . mysql_real_escape_string($_POST['state']) . "'";
				}
			
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", zip='" . mysql_real_escape_string($_POST['zip']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " zip='" . mysql_real_escape_string($_POST['zip']) . "'";
				}
			
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", phone='" . mysql_real_escape_string($_POST['phone']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " phone='" . mysql_real_escape_string($_POST['phone']) . "'";
				}
				if(!empty($sv)) {  //sw clause exists, add to it
				$sv .= ", fax='" . mysql_real_escape_string($_POST['fax']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " fax='" . mysql_real_escape_string($_POST['fax']) . "'";
				}
						
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", webURL='" . mysql_real_escape_string($_POST['webURL']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " webURL='" . mysql_real_escape_string($_POST['webURL']) . "'";
				}

				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", mapURL='" . mysql_real_escape_string($_POST['mapURL']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " mapURL='" . mysql_real_escape_string($_POST['mapURL']) . "'";
				}
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", email='" . mysql_real_escape_string($_POST['email']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " email='" . mysql_real_escape_string($_POST['email']) . "'";
				}
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", analyticsID='" . mysql_real_escape_string($_POST['analyticsID']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " analyticsID='" . mysql_real_escape_string($_POST['analyticsID']) . "'";
				}
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", gtm_id='" . mysql_real_escape_string($_POST['gtm_id']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " gtm_id='" . mysql_real_escape_string($_POST['gtm_id']) . "'";
				}
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", directions='" . mysql_real_escape_string($_POST['directions']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " directions='" . mysql_real_escape_string($_POST['directions']) . "'";
				}
			} elseif($update=="social"){
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", fantools_email='" . mysql_real_escape_string($_POST['fantoolsid']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " fantools_email='" . mysql_real_escape_string($_POST['fantoolsid']) . "'";
				}
				
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", fantools_pwd='" . mysql_real_escape_string($_POST['fantoolspwd']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " fantools_pwd='" . mysql_real_escape_string($_POST['fantoolspwd']) . "'";
				}
			
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", facebook='" . mysql_real_escape_string($_POST['facebook']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " facebook='" . mysql_real_escape_string($_POST['facebook']) . "'";
				}
				
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", fbpage='" . mysql_real_escape_string($_POST['fbpage']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " fbpage='" . mysql_real_escape_string($_POST['fbpage']) . "'";
				}
				
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", twitter='" . mysql_real_escape_string($_POST['twitter']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " twitter='" . mysql_real_escape_string($_POST['twitter']) . "'";
				}
				
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", twitterid='" . mysql_real_escape_string($_POST['twitterid']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " twitterid='" . mysql_real_escape_string($_POST['twitterid']) . "'";
				}
				
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", google_plus='" . mysql_real_escape_string($_POST['google_plus']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " google_plus='" . mysql_real_escape_string($_POST['google_plus']) . "'";
				}
				
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", myspace='" . mysql_real_escape_string($_POST['myspace']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " myspace='" . mysql_real_escape_string($_POST['myspace']) . "'";
				}
			} elseif($update=="hours"){	
			//************************ This section updates any HOURS and timezone fields **************************************
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", hours1='" . mysql_real_escape_string($_POST['hours1']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " hours1='" . mysql_real_escape_string($_POST['hours1']) . "'";
				}
			
			
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", hours2='" . mysql_real_escape_string($_POST['hours2']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " hours2='" . mysql_real_escape_string($_POST['hours2']) . "'";
				}
			
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", hours3='" . mysql_real_escape_string($_POST['hours3']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " hours3='" . mysql_real_escape_string($_POST['hours3']) . "'";
				}
				
				if(!empty($_POST['timezone'])) { //only save timezone if it is selected
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", timeZone='" . mysql_real_escape_string($_POST['timezone']) . "'";
					} else { //sw clause does not exist, create it now
						$sv .= " timeZone='" . mysql_real_escape_string($_POST['timezone']) . "'";
					}
				}
				
				If (!empty($_POST['chkOpenSign'])){ //field is populated, need to update data
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", open_sign='1'";
					} else { //sw clause does not exist, create it now
						$sv .= " open_sign='1'";
					}
				} else {
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", open_sign='0'";
					} else { //sw clause does not exist, create it now
						$sv .= " open_sign='0'";
					}
				}
			} elseif($update=="ordering"){
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", orderURL='" . mysql_real_escape_string($_POST['orderURL']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " orderURL='" . mysql_real_escape_string($_POST['orderURL']) . "'";
				}
							if(!empty($sv)) {  //sw clause exists, add to it
				$sv .= ", salesTax='" . mysql_real_escape_string($_POST['salesTax']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " salesTax='" . mysql_real_escape_string($_POST['salesTax']) . "'";
				}
			
				If (!empty($_POST['chkDeltax'])){ //field is populated, need to update data
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", taxdelivery='1'";
					} else { //sw clause does not exist, create it now
						$sv .= " taxdelivery='1'";
					}
				} else {
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", taxdelivery='0'";
					} else { //sw clause does not exist, create it now
						$sv .= " taxdelivery='0'";
					}
				}
				If (!empty($_POST['chkDeliver'])){ //field is populated, need to update data
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", deliver='1'";
					} else { //sw clause does not exist, create it now
						$sv .= " deliver='1'";
					}
				} else {
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", deliver='0'";
					} else { //sw clause does not exist, create it now
						$sv .= " deliver='0'";
					}
				}
				If (!empty($_POST['chkHalfTopping'])){ //field is populated, need to update data
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", half_topping_prices='1'";
					} else { //sw clause does not exist, create it now
						$sv .= " half_topping_prices='1'";
					}
				} else {
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", half_topping_prices='0'";
					} else { //sw clause does not exist, create it now
						$sv .= " half_topping_prices='0'";
					}
				}
				If (!empty($_POST['chkMultipleSauces'])){ //field is populated, need to update data
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", use_multiple_sauces='1'";
					} else { //sw clause does not exist, create it now
						$sv .= " use_multiple_sauces='1'";
					}
				} else {
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", use_multiple_sauces='0'";
					} else { //sw clause does not exist, create it now
						$sv .= " use_multiple_sauces='0'";
					}
				}
				If (!empty($_POST['chkMultipleCrusts'])){ //field is populated, need to update data
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", use_multiple_crusts='1'";
					} else { //sw clause does not exist, create it now
						$sv .= " use_multiple_crusts='1'";
					}
				} else {
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", use_multiple_crusts='0'";
					} else { //sw clause does not exist, create it now
						$sv .= " use_multiple_crusts='0'";
					}
				}
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", deliveryCharge='" . mysql_real_escape_string($_POST['deliveryCharge']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " deliveryCharge='" . mysql_real_escape_string($_POST['deliveryCharge']) . "'";
				}
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", minimum_order='" . mysql_real_escape_string($_POST['minimum_order']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " minimum_order='" . mysql_real_escape_string($_POST['minimum_order']) . "'";
				}
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", deltime='" . mysql_real_escape_string($_POST['deltime']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " deltime='" . mysql_real_escape_string($_POST['deltime']) . "'";
				}
				
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", preptime='" . mysql_real_escape_string($_POST['preptime']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " preptime='" . mysql_real_escape_string($_POST['preptime']) . "'";
				}
				If (!empty($_POST['chkChecks'])){ //field is populated, need to update data
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", acceptChecks='1'";
					} else { //sw clause does not exist, create it now
						$sv .= " acceptChecks='1'";
					}
				} else {
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", acceptChecks='0'";
					} else { //sw clause does not exist, create it now
						$sv .= " acceptChecks='0'";
					}
				}
				If (!empty($_POST['paypal_auth'])){ //field is populated, need to update data
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", paypal_auth='1'";
					} else { //sw clause does not exist, create it now
						$sv .= " paypal_auth='1'";
					}
				} else {
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", paypal_auth='0'";
					} else { //sw clause does not exist, create it now
						$sv .= " paypal_auth='0'";
					}
				}
				
				If (!empty($_POST['chkTipline'])){ //field is populated, need to update data
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", include_tipline='1'";
					} else { //sw clause does not exist, create it now
						$sv .= " include_tipline='1'";
					}
				} else {
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", include_tipline='0'";
					} else { //sw clause does not exist, create it now
						$sv .= " include_tipline='0'";
					}
				}
				
				if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", order_notice='" . mysql_real_escape_string($_POST['order_notice']) . "'";
					} else { //sw clause does not exist, create it now
						$sv .= " order_notice='" . mysql_real_escape_string($_POST['order_notice']) . "'";
				}
				if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", custom_order_confirmation='" . mysql_real_escape_string($_POST['order_conf']) . "'";
					} else { //sw clause does not exist, create it now
						$sv .= " custom_order_confirmation='" . mysql_real_escape_string($_POST['order_conf']) . "'";
				}
				
				if(($roladmin==1)||($masteradmin==1)){    //***********only allow updating these two fields if logged in as ROO administrator
					If (!empty($_POST['chkFaxOrders'])){ //field is populated, need to update data
							if(!empty($sv)) {  //sw clause exists, add to it
								$sv .= ", orderByFax='1'";
							} else { //sw clause does not exist, create it now
								$sv .= " orderByFax='1'";
							}
						} else {
							if(!empty($sv)) {  //sw clause exists, add to it
								$sv .= ", orderByFax='0'";
							} else { //sw clause does not exist, create it now
								$sv .= " orderByFax='0'";
							}
						}
						
						If (!empty($_POST['chkOnline'])){ //field is populated, need to update data
							if(!empty($sv)) {  //sw clause exists, add to it
								$sv .= ", orderOnline='1'";
							} else { //sw clause does not exist, create it now
								$sv .= " orderOnline='1'";
							}
						} elseif($masteradmin==1) {
							if(!empty($sv)) {  //sw clause exists, add to it
								$sv .= ", orderOnline='0'";
							} else { //sw clause does not exist, create it now
								$sv .= " orderOnline='0'";
							}
						}
						
				}  //****************END of if 'ROO Admin' loop
				
				if(($roladmin==1)||($masteradmin==1)||($admin==1)){
					If (!empty($_POST['chkSuspend'])){ //field is populated, need to update data
							if(!empty($sv)) {  //sw clause exists, add to it
								$sv .= ", suspend_ordering='1'";
							} else { //sw clause does not exist, create it now
								$sv .= " suspend_ordering='1'";
							}
						} else {
							if(!empty($sv)) {  //sw clause exists, add to it
								$sv .= ", suspend_ordering='0'";
							} else { //sw clause does not exist, create it now
								$sv .= " suspend_ordering='0'";
							}
						}
				} 
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", orderEmail1='" . mysql_real_escape_string($_POST['orderemail1']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " orderEmail1='" . mysql_real_escape_string($_POST['orderemail1']) . "'";
				}
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", orderEmail2='" . mysql_real_escape_string($_POST['orderemail2']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " orderEmail2='" . mysql_real_escape_string($_POST['orderemail2']) . "'";
				}
				/*
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", paypalid='" . $_POST['paypalid'] . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " paypalid='" . $_POST['paypalid'] . "'";
				}
				*/
			} elseif($update=="appearance"){
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", categoryColor='" . mysql_real_escape_string($_POST['catcolor']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " categoryColor='" . mysql_real_escape_string($_POST['catcolor']) . "'";
				}
				
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", categoryFontColor='" . mysql_real_escape_string($_POST['catfontcolor']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " categoryFontColor='" . mysql_real_escape_string($_POST['catfontcolor']) . "'";
				}
			} elseif($update=="lennox"){	//LENNOX
				
				if($_POST['lennox_api_key']){
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", lennox_api_key='" . mysql_real_escape_string($_POST['lennox_api_key']) . "'";
					} else { //sw clause does not exist, create it now
						$sv .= " lennox_api_key='" . mysql_real_escape_string($_POST['lennox_api_key']) . "'";
					}
				}
			
			} elseif($update=="linkpos"){	//LINKPOS
				if($_POST['linkpos_partner_name']){
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", linkpos_partner_name='" . mysql_real_escape_string($_POST['linkpos_partner_name']) . "'";
					} else { //sw clause does not exist, create it now
						$sv .= " linkpos_partner_name='" . mysql_real_escape_string($_POST['linkpos_partner_name']) . "'";
					}
				}
				if($_POST['linkpos_partner_pwd']){
					if(!empty($sv)) {  //sw clause exists, add to it
						$sv .= ", linkpos_partner_pwd='" . mysql_real_escape_string($_POST['linkpos_partner_pwd']) . "'";
					} else { //sw clause does not exist, create it now
						$sv .= " linkpos_partner_pwd='" . mysql_real_escape_string($_POST['linkpos_partner_pwd']) . "'";
					}
				}				
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", linkpos_store_name='" . mysql_real_escape_string($_POST['linkpos_store_name']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " linkpos_store_name='" . mysql_real_escape_string($_POST['linkpos_store_name']) . "'";
				}				
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", linkpos_store_pwd='" . mysql_real_escape_string($_POST['linkpos_store_pwd']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " linkpos_store_pwd='" . mysql_real_escape_string($_POST['linkpos_store_pwd']) . "'";
				}
				if(!empty($sv)) {  //sw clause exists, add to it
					$sv .= ", linkpos_company='" . mysql_real_escape_string($_POST['linkpos_company']) . "'";
				} else { //sw clause does not exist, create it now
					$sv .= " linkpos_company='" . mysql_real_escape_string($_POST['linkpos_company']) . "'";
				}
			}
			

			
			
			
	if ($sv !==""){
		$query .= $sv;
	}
	//echo $query .'<br>';	//for testing
	//query is created, now execute:
	if (!mysql_query($query)){
		//if errors, display query and error message
		echo $query;
		die('Error: ' . mysql_error());
	} else {
		//echo $query .'<br>';	//for testing
		echo "<div align=center><font color=red>Store preferences updated successfully. </font></div>";	/*now check online ordering status and hide or unhide mobile ordering button as needed, manage redirect url	*/		include('../orderonline.php');		if($orderonline=='1'){			if(empty($orderurl)){				$orderurl = "order-m.php";			}			$active=1;		} else {			$active=0;		}			$update = "update nav_slider_mobile set active='$active', button_url='$orderurl' where icon_image='mobile-order-icon.png'";			mysql_query($update);		
		$fullAddress = $_POST['address1']." ".$_POST['city']." ".$_POST['state']." ".$_POST['zip'];
		$your_location = getCoordinates($fullAddress);
		$coordinates = explode(',',$your_location);
		$lQuery = "Update storePrefs set longitude='".$coordinates[1]."' , latitude='".$coordinates[0]."'";
		mysql_query($lQuery);
	}		


}	//end of update query

	//Code to save manage-ordering menu item   
	if(isset($_POST['save-menu-time']))
	{
			//delete existing page setting		
		$delQuery = "DELETE from manage_ordering_menu";
		$delResult = mysql_query($delQuery);

		//insert code here
		if(!empty($_POST['menu'])){
		$i=0;
			foreach ($_POST['menu'] as $key => $value)
			{
				$menuName =  $value;
				$userId = $_SESSION['UserID'];
			 	$starttime = $_POST['start_time'][$i];
				$query = "INSERT INTO manage_ordering_menu (menu_name,start_time,user_id)
						  values('".$menuName."' , '".$starttime."' , '".$userId."')";
				mysql_query($query);
				$i++; 
			}
		}
	}


$query = "SELECT * from storePrefs";
$rt=mysql_query($query);

echo '<div id="single-admin-button">
<ul>
<a href="index.php"><li>BACK TO HOME ADMIN</li></a>
</ul>
</div>';
##******************************************* BEGIN LOCATION & CONTACT INFO SECTION *****************************************##
echo '<div class="arrowlistmenu">';
echo "<h3 class='menuheader expandable'>LOCATION, CONTACT & GENERAL INFO</h3>";	
echo'<ul class="categoryitems">';

echo '<button id="save-button" class="popup other_location_btn " data-popup-id="1">Other locations</button>
<div class="toPopDiv location-item" id="popup_1"> 
                    <div class="close"></div>
                    <span class="ecs_tooltip">Esc to close <span class="arrow"></span></span>
                    <iframe class="menu-item-iframe edit" id="iframe-1" data-menu-id="1" src=""></iframe>
                </div> ' ;

echo "<table border=0 width='100%'><tr><td>";
	echo '<form action="' . $_SERVER['PHP_SELF'] . '?a=update&key=' . $nt[recordKey] . '" method="post">
	<input type="hidden" name="section" value="general">';
	while($nt=mysql_fetch_array($rt)){
		echo '<div id="table-wrapper"><table width="74%" valign="top"><tr><td width="35%">Site title (business name):</td><td> <input type="text" name="title" size="35" value="' . $nt[title] . '"></td><td width="4%"><img src="images/question.png" title="40 characters maximum."></td></tr>'; 
		echo '<tr><td>Street address: </td><td><input type="text" name="address1" size="35" value="' . $nt[address1] . '"></td><td> <img src="images/question.png" title="40 characters maximum."></td></tr>';  
		echo '<tr><td>Address line 2: </td><td><input type="text" name="address2" size="35" value="' . $nt[address2] . '"></td><td> <img src="images/question.png" title="40 characters maximum. (suite #, etc)"></td></tr>';
		echo '<tr><td>City: </td><td><input type="text" name="city" size="35" value="' . $nt[city] . '"></td><td> <img src="images/question.png" title="40 characters maximum."></td></tr>';  
		echo '<tr><td>State: </td><td><input type="text" name="state" size="35" value="' . $nt[state] . '"></td><td> <img src="images/question.png" title="Type the name of your state or the 2-digit abbreviation."></td></tr>';  
		echo '<tr><td>Zip: </td><td><input type="text" name="zip" size="35" value="' . $nt[zip] . '"></td><td> <img src="images/question.png" title="10 characters maximum."></td></tr>';  
		echo '<tr><td>Phone: </td><td><input type="text" name="phone" size="35" value="' . $nt[phone] . '"></td><td> <img src="images/question.png" title="15 characters maximum."></td></tr>';  
		echo '<tr><td>Fax: </td><td><input type="text" name="fax" size="35" value="' . $nt[fax] . '"></td><td> <img src="images/question.png" title="15 characters maximum."></td></tr>';  
		echo '<tr><td>Email: </td><td><input type="text" name="email" size="35" value="' . $nt[email] . '"></td><td> <img src="images/question.png" title="50 characters maximum."></td></tr>'; 
		echo '<tr><td>Website URL: </td><td><input type="text" name="webURL" size="35" value="' . $nt[webURL] . '"></td><td> <img src="images/question.png" title="This is the website address you want to show up on your website."></td></tr>';  
		echo '<tr><td valign="top">Map URL:</td><td><textarea name="mapURL" cols="38" rows="3">' . $nt[mapURL] . '</textarea><br><font color="red"><i>Leave blank to use default google map or paste in code to display a custom map.</i></font></td><td></td></tr>'; 
		echo '<tr><td>Google Analytics ID: </td><td><input type="text" name="analyticsID" size="35" value="' . $nt[analyticsID] . '"></td><td><img src="images/question.png" title="Enter your Google Analytics ID here. It should be a number formatted similar to: UA-1234567-7"></td></tr>';
		echo '<tr><td>Google Tag Mgr ID: </td><td><input type="text" name="gtm_id" size="35" value="' . $nt[gtm_id] . '"></td><td><img src="images/question.png" title="Enter your Google Tag Manager ID here. It should be a number formatted similar to: GTM-NRHFNFF"></td></tr>';
		echo '<tr><td valign="top">Directions:</td><td><textarea name="directions" cols="38" rows="3">' . $nt[directions] . '</textarea><br></td><td> <img src="images/question.png" title="Any directions entered here will show up on the contact page for visitors to see."></td></tr>'; 
		if(empty($nt[longitude]) || empty($nt[latitude]) )echo '<tr><td></td><td><font color=red>Unable to get coordinates, please verify your address.</font></td></tr>';
		echo '<tr><td>Longitude: </td><td><input type="text" size="35" value="';if(isset($nt[longitude])){echo $nt[longitude];} else{ echo '';} echo '"></td><td> <img src="images/question.png"  title="It will be update according to your Address" ></td></tr>';
		echo '<tr><td>Latitude.: </td><td><input type="text" size="35" value="';if(isset($nt[latitude])){echo $nt[latitude];} else{ echo '';} echo '"></td><td> <img src="images/question.png" title="It will be update according to your Address"></td></tr>';
	}

	echo '<tr><td></td><td><input id="save-button" type="submit" name="save" value="Save Changes"></td><td></td></tr></table></div></form></td></tr>';
echo "</table>";
echo "</ul>";

function getCoordinates($address)
{
	$address = str_replace(" ", "+", $address); // replace all the white space with "+" sign to match with google search pattern
	$url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=$address";
	$response = file_get_contents($url);
	$json = json_decode($response,TRUE); //generate array object from the response from the web
	return ($json['results'][0]['geometry']['location']['lat'].",".$json['results'][0]['geometry']['location']['lng']);
}
##******************************************* END LOCATION & CONTACT INFO SECTION *****************************************##

##******************************************* BEGIN HOURS AND TIMEZONE SECTION *****************************************##
$rt=mysql_query($query); //refresh recordset

echo "<h3 class='menuheader expandable'>HOURS AND TIMEZONE</h3>";	
echo'<ul class="categoryitems">';

echo "<table border=0 width='100%'><tr><td>";
	echo '<form action="' . $_SERVER['PHP_SELF'] . '?a=update&key=' . $nt[recordKey] . '" method="post">
	<input type="hidden" name="section" value="hours">';
	while($nt=mysql_fetch_array($rt)){
		echo '<div id="table-wrapper"><table width="74%" valign="top"><tr><td width="35%" valign="top">Displayed Hours:</td><td><textarea name="hours1" id="hours1" class="" cols="40" rows="4">' . $nt[hours1] . '</textarea></td><td valign=top align=left><img src="images/question.png" title="This is what will be displayed in the HOURS area on your live website."></td></tr>';  
		//use open sign
		echo '<tr><td>Show Open/Closed Sign:</td><td><input type="checkbox" name="chkOpenSign"';
		if(!empty($nt[open_sign])){
			echo 'checked=true';
		}
		echo '><td><img src="images/question.png" title="If selected, an OPEN or CLOSED sign will be displayed, based on the Ordering hours antered above."></td></tr>';
		if(!empty($nt[open_sign])){
			echo '<tr><td></td><td><b>Open Hours</b></td></tr>';
			//setup hours
			$qry = "select * from hours where delivery='0' order by day, start_time";
			$rtt=mysql_query($qry); //refresh recordset
			while($ntt=mysql_fetch_array($rtt)){
				 echo '<tr id="trHours'.$ntt['recordKey'].'"><td valign="bottom"><div align="right">';
				 $textDay = '';
				 if($ntt[day]=='0'){$textDay = "Sunday";}
				 if($ntt[day]=='1'){$textDay = "Monday";}
				 if($ntt[day]=='2'){$textDay = "Tuesday";}
				 if($ntt[day]=='3'){$textDay = "Wednesday";}
				 if($ntt[day]=='4'){$textDay = "Thursday";}
				 if($ntt[day]=='5'){$textDay = "Friday";}
				 if($ntt[day]=='6'){$textDay = "Saturday";}
				 echo $textDay;
				 echo'</div></td><td valign="bottom">';
				 echo"From: ";
				 $var = date('h:ia', strtotime($ntt[start_time]));
				 echo '<span id="fromTime'.$ntt['recordKey'].'">' . $var . '</span>';
				 echo" to: ";
				 $var = date('h:ia', strtotime($ntt[end_time]));
				 echo '<span id="toTime'.$ntt['recordKey'].'">' . $var . '</span>';
				 echo'&nbsp;&nbsp;<a class="edit_hours_modal'.$ntt['recordKey'].'_open" href="">Edit</a>&nbsp;&nbsp;<a href="javascript:removeHours('.$ntt['recordKey'].')">Remove</a></td>';

				 
				 echo '<div id="edit_hours_modal'.$ntt['recordKey'].'" class="popup_modal">';
				 echo '<a href="#" class="edit_hours_modal'.$ntt['recordKey'].'_close modal_close_button"><img src="/images/x-15.png" width="15" height="15" /></a>';
				 echo '<h3>Edit ' . $textDay . ' Hours</h3>';
				 echo '<br />';
				 echo '<label>From: </label>';
				 echo '<select id="fromHour'.$ntt['recordKey'].'">';
				 for($i = 1; $i < 13; $i++) {
				 	$iDisplay = str_pad($i, 2, '0', STR_PAD_LEFT);
				 	echo '<option';
				 	if($iDisplay == date('h', strtotime($ntt[start_time]))) echo ' selected';
				 	echo '>'.$iDisplay.'</option>';
				 }
				 echo '</select>';
				 echo ':';
				 echo '<select id="fromMinute'.$ntt['recordKey'].'">';
				 for($i = 0; $i < 60; $i++) {
				 	$iDisplay = str_pad($i, 2, '0', STR_PAD_LEFT);
				 	echo '<option';
				 	if($iDisplay == date('i', strtotime($ntt[start_time]))) echo ' selected';
				 	echo '>'.$iDisplay.'</option>';
				 }
				 echo '</select>';
				 echo '<select id="fromMeridiem'.$ntt['recordKey'].'">';
				 echo '<option value="am"';
				 if(date('a', strtotime($ntt[start_time])) == 'am') echo ' selected';
				 echo '>am</option>';
				 echo '<option value="pm"';
				 if(date('a', strtotime($ntt[start_time])) == 'pm') echo ' selected';
				 echo '>pm</option>';
				 echo '</select>';
				 echo '<br />';
				 echo '<br />';

				 echo '<label>To: </label>';
				 echo '<select id="toHour'.$ntt['recordKey'].'">';
				 for($i = 1; $i < 12; $i++) {
				 	$iDisplay = str_pad($i, 2, '0', STR_PAD_LEFT);
				 	echo '<option';
				 	if($iDisplay == date('h', strtotime($ntt[end_time]))) echo ' selected';
				 	echo '>'.$iDisplay.'</option>';
				 }
				 echo '</select>';
				 echo ':';
				 echo '<select id="toMinute'.$ntt['recordKey'].'">';
				 for($i = 0; $i < 60; $i++) {
				 	$iDisplay = str_pad($i, 2, '0', STR_PAD_LEFT);
				 	echo '<option';
				 	if($iDisplay == date('i', strtotime($ntt[end_time]))) echo ' selected';
				 	echo '>'.$iDisplay.'</option>';
				 }
				 echo '</select>';
				 echo '<select id="toMeridiem'.$ntt['recordKey'].'">';
				 echo '<option value="am"';
				 if(date('a', strtotime($ntt[end_time])) == 'am') echo ' selected';
				 echo '>am</option>';
				 echo '<option value="pm"';
				 if(date('a', strtotime($ntt[end_time])) == 'pm') echo ' selected';
				 echo '>pm</option>';
				 echo '</select>';

				 echo '<br />';
				 echo '<button id="save-button" class="edit_hours_modal'.$ntt['recordKey'].'_close" type="button" onclick="updateHours(\''.$ntt['recordKey'].'\')">Save</button>';

				 echo '</div>'; // end modal div
				 echo '<script>';
				 echo '$(document).ready(function() { ';
				 echo "	$('#edit_hours_modal".$ntt['recordKey']."').popup();";
				 echo '});';
				 echo '</script>';

				 echo '</tr>';
			}

			echo '<tr><td></td><td><a href="" class="add_hours_modal_open" onclick="updateAddHoursType(\'open\')">Add Hours</a><br></td></tr>';
			echo '<input id="addHoursType" type="hidden" name="addHoursType" value="0" />';

			// add hours modal
			echo '<div id="add_hours_modal" class="popup_modal">';
			echo '<a href="#" class="add_hours_modal_close modal_close_button"><img src="/images/x-15.png" width="15" height="15" /></a>';
			echo '<h3>Add Hours</h3>';
			echo '<br />';

			echo '<label>Day: </label>';
			echo '<select id="addDay">';
			echo '<option value="0">Sunday</option>';
			echo '<option value="1">Monday</option>';
			echo '<option value="2">Tuesday</option>';
			echo '<option value="3">Wednesday</option>';
			echo '<option value="4">Thursday</option>';
			echo '<option value="5">Friday</option>';
			echo '<option value="6">Saturday</option>';
			echo '</select>';
			echo '<br />';
			echo '<br />';

			echo '<label>From: </label>';
			echo '<select id="addFromHour">';
			for($i = 1; $i < 13; $i++) {
				$iDisplay = str_pad($i, 2, '0', STR_PAD_LEFT);
				echo '<option>'.$iDisplay.'</option>';
			}
			echo '</select>';
			echo ':';
			echo '<select id="addFromMinute">';
			for($i = 0; $i < 60; $i++) {
				$iDisplay = str_pad($i, 2, '0', STR_PAD_LEFT);
				echo '<option>'.$iDisplay.'</option>';
			}
			echo '</select>';
			echo '<select id="addFromMeridiem">';
			echo '<option value="am">am</option>';
			echo '<option value="pm">pm</option>';
			echo '</select>';
			echo '<br />';
			echo '<br />';

			echo '<label>To: </label>';
			echo '<select id="addToHour">';
			for($i = 1; $i < 13; $i++) {
				$iDisplay = str_pad($i, 2, '0', STR_PAD_LEFT);
				echo '<option>'.$iDisplay.'</option>';
			}
			echo '</select>';
			echo ':';
			echo '<select id="addToMinute">';
			for($i = 0; $i < 60; $i++) {
				$iDisplay = str_pad($i, 2, '0', STR_PAD_LEFT);
				echo '<option>'.$iDisplay.'</option>';
			}
			echo '</select>';
			echo '<select id="addToMeridiem">';
			echo '<option value="am">am</option>';
			echo '<option value="pm">pm</option>';
			echo '</select>';

			echo '<br />';
			echo '<br />';
			echo '<button id="save-button" class="add_hours_modal_close" type="button" onclick="addHours()">Save</button>';
			echo '</div>'; // end add_hours_modal

			echo '<script>';
			echo '$(document).ready(function() { ';
			echo "	$('#add_hours_modal').popup();";
			echo '});';
			echo '</script>';
		}
		if($restaurant_pkg=='1'){
			//use delivery hours
			echo '<tr><td>Use Delivery Schedule:</td><td><input type="checkbox" name="chkDelSchedule"';
			if(!empty($nt[open_sign])){
				echo 'checked=true';
			}
			echo '><td><img src="images/question.png" title="If selected, delivery will only be available during the hours you setup below. Otherwise delivery hours will be based on store open hours."></td></tr>';
			//setup delivery hours
			if(!empty($nt[open_sign])){
				echo '<tr><td></td><td><b>Delivery Hours</b></td></tr>';
				//setup hours
				$qry = "select * from hours where delivery='1' order by day, start_time";
				$rtt=mysql_query($qry); //refresh recordset
				while($ntt=mysql_fetch_array($rtt)){
					 echo '<tr id="trHours'.$ntt['recordKey'].'"><td valign="bottom"><div align="right">';
					 $textDay = '';
					 if($ntt[day]=='0'){$textDay = "Sunday";}
					 if($ntt[day]=='1'){$textDay = "Monday";}
					 if($ntt[day]=='2'){$textDay = "Tuesday";}
					 if($ntt[day]=='3'){$textDay = "Wednesday";}
					 if($ntt[day]=='4'){$textDay = "Thursday";}
					 if($ntt[day]=='5'){$textDay = "Friday";}
					 if($ntt[day]=='6'){$textDay = "Saturday";}
					 echo $textDay;
					 echo'</div></td><td valign="bottom">';
					 echo"From: ";
					 $var = date('h:ia', strtotime($ntt[start_time]));
					 echo '<span id="fromTime'.$ntt['recordKey'].'">' . $var . '</span>';
					 echo" to: ";
					 $var = date('h:ia', strtotime($ntt[end_time]));
					 echo '<span id="toTime'.$ntt['recordKey'].'">' . $var . '</span>';
					 echo'&nbsp;&nbsp;<a class="edit_hours_modal'.$ntt['recordKey'].'_open" href="">Edit</a>&nbsp;&nbsp;<a href="javascript:removeHours('.$ntt['recordKey'].')">Remove</a></td>';

					 
					 echo '<div id="edit_hours_modal'.$ntt['recordKey'].'" class="popup_modal">';
					 echo '<a href="#" class="edit_hours_modal'.$ntt['recordKey'].'_close modal_close_button"><img src="/images/x-15.png" width="15" height="15" /></a>';
					 echo '<h3>Edit ' . $textDay . ' Hours</h3>';
					 echo '<br />';
					 echo '<label>From: </label>';
					 echo '<select id="fromHour'.$ntt['recordKey'].'">';
					 for($i = 1; $i < 13; $i++) {
						$iDisplay = str_pad($i, 2, '0', STR_PAD_LEFT);
						echo '<option';
						if($iDisplay == date('h', strtotime($ntt[start_time]))) echo ' selected';
						echo '>'.$iDisplay.'</option>';
					 }
					 echo '</select>';
					 echo ':';
					 echo '<select id="fromMinute'.$ntt['recordKey'].'">';
					 for($i = 0; $i < 60; $i++) {
						$iDisplay = str_pad($i, 2, '0', STR_PAD_LEFT);
						echo '<option';
						if($iDisplay == date('i', strtotime($ntt[start_time]))) echo ' selected';
						echo '>'.$iDisplay.'</option>';
					 }
					 echo '</select>';
					 echo '<select id="fromMeridiem'.$ntt['recordKey'].'">';
					 echo '<option value="am"';
					 if(date('a', strtotime($ntt[start_time])) == 'am') echo ' selected';
					 echo '>am</option>';
					 echo '<option value="pm"';
					 if(date('a', strtotime($ntt[start_time])) == 'pm') echo ' selected';
					 echo '>pm</option>';
					 echo '</select>';
					 echo '<br />';
					 echo '<br />';

					 echo '<label>To: </label>';
					 echo '<select id="toHour'.$ntt['recordKey'].'">';
					 for($i = 1; $i < 12; $i++) {
						$iDisplay = str_pad($i, 2, '0', STR_PAD_LEFT);
						echo '<option';
						if($iDisplay == date('h', strtotime($ntt[end_time]))) echo ' selected';
						echo '>'.$iDisplay.'</option>';
					 }
					 echo '</select>';
					 echo ':';
					 echo '<select id="toMinute'.$ntt['recordKey'].'">';
					 for($i = 0; $i < 60; $i++) {
						$iDisplay = str_pad($i, 2, '0', STR_PAD_LEFT);
						echo '<option';
						if($iDisplay == date('i', strtotime($ntt[end_time]))) echo ' selected';
						echo '>'.$iDisplay.'</option>';
					 }
					 echo '</select>';
					 echo '<select id="toMeridiem'.$ntt['recordKey'].'">';
					 echo '<option value="am"';
					 if(date('a', strtotime($ntt[end_time])) == 'am') echo ' selected';
					 echo '>am</option>';
					 echo '<option value="pm"';
					 if(date('a', strtotime($ntt[end_time])) == 'pm') echo ' selected';
					 echo '>pm</option>';
					 echo '</select>';

					 echo '<br />';
					 echo '<button id="save-button" class="edit_hours_modal'.$ntt['recordKey'].'_close" type="button" onclick="updateHours(\''.$ntt['recordKey'].'\')">Save</button>';

					 echo '</div>'; // end modal div
					 echo '<script>';
					 echo '$(document).ready(function() { ';
					 echo "	$('#edit_hours_modal".$ntt['recordKey']."').popup();";
					 echo '});';
					 echo '</script>';

					 echo '</tr>';
				}
				echo '<tr><td></td><td><a href="" class="add_hours_modal_open" onclick="updateAddHoursType(\'delivery\')">Add Hours</a><br></td></tr>';
			}
		}
		echo '<tr><td>Time Zone: </td><td>';  
		//******************populate time zone list
		echo '<select name="timezone" width="40">';
		echo '<option value=\"NULL\">Select Time Zone</option>\n';
		echo '<option value="America/Puerto_Rico"'; if ($nt[timeZone]=="America/Puerto_Rico"){echo ' selected="selected"';} echo '>America/Puerto Rico (AST)</option>';
		echo '<option value="America/New_York"'; if ($nt[timeZone]=="America/New_York"){echo ' selected="selected"';} echo '>America/New York (EDT)</option>';
		echo '<option value="America/Chicago"'; if ($nt[timeZone]=="America/Chicago"){echo ' selected="selected"';} echo '>America/Chicago (CDT)</option>';
		echo '<option value="America/Boise"'; if ($nt[timeZone]=="America/Boise"){echo ' selected="selected"';} echo '>America/Boise (MDT)</option>';
		echo '<option value="America/Phoenix"'; if ($nt[timeZone]=="America/Phoenix"){echo ' selected="selected"';} echo '>America/Phoenix (MST)</option>';
		echo '<option value="America/Los_Angeles"'; if ($nt[timeZone]=="America/Los_Angeles"){echo ' selected="selected"';} echo '>America/Los Angeles (PDT)</option>';
		echo '<option value="America/Juneau"'; if ($nt[timeZone]=="America/Juneau"){echo ' selected="selected"';} echo '>America/Juneau (AKDT)</option>';
		echo '<option value="Pacific/Honolulu"'; if ($nt[timeZone]=="America/Pacific/Honolulu"){echo ' selected="selected"';} echo '>Pacific/Honolulu (HST)</option>';
		echo '<option value="Pacific/Guam"'; if ($nt[timeZone]=="Pacific/Guam"){echo ' selected="selected"';} echo '>Pacific/Guam (ChST)</option>';
		echo '<option value="Pacific/Samoa"'; if ($nt[timeZone]=="Pacific/Samoa"){echo ' selected="selected"';} echo '>Pacific/Samoa (SST)</option>';
		echo '<option value="Pacific/Wake"'; if ($nt[timeZone]=="Pacific/Wake"){echo ' selected="selected"';} echo '>Pacific/Wake (WAKT)</option>';
		echo '</select>
		<td><img src="images/question.png" title="Select a time zone to allow orders only at the correct times for your time zone."></td><td></td></tr>';
		date_default_timezone_set($nt[timeZone]);
		 echo '<tr><td colspan="2"><font color="red" size=1>Current time: ' . date('h:i:s A') . '</font></td><td></td></tr>';
	}

	echo '<tr><td></td><td><input id="save-button" type="submit" name="save" value="Save Changes"></td><td></td></tr></table><br /></div></form>';
echo "</td></tr></table>";
echo "</ul>";
##******************************************* END HOURS AND TIMEZONE SECTION *****************************************##

##******************************************* BEGIN ONLINE ORDERING SECTION *****************************************##
if($restaurant_pkg=='1'){
	$rt=mysql_query($query); //refresh recordset

	echo "<h3 class='menuheader expandable'>ONLINE ORDERING</h3>";	
	echo'<ul class="categoryitems">';

	echo "<table border=0 width='100%'><tr><td>";
		echo '<form action="' . $_SERVER['PHP_SELF'] . '?a=update&key=' . $nt[recordKey] . '" method="post">
		<input type="hidden" name="section" value="ordering">';
		while($nt=mysql_fetch_array($rt)){
			echo '<div id="table-wrapper"><table width="74%" valign="top"><tr><td width="35%" valign="top">Sales tax: </td><td><input type="text" name="salesTax" size="10" value="' . $nt[salesTax] . '"></td><td><img src="images/question.png" title=""></td></tr>
			<tr><td colspan="2"><font color="red"><i>Enter in decimal format. (ex: 7.5% should be entered as .075</i></font></td><td></td></tr>';  
			echo '<tr><td>Delivery charge: </td><td><input type="text" name="deliveryCharge" size="10" value="' . $nt[deliveryCharge] . '"></td><td><img src="images/question.png" title="Any delivery charge will be added to online orders that select the delivery option."></td></tr>';  
			echo '<tr><td>Minimum order: </td><td><input type="text" name="minimum_order" size="10" value="' . $nt[minimum_order] . '"></td><td><img src="images/question.png" title="Minimum order (dollar amount) accepted for online ordering."></td></tr>';  
			
			echo '<tr><td>Prep time: </td><td><input type="text" name="preptime" size="28" value="' . $nt[preptime] . '"></td><td><img src="images/question.png" title="This is what the customer will see on their order as the expected preparation time."></td></tr>
			<tr><td colspan="2"><font color="red"><i>Time it usually takes to have order ready for pickup.</i></font></td><td></td></tr>';
			echo '<tr><td>Delivery time: </td><td><input type="text" name="deltime" size="28" value="' . $nt[deltime] . '"></td><td><img src="images/question.png" title="This is what the customer will see on their order as the expected delivery time."></td></tr>
			<tr><td colspan="2"><font color="red"><i>Time it usually takes for delivery.</i></font></td><td></td></tr>';
			echo '<tr><td>3rd party ordering URL: </td><td><input type="text" name="orderURL" size="28" value="' . $nt[orderURL] . '"></td><td><img src="images/question.png" title="This is the address of a 3rd party online ordering site. (Leave off the http at the beginning.)"></td></tr>
			<tr><td colspan="2"><font color="red"><i>If you use another ordering solution, insert the link here.</i></font></td></tr>';
			echo '<tr><td>Manage ordering menu: </td><td><img id="order_menu_gear" src="images/gear-icon.png"></td><td><img src="images/question.png" title="Select which menu will be available for online ordering based on the time of day."></td></tr>';
			
			
			echo '<tr><td>Delivery available: </td><td><input type="checkbox" name="chkDeliver"';
			if(!empty($nt[deliver])){
				echo 'checked=true';
			}
			echo '><td><img src="images/question.png" title="Check this box to allow delivery to customers."></td></tr>';
			
			echo '<tr><td>Half topping prices: </td><td><input type="checkbox" name="chkHalfTopping"';
			if(!empty($nt[half_topping_prices])){
				echo 'checked=true';
			}
			echo '><td><img src="images/question.png" title="Check this box to charge half prices for half-pizza toppings."></td></tr>';
			
			echo '<tr><td>Use multiple crusts: </td><td><input type="checkbox" name="chkMultipleCrusts"';
			if(!empty($nt[use_multiple_crusts])){
				echo 'checked=true';
			}
			echo '><td><img src="images/question.png" title="Check this box to enable multiple crust options for pizza categories."></td></tr>';
			
			echo '<tr><td>Use multiple sauces: </td><td><input type="checkbox" name="chkMultipleSauces"';
			if(!empty($nt[use_multiple_sauces])){
				echo 'checked=true';
			}
			echo '><td><img src="images/question.png" title="Check this box to enable multiple sauce options for pizza categories."></td></tr>';
			
			echo '<tr><td>Delivery taxable: </td><td><input type="checkbox" name="chkDeltax"';
			if(!empty($nt[taxdelivery])){
				echo 'checked=true';
			}
			echo '><td><img src="images/question.png" title="Check this box to apply sales tax to delivery charges."></td></tr>';
			echo '<tr><td>Accept checks:</td><td> <input type="checkbox" name="chkChecks"';
			if(!empty($nt[acceptChecks])){
				echo 'checked=true';
			} 
			echo '><td><img src="images/question.png" title="Check this box to let customers know that you accept checks."></td></tr>';  
			echo '<td>Online ordering:</td><td> <input type="checkbox" name="chkOnline"';
			if(!empty($nt[orderOnline])){
				echo 'checked="true" ';
			} 
			if ($masteradmin !==1){echo ' disabled="disabled"';}
			echo '> <font color="red"><i>(requires subscription)</i></font><td><img src="images/question.png" title="This shows whether or not you subscribe to the online ordering service."></td></tr>';
			if($nt[orderOnline]==1){	//only show orderind specific fields if online ordering is activated
				echo '<td>Suspend ordering:</td><td> <input type="checkbox" name="chkSuspend"';
				if($nt[suspend_ordering]==1){
					echo 'checked="true" ';
				} 
				if (($roladmin !==1)&&($masteradmin !==1)&&($admin !==1)){echo ' disabled="disabled"';}
				echo '> <font color="red"></font><td><img src="images/question.png" title="This temporarily disables the online ordering service."></td></tr>';
				echo '<tr><td>Order Email #1:</td><td><input type="text" name="orderemail1" size="28" value="' . $nt[orderEmail1] . '"></td><td><img src="images/question.png" title="This is the store email address that online customer orders will be delivered to. 50 characters maximum."></td></tr>';
				echo '<tr><td>Order Email #2:</td><td><input type="text" name="orderemail2" size="28" value="' . $nt[orderEmail2] . '"></td><td><img src="images/question.png" title="This is the 2nd store email address that online customer orders will be delivered to. 50 characters maximum."></td></tr>';
				echo '<tr><td colspan="2"><font color="red"><i>These are the email accounts that will receive customer orders. You may also use text email addresses to receive via text message.</i></font>';
				echo '<tr><td valign="top">Order Notice:</td><td><textarea name="order_notice" cols=34 rows=3>' . $nt[order_notice] . '</textarea></td><td><img src="images/question.png" title="This is a notice displayed at the top of each online ordering page. 100 characters maximum."></td></tr>';
				echo '<tr><td valign="top">Custom confirmation message:</td><td><textarea name="order_conf" cols=34 rows=4>' . $nt[custom_order_confirmation] . '</textarea></td><td><img src="images/question.png" title="This is a custom confirmation displayed on screen after a succesfully placed order. 200 characters maximum."></td></tr>';
				echo '<tr><td>Include tip field:</td><td><input type="checkbox" name="chkTipline"';
				if(!empty($nt[include_tipline])){
					echo 'checked="true" ';
				} 
				//if ($roladmin !==1){echo ' disabled="disabled"';}
				echo '></td><td><img src="images/question.png" title="This determines whether or not you will inlude a place for customer to enter a tip while ordering."></td></tr>';
				echo '<tr><td>Faxed orders:</td><td><input type="checkbox" name="chkFaxOrders"';
				if(!empty($nt[orderByFax])){
					echo 'checked="true" ';
				}
				if ($roladmin !==1){echo ' disabled="disabled"';}
				echo '><font color="red"><i>(requires subscription)</i></font></td><td><img src="images/question.png" title="This shows whether or not you subscribe to the online order-to-fax service."></td></tr>';
				//save here temporarily - not sure if will be needed here...
				//echo 'PayPal ID: <input type="text" name="paypalid" size="30" value="' . $nt[paypalid] . '"><img src="images/question.png" title="Enter your PayPal ID here. This will be the email address you have registered to your PayPal account.">';
				//echo 'Use PayPal Auth: <input type="checkbox" name="paypal_auth"';
				//if(!empty($nt[paypal_auth])){
				//	echo 'checked=true';
				//} 
				//echo '><img src="images/question.png" title="This option places authorizations when customers check out via paypal, instead of collecting final payment. This allows you to add up to 15% tip before capturing.">';  
				//echo '<font color="red"><i>If using PayPal, this should be your PayPal email address. If no PayPal ID is entered, customer payment info will be transmitted directly to you with the order, to be processed manually.</i></font>';

			}
		}

	echo '<tr><td></td><td><input id="save-button" type="submit" name="save" value="Save Changes"></td></tr></td></tr></table></form>';
	echo "</table>";
	echo "</ul>";
			/*$menuSelect = array();
			$menuSelectquery = "SELECT recordKey, categoryName, orderNum, headerImg from menuCategory WHERE active ='1' AND categoryName <> 'Options' AND categoryName <> 'Pizza Crust' AND categoryName <> 'Pizza Sauce' AND categoryName <> 'Pizza Toppings' AND categoryName <> 'Fixings' Order By orderNum";
			$menuSelectResult = mysql_query($menuSelectquery);
			while($menuData=mysql_fetch_array($menuSelectResult)){	
					$menuSelect[$menuData['recordKey']] = $menuData['categoryName'];
			}*/

			$menuSelect = array();
			$menuSelectquery = "SELECT * from menu_master ORDER BY menu_name";
			$menuSelectResult = mysql_query($menuSelectquery);
			while($menuData=mysql_fetch_array($menuSelectResult)){	
				if($menuData['menu_name']!='Timed menu rotation'){
					$menuSelect[$menuData['recordkey']] = $menuData['menu_name'];
				}
			}
			echo '<div id="timeSettingPopup" class="toPopDiv ">
					<div id="close_btn"></div>
					<div class="close close_Popup"></div>
					<div id="popup_content">
						<form action="'. $_SERVER['PHP_SELF'].'" method="POST" >
						<input type="hidden" value="'.$globalMenuId.'" name="menu_id">
						<input type="hidden" value="'.$globalPageId.'" name="page_id">
							<table border="0" id="time-table" cellpadding=15 cellspacing=0 style="text-align:center">
								';
								$query2 = "SELECT * FROM `manage_ordering_menu` where user_id = '".$_SESSION['UserID']."' ORDER BY id";
								$result = mysql_query($query2);
								if(mysql_num_rows($result)>0){
											echo '<tr>
													<th>Menu To Display</th>
													<th>Start Time</th>	
													<th> </th>			
												</tr>';
									 $idCount=1;
									 while($data=mysql_fetch_array($result)){
										echo '<tr>
											<td>
												<select name="menu[]">';
												foreach ($menuSelect as $key => $value) {
													$selected='';
													if($data[menu_name] == $key){ $selected='selected="selected"';}
													echo "<option ".$selected." value='".$key."'>".$value."</option>";
												}												
											echo '</select>
											</td>
											<td>
												<input  size="6" type="text" class="timepicker" value="'.$data[start_time].'" name="start_time[]" onkeypress="return false;" />
											</td>
											<td>
											 <img onclick="$(this).parents(\'tr\').remove(); return false;" class="removeField" src="../images/remove-icon.png">
											</td>
										</tr>';
										$idCount++;
									}
								}else{
								echo '<tr>
									<th>Menu To Display</th>
									<th>Start Time</th>
								</tr>
								<tr>
									<td>
										<select name="menu[]">';

										foreach ($menuSelect as $key => $value) {
											echo "<option value='".$key."'>".$value."</option>";
										}
								echo '</select>
									</td>
									<td>
										<input size="6" type="text" class="timepicker" name="start_time[]" onkeypress="return false;"/>		
									</td>
								</tr>';
							}
							echo '</table>
							<input type="submit" class="save_time_btn" value="SAVE" name="save-menu-time">
						</form>
						<button id="add_more_btn">+ ADD MORE</button>
					</div>
				  </div>';
}
##******************************************* END ONLINE ORDERING SECTION *****************************************##
/*
##******************************************* BEGIN SOCIAL NETWORKING SECTION *****************************************##
$rt=mysql_query($query); //refresh recordset

echo "<h3 class='menuheader expandable'>SOCIAL NETWORKING</h3>";	
echo'<ul class="categoryitems">';

echo "<table border=0 width='100%'><tr><td>";
	echo '<form action="' . $_SERVER['PHP_SELF'] . '?a=update&key=' . $nt[recordKey] . '" method="post">
	<input type="hidden" name="section" value="social">';
	while($nt=mysql_fetch_array($rt)){
		echo '<div id="table-wrapper"><table width="74%" valign="top"><tr><td width="35%" valign="top">Facebook:</td><td><input type="text" name="facebook" size="30" value="' . $nt[facebook] . '"></td><td><img src="images/question.png" title="Paste in the link to your Facebook page and this will allow visitors to access your Facebook page directly through your website."></td></tr>';  
		echo '<td>Facebook Page ID:</td><td><input type="text" name="fbpage" size="30" value="' . $nt[fbpage] . '"></td><td><img src="images/question.png" title="Paste in the page ID for your Facebook business page. This is usually a 15 digit string of numbers that can be seen in the address bar when you sit your Facebook page. This will allow you to publish coupons from your ROO website directly to your Facebook Page."></td></tr>';  
		echo '<td>Twitter:</td><td><input type="text" name="twitter" size="30" value="' . $nt[twitter] . '"></td><td><img src="images/question.png" title="Paste in the link to your Twitter account and this will allow your visitors to go to your Twitter page directly through your website."></td></tr>';  
		echo '<td>Twitter ID:</td><td><input type="text" name="twitterid" size="30" value="' . $nt[twitterid] . '"></td><td><img src="images/question.png" title="Paste in the ID for your Twitter account. This will allow you to publish coupons from your ROO website directly to your Twitter account."></td></tr>';  
		echo '<td>Google+:</td><td><input type="text" name="google_plus" size="30" value="' . $nt[google_plus] . '"></td><td><img src="images/question.png" title="Paste in the URL for your Google+ account. This will put a Google+ button on your website."></td></tr>';  
		echo '<td>MySpace:</td><td><input type="text" name="myspace" size="30" value="' . $nt[myspace] . '"></td><td><img src="images/question.png" title="Paste in the link to your MySpace page and this will allow your visitors to visit your MySpace page directly through your website."></td></tr>';  
		if($fantools_subscribed==1){
			echo '<td>FanTools User ID:</td><td><input type="text" name="fantoolsid" size="30" value="' . $nt[fantools_email] . '"></td><td><img src="images/question.png" title="This is the email address you use to log into your FanTools account."></td></tr>';  
			echo '<td>FanTools Password:</td><td><input type="text" name="fantoolspwd" size="30" value="' . $nt[fantools_pwd] . '"></td><td><img src="images/question.png" title="This is the password you use to log into your FanTools account."></td></tr>';  
		}
	}

	echo '<tr><td></td><td><input id="save-button" type="submit" name="save" value="Save Changes"></td></tr></td></tr></table></form>';
echo "</table>";
echo "</ul>";
##******************************************* END SOCIAL NETWORKING SECTION *****************************************##
*/
##******************************************* BEGIN APPEARANCE SECTION *****************************************##
if($restaurant_pkg=='1'){
	$rt=mysql_query($query); //refresh recordset

	echo "<h3 class='menuheader expandable'>MENU APPEARANCE OPTIONS</h3>";	
	echo'<ul class="categoryitems">';

	echo "<table border=0 width='100%'><tr><td>";
		echo '<form action="' . $_SERVER['PHP_SELF'] . '?a=update&key=' . $nt[recordKey] . '" method="post">
		<input type="hidden" name="section" value="appearance">';
		while($nt=mysql_fetch_array($rt)){
			echo '<div id="table-wrapper"><table width="74%" valign="top"><tr><td width="35%" valign="top">Menu Bar Color:</td><td><input type="text" name="catcolor" class="color" size="30" value="' . $nt[categoryColor] . '"></td><td><img src="images/question.png" title="The category headers on the menu will have this color background. You may enter a color name or a 6-character HTML color code. "></td></tr>'; 
			echo '<td>Menu Font Color:</td><td><input type="text" name="catfontcolor" class="color" size="30" value="' . $nt[categoryFontColor] . '"></td><td><img src="images/question.png" title="The category headers on the menu will have this color text. You may enter a color name or a 6-character HTML color code. "></td></tr>'; 

		}

		echo '<tr><td></td><td><input id="save-button" type="submit" name="save" value="Save Changes"></td></tr></td></tr></table></form>';
	echo "</table>";
	echo "</ul>";
}
##******************************************* END APPEARANCE SECTION *****************************************##

##******************************************* BEGIN LINKPOS SECTION *****************************************##
if($restaurant_pkg=='1'){
	if($linkpos_enabled=='1'){
		if(($roladmin==1)||($masteradmin==1)){
			$rt=mysql_query($query); //refresh recordset
		
			echo "<h3 class='menuheader expandable'>LinkPOS Settings</h3>";	
			echo'<ul class="categoryitems">';
		
			echo "<table border=0 width='100%'><tr><td>";
				echo '<form action="' . $_SERVER['PHP_SELF'] . '?a=update&key=' . $nt[recordKey] . '" method="post">
				<input type="hidden" name="section" value="linkpos">';
				while($nt=mysql_fetch_array($rt)){
					echo '<div id="table-wrapper"><table width="74%" valign="top">';
					if($masteradmin==1){
						echo '<tr><td width="35%" valign="top">Partner:</td><td><input type="text" name="linkpos_partner_name" size="30" value="' . $nt[linkpos_partner_name] . '"></td><td><img src="images/question.png" title="Menuetta"></td></tr>'; 
						echo '<tr><td width="35%" valign="top">Partner Password:</td><td><input type="text" name="linkpos_partner_pwd" size="30" value="' . $nt[linkpos_partner_pwd] . '"></td><td><img src="images/question.png" title="0987"></td></tr>'; 
					}
					echo '<tr><td width="35%" valign="top">Company:</td><td><input type="text" name="linkpos_company" size="30" value="' . $nt[linkpos_company] . '"></td><td><img src="images/question.png" title="This is the company, or parent company if multiple stores in chain."></td></tr>'; 
					echo '<tr><td width="35%" valign="top">Store Name:</td><td><input type="text" name="linkpos_store_name" size="30" value="' . $nt[linkpos_store_name] . '"></td><td><img src="images/question.png" title="Store name for this specific store, not the parent company."></td></tr>'; 
					echo '<tr><td width="35%" valign="top">Store Password:</td><td><input type="text" name="linkpos_store_pwd" size="30" value="' . $nt[linkpos_store_pwd] . '"></td><td><img src="images/question.png" title="LinkPOS password for this specific store."></td></tr>'; 
				}
		
				echo '<tr><td></td><td><input id="save-button" type="submit" name="save" value="Save Changes"></td></tr></td></tr></table></form>';
			echo "</table>";
			echo "</ul>";
		}
	}
}
##******************************************* END LINKPOS SECTION *****************************************##

##******************************************* BEGIN HVAC SECTION *****************************************##
if($hvac_pkg=='1'){
	//if($lennox_enabled=='1'){
		if(($roladmin==1)||($masteradmin==1)){
			$rt=mysql_query($query); //refresh recordset
		
			echo "<h3 class='menuheader expandable'>Lennox Settings</h3>";	
			echo'<ul class="categoryitems">';
		
			echo "<table border=0 width='100%'><tr><td>";
				echo '<form action="' . $_SERVER['PHP_SELF'] . '?a=update&key=' . $nt[recordKey] . '" method="post">
				<input type="hidden" name="section" value="lennox">';
				while($nt=mysql_fetch_array($rt)){
					echo '<div id="table-wrapper"><table width="74%" valign="top">';
					if($masteradmin==1){
						echo '<tr><td width="35%" valign="top">Lennox API key:</td><td><input type="text" name="lennox_api_key" size="30" value="' . $nt[lennox_api_key] . '"></td><td><img src="images/question.png" title="Menuetta"></td></tr>'; 
						
					}
					
				}
		
				echo '<tr><td></td><td><input id="save-button" type="submit" name="save" value="Save Changes"></td></tr></td></tr></table></form>';
			echo "</table>";
			echo "</ul>";
		}
	//}
}
##******************************************* END HVAC SECTION *****************************************##

echo"</div>";	




?>

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

<script type="text/javascript">

//Code for order menu display time setting
$('#order_menu_gear').click(function() {
			$('#timeSettingPopup').fadeIn( "slow", function() {
			});
		});

$('input.timepicker').timepicker({ 'showDuration': true, 'step': 15, 'timeFormat': 'H:i' });

		$('#close_btn').click(function() {
			$('#timeSettingPopup').hide();
		});

		$('#add_more_btn').click(function() { 
		var rowCount = $('#time-table tr').length;
		var x = rowCount-1;
		var endHour = $( "#end-h-box_"+x+" option:selected" ).val();
		var endMin = $( "#end-m-box_"+x+" option:selected" ).val();
		var endMod = $( "#end-mod option:selected" ).val();
		var i=0;
		var html = "<tr><td><select name='menu[]'>";
			<?php
				foreach ($menuSelect as $key => $value) { ?>
			html +="<option value='<?php echo $key; ?>' ><?php echo $value; ?></option>";
			<?php } ?>
			html +="</td><td><input size='6' type='text' class='timepicker' name='start_time[]' onkeypress='return false;' /></td><td><img onclick='$(this).parent().parent().remove(); return false;' class='removeField' src='../images/remove-icon.png'></td></tr>";
	$('#time-table').append(html);
		$('input.timepicker').timepicker({ 'showDuration': true, 'step': 15, 'timeFormat': 'H:i' });
	});


//////////////

//code to open jquery popup for other location
 $('.popup.other_location_btn').click(function() {
 	$('toPopDiv menu-item').show();
        var popupId = $(this).data('popup-id');
        $('#iframe-'+popupId).attr('src', 'editprefsiframe.php?a=list_location&key='+popupId);
    });


var parentAccordion=new TINY.accordion.slider("parentAccordion");
parentAccordion.init("acc","h3",1,-1);

var nestedAccordion=new TINY.accordion.slider("nestedAccordion");
nestedAccordion.init("nested","h3",1,-1,"acc-selected");

var nestedAccordion2=new TINY.accordion.slider("nestedAccordion2");
nestedAccordion2.init("nested2","h3",1,-1,"acc-selected");


//var parentAccordion=new TINY.accordion.slider("parentAccordion");
//parentAccordion.init("acc","h3",0);

//var nestedAccordion=new TINY.accordion.slider("nestedAccordion");
//nestedAccordion.init("nested","h3",1,-1,"acc-selected");
//nestedAccordion.init("nested","h3",1,-1,"acc-selected");
</script>