
function revealtimes(){
			
	document.getElementById("findtimeswait").style.display = 'none';
	document.getElementById("findtimespanel").style.display = 'block';
	
}

function showProgress(){
document.getElementById('progress').style.display='block';




}
					
					var LRtimeslot;
						var LRsessionid;
						var LRdiners;
						var LRlocationid;
						var LRcorrelation;
						var LRpromotion;
						var LRfirstname;
						var LRlastname;
						var LRemail;
						var LRmobile;
						var LRrestid;
						var LRonlypromotions;
				
/*function checkAvailability(){
					var restaurantid = document.getElementById("LRsk_restaurantid").value;
						LRrestid = restaurantid;
					dd = document.getElementById("ddLRdate").value;
					mm = document.getElementById("mmLRdate").value;
					yyyy = document.getElementById("yyyyLRdate").value;
					
					LRtimeslot = yyyy+'-'+mm+'-'+dd;

					nicetimeslot = dd+'/'+mm+'/'+yyyy;
					
					LRsessionid = document.getElementById("LRsessionid").value;
					LRdiners = document.getElementById("LRdiners").value;
					if(document.getElementById("LRonlypromotions")){
						
						//return false;
						LRonlypromotions = (document.getElementById("LRonlypromotions").checked ==true?1:0);
					}else{
							LRonlypromotions = 0;

					}
					//alert(LRonlypromotions);
					document.getElementById("findpanel").innerHTML = '<p>Searching '+LRsessionid+'  for party of '+LRdiners+', on '+nicetimeslot+'</p>';
					document.getElementById("resultspanel").innerHTML = '<br/><img src="http://book.livebookings.net/res/App_Themes/UK-VUE_000/graphics/searchinprogress.gif" align="left" style="border:2px solid #FFF;padding:10px;">Contacting restaurant to find availability. Please wait...<br/>If this is taking too long, please try again<br/>';

						var connection = new AjaxConnection('/functions/ajax_restaurants.php');
						opts = new Array("action=checkRestaurantAvailability",
							"sk_restaurantid="+restaurantid,
							"diners="+LRdiners,
							"date="+LRtimeslot,
							"sessionid="+LRsessionid,
							"onlypromotions="+LRonlypromotions
							);
						connection.setOptions(opts);
						connection.connect("checkedAvailability");

}*/

function checkedAvailability(content){
	
	document.getElementById("resultspanel").innerHTML = content;
	//document.getElementById("resultspanel").style.background='1px solid red';

}

