function show_map()
{
window.location = "http://maps.google.co.uk/maps?hl=en&ie=UTF8&q=chequers+billericay&fb=1&split=1&gl=uk&cid=499852067792859820&li=lmd&z=14&iwloc=A"
}

function show_blogg()
{
window.open("http://www.thechequersbillericay.com/new_chequers/blog")
}

function whatsOn()
{
window.open('showWhatsOn.htm')
}




function get_seconds()
 { 
  var time = new Date();
  var hours = time.getHours();
  var mins = time.getMinutes();
  var secs = time.getSeconds();
  totsecs = (hours * 60 * 60) + (mins * 60) + secs
  return totsecs  
 }

function show_whatson(period)
{
hide_windows()
retval = ajax("get_whats_on.php?period="+period)
document.all.whats_on_id.innerHTML = retval
document.all.whats_on_id.style.visibility = "visible"
}


function show_sports()
{
hide_windows()
retval = ajax("getfootball.php?period=monthly")
document.all.sports.innerHTML = retval
document.all.sports.style.visibility = "visible"
}

function waitfor(seconds)
{
 var waituntil = 0
  start_secs = get_seconds()
  waituntil = start_secs + parseInt(seconds)
  
  end_secs = get_seconds()
  
while (end_secs<=waituntil)
{
  end_secs = get_seconds() 
}
 return 
}

function show_home()
{
hide_windows()
document.all.init_page.style.visibility = "visible"
}

function startup() {
    
    get_cart_value()
	//setTimeout("show_weekly_whatson()",3000);
    }

function send_contact_mess()
{
email = document.all.contact_form.email.value
message = document.all.contact_form.message.value
retval = ajax("send_contact_mess.php?email="+email+"&message="+message)
if(retval = "SUCCESS")
{
alert("Your message has been sent.\nIf a reply is required you should receive one shortly");
close_contactus()
}
}


function show_contactus()
{
document.all.contact.style.visibility = "visible"
}

function close_contactus()
{
document.contact_form.reset()
document.all.contact.style.visibility = "hidden"
}

function hide_windows()
{
document.all.frame.style.visibility = "hidden"
document.all.weekly_view.style.visibility = "hidden"
document.all.main.style.visibility = "hidden"
document.all.gallery.style.visibility = "hidden"
document.all.contact.style.visibility = "hidden"
document.all.sports.style.visibility = "hidden"
document.all.whats_on_id.style.visibility = "hidden"
document.all.menu_holder.style.visibility = "hidden"
document.all.merchandise.style.visibility = "hidden"
document.all.cartpage.style.visibility = "hidden"
document.all.init_page.style.visibility = "hidden"
}

function get_galleries()
{
hide_windows()
retval = ajax("getgalleries.php")
document.all.gallery.innerHTML = retval
document.all.gallery.style.visibility = "visible"
}

function show_gallery(gallery)
{
hide_windows()
document.all.frame.src = "programs/gallery.php?gallery=../"+gallery
timer=setTimeout('document.getElementById("frame").style.visibility="visible";',2000); 
//document.all.frame.style.visibility = "visible"
}


function hide_details()
{
  document.all.details.innerHTML = ""
  document.all.details.style.visibility = "hidden"
}

function showstaff(image)
{
  retval = ajax("get_staff_details.php?file="+image)
  if(retval == "")
  {
    hide_details()
    alert("There are no details for this person")
    return
  }
  document.all.details.innerHTML = retval
  document.all.details.style.visibility = "visible"
}



function whats_on()
{
hide_windows()
document.all.whatson.style.visibility = "visible"

}

function show_menu()
{
hide_windows()
retval = ajax("get_menu.php")
document.all.menu_list.innerHTML = retval
document.all.menu_holder.style.visibility = "visible"
}

function show_merchandise()
{
//hide_windows()
//retval = ajax("get_merchandise.php")
alert("Sorry, This facility is not yet available")
//document.all.merchandise.innerHTML = retval
//document.all.merchandise.style.visibility = "visible"
}


function get_cart_value()
{
  retval = ajax("get_cart_value.php")
  if(retval != "NOCART") 
    {
     document.all.cart.style.visibility = "visible"
     document.all.cart_total.innerHTML = "Total&nbsp;"+retval      
      
    }
}



function show_cart()
{
hide_windows()
retval = ajax("view_cart.php")
document.all.cartpage.innerHTML = retval
document.all.cartpage.style.visibility = "visible"
}


function clear_cart()
{
 retval = ajax("cart.php?action=delete_cart")
 if(retval == "DELETED_CART")
  {
   document.all.cart_total.innerHTML = ""      
   document.all.cart.style.visibility = "hidden"
   get_cart_value()
   show_home()
  }
}

function clear_item(ref_no)
{
 retval = ajax("cart.php?action=delete_item&ref=" + ref_no)
 if(retval == "DELETED_ITEM")
  {
  	get_cart_value()
	show_cart()
    return
  }
 if(retval == "DELETED_CART")
  {
     document.all.cart_total.innerHTML = ""      
     document.all.cart.style.visibility = "hidden"
     get_cart_value()
     hide_windows()
  }
}



function add_cart_item(ref_no)
{
 retval = ajax("cart.php?action=add&ref=" + ref_no)
 if(retval == "ADDED")
  {get_cart_value()
  alert("A new item has been added to your shopping cart")
  }
}

function meet()
{
retval = ajax("team.php")
document.all.main.innerHTML = retval
hide_windows()
document.all.main.style.visibility = "visible"
}
