// 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 kciM_detectsupportedDevices() ----------
function kciM_detectsupportedDevices(){
// return true if supported
// otherwise return false
	if (DetectTierIphone())
      return true;
	if (DetectTierRichCss())
      return true;
//Otherwise, return false.
   return false;
}
//-->
//----------function kciM_redirectOnMobile() ----------
function kciM_redirectOnMobile(mobileSite, fullSiteCookie) {
// this function will redirect to a mobile site if a supported device is
// detected and a cookie is not set.

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

// entryspace to begin for mobile detection

if(document.location.href == "http://www.killingtoncountryinns.com/propertyguide.php")
	{kciM_redirectOnMobile("m.killingtoncountryinns.com/index.html", "kciFullSite");}
if(document.location.href == "http://www.killingtoninns.com/Restaurant/propertyguide.php")
	{kciM_redirectOnMobile("m.killingtoncountryinns.com/index.html", "kciFullSite");}	
else {kciM_redirectOnMobile("m.killingtoncountryinns.com", "kciFullSite");}