/*function checkOfferAvailability(timeslot,sessionid,diners){
					var restaurantid = document.getElementById("LRsk_restaurantid").value;
						LRrestid = restaurantid;
					LRsessionid = sessionid;
					LRtimeslot = timeslot;
					LRdiners = diners;
					//alert(LRonlypromotions);
					document.getElementById("findpanel").innerHTML = '<p>Searching '+LRsessionid+'  for party of '+LRdiners+'</p>';
					document.getElementById("resultspanel").innerHTML = '<br/><img src="http://book.livebookings.net/res/App_Themes/UK-VUE_000/graphics/searchinprogress.gif" align="left" style="border:2px solid #FFF;padding:10px;">Contacting restaurant to find availability. Please wait...<br/>If this is taking too long, please try again<br/>';

						var connection = new AjaxConnection('/functions/ajax_restaurants.php');
						opts = new Array("action=checkRestaurantAvailability",
							"sk_restaurantid="+LRrestid,
							"diners="+LRdiners,
							"date="+LRtimeslot,
							"sessionid="+LRsessionid,
							"onlypromotions=1"
							);
						connection.setOptions(opts);
						connection.connect("checkedAvailability");

}	*/					
Date.prototype.setISO8601 = function (string) {
    var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" +
        "(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?" +
        "(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
    var d = string.match(new RegExp(regexp));

    var offset = 0;
    var date = new Date(d[1], 0, 1);

    if (d[3]) { date.setMonth(d[3] - 1); }
    if (d[5]) { date.setDate(d[5]); }
    if (d[7]) { date.setHours(d[7]); }
    if (d[8]) { date.setMinutes(d[8]); }
    if (d[10]) { date.setSeconds(d[10]); }
    if (d[12]) { date.setMilliseconds(Number("0." + d[12]) * 1000); }
    if (d[14]) {
        offset = (Number(d[16]) * 60) + Number(d[17]);
        offset *= ((d[15] == '-') ? 1 : -1);
    }

    offset -= date.getTimezoneOffset();
    time = (Number(date) + (offset * 60 * 1000));
    this.setTime(Number(time));
}
		/*		function prepareRestaurantTable(timeslot,locationid,correlation,promotion){
						LRtimeslot = timeslot;
					//	LRsessionid = sessionid;
					//	LRdiners = diners;
						LRlocationid = locationid;
						LRcorrelation = correlation;
						LRpromotion = promotion;

						var myDate = new Date();
					
						myDate.setISO8601(LRtimeslot);
					//	var nicetimeslot = myDate.getDate() +"/"+ (myDate.getMonth()+1) +"/"+ myDate.getFullYear() +" at "+ myDate.getHours() +":"+ myDate.getMinutes()
						var nicetimeslot = myDate.getDate() +"/"+ (myDate.getMonth()+1) +"/"+ myDate.getFullYear() +"";

						document.getElementById("findpanel").style.display = 'none';
					//	document.getElementById("findpanel").innerHTML = '<p>Preparing '+LRsessionid+' booking for party of '+LRdiners+', on '+nicetimeslot+'</p>';
						document.getElementById("resultspanel").innerHTML = '<img src="http://book.livebookings.net/res/App_Themes/UK-VUE_000/graphics/searchinprogress.gif" align="left" style="border:2px solid #FFF;padding:10px;">Checking time slot...';

						var connection = new AjaxConnection('/functions/ajax_restaurants.php');
						opts = new Array("action=prepareRestaurantTable",
							"diners="+LRdiners,
							"date="+LRtimeslot,
							"sessionid="+LRsessionid,
							"locationid="+LRlocationid,
							"correlationdata="+LRcorrelation,
							"promotionid="+LRpromotion
							);
						connection.setOptions(opts);
						connection.connect("preparedRestaurantTable");
				}*/
				
				
			/*	function bookRestaurantTable(){

					

					LRfirstname = document.getElementById("LRfirstname").value;
					LRlastname = document.getElementById("LRlastname").value;
					LRemail = document.getElementById("LRemail").value;
					LRmobile = document.getElementById("LRmobile").value;
					if(LRfirstname==""){
						alert("Please enter your first name for this booking");
						return false;
					}
					if(LRlastname==""){
						alert("Please enter your last name for this booking");
												return false;

					}
					if(LRemail==""){
						alert("Please enter your email address for this booking");
												return false;

					}
					
					document.getElementById("findpanel").innerHTML = "";
				//document.getElementById('bookbar').style.display='none';
					document.getElementById("resultspanel").innerHTML = '<img src="http://book.livebookings.net/res/App_Themes/UK-VUE_000/graphics/searchinprogress.gif" align="left" style="border:2px solid #FFF;padding:10px;">Connecting to restaurant to book your table...';

					//makeReservation($sessionid,$datetime,$size,$locationid,$correlation,$firstname,$lastname,$email,$mobile)
					var connection = new AjaxConnection('/functions/ajax_restaurants.php');
						opts = new Array("action=bookRestaurantTable",
							"restid="+LRrestid,
							"diners="+LRdiners,
							"date="+LRtimeslot,
							"sessionid="+LRsessionid,
							"locationid="+LRlocationid,
							"correlationdata="+LRcorrelation,
							"promotionid="+LRpromotion,

							"firstname="+LRfirstname,
							"lastname="+LRlastname,
							"email="+LRemail,
							"mobile="+LRmobile
							);
						connection.setOptions(opts);
						connection.connect("bookedRestaurantTable");

				}*/
					
				/*function preparedRestaurantTable(content){
				document.getElementById("resultspanel").innerHTML = content;
				document.getElementById('bookbar').style.display='none';
document.getElementById('nocharge').style.display='none';

				}
				function bookedRestaurantTable(content){
				document.getElementById("resultspanel").innerHTML = content;


				}*/
