﻿var $=function(tid)
{
return document.getElementById(tid);
}
function isIE()
{
   // ie ?
   if (window.navigator.userAgent.toLowerCase().indexOf("msie") >= 1)
   return true;
   else
   return false;
}

if( ! isIE())
{
   // firefox innerText define
   HTMLElement.prototype.__defineGetter__("innerText",
   function()
   {
      var anyString = "";
      var childS = this.childNodes;
      for(var i = 0; i < childS.length; i ++ )
      {
         if(childS[i].nodeType == 1)
         // anyString += childS[i].tagName == "BR" ? "\n" : childS[i].innerText;
         anyString += childS[i].innerText;
         else if(childS[i].nodeType == 3)
         anyString += childS[i].nodeValue;
      }
      return anyString;
   }
   );
   HTMLElement.prototype.__defineSetter__("innerText",
   function(sText)
   {
      this.textContent = sText;


   }
   );
}
function GetCookieVal(offset)
{
   var endstr = document.cookie.indexOf(";", offset);
   if (endstr == - 1)
   endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}


function SetCookie(name, value) 
{ 
var expdate = new Date();
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
+((secure == true) ? "; secure" : "");
}





function GetCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
        return GetCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}


function DeleteCookie(name)
{
   var exp = new Date();
   exp.setTime(exp.getTime() - 1);
   var cval = GetCookie(name);
   document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


function ClearCookies()
{
   if(confirm('你确定要清空所有COOKIE吗？'))
   {
      var temp = document.cookie.split(";");
      var ts;
      for (var i = 0; ; i ++ )
      {
         if( ! temp[i])
         break;
         ts = temp[i].split("=")[0];
         DeleteCookie(ts);
      }
      alert('COOKIE已清除！');
   }
}
var hasthis = function(str)
{
   var scr = window.location.href.toLowerCase();
   if(scr.indexOf(str.toLowerCase()) > 0)
   return true;
   return false;
}
;
String.prototype.Trim = function() {  
  var m = this.match(/^\s*(\S+(\s+\S+)*)\s*$/);  
  return (m == null) ? "" : m[1];  
}


var checkemail=function(str)
{
var pattern_cn = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
if(pattern_cn.test(str)) return true;
return false;
}












String.prototype.isMobile = function() {  
  return (/^(?:13\d|15[012689])-?\d{5}(\d{3}|\*{3})$/.test(this.Trim()));  
} 

String.prototype.isTel = function()
{
    return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));
}
var showhover=function(obj)
	  {
		  obj.className="hover";
	  }
var LeftSale=function()
   {
   
      var a = $('menu').getElementsByTagName('a');
	  if(hasthis('Room-sale'))
      {
         showhover(a[0]);
      }
      else if(hasthis('Z-Food-sale'))
      {
         showhover(a[1]);
      }
      else if(hasthis('X-Food-sale'))
      {
         showhover(a[2]);
      }
      else if(hasthis('Meeting-sale'))
      {
         showhover(a[3]);
      }
//      else if(hasthis('Health-sale'))
//      {
//         showhover(a[4]);
//      }
	  else if(hasthis('other-sale'))
      {
         showhover(a[4]);
      }
	};
var LeftBone=function()
   {
   
      var a = $('menu').getElementsByTagName('a');
	  if(hasthis('bones.htm'))
      {
         showhover(a[0]);
      }
      else if(hasthis('show.htm'))
      {
         showhover(a[0]);
      }
      else if(hasthis('order'))
      {
         showhover(a[2]);
      }
      else if(hasthis('room-sale'))
      {
         showhover(a[1]);
      }
      else if(hasthis('price'))
      {
         showhover(a[3]);
      }
    };
  var LeftCatering=function()
   {
   
      var a = $('menu').getElementsByTagName('a');
	  if(hasthis('dining_z.htm') || hasthis('Z-dining-hall.htm'))
      {
         showhover(a[0]);
      }
      else if(hasthis('dining_x.htm') || hasthis('X-dining-hall.htm'))
      {
         showhover(a[1]);
      }
      else if(hasthis('room_service.htm'))
      {
         showhover(a[3]);
      }
    };
    var LeftMeeting=function()
   {
   
      var a = $('menu').getElementsByTagName('a');
	  if(hasthis('meeting.htm'))
      {
         showhover(a[0]);
      }
      else if(hasthis('Business.htm'))
      {
         showhover(a[1]);
      }
      else if(hasthis('meetingbook.htm'))
      {
         showhover(a[2]);
      }
      
    };
    
     var LeftHealth=function()
   {
   
      var a = $('menu').getElementsByTagName('a');
	  if(hasthis('recreation.htm'))
      {
         showhover(a[0]);
      }
      
    };
    
    var LeftMember=function()
   {
   
      var a = $('menu').getElementsByTagName('a');
      if(hasthis('member'))
      {
          showhover(a[0]);
      }
      else if(hasthis('modify'))
      {
         showhover(a[1]);
      }
	  else if(hasthis('login') || hasthis('reg'))
      {
         showhover(a[2]);
      }
      else if(hasthis('myorder'))
      {
         showhover(a[3]);
      }
      else if(hasthis('wedding'))
      {
         showhover(a[4]);
      }
      else if(hasthis('meeting'))
      {
         showhover(a[5]);
      }
      else if(hasthis('exchange'))
      {
         showhover(a[6]);
      }
      else if(hasthis('history'))
      {
         showhover(a[7]);
      }
      else if(hasthis('review'))
      {
         showhover(a[8]);
      }
      else if(hasthis('help'))
      {
         showhover(a[9]);
      }
    };
    var LeftAbout=function()
   {
   
      var a = $('menu').getElementsByTagName('a');
	  if(hasthis('about'))
      {
         showhover(a[0]);
      }
      else if(hasthis('news'))
      {
         showhover(a[1]);
      }
      else if(hasthis('detail'))
      {
         showhover(a[1]);
      }
      else if(hasthis('service'))
      {
         showhover(a[2]);
      }
      else if(hasthis('recruiter'))
      {
         showhover(a[3]);
      }
      else if(hasthis('contact'))
      {
         showhover(a[4]);
      }
    };
    var LeftService=function()
   {
   
      var a = $('menu').getElementsByTagName('a');
      showhover(a[0]);
     
   };
    var LeftE=function()
   {
   
      var a = $('menu').getElementsByTagName('a');
	  if(hasthis('map'))
      {
         showhover(a[0]);
      }
      else if(hasthis('buy'))
      {
         showhover(a[1]);
      }
      else if(hasthis('spot'))
      {
         showhover(a[2]);
      }
    };
