var blnCheckUnload = true;
var exitwithConfirm = true;
var logout_token ="";
window.onbeforeunload = function() {
		logout_token = readCookie("xlands_token");
		return("YOHO夢境虛擬社區 | Dream.uyoho.com");
//	if(blnCheckUnload) {
//		var favorited = readCookie("favoriteCookie");
//		if (favorited == "havaAddfavorited")
//		{
//			if (exitwithConfirm){
//				if(confirm("YOHO夢境虛擬社區 | Dream.uyoho.com\n\n您確定要退出YOHO夢境嗎?")){
//					var send = readCookie("xlands_token");
//					jQuery.post("http://sso.dream.uyoho.com/ssoc/account/logout",{token:send});
//					window.location.href("http://dream.uyoho.com/index.php?action=loginout");
//					writeCookie("xlands_token", "", 24);
//				}
//					event.returnValue = "YOHO夢境虛擬社區 | Dream.uyoho.com";
//			}
//		}else{
//			if (confirm("感謝您光臨YOHO夢境 | Dream.uyoho.com\n\n現在要把YOHO夢境加入收藏嗎？"))
//			{
//				writeCookie("xlands_token", "", 24);
//				writeCookie("favoriteCookie", "havaAddfavorited", 365*24);
//				addfavorite();
//			}
//				event.returnValue = "感謝您光臨YOHO夢境 | Dream.uyoho.com\n\n現在要把YOHO夢境加入收藏嗎？";
//		}
//	}
}



function beforWindowUnloadToAddFavorite(){
	writeCookie("xlands_token", "", 24);
	writeCookie("favoriteCookie", "havaAddfavorited", 365*24);
	addfavorite();
}
function exitWithoutConfirm(){
	exitwithConfirm = false;
}

function addfavorite()
{
	if (document.all)
	{ 
	window.external.addFavorite('http://dream.uyoho.com','YOHO夢境');
	}
	else if (window.sidebar)
	{ 
	window.sidebar.addPanel('YOHO夢境', 'http://dream.uyoho.com', ""); 
	}
} 

function  readCookie(name)   
  {   
      var   cookieValue   =   "";   
      var   search   =   name   +   "=";   
      if(document.cookie.length   >   0)   
      {     
          offset   =   document.cookie.indexOf(search);   
          if   (offset   !=   -1)   
          {     
              offset   +=   search.length;   
              end   =   document.cookie.indexOf(";",   offset);   
              if   (end   ==   -1)   end   =   document.cookie.length;   
              cookieValue   =   unescape(document.cookie.substring(offset,   end))   
          }   
      }   
      return   cookieValue;
  }
    
  function   writeCookie(name,   value, hours)   
  {   
      var   expire   =   Date.MaxValue;  
      if(hours   !=   null)   
      { 
          expire   =   new   Date((new   Date()).getTime()   +   hours   *   3600000);   
          expire   =   ";   expires="   +   expire.toGMTString();   
      }
      document.cookie   =   name   +   "="   +   escape(value)   +   expire;   
  }