function showRestForm(type){
	document.getElementById("restsearchbox").style.display='none';
	document.getElementById("restnamesearchbox").style.display='none';
	document.getElementById("restsearchbox").style.display='none';
	document.getElementById('restType1').checked = false;
	document.getElementById('restType2').checked = false;
	//document.getElementById('restType3').checked = false;
	document.getElementById('restType4').checked = false;
	document.getElementById('restType5').checked = false;
	//document.getElementById('restType6').checked = false;




//document.getElementById('restType3').checked = false;
switch(type){

		case 1:	document.getElementById("restsearchbox").style.display='block'; document.getElementById('restType1').checked = true; break;
		case 2:	document.getElementById("restnamesearchbox").style.display='block'; document.getElementById('restType5').checked = true; break;
		//case 3:	document.getElementById("restsearchbox").style.display='block'; document.getElementById('restType3').checked = true; break;

}

}
function changeRestSearch(type,diners,date,session,cuisine){
var connection = new AjaxConnection('/functions/ajax_restaurants.php');
						opts = new Array("action=getSearchForm",
							"type="+type,
							"d="+diners,
							"date="+date,
							"s="+session,
							"c="+cuisine);

						connection.setOptions(opts);
						connection.connect("changedRestSearch");


}

function changedRestSearch(content){

		document.getElementById("restsearchbox").innerHTML = content;
}

function restSearchSuggest(lat,lng){

var name = document.getElementById("LRName").value;

var connection = new AjaxConnection('/functions/ajax_restaurants.php');
						opts = new Array("action=findVenue",
							"name="+name,
							"lat="+lat,
							"long="+lng
							);

						connection.setOptions(opts);
						connection.connect("findVenueSuggestions");



}

function findVenueSuggestions(content){
var ss = document.getElementById('search_suggest')
//		ss.innerHTML = '<strong>Matching restaurants:</strong><br/>';
ss.innerHTML = content;

}

//Mouse over function
function suggestOver(div_value) {
	div_value.className = 'suggest_link_over';
}
//Mouse out function
function suggestOut(div_value) {
	div_value.className = 'suggest_link';
}


//Click function
function setSearch(value) {
	document.getElementById('LRName').value = value;
	document.getElementById('search_suggest').innerHTML = '';
}

function getAvailCalendar(restid,promotionid,year,month,sessionid,diners){

var connection = new AjaxConnection('/functions/ajax_restaurants.php');
						opts = new Array("action=showAvailCalendar",
							"sk_restaurantid="+restid,
							"sessionid="+sessionid,
							"y="+year,
							"m="+month,
							"pid="+promotionid,
							"diners="+diners
							
							);

						connection.setOptions(opts);
						connection.connect("showAvailCalendar");



}
function showAvailCalendar(content){

document.getElementById("resultspanel").innerHTML = content;

}
function checkRestBookingForm2(){

var checkBoxArr = getSelectedCheckbox(document.bookrestaurantform2.date);
if (checkBoxArr.length == 0) { alert("Please select a date");return false; }

					
return true;
}

function checkRestBookingForm4(){

	LRfirstname = document.getElementById("LRfirstname").value;
	LRlastname = document.getElementById("LRlastname").value;
	LRemail = document.getElementById("LRemail").value;
	LRmobile = document.getElementById("LRmobile").value;
	if(LRfirstname==""){
		alert("Please enter your first name for this booking");
		return false;
	}
	if(LRlastname==""){
		alert("Please enter your last name for this booking");
								return false;

	}
	if(LRemail==""){
		alert("Please enter your email address for this booking");
								return false;

	}
	if(LRmobile==""){
		alert("Please enter your mobile number for this booking");
								return false;

	}
					
return true;
}


//-----
var enabled;
function enableSessions(){
	enabled=0;
	$('nosessionsavail').style.display = 'none';
	for (i=0;i<enabledsessions.length;i++)
	{
		enabled++;
	 //   alert("ENABLING"+ enabledsessions[i] );
		$(enabledsessions[i]).disabled = false;
			$(enabledsessions[i]+'_label').style.display = '';

	}
}

