

function addToFavorites()
{ 
if (window.sidebar) {alert("Sorry! Your browser doesn't support this function.\nPress Ctrl+D to add site to bookmark list."); return;}
if (window.external) { window.external.AddFavorite(document.location.href + "?WT.cg_n=bookmarkreturn",document.title); return;}
else  { alert("Sorry! Your browser doesn't support this function.\nPress Ctrl+D to add site to bookmark list."); } };


function popup(url, width, height, scrollable)
{ if(scrollable){scbars = 1;} else{scbars = 0;} var nomargin; if(scrollable == 2){ nomargin = true; scbars = 0; }
  if(url == "ecap"){ url="http://www.secure-res.com/emgr/csemail.asp?ID="+width; width=400; height = 455;}
  if(url == "srlogo"){ width = 445; height = 455; url="http://www.hotelwebsitedesign.com/secureres/srpopup/"}
  if(url == "stf"){ if(height==1){height=80;} if(!height){height=0;} url="http://www.secure-res.com/emgr/stf/sendpage.asp?id="+width+"&pg="+escape(location.href); width = 560; height += 490;   }
  var wopt = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+ scbars +",resizable=0,width="+width+",height="+height+",top="+(screen.height/2-height/2)+",left="+(screen.width/2 - width/2);
  if(nomargin){ newwin=window.open("","",wopt);	newwin.document.write("<html><head><style>body{margin:0}</style></head><body><img src='"+ url +"'></body></html>");  }
  else { newwin=window.open(url,"popup",wopt); }			
  newwin.focus(); };


function generate_address( un, hn, sty, lnk, subline) 
{ var stycl = ""; var atsign = "&#64;"; var subject = "";
  var addr = un + atsign + hn;
  if(sty){stycl = " class=" + sty } if(subline){subject = "?Subject=" + subline } 
  if(!lnk){ var lnk = addr; } 
  document.write( "<" + "a " + stycl + " href='" + "mail" + "to:" + addr + subject +"'>" + lnk + "</a>");	};

var wmonths = ["Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; 

function do_opt(numopts,startnum,selnum)
{ if(!startnum && startnum != 0){startnum=1} 
  if(numopts == "mo"){ for (var xi=0; xi<wmonths.length; xi++) { document.write('<option value=' + (xi+1) + '>' + (wmonths[xi])); } }
  else { for (var xi=startnum; xi<=numopts; xi++) { sel=(selnum == xi)?" selected ":""; document.write('<option value=' + (xi) + sel + '>' + (xi) ); } }
};
function do_year()
{ var tdate = new Date();  var curyr = tdate.getFullYear();
  for (var jj=0; jj<3; jj++) { document.write('<option value=' + (curyr+jj) + '>' + (curyr+jj) + '</option>'); } };

if(document.location.href) 
	hrefString = document.location.href;
else
	hrefString = document.location;

var pagename = extractPageName(hrefString);

function extractPageName(hrefString)
{
	var arr = hrefString.split('.');
	if(arr.length >= 2) {
		arr = arr[arr.length-2].split('/');
		return arr[arr.length-1].toLowerCase();
	} else {
		return "x";
	}
}

function setActiveMenu(arr)
{
  for(var i=0; i < arr.length; i++)
  {
	  if(extractPageName(arr[i].href) == pagename)
	  {
		addClass(arr[i],'current');
		addClass(arr[i].parentNode,'current');
	  }
	  
	  var relarr = arr[i].rel.split(",");
	  for(var x=0; x < relarr.length; x++)
	  {
		  if(relarr[x].toLowerCase() == pagename)
		  {
			addClass(arr[i],'current');
			addClass(arr[i].parentNode,'current');
		  }
	  }
  }
}

<!-- call this method from your page-->
function highlightPages(classname)
{
	var lists = getElementsByClass(classname, null,"ul");
    for (var i=0; i < lists.length; i++)
		setActiveMenu(lists[i].getElementsByTagName('a'));
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function addClass(element, value) {
	if (!element.className) {
		element.className = value;
	} else {
		var newClassName = element.className;
		newClassName += " ";
		newClassName += value;
		element.className = newClassName;
	}
}

//2. PLACE THIS IN THE SITE'S SCRIPTS.JS/PROPERTY.JS FILE IF THE FUNCTION
//   DOESN'T ALREADY EXIST
//-----------------------------------------------------------------------------
// IDENTIFIES VISITORS USING MOBILE DEVICES AND SENDS THEM TO THE MOBILE
// VERSION OF THE SITE
//----------------------------------------------------------------------------- 

/*
	parseUri 1.2.1
	(c) 2007 Steven Levithan <stevenlevithan.com>
	MIT License
*/
function parseUri (str) {
	var	o   = parseUri.options,
		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i   = 14;

	while (i--) uri[o.key[i]] = m[i] || "";

	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});

	return uri;
};

parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};


function RedirectMobileDevicesToMobileSite(VisitorInformation)
{
  //get visitor information
  if(VisitorInformation.isMobileDevice == true)
  {
    //don't redirect if the override querystring is present
    var uri = parseUri(window.location);
    if (typeof(uri.queryKey["mobileRedirect"]) == "undefined")
    {
      var url = "http://mobile."+document.domain.replace("www.", "");
      var qsConcatSymbol = "?";
        
      //pass original querystring information if it existed
      var qs = window.location.search.substring(1);
      if (qs != "")
      {
        url += "?" + qs;
        qsConcatSymbol = "&";
      }
      //pass referrer information so webtrends can maintain tracking
      var referrer = document.referrer;
      if (referrer != "")
      {
        url += qsConcatSymbol + "referrer="+encodeURIComponent(referrer);
        
      }
      
      document.location = url;
    }
  }
}
