// JavaScript Document
// this function contains all of the glue to complete mobile detection.
// if the device requesting the page is mobile, it will redirect
// the request to a mobile domain as long as a cookie is not set.

//----------function briM_detectsupportedDevices() ----------
function briM_detectsupportedDevices(){
// return true if supported
// otherwise return false
	if (DetectTierIphone())
      return true;
	if (DetectTierRichCss())
      return true;
//Otherwise, return false.
   return false;
}
//-->
//----------function briM_redirectOnMobile() ----------
function briM_redirectOnMobile(mobileSite, fullSiteCookie) {
// this function will redirect to a mobile site if a supported device is
// detected and a cookie is not set.

if(!briM_detectsupportedDevices()){
	return;
}
var briM_redirect = false;
// the browser is supported.  Has a cookie been set?
var briM_cookie_jar = document.cookie;
if(briM_cookie_jar == ""){
	// no cookie has been set, redirect is ok
	briM_redirect = true;
}
if(!briM_redirect){
	// now test to see what cookie we have
	var briM_cookie = briM_cookie_jar.indexOf(fullSiteCookie + "=");
	if(briM_cookie == -1){
		// no cookie... redirect is ok
		briM_redirect = true;
	}
}
if(!briM_redirect){return;}
window.location.replace("http://"+mobileSite);
}	
//-->
//----------function briM_del_cookie() ----------
function briM_del_cookie(fullSiteCookie) {
document.cookie = fullSiteCookie +
'=; expires=Thu, 01-Jan-70 00:00:01 GMT;' +
 "; path=" + "/" +
 "; domain=" + ".birchridge.com";
}
//-->

// entryspace to begin for mobile detection

if(document.location.href == "http://www.birchridge.com/Restaurant/current_menu.php")
	{briM_redirectOnMobile("m.birchridge.com/Restaurant/restaurant_menu.php", "briFullSite");}
if(document.location.href == "http://www.birchridge.com/Restaurant/christmas_menu.php")
	{briM_redirectOnMobile("m.birchridge.com/Restaurant/christmas_menu.php", "briFullSite");}	
if(document.location.href == "http://www.birchridge.com/Availability/availability.html")
	{briM_redirectOnMobile("http://availabilityonline.com/availtable.asp?un=birchridge&briDevice=mobile", "briFullSite");}	
else {briM_redirectOnMobile("m.birchridge.com", "briFullSite");}

