// JavaScript Document
// JavaScript Document
function ftn_menuItem(strTitle, strPrice, strDescription, menuItemClass){
	var strCurrency = '&pound;';
	if (!menuItemClass){
		menuItemClass = 'menuItem';
	}else{
		strCurrency = '&pound;';
	}
	
	if(!strPrice)
		strCurrency = '';
	var strMenuItem = '<div class="menuItemNormal" style="width:249px;cursor:pointer" onClick="ftnAddToOrder(\'' + strTitle + '\');">'+
						'<div class="menuItemTitle" style="width:200px;">' + strTitle + '</div>' + 
						'<div class="menuItemPrice" style="width:49px;" >'  + strCurrency + strPrice +  '</div>' 

+ 
						'<div class="menuItemDescription" style="width:249px;" ><img src="/images/global/labesi.png"  width="210" height="1"></div>' +
					'</div>' +
					'<div class="menuItemNoBg" style="width:249px;" >' +
						'<div class="menuItemDescription" style="width:249px;" ><img src="/images/global/labesi.png" width="210" height="8" ></div>' +
						'<div class="menuItemDescription" style="width:249px; text-align:left">' + strDescription + '</div>' + 
						'<div class="menuItemDescription" ><img src="/images/global/labesi.png"  width="210" height="8"></div>' +
					'</div>';

	return strMenuItem;				
				
}
function ftn_InsertMenu(menuNumber){
	
	var d = document.getElementById('thefood');
  
  	 	var strItem1 = '<img src="images/menu/menusPanini.png" alt="Panini">' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					ftn_menuItem('BACON AND MOZZARELLA CHEESE', '3.10', '') + 
					ftn_menuItem('HAM, FRESH TOMATOES & CHEDDAR CHEESE', '3.10', '') + 
					ftn_menuItem('BEEF STEAK, RED ONIONS & CHEDDAR CHEESE', '4.50', '') + 
					ftn_menuItem('CHEDDAR CHEESE, FRESH TOMATOES, MIXED PEPPERS & MIX LETTUCE', '2.50', '') + 
					ftn_menuItem('ITALIAN SALAMI, FRESH TOMATOES, MOZZARELLA & MIX LETTUCE', '3.10', '') + 
					ftn_menuItem('ITALIAN PEPPERONI, FRESH TOMATOES, MOZZARELLA CHEESE & MIX LETTUCE', '3.00', '') + 
					ftn_menuItem('TUNA, CHEDDAR CHEESE, RED ONIONS & MIX LETTUCE', '2.95', '') + 
					ftn_menuItem('CHICKEN BREAST, FRESH TOMATOES, MIXED PEPPERS & MOZZARELLA', '3.50', '') +
					ftn_menuItem('CHICKEN BREAST, BACON,MAYONNAISE & MIX LETTUCE', '3.95', '') + 
					ftn_menuItem('ITALIAN PARMA HAM, ROCKET,MOZZARELLA CHEESE & FRESH TOMATOES', '3.95', '') + 
					ftn_menuItem('SPICY CHICKEN & CORIANDER', '3.50', 'Piri piri chicken, coriander and mayonnaise') + 
					ftn_menuItem('MEDITERRANEAN VEGETABLE PANINI', '2.95', 'Mixed peppers, tomatoes & red onions slow roasted in garlic and mozzarella cheese') + 
					ftn_menuItem('LA BESI PANINI', '2.95', 'Feta cheese, fresh tomatoes, cucumber, red onion, black olives and lettuce');
  
	var strItem2 = '<img src="images/menu/menusStarters.png"  alt="Starters">' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					ftn_menuItem('SOUP OF THE DAY', '2.30', '') + 
					ftn_menuItem('GARLIC PIZZA BREAD WITH CHEESE', '2.95', 'Freshly made pizza bread with garlic, mozzarella cheese and fresh basil') + 
					ftn_menuItem('GARLIC PIZZA BREAD', '2.50', 'Freshly made pizza bread with tomato sauce, garlic, olive oil and basil') + 
					ftn_menuItem('BRUSCHETTA', '2.50', 'Toasted Italian bread with fresh tomato, garlic, olive oil and basil') + 
					ftn_menuItem('CALAMARI FRITTI', '3.50', 'Deep fried calamari with homemade tartar sauce and garnish') + 
					ftn_menuItem('FUNGHETTI  ALL CREMA', '3.50', 'Garlic mushrooms in cream and white wine sauce') + 
					ftn_menuItem('ANTIPASTO LA BESI', '4.95', 'With boscalola olives, a selection of salami, marinated mixed pickled vegetables') +
					ftn_menuItem('MOZZARELLA FRITTA', '4.25', 'Deep fried mozzarella wrapped in Parma ham with rocket and tomato gramolata') + 
					ftn_menuItem('INSALATA TRICOLORE', '3.50', 'Fresh tomato, avocado, mozzarella, fresh basil with olive oil') + 
					ftn_menuItem('COCKTAIL DI GAMBERETTI', '3.80', 'Prawns served with lettuce, Marie-Rose sauce') +
					ftn_menuItem('PRAWNS WITH AVOCADO', '3.95', 'Served on a bed of lettuce and Marie-rose sauce') +
					ftn_menuItem('MOZZARELLA IN CARROZZA', '4.95', 'Mozzarella cheese & ham encased in breadcrumbs, deep fried and served with a rich tomato basil sauce');
					
					
	
					
	var strItem3 = '<img src="images/menu/menusPizzas.png"  alt="Pizzas">' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					ftn_menuItem('MARGHERITA', '4.50', 'Mozzarella, tomato sauce and fresh basil') +
					ftn_menuItem('MEDITERRANEAN', '4.95', 'Mozzarella cheese, tomato sauce, sliced tomato, olives, feta cheese and oregano ') + 
					ftn_menuItem('NAPOLI', '4.95', 'Mozzarella, tomato sauce, anchovies, capers, and black olives') +
					ftn_menuItem('ALLA FUNGHI', '4.95', 'Tomato sauce, mozzarella cheese, fresh mushrooms') +
					ftn_menuItem('PIZZA ROSA', '5.25', 'Tomato sauce, mozzarella cheese, onions and tuna.') +
					ftn_menuItem('VEGETARIAN', '5.20', 'Tomato sauce, Mozzarella cheese, mixed peppers, onions and mushrooms') +
					ftn_menuItem('PEPPERONI', '5.50', 'Tomato sauce, mozzarella cheese and Italian pepperoni') +
					ftn_menuItem('TROPICANA', '5.95', 'Tomato sauce, mozzarella cheese, ham and pineapple') +
					ftn_menuItem('FRANCESCANA PIZZA', '5.95', 'Tomato Sauce, Mozzarella cheese, parma ham and fresh rocket.') +
					ftn_menuItem('QUATTRO FORMAGGI', '6.50', 'Tomato sauce with four cheeses') +
					ftn_menuItem('AL CAPONE', '6.50', 'Mozzarella cheese, tomato sauce, Garlic, Ham, Salami and Peperoni') + 
					ftn_menuItem('QUATTRO STAGIONI', '6.50', 'Ham, mixed peppers, mushrooms and pepperoni') + 
					ftn_menuItem('MAMA MIA PIZZA', '6.50', 'Mozzarella cheese, Tomato sauce, chicken, peperoni and Jalapeno peppers') +					
					ftn_menuItem('POLLO CALZONE', '6.30', 'Folded pizza stuffed with chicken, garlic, spinach, mozzarella cheese and tomato sauce') +
					ftn_menuItem('FLORENTINA', '5.95', 'Fresh spinach, egg, parmesan cheese, olives, mozzarella cheese and tomato sauce') +
					ftn_menuItem('PIZZA DEL MILLENNIO', '6.60', 'Parma ham, baby mozzarella with tomato sauce topped with rocket leaves and parmesan cheese') +
					ftn_menuItem('MARINARA', '6.50', 'Tomato sauce, mozzarella cheese, prawns, calamari, clams and olives') +
					ftn_menuItem('CALZONE', '6.50', 'Folded pizza with mozzarella cheese, tomato sauce, ham and salami pepperoni and oregano') + 
					ftn_menuItem('PARMA E RUCOLA', '6.50', 'Tomato sauce, mozzarella cheese, parma ham and fresh rocket') +
					ftn_menuItem('LA BESI PIZZA', '6.95', 'Our Chef\'s own irresistible recipe, a little bit of everything and a lot of love');
					
					
					
					
	var strItem4 = '<img src="images/menu/menusPasta.png"  alt="Pasta">' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					ftn_menuItem('LASAGNE', '5.95', 'Made with 100% prime beef mince, Bolognese sauce, béchamel, tomato sauce, mozzarella cheese and parmesan cheese') +
					ftn_menuItem('CANNELLONI', '5.95', 'Pasta rolls filled with spinach and ricotta cheese and oven baked') +
					ftn_menuItem('TAGLIATELLE SALMONE', '6.50', 'Pasta strips tossed with fresh salmon, broccoli, shallots,   Parsley and a creamy white wine and tomato sauce') +
					ftn_menuItem('TAGLIATELLE PRIMAVERA', '5.95', 'Pasta strips in tomato and cream sauce with mushrooms and ham') +
					ftn_menuItem('TAGLIATELLE STEAK', '6.95', 'Strips of sirloin steak, fresh tomatoes, garlic, chilli and a touch of tomato sauce') +
					ftn_menuItem('SPAGHETTI ALLA CARBORANA', '5.95', 'Spaghetti with bacon and egg yolk in a creamy sauce with parmesan cheese') +
					ftn_menuItem('SPAGHETTI ALLA MARE', '6.50', 'Spaghetti tossed in a seafood sauce of mussels, clams, prawns, calamari and tomato sauce') +
					ftn_menuItem('SPAGHETTI BOLOGNESE', '4.95', 'Made with 100% prime beef mince, and tomato sauce') +
					ftn_menuItem('SPAGHETTI NAPOLI', '4.50', 'Tomato sauce, garlic, fresh basil and parmesan cheese') +
					ftn_menuItem('RISOTTO DELLA NONNA', '6.50', 'Rice with chicken, garlic, parmesan cheese, mushrooms and tomato sauce') +
					ftn_menuItem('SEAFOOD RISOTTO', '6.50', 'Rice tossed in a seafood sauce of mussels, clams, prawns, calamari, white wine, garlic and tomato sauce') +
					ftn_menuItem('PENNE ARRABBIATA', '5.50', 'Penne with hot Italian pepperoni, olives, garlic, chillies in tomato sauce') +
					ftn_menuItem('PENNE AL FORNO', '5.50', 'Oven baked pasta with fresh vegetables, garlic, tomato sauce and mozzarella cheese') +
					ftn_menuItem('CHEF’S PASTA', '6.50', 'Penne with chicken, onions, mushrooms, garlic, tomato sauce and a touch of cream') +
					ftn_menuItem('TORTELLONI', '6.50', 'Filled with spinach, ricotta cheese cooked in a creamy sauce and parmesan cheese') +
					ftn_menuItem('ITALIAN MEATBALLS', '6.80', 'Made with 100% beef and herbs. Cooked with tender love in a traditional tomato sauce and basil on a bed of spaghetti');
					
					var strItem5 = '<img src="images/menu/menusSecondiPiatti.png"  alt="Secondi Piatti">' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					ftn_menuItem('POLLO ALLA GRIGLIA', '7.00', 'Grilled chicken breast served with garnished and a wedge of lemon') +
					ftn_menuItem('POLLO CACCIATORE', '7.50', 'Chicken cooked in a spicy tomato sauce, mixed peppers, onions, mushrooms, garlic, ham and Italian herbs') +
					ftn_menuItem('POLLO AL FUNGHI', '7.50', 'Chicken breast cooked with mushrooms, shallots, tomato sauce, cream, garlic and white wine sauce') +
					ftn_menuItem('BATUTTA DI POLLO ALLA MILANESE', '8.50', 'Breadcrumbed chicken breast with fresh peppers, tomato sauce and chilli spaghetti') +
					ftn_menuItem('SALMONE ALLA GRIGLIA', '8.50', 'Grilled salmon served with vegetables of the day and a lemon wedge');
					
					var strItem6 = '<img src="images/menu/menusBistecca.png"  alt="Bistecca Alla Griglia">' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					ftn_menuItem('GRILLED SIRLOIN STEAK', '9.95', 'With fried egg and French fries') +
					ftn_menuItem('GRILLED SIRLOIN STEAK', '9.95', 'With pepper sauce');
					
					var strItem7 = '<img src="images/menu/menusSundries.png"  alt="Sundries">' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					ftn_menuItem('STEAK BURGER', '3.95', 'Our own recipe homemade 8 ounce burger served with fries and garnish') +
					ftn_menuItem('CHICKEN FILLET BURGER', '4.25', 'Grilled chicken with lettuce, fresh tomatoes and mayonnaise, served with fries and garnish') +
					ftn_menuItem('ANY BURGER TOPPING', '0.50', '');
					
					var strItem8 = '<img src="images/menu/menusAccompaniments.png"  alt="Accompaniments">' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					ftn_menuItem('VEG OF THE DAY', '2.00', '') +
					ftn_menuItem('GREEK SALAD', '2.60', '') +
					ftn_menuItem('ITALIAN MIXED SALAD', '2.00', '(ask for our home made dressing)') +
					ftn_menuItem('GREEN SALAD', '2.00', '') +
					ftn_menuItem('FRENCH FRIES', '1.50', '') +
					ftn_menuItem('FRENCH FRIES WITH CHEESE', '2.00', '') +
					ftn_menuItem('SAUTEED SPINACH WITH GARLIC OLIVE OIL', '2.00', '') +
					ftn_menuItem('SAUTEED POTATOES', '2.00', 'With onions and fresh herbs') +
					ftn_menuItem('ZUCCHINI', '2.20', 'Breadcrumbed fried courgettes') +
					ftn_menuItem('RUCOLA E PARMIGIANO', '2.20', 'Rocket and parmesan salad with balsamic dressing') +
					ftn_menuItem('INSALATA VERDE CON AVOCADO', '2.50', 'Green salad with avocado');
					
					var strItem9 = '<img src="images/menu/menusDesserts.png"  alt="Desserts>' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					ftn_menuItem('CHOCOLATE FUDGE CAKE WITH CREAM', '2.25', 'A rich moist chocolate sponge layered with fudge and coated in a wonderfully smooth chocolate fudge icing') +
					ftn_menuItem('HOMEMADE TIRAMISU WITH CREAM', '2.50', 'Layers of sponge soaked liqueur & coffee filled with zabaglione & coffee cream, dusted with a rich cocoa powder') +
					ftn_menuItem('COPPA PROFITEROLES', '2.95', 'Rich chocolate cream covering choux pastries filled with chantilly cream') +
					ftn_menuItem('CASSATA SICILIANA', '2.95', 'A slice of vanilla and chocolate ice cream with a cream and candied fruit centre') +
					ftn_menuItem('TORTA LIMONE', '2.75', 'Delicate shortcrust pastry filled with lemon flavoured patisserie cream, topped with a lightly browned meringue') +
					ftn_menuItem('COPPA CIOCCOLATO', '2.95', 'Vanilla ice cream rippled with chocolate cream swirls') +
					ftn_menuItem('LEMON SORBET OR ORANGE SORBET', '2.75', 'A real lemon or orange with its flesh removed & filled with a tangy sorbet') +
					ftn_menuItem('BANANA SPLIT', '2.50', 'Fresh banana, three scoops of ice cream and cream. Comes with a choice of strawberry, chocolate or rasberry sauce');
					
					var strItem10 = '<img src="images/menu/menusDrinks.png"  alt="Drinks">' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					'<div class="menuItemDescription"><img src="/images/global/labesi.png" width="340" height="6"></div>' +
					ftn_menuItem('SOFT DRINKS (see below)', '0.70', '') +
					ftn_menuItem('COKE', '0.70', '') +
					ftn_menuItem('DIET COKE', '0.70', '') +
					ftn_menuItem('FANTA', '0.70', '') +
					ftn_menuItem('7UP', '0.70', '') +
					ftn_menuItem('ITALIAN WATER, STILL OR SPARKLING', '1.20', '') +
					ftn_menuItem('FRESH JUICES AND SMOOTHIES (see below)', '1.50', '') +
					ftn_menuItem('FRESHLY SQUEEZED ORANGE JUICE', '1.50', '') +
					ftn_menuItem('STRAWBERRY AND BANANA SMOOTHIE', '1.50', '') +
					ftn_menuItem('BANANA AND KIWI SMOOTHIE', '1.50', '') +
					ftn_menuItem('MIXED FRUIT OF THE SEASON SMOOTHIE', '1.50', '') +
					ftn_menuItem('ALL THE J2O FLAVOURS (see below)', '1.30', '') +
					ftn_menuItem('PASSIONFRUIT J20', '1.30', '') +
					ftn_menuItem('APPLE AND MELON J20', '1.30', '') +
					ftn_menuItem('APPLE AND MANGO J20', '1.30', '') +
					ftn_menuItem('ORANGE AND CRANBERRY J20', '1.30', '') +
					ftn_menuItem('ALL COFFEE (see below)', '1.50', '') +
					ftn_menuItem('AMERICANO COFFEE', '1.50', '') +
					ftn_menuItem('CAPPUCCINO', '1.50', '') +
					ftn_menuItem('CAFFEE LATTE', '1.50', '') +
					ftn_menuItem('HOT CHOCOLATE', '1.50', '') +
					ftn_menuItem('CAFFE LATTE', '1.50', '') +
					ftn_menuItem('FRAPPE COFFEE', '1.50', 'Ice coffee') +
					ftn_menuItem('LA BESI COFFEE WITH CREAM', '1.50', '') +
					ftn_menuItem('PAGO JUICES (see below)', '1.30', '') +
					ftn_menuItem('STRAWBERRY', '1.30', '') +
					ftn_menuItem('APPLE', '1.30', '') +
					ftn_menuItem('PEACH', '1.30', '');
	
	switch(menuNumber) {
      case 1: d.innerHTML = strItem1; break
	
      case 2: d.innerHTML = strItem2; break
	  
      case 3: d.innerHTML = strItem3; break   
	  
	  case 4: d.innerHTML = strItem4; break   
	  
	  case 5: d.innerHTML = strItem5; break   
	  
	  case 6: d.innerHTML = strItem6; break   
	  
	  case 7: d.innerHTML = strItem7; break
	  
	  case 8: d.innerHTML = strItem8; break   
	  
	  case 9: d.innerHTML = strItem9; break   
	  
	  case 10: d.innerHTML = strItem10; break   
	  
	  

   }

	

}


