/*  $Header: property.js, 2, 9/27/04 10:14:14 AM MDT, StarTeam Server Administrator$ : $Name: ST_migration_20040513 $  */
function Nav() {
	var r = '/property/';
	this.dir = ['no','/reservations/',r+'specialoffers/',r+'rooms/',r+'areaguide/',r+'hotelinfo/',r+'sportsrelax/',r+'meetingsevents/',r+'careers/'];
	//------------------------------
	var sib = 'childNodes';
  var prt = 'parentNode';
  var clr = 'backgroundColor';
	this.highlight = '';
  this.active = function() {
    var p,i,c;
    p = (request && request.getParameter) ? request.getParameter('navH') : false;
		if(p) { p = p.replace(/[^0-9]/gi,''); return p; }
		for(i=0,c=0; i<this.dir.length; i++) { if(this.dir[i]) { if(this.dir[i]!='no' && window.location.pathname.indexOf(this.dir[i]) == 0) { return c; } c++; } }
	  return -1;
  }
  this.setup = function(hlt, cet) {
    var p,a,c,l,i,ii,t,o,act;
		this.highlight = hlt;
		p = document.getElementById('navItems');
		a = p.getElementsByTagName('div');
		p.active = null;
		act = this.active();
    for(i=0,t=121; i<a.length; i++) {
      o = a[i];
			ii = o.id.substr(4)
			if(ii == act) {
        o.active = true;
        o[sib][0].style[clr] = this.highlight;
      }
			if(!cet) {
		  	c = document.getElementById('navM'+ii);
	  		if(c) {
  				l = c.getElementsByTagName('a');
				  c.navP = o;
        	o.navC = c;
        	c.active = null;
		  		c.style.top = (i > (a.length/2)) ? t-(18*(l.length-1)) : t;
      	  c.style.height = 18*(l.length+1);
    	    c.style.zIndex = i+25;
	        c.onmouseout = this.eventHandler;	
		  	}
        o.onmouseover = this.eventHandler;
        o.onmouseout = this.eventHandler;
			  t += (i==0) ? 31 : 24
			}
    }
  }
	this.eventHandler = function(evt) {
    var c,e,t,src,tgt,cls;
    cls = 'className';
    c = function(o) {
      for(var i=0; i<5; i++) {
        if(o && o[cls] && o[cls].match(/^nav(T|M|I)$/)) return o;
        if(o && o[prt]) {
          o = o[prt];
        } else {
          return null;
        }
      }
      return null;
    }
    e = (window.Event) ? evt : event;
    t = e.type;
    src = c((window.Event)?e[(t=='mouseover')?'relatedTarget':'currentTarget']:e.fromElement);
    tgt = c((window.Event)?e[(t!='mouseover')?'relatedTarget':'currentTarget']:e.toElement);
    if(t=='mouseover' && tgt && tgt[prt].active!=tgt) {
      if(tgt[cls]=='navT') {
        document.nav.msOverTtl(tgt[prt],tgt);
      } else if(tgt[cls]=='navI') {
        document.nav.msOverItm(tgt[prt][prt],tgt);
      }
    } else if(t=='mouseout') {
      if(src && tgt == null) {
        document.nav.close((src[cls]=='navT')?src[prt]:(src[cls]=='navM')?src.navP[prt]:src[prt][prt].navP[prt]);
      } else if(src && tgt && src[cls]=='navI' && tgt[cls]!='navI') {
        document.nav.msOutItm((tgt[cls]=='navM')?tgt:tgt.navC);
      }
    }
    e.returnValue = false;
  }
  this.close = function(o) {
    var a,c;
    a = o.active;
    if(a) {
      if(a.navC) {
        c = a.navC;
        this.msOutItm(c);
        c.style.visibility = 'hidden';
        c[sib][1].style.visibility = 'hidden';
      }
      if(!a.active) a[sib][0].style[clr] = '';
      o.active = null;
      o.aId = null;
    }
  }
  this.msOverTtl = function(p,o) {
    this.close(p);
    o[sib][0].style[clr] = this.highlight;
    if(o.navC) {
      o.navC[sib][1].style.visibility = 'visible';
      o.navC.style.visibility = 'visible';
    }
    p.active = o;
    p.aId = o.id;
  }
  this.msOverItm = function(p,o) {
    if(p.active) p.active.style[clr] = '#cccccc';
    o.style[clr] = '#ffffff';
    p.active = o;
  }
  this.msOutItm = function(o) {
    if(o.active) o.active.style[clr] = '#cccccc';
    o.active = null;
  }
}
document.nav = new Nav();