function disableSessions(seshstring){
enableSessions();
var disabledsessions = seshstring.split(',');

for (i=0;i<disabledsessions.length;i++)
{
		  //  alert("DISABLING"+ disabledsessions[i] );

  if($(disabledsessions[i])){
	  enabled--;
	$(disabledsessions[i]).disabled = true;
	$(disabledsessions[i]+'_label').style.display = 'none';
  }
}
if(enabled<1){
	//alert("Showing because enabledcnt= "+enabled+" disabled = "+disabledsessions.length+" AND enabled = "+enabledsessionsCount);
	$('nosessionsavail').style.display = '';
}
}

function openPartyPlanner(){

window.open ("http://www.livebookings.com/utilities/forms/partybooking/skiddle/",
"party","status=0,toolbar=0,width=700px,height=600px,menubar=0,location=0,scrollbars=1"); 

}


 
var imageIndex = 1;



function restHomepageSlideshow() {

	imageArray = new Array(); 
 
var image01 = new Image();
image01.src = '/images/skin/restaurantshomepage0.jpg';
imageArray[imageArray.length] = image01;
 
var image02 = new Image();
image02.src = '/images/skin/restaurantshomepage1.jpg';
imageArray[imageArray.length] = image02;
 
var image03 = new Image();
image03.src = '/images/skin/restaurantshomepage2.jpg';
imageArray[imageArray.length] = image03;
 
var image04 = new Image();
image04.src = '/images/skin/restaurantshomepage3.jpg';
imageArray[imageArray.length] = image04;

	// place the next image to be displayed to the front
	$('index_restpic').src = imageArray[imageIndex].src;
 
	// make the image in front appear, when it is done swap it with the image in the back
	new Effect.Appear('index_restpic', {
		
		afterFinish: function() { 
			// make the image in the back the same src as the image in the front
			document.getElementById('index_restpicbehind').src = document.getElementById('index_restpic').src;
			
			//hide the image in the front
			document.getElementById('index_restpic').style.display = 'none';
			
			// increment the index
			imageIndex++;
			// if we have indexed past the end of the array, go back to zero
			if (imageIndex == imageArray.length) { 
				imageIndex = 0;
			}
		}
	});
}




function showBookingForm(url) {
	
showLightviewIFrameSetSize(url,800,700);
/*
if(lightviewLoaded==true && mobileDevice==0){
  Lightview.show({
    href: url,
    rel: 'iframe',
    options: {
      width:800,
	  height:600,
      topclose: true
		}
	});

}else if(window.jQuery && jQuery.colorbox && mobileDevice==0){
		
	jQuery.colorbox({
		href:url,
		width:800,
			height:600,
			iframe:true	,
			close:'Close Window'
	});

	

}else{
		window.open(url,'bookform','width=800,height=600');

}
*/
}
	

if(document.observe){
	document.observe('dom:loaded', function() {
	$$('a.restdescajax[rel]').each(function(element) {
		
	   new Tip(element, {
			style:  'restaurants',
			width:400,
			showOn: 'click',
			ajax: {
			url: '/restaurantmain/ajaxtooltip.php?type=description&id='+element.rel,
			options: {
			method: 'get'
			}  }});  });
		   
	$$('a.restreviewsajax[rel]').each(function(element) {
		
	   new Tip(element, {
		style:  'restaurants',
		width:400,
		showOn: 'click',
		ajax: {
		url: '/restaurantmain/ajaxtooltip.php?type=reviews&id='+element.rel,
		options: {
			method: 'get'
		   }  }});  });   
		   
	$$('a.restlocalajax[rel]').each(function(element) {
		
	   new Tip(element, {
			style:  'restaurants',
			showOn: 'click',
			width:410,
			ajax: {
			url: '/restaurantmain/ajaxtooltip.php?type=localarea&id='+element.rel,
			options: {
			method: 'get'
		   }  }});  });  


		   
	});
}