function fn_validateFieldIsEmpty(formDOMObj, fieldname, identifier){
	/* this function validates a form field, basically it checks to 
	see if a parameter sent to it is empty and if it is, return false */
	
	if(formDOMObj[fieldname].value.length < 1){
		
		//set the two fields which proclaim an error ro "inline" (ie. visible)
		
		
		alert('The ' +  identifier + ' is blank.\nPlease enter your ' + identifier);
		return false;
	}
	return true;
}

function ftnValidateOrder(formDOMObj){
	//alert();
	
	 if(fn_validateFieldIsEmpty(formDOMObj, 'strName', 'name') == false
			|| fn_validateFieldIsEmpty(formDOMObj,  'strTelephone', 'telephone number') == false
			|| fn_validateFieldIsEmpty(formDOMObj,  'strOrder', 'order') == false){
			 
		 	return false;
	 }
	 if(formDOMObj.strDeliveryType.value=='For delivery'){
		 if(fn_validateFieldIsEmpty(formDOMObj,  'strAddress', 'address') == false){
				 
				return false;
		 }
	 }
		//otherwise return true
		return true;
	

}



function ftnAddToOrder(orderTitle){
	
	//define new line variable
	var strNewLine = '\n';
	//define the current takeaway order
	var strCurrentOrder = document.frmOrderOnline.strOrder.value;
	//if the current order is blank, no need for a new line
	if(document.frmOrderOnline.strOrder.value.length <= 1){
		strNewLine = '';
	}else{
		//if not blank, check for a match betweek the current order and the new order item
		var intIndexOf = strCurrentOrder.indexOf(orderTitle);
	}
	
	//if there is a match we need to increase the quantity by one
	if(intIndexOf > 1){
		var intTens = (strCurrentOrder.charAt(intIndexOf-5));
		var intQuantityOf = parseInt(strCurrentOrder.charAt(intIndexOf-4));
		
		//intQuantityOf = parseInt(intQuantityOf);
		
		intQuantityOf += 1;
		
		if(intTens.length>0 && intQuantityOf==10){
			intTens = parseInt(strCurrentOrder.charAt(intIndexOf-5));
			
			intQuantityOf = (intTens*10) + intQuantityOf;
			
			strCurrentOrder = strCurrentOrder.substring(0,intIndexOf-5) + intQuantityOf + ' x ' + strCurrentOrder.substring(intIndexOf)
		}else{
			strCurrentOrder = strCurrentOrder.substring(0,intIndexOf-4) + intQuantityOf + ' x ' + strCurrentOrder.substring(intIndexOf)
		};
		
		
		
		
		
		
	}else{
		strCurrentOrder += strNewLine + '1 x ' + orderTitle;	
	}
		 
		
	
	
	document.frmOrderOnline.strOrder.value = strCurrentOrder;
	
}

