//var menuXvalues = new Array(73,136,190,273,340,395,667)

var menuXvalues = new Array(73,136,190,273,340,412,667)

var Categories = new Array("ra","events","cs","dt","ag","help")
var Circles = new Array()

for (i=0;i<Categories.length;i++){
	abbrev = Categories[i]
	Categories[i] = new Object
	Categories[i].abbrev = abbrev
}

var trans = new Image(); trans.src = "images/trans_pixel.gif"

var MENU_ON = true, MENU_OFF = false
var content = null
var header = self
var Headers = new Array()

var Delay = new Object
Delay.menu = null
Delay.period = new Array()
Delay.display = null

function showMenu(category,state){
	if (readyState!="complete") return
	Delay.menu = category-1
	Delay.display = state
	if(state){
		if (Delay.period[Delay.menu]) clearDelay(Delay.menu)
		//document.images["circle"+(Delay.menu+1)].src = Circles[Delay.menu].on.src
		showItems(Delay.menu)
	} else {
		setDelay(Delay.menu)
	}
}

function showItem(m,n,state){
	Delay.display = state
	if (state){
		clearDelay(m)
		Menus[m].items[n].on.show()
	} else {
		Menus[m].items[n].on.hide()
		setDelay(m)
	}
}

function showItems(n){
	Menus[n].obj.show()
	for (i=0;i<Menus[n].items.length;i++){
		Menus[n].items[i].off.show()
		Menus[n].items[i].cover.show()
	}
}

function hideItems(n){
	Menus[n].obj.hide()
	for (i=0;i<Menus[n].items.length;i++){
		Menus[n].items[i].on.hide()
		Menus[n].items[i].off.hide()
		Menus[n].items[i].cover.hide()
	}
}

function setDelay(t){
	Delay.period[t] = setTimeout('hideItems('+t+');//document.images["circle'+(t+1)+'"].src = Circles['+t+'].off.src;',10) //"Categories["+Delay.menu+"].on.hide();Menus["+Delay.menu+"].obj.hide()",10) 
}

function clearDelay(t){
	clearTimeout(Delay.period[t])
	Delay.period[t] = 0
}

var Menus = new Array()
var ITEM_ON = 1, ITEM_OFF = 0

function Menu(name,w,bg,bd,tc,htc){
	this.index = Menus.length
	this.id = "menu"+(this.index+1)
	this.name = name
	this.width = w
	this.left = menuXvalues[this.index]
	this.bgColor = bg
	this.borderColor = bd
	this.textColor = tc
	this.highlightTextColor = htc
	this.addItem = mnu_addItem
	this.create = mnu_create
	this.init = mnu_init
	this.items = new Array()
	Menus[this.index] = this
}

function mnu_addItem(text,href,newWin){
	this.items[this.items.length] = new Array(text,href,newWin)
}

function mnu_create(){
	menuTop = 100
	itemHeight = 17
	this.height = this.items.length*(itemHeight+1)+1
	menuStyle = 'position:absolute; top:'+menuTop+'px; '
	menuStyle += 'left:' + this.left + 'px; '
	menuStyle += 'width:' + this.width + 'px; '
	menuStyle += 'height:' + this.height + 'px; '
	menuStyle += 'clip:rect(0px,' + this.width + 'px,'+ this.height +'px,0px); '
	menuStyle += 'background-color:' + this.borderColor + '; layer-background-color:' + this.borderColor + '; z-index:1000; visibility:hidden; '
	strMenu = '<div id="'+this.id+'" style="'+menuStyle+'"></div>\n'
	for(n=0;n<this.items.length;n++){
		itemWidth = this.width-2
		itemStyle = 'position:absolute; top:'+(n*18+1+menuTop)+'px; left:'+(menuXvalues[this.index]+1)+'px; height:' + itemHeight + 'px; width:' + itemWidth + 'px; clip:rect(0px,' + itemWidth + 'px,'+ itemHeight +'px,0px); z-index:1001; visibility:hidden; '
		coverStyle = 'position:absolute; top:'+(n*18+menuTop)+'px; left:'+(menuXvalues[this.index])+'px; height:' + (itemHeight+1) + 'px; width:' + (itemWidth+2) + 'px; clip:rect(0px,' + (itemWidth+2) + 'px,'+ (itemHeight+1) +'px,0px); z-index:1002; visibility:hidden; '
		
		if (this.items[n][2] == "1") {
			clickTo = 'openNewAdmin(\''+this.items[n][1]+'\')'
			linkTo = '#';
		} else if (this.items[n][2] == "2") {
			clickTo = 'window.open(\''+this.items[n][1]+'\')'
			linkTo = '#';
		} else {
			clickTo = (bw.ns4)?'':'gotoLink(\''+this.items[n][1]+'\')'
			linkTo = this.items[n][1]
		}
		
		itemEvents = (bw.ns4)?'"><a href="'+linkTo+'" onclick="'+clickTo+'" onmouseover="showItem('+this.index+','+n+',ITEM_ON)" onmouseout="showItem('+this.index+','+n+',ITEM_OFF)"><img src="images/trans_pixel.gif" width="'+(this.width-1)+'" height="'+(itemHeight+1)+'" border="0" alt=""></a>':'" onclick="'+clickTo+'" onmouseover="showItem('+this.index+','+n+',ITEM_ON)" onmouseout="showItem('+this.index+','+n+',ITEM_OFF)" class="cover"><img src="images/trans_pixel.gif" width="'+(this.width-1)+'" height="'+itemHeight+'" border="" alt="">'
				
		m = n+1
		strMenu += '<div id="'+this.id+m+'off" style="'+itemStyle+'color:'+this.textColor+'; background-color:' + this.bgColor + '; layer-background-color:' + this.bgColor + '"><span class="content">&nbsp;'+this.items[n][0]+'</span></div>\n'
		strMenu += '<div id="'+this.id+m+'on" style="'+itemStyle+'color:'+this.highlightTextColor+'; background-color:#ffffff; layer-background-color:#ffffff; visibility:hidden;"><span class="content">&nbsp;'+this.items[n][0]+'</span></div>\n'
		strMenu += '<div id="'+this.id+m+'cover" style="'+coverStyle+itemEvents+'</div>\n'
	}
	return strMenu
}

function mnu_init(){
	this.obj = new objLayer(this.id)
	for(n=0;n<this.items.length;n++){
		this.items[n].on = new objLayer(this.id+(n+1)+'on')
		this.items[n].off = new objLayer(this.id+(n+1)+'off')
		this.items[n].cover = new objLayer(this.id+(n+1)+'cover')
	}
}


function gotoLink(href){
	location.href = href
}



function getBrowserHeight() {
   if (bw.ns4){
      return window.innerHeight
   } else {
      return document.body.clientHeight
   }
}


var strzCode = new String("z").charCodeAt(0);
var strZCode = new String("Z").charCodeAt(0);
var straCode = new String("a").charCodeAt(0);
var strACode = new String("A").charCodeAt(0);


function isAlpha(str) {
   alpha = true
   for (a=0; a<str.length; a++) {
      charStr = str.charAt(a)
      charCode = charStr.charCodeAt(0)
      if (charStr == " "
            || (charCode >= straCode && charCode <= strzCode)
            || (charCode >= strACode && charCode <= strZCode)) {
         // do nothing
      } else {
         alpha = false;
      }
   }
   return alpha
}


function isAlphaNumeric(str) {
   for(i=0; i<str.length; i++){
      if (!isAlpha(str.charAt(i)) && !isNumeric(str.charAt(i))) {
         return false;
      }
   }
   return true;
}


function isBlank(s) {
   if ((s == ' ') || (s == '\n') || (s == '\t')) {
      return true;
   } else {
      return false;
   }
}


function isNumeric(str) {
   for (a=0; a<str.length; a++){
      charStr = str.charAt(a)
      if (isNaN(parseInt(charStr))) return false
   }
   return true
}


function isValidDate(strDate) {
   intYear = parseInt(strDate.substring(0,4))
   intMonth = parseInt(strDate.substring(4,6))
   intDay = parseInt(strDate.substring(6,8))
   month_length = new Array(31,29,31,30,31,30,31,31,30,31,30,31)
   if (intMonth == 2 && intDay > 28 && (intYear%4 > 0) ) {
      return false;
   }
   if (intDay > month_length[intMonth-1]) {
      return false;
   }
   return true;
}


function isValidEMail(str) {
   email = str ;
   var indDot = email.lastIndexOf(".");
   var indAt = email.indexOf("@");
   var semi = email.indexOf(";");
   var space = email.indexOf(" ");
   var tick = email.indexOf("`");
   var quote = email.indexOf("\"");
   if ((indDot <= 0)
         || (semi > 0)
         || (space > 0)
         || (tick > 0)
         || (quote > 0)
         || (indAt <= 0)
         || ((indDot - indAt) <= 1)
         || (indDot == (email.length - 1))) {
      return false;
   } else {
      return true;
   }
}


function isValidPassword(str) {
   alpha_count = 0
   numeric_count = 0
   for(i=0; i<str.length; i++) {
      if (isAlpha(str.charAt(i))) {
         alpha_count++;
      }
      if (isNumeric(str.charAt(i))) {
         numeric_count++;
      }
   }
   if (alpha_count && numeric_count && isAlphaNumeric(str)) {
      return true;
   } else {
      return false;
   }
}


function openAdmin(href) {
    window.open(href,'_blank','height=550,width=563,scrollbars=yes');
}


function openAdminFooter(href) {
   newWin = window.open(href,'_blank','height=550,width=563,scrollbars=yes');
   storeNewWin(newWin);
   return false;
}

function openBio(href) {
   window.open(href,'_blank','height=550,width=580,scrollbars=yes,resizeable=no');
   return false;
}


function openBlankWindow(href) {
   window.open(href,'','height=450,width=750,toolbar=yes,location=yes,scrollbars=yes,resizeable=yes');
   return false;
}


function openDocFromDoc(href) {
   window.open(href,'_blank','height=550,width=680,scrollbars=yes,menubar=yes,resizable=yes');
}


function openHelp(href) {
   openNewAdmin(href);
   return false
}


function openNewAdmin(href) {

/*
   if (document.URL.substr(0,5)!="https" && top && top.footer) {
      top.footer.storeNewWin(
         window.open(href,'_blank','height=520,width=632,scrollbars=yes'));

   } else if (document.URL.substr(0,5) != "https"
         && opener
         && opener.top
         && opener.top.footer) {
      opener.top.footer.storeNewWin(
         window.open(href,'_blank','height=520,width=632,scrollbars=yes'));

   } else if (document.URL.substr(0,5)!="https"
         && opener
         && opener.opener
         && opener.opener.top
         && opener.opener.top.footer) {
      opener.opener.top.footer.storeNewWin(
         window.open(href,'_blank','height=520,width=632,scrollbars=yes'));

   } else if (document.URL.substr(0,5)!="https"
         && opener
         && opener.opener
         && opener.opener.opener
         && opener.opener.opener.top
         && opener.opener.opener.top.footer) {
      opener.opener.opener.top.footer.storeNewWin(
         window.open(href,'_blank','height=520,width=632,scrollbars=yes'));

   } else {
      window.open(href,'_blank','height=520,width=632,scrollbars=yes');
   }
*/
   if (document.URL.substr(0,5)!="https" && storeNewWin) {
      storeNewWin(window.open(href,'_blank','height=520,width=632,scrollbars=yes'));
   } else {
      window.open(href,'_blank','height=520,width=632,scrollbars=yes');
   }
}


function openNewAdminFooter(href) {
   newWin = window.open(href,'_blank','height=550,width=620,scrollbars=yes,status=yes');
   storeNewWin(newWin);
   return false;
}


function openNewRegWinFromSearchWin(href) {
   window.open(href,'_blank','height=520,width=632,scrollbars=yes');
}

function openRegistration(href) {
   window.open(href,'','height=550,width=675,scrollbars=yes');
   return false;
}

function openResult(href) {
   window.open(href,'_blank',
      'height=550,width=680,scrollbars=yes,menubar=yes');
}


function openSearch(href) {
   self.name = "mainwin";
   newWin = window.open(href,'_blank','width=750,height=500,scrollbars=yes,resizable=yes');
   //if (top && top.footer) {
      storeNewWin(newWin);
   //}
   return false;
}


function openSigninPopup(href) {

   var iMyLeft;
   var iMyTop;
   var sWinStr;
   //gets top and left positions based on user's resolution so hint window is centered.
   iMyLeft = (window.screen.width/2) - (140 + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
   iMyTop = (window.screen.height/2) - (135 + 27); //half the screen height minus half the new window height (plus title and status bars).
   sWinStr="left=" + iMyLeft + ",top=" + iMyTop + ",screenX=" + iMyLeft + ",screenY=" + iMyTop;
   self.name = "mainwin"+ Math.round(Math.random()*(1000));
   
   signinPopup = window.open(href+'&parentWindow='+self.name,'LoginPopup', sWinStr + ',height=275,width=280,scrollbars=no,menubar=no');

   var killPopup = setTimeout("signinPopup.close()", 180000);
}


function openTechSup(href) {
   window.open(href,'','height=550,width=625,scrollbars=yes');
   return false;
}


function openHelpWindow(href) {
   window.open(href,'_blank','height=310,width=450,scrollbars=no');
   return false;
}

function openWindow(href) {
   window.open(href,'','height=550,width=563,scrollbars=yes');
   return false;
}


function rollover(layRef,imgRef,srcRef) {
   var srcObj = eval(srcRef)
   if (bw.ns4){
      if ((layRef==null)||(layRef=='')){
         document[imgRef].src = srcObj;
      } else {
         document.layers[layRef].document.images[imgRef].src = srcObj;
      }
   } else {
      document[imgRef].src = srcObj;
   }
}


function toAlphaNumber(checkString) {
   newString = "";
   count = 0;
   for (i = 0; i < checkString.length; i++) {
      ch = checkString.substring(i, i+1);
      if ((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z") ||
      (ch >= "0" && ch <= "9")) {
      newString += ch;
      }
   }
   if (checkString != newString) {
      if (confirm("The value you have entered\n"
            + "contains invalid characters,\n"
            + "please correct them and resubmit.")) {
         return false;
      } else {
         return true;
      }
   }
   return true;
}

function storeNewWin( newWin ) {
   winCTR = winCTR + 1 ;
   if (winCTR > 40) {
      alert ("No more windows allowed");
      return false;
   } else  {
    childWindow[winCTR] = newWin ;
   }
}

function signout(){
   for ( i = 1; i < winCTR + 1 ; i++) {
      if(childWindow[i] != null){
         childWindow[i].close();
      }
   }
   return true;
}

function closeLogin(){


/**
   if (signinPopup != null)
   {
      signinPopup.close();
   }
*/
}

// MOUSEEVENTS ------------------------------------------------

function initMouseEvents() {
	document.onmousedown = mouseDown
	document.onmousemove = mouseMove
	document.onmouseup = mouseUp
	document.onselectstart = selectStart
	if (bw.ns4) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
}

function cancelMouseEvents() {
	if (bw.ns4) document.releaseEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
}

function mouseDown(e) {
	if ((bw.ns4 && e.which!=1) || (bw.ie5 && event.button!=1)) return true
	var x = (bw.ns4)? e.pageX : event.x+document.body.scrollLeft
	var y = (bw.ns4)? e.pageY : event.y+document.body.scrollTop
	return objMouseDown(x,y)
}

function mouseMove(e) {
	var x = (bw.ns4)? e.pageX : event.x+document.body.scrollLeft
	var y = (bw.ns4)? e.pageY : event.y+document.body.scrollTop
	return objMouseMove(x,y)
}

function mouseUp(e) {
	var x = (bw.ns4)? e.pageX : event.x+document.body.scrollLeft
	var y = (bw.ns4)? e.pageY : event.y+document.body.scrollTop
	return objMouseUp(x,y)
}

function selectStart(e){
	objElement = window.event.srcElement
	if (objElement.name && objElement.name.indexOf("txt")!=-1)
		return true
	else
		return false
}
// DRAG ---------------------------------------

function objDrag(){
	this.Layers = new Array()
	this.buffer = new Array()
	this.obj = null
	this.dragActive = false
	this.offsetX = 0
	this.offsetY = 0
	this.add = obj_dragAdd
	this.dragMouseDown = obj_dragMouseDown
	this.dragMouseMove = obj_dragMouseMove
	this.dragMouseUp = obj_dragMouseUp
	this.setFirstLayer = obj_setFirstLayer
}

function obj_dragAdd() {
	for (var i=0; i<arguments.length; i++) {
		this.Layers[this.Layers.length] = arguments[i]
		this.zIndex = i+1
	}
}

function obj_dragMouseDown(x,y){
	if (scrolling) return false
	/* loop through this.Layers to see if the mouse was clicked on a layer */
	for (i=0;i<this.Layers.length;i++){
		var div = this.Layers[i]
		if (checkWithinLayer(x,y,div)) {
			this.obj = this.Layers[i]
			this.offsetX = x-this.obj.x
			this.offsetY = y-this.obj.y
			
			if (!this.obj.dragParent) {currentWindow = this.obj.windowIndex} else if (this.obj.dragParentIndex) {currentWindow = this.obj.dragParentIndex-1}
			
			zIndex++
			if (!this.Layers[i].dragParent && this.Layers[i].windowIndex<100){
				this.obj.css.zIndex = zIndex
			} else if (this.Layers[i].dragParent){
				this.obj.dragParent.css.zIndex = zIndex
			}
			
			this.dragActive = true
			if (!this.obj.dragParent && this.obj.windowIndex==101 && bw.ns4) this.obj.dragChild.hide()
			
			this.setFirstLayer(i)
			break
		}
	}
	if (this.dragActive){
		return true
	}
	else return false
}

function obj_setFirstLayer(m){
	for (n=0;n<this.Layers.length;n++){
		this.buffer[n] = this.Layers[n]
	}
	
	firstLayer = this.Layers[m]
	do {
		this.buffer[m] = this.buffer[m-1]
		m--
	} while (m-1>=0)
	
	this.buffer[0] = firstLayer
	
	for (n=0;n<this.Layers.length;n++){
		this.Layers[n] = this.buffer[n]
	}
}
		

function obj_dragMouseMove(x,y){
	if (this.dragActive) {
		if (this.obj.dragParentIndex) {
			if (y>(this.obj.dragParent.y+75)){
				this.obj.moveTo(this.obj.x,y-this.offsetY)
				windows[VER][this.obj.dragParentIndex-1][3] = this.obj.y+18
				windows[VER][currentWindow][3] = this.obj.y+18
				sizeWindow(this.obj.dragParentIndex-1)
			}
		} else {
			if ((x>0)&&(x<getBrowserWidth()-2)&&(y>windowCeiling+this.offsetY)&&(y<getBrowserHeight()-(16-this.offsetY))){
				this.obj.moveTo(x-this.offsetX,y-this.offsetY)
			} else {
				this.dragMouseUp(x,y)
			}
		}
		return false
	}
	else return true
}

function obj_dragMouseUp(x,y){
	if (this.dragActive&&!this.obj.dragParent&&currentWindow<=windows[VER].length) {
		windows[VER][currentWindow][0] = x-this.offsetX
		windows[VER][currentWindow][1] = y-this.offsetY
		windows[VER][currentWindow].objContent.scrollActive = 0
	}
	writeCookies(currentWindow)
	if (this.dragActive){
		if (this.obj&&this.obj.dragChild) {this.obj.dragChild.globalX=this.obj.x; this.obj.dragChild.globalY=this.obj.y}
		if (!this.obj.dragParent && this.obj.windowIndex==101 && bw.ns4) this.obj.dragChild.show()
	}
	this.dragActive = false
	return true
}

var drag = new objDrag()

function checkWithin(x,y,left,right,top,bottom) {
	if (x>=left && x<right && y>=top && y<bottom) return true
	else return false
}
function checkWithinLayer(x,y,div) {
	if (checkWithin(x,y,div.x+div.globalX+div.grabRegion[3],div.x+div.globalX+div.grabRegion[1],div.y+div.globalY+div.grabRegion[0],div.y+div.globalY+div.grabRegion[2])) {return true}
	else return false
}

function getBrowserHeight(){
	if (bw.ns4){
		return window.innerHeight
	} else {
		return document.body.clientHeight
	}
}

function getBrowserWidth(){
	if (bw.ns4){
		return window.innerWidth
	} else {
		return document.body.clientWidth
	}
}

// COOKIE -------------------------------------------------------

// The constructor function: creates a cookie object for the specified
// document, with a specified name and optional attributes.
// Arguments:
//   document: The Document object that the cookie is stored for. Required.
//   name:     A string that specifies a name for the cookie. Required.
//   hours:    An optional number that specifies the number of hours from now
//             that the cookie should expire.
//   path:     An optional string that specifies the cookie path attribute.
//   domain:   An optional string that specifies the cookie domain attribute.
//   secure:   An optional Boolean value that, if true, requests a secure cookie.
//
function Cookie(document, name, hours, path, domain, secure){
    // All the predefined properties of this object begin with '$'
    // to distinguish them from other properties which are the values to
    // be stored in the cookie.
    this.$document = document;
    this.$name = name;
    if (hours)
        this.$expiration = new Date((new Date()).getTime() + hours*3600000);
    else this.$expiration = null;
    if (path) this.$path = path; else this.$path = null;
    if (domain) this.$domain = domain; else this.$domain = null;
    if (secure) this.$secure = true; else this.$secure = false;
}

// This function is the store() method of the Cookie object.
function _Cookie_store(){
    // First, loop through the properties of the Cookie object and
    // put together the value of the cookie. Since cookies use the
    // equals sign and semicolons as separators, we'll use colons
    // and ampersands for the individual state variables we store 
    // within a single cookie value. Note that we escape the value
    // of each state variable, in case it contains punctuation or other
    // illegal characters.
    var cookieval = "";
    for(var prop in this) {
        // Ignore properties with names that begin with '$' and also methods.
        if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')) 
            continue;
        if (cookieval != "") cookieval += '&';
        cookieval += prop + ':' + escape(this[prop]);
    }
	
    // Now that we have the value of the cookie, put together the 
    // complete cookie string, which includes the name and the various
    // attributes specified when the Cookie object was created.
    var cookie = this.$name + '=' + cookieval;
    if (this.$expiration)
        cookie += '; expires=' + this.$expiration.toGMTString();
    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    if (this.$secure) cookie += '; secure';

    // Now store the cookie by setting the magic Document.cookie property.
    this.$document.cookie = cookie;
}
// This function is the load() method of the Cookie object.
function _Cookie_load(){
    // First, get a list of all cookies that pertain to this document.
    // We do this by reading the magic Document.cookie property.
    var allcookies = this.$document.cookie;
    if (allcookies == "") return false;

    // Now extract just the named cookie from that list.
    var start = allcookies.indexOf(this.$name + '=');
    if (start == -1) return false;   // Cookie not defined for this page.
    start += this.$name.length + 1;  // Skip name and equals sign.
    var end = allcookies.indexOf(';', start);
    if (end == -1) end = allcookies.length;
    var cookieval = allcookies.substring(start, end);
	
    // Now that we've extracted the value of the named cookie, we've
    // got to break that value down into individual state variable 
    // names and values. The name/value pairs are separated from each
    // other by ampersands, and the individual names and values are
    // separated from each other by colons. We use the split method
    // to parse everything.
    var a = cookieval.split('&');    // Break it into array of name/value pairs.
    for(var i=0; i < a.length; i++)  // Break each pair into an array.
        a[i] = a[i].split(':');

    // Now that we've parsed the cookie value, set all the names and values
    // of the state variables in this Cookie object. Note that we unescape()
    // the property value, because we called escape() when we stored it.
    for(var i = 0; i < a.length; i++) {
        this[a[i][0]] = unescape(a[i][1]);
    }
	
    return true;
}

// This function is the remove() method of the Cookie object.
function _Cookie_remove(){
    var cookie;
    cookie = this.$name + '=';
    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';

    this.$document.cookie = cookie;
}

// Create a dummy Cookie object, so we can use the prototype object to make
// the functions above into methods.
new Cookie();
Cookie.prototype.store = _Cookie_store;
Cookie.prototype.load = _Cookie_load;
Cookie.prototype.remove = _Cookie_remove;

// LEYERAPI -------------------------------------

function checkBrowser(){
	this.win=(navigator.platform=="Win32")?1:0;
	this.mac=(navigator.platform=="MacPPC")?1:0;
	this.ver=navigator.appVersion;
	this.dom=document.getElementById?1:0;						/* The getElementById method is applicable to 5th generation browsers only. */
	this.ie5=(this.ver.indexOf("MSIE 5")!=-1 && this.dom)?1:0; 	/* Will handle both ie5 and ie5.5 */
	this.ie4=(document.all && !this.dom)?1:0;					/* Specifically ie4 */
	this.ns6=(this.dom && parseInt(this.ver)>=5)?1:0;			/* Netscape 6 (Mozilla) */
	this.ns4=(document.layers && !this.dom)?1:0;				
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5);		/* Only IE or Navigator */
	
	if (this.ns4) {
		lastWidth = window.innerWidth;
		lastHeight = window.innerHeight;
		window.onresize = handleResize;
	}
	return this
}

var bw = new checkBrowser();

function handleResize(){
	winWidth = window.innerWidth;
	winHeight = window.innerHeight
	if ((lastWidth != winWidth) || (lastHeight != winHeight)){
		lastWidth = winWidth;
		lastHeight = winHeight;
		location.reload();
	}
}

function objLayer(id,nest){
	nest=(!nest)?'':'document.'+nest+'.'
	
	/* object pointer */ 
	this.obj=bw.dom?document.getElementById(id):bw.ie4?document.all[id]:bw.ns4?eval(nest+'document.'+id):0	
	
	/* style reference */
	
	this.css=bw.dom?document.getElementById(id).style:bw.ie4?document.all[id].style:bw.ns4?eval(nest+'document.'+id):0
		
	if (bw.ie4 || bw.ie5 || bw.ns6) {this.x=this.css.pixelLeft; this.y=this.css.pixelTop; this.h=this.obj.clientHeight; this.w=this.obj.clientWidth}   
	if (bw.ns4) {this.x=this.css.left; this.y=this.css.top; this.h=this.obj.document.height; this.w=this.obj.document.width} 
		
	this.defaultTop = this.y	
	this.defaultBottom = this.y + this.h
	
	this.globalX = 0
	this.globalY = 0
	
	return this;
}

function obj_moveTo(x,y){
	this.x=x
	this.y=y
	this.css.left=this.x
	this.css.top=this.y
}

function obj_moveBy(x,y){
	this.x+=x
	this.y+=y
	this.css.left=this.x
	this.css.top=this.y
}

function obj_setZIndex(z){
	this.css.zIndex = z
}

function obj_clipValues(which){
	if (bw.ns4){
		if (which=="t") return this.css.clip.top
		if (which=="r") return this.css.clip.right
		if (which=="b") return this.css.clip.bottom
		if (which=="l") return this.css.clip.left
	} else {
		var clipv = this.css.clip.split("rect(")[1].split(")")[0].split("px")
		if (which=="t") return Number(clipv[0])
		if (which=="r") return Number(clipv[1])
		if (which=="b") return Number(clipv[2])
		if (which=="l") return Number(clipv[3])
	}
}

function obj_clipTo(t,r,b,l){
	if(bw.ns4){
		this.css.clip.top = t
		this.css.clip.right = r
		this.css.clip.bottom = b
		this.css.clip.left = l
	} else {
		this.css.clip="rect("+t+","+r+","+b+","+l+")"
	}
}

function obj_clipBy(t,r,b,l){
	this.clipTo(this.clipValues('t')+t,this.clipValues('r')+r,this.clipValues('b')+b,this.clipValues('l')+l)
}

function obj_hide(){
	this.css.visibility=(bw.ns4)?'hide':'hidden'
}

function obj_show(){
	this.css.visibility=(bw.ns4)?'show':'visible'
}

function obj_vis(){if(this.css.visibility=="hidden" || this.css.visibility=="hide") return true;}

function obj_writeIt(txt){
	if (bw.ns4){
		this.obj.document.write(txt)
		this.obj.document.close()
	} else {
		this.obj.innerHTML = txt
	}
}

function obj_swapImage(imgName,imgSrc){
	if (bw.ns4){
		this.obj.document.images[imgName].src = imgSrc
	} else {
		document[imgName].src = imgSrc
	}
}

objLayer.prototype.moveTo=obj_moveTo
objLayer.prototype.moveBy=obj_moveBy
objLayer.prototype.clipValues=obj_clipValues
objLayer.prototype.clipTo=obj_clipTo
objLayer.prototype.clipBy=obj_clipBy
objLayer.prototype.hide=obj_hide
objLayer.prototype.show=obj_show
objLayer.prototype.vis=obj_vis
objLayer.prototype.writeIt=obj_writeIt
objLayer.prototype.setZIndex = obj_setZIndex
objLayer.prototype.swapImage = obj_swapImage

// ADD1 ------------------------------------------------------

		var readyState = null
		var content = self
		var footer = parent.footer		
		var UNREC=0, REC=1 
		var EVENTS=0, GARTNER_SUGGESTS=1, FOCUS_AREAS=2, NEWS_INFO=3, YOUR_RESEARCH=4
		var sessionID = null
		var textFocus = 0;
							
		function pageInit(){
			
			for (i=0;i<Menus.length;i++){
				Menus[i].init()
			}
			readyState = "complete"
		}
			

		function keydown(e){
			if (bw.ns4 || bw.ns6) {
				intKey=e.which;
			} else {
				intKey=event.keyCode;
			}
			if (intKey==13){
				switch (textFocus){
					case 0: submitSearch(); break;
					case 1: submitSignin(); break;
					case 2: submitEmail(); break;
					case 3: break;
				}
			}
		}	
		
		var objSearchForm = document.frmSearch
		var mystrng ;		
		function validSearch(){
			var objSearchForm = document.frmSearch
			if (objSearchForm.txtSearch.value.length==0) {alert("Please enter a search phrase.");return false} 
			else 
			if(isBlank(objSearchForm.txtSearch.value)){
				alert("Please enter a search phrase");
				return false
			}
			return true
		}
		
		function submitSearch(){
			var objSearchForm = document.frmSearch
			if (validSearch()) {
				mystrng = objSearchForm.txtSearch.value ;
				mystrng = mystrng.replace(/\%/g,"%25");
				mystrng = mystrng.replace(/\&/g,"%26");
				mystrng = mystrng.replace(/\+/g,"%2B");	
				mystrng = mystrng.replace(/ /g,"+");	
				openSearch('/7_search/Search2Frame.jsp?&keywords='+ mystrng) 
			}
			
		}
		
		

		function advancedSearch() {
			
			alert("Advanced Search is only available to registered users.");
			
		}	

		function browse() {
			
				alert("Browse is only available to registered users.");
			
		}

		 if (bw.ns4) {
      			origWidth = innerWidth;
      			origHeight = innerHeight;;
   		}

		function reDo() {
   			if (innerWidth != origWidth || innerHeight != origHeight) {
      				location.reload();
   			}
		}

		if (bw.ns4) onresize = reDo;		

// NAVIGATION -----------------------------------------------------------

var subLinks = new Array()
var topLinks = new Array()
var relLinks = new Array()
var level2Links = new Array()
var pageOffset = 0
var scrollOffset = 0

function topLink(tTopic,tHref,tLevel,tHigh){
	this.topic = tTopic
	this.href = tHref
	this.level = tLevel
	this.high = tHigh
	topLinks[topLinks.length] = this
}

function subLink($topic,$href,$level,$high,$onclick){
	this.topic = $topic
	this.href = $href
	this.level = $level
	this.high = $high
	this.onclick = $onclick
	subLinks[subLinks.length] = this
}

function subLink2($topic,$href,$level,$high){
	this.topic = $topic
	this.href = $href
	this.level = $level
	this.high = $high
	subLinks[subLinks.length] = this
}

function sublinkParent(sTitle, sName){
	this.title = sTitle
	this.name = sName
	level2Links[level2Links.length] = new Array()
	level2Links[level2Links.length - 1][0] = this
}

function sublinkChild(sTitle, sParent, sHref, iLevel, iGraphic){
	this.title = sTitle
	this.parent = sParent
	this.href = sHref
	this.level = iLevel
	this.graphic = iGraphic
	for (i=0;i<level2Links.length;i++){
		if (sParent==level2Links[i][0].name){ 
			level2Links[i][level2Links[i].length] = this
		}
	}
}

function relLink($topic,$href){
}

function buildSubNav(){
	
	var sNav= ''
	
	if (subLinks.length){
		sNav = '<table border="0" cellspacing="0" cellpadding="0" width="185">\n'
		sNav += '<tr>\n\t<td class="borderCell" rowspan="100"><img src="/images/trans_pixel.gif" height="1" width="1" alt="" border="0"></td>\n'
		sNav += '\t<td class="borderCell"><img src="/images/trans_pixel.gif" height="1" width="183" alt="" border="0"></td>\n'
		sNav += '\t<td class="borderCell" rowspan="100"><img src="/images/trans_pixel.gif" height="1" width="1" alt="" border="0"></td>\n</tr>\n'

		for (i=0; i<subLinks.length; i++){
			if (subLinks[i].onclick){strOnclick = 'onclick="'+subLinks[i].onclick+'" '} else {strOnclick=''}
			if (subLinks[i].high){
				sNav += '<tr>\n\t<td class="highlightCell"><img src="/images/transparent.gif" width="6" height="16" align="left" alt="" border="0"><span class="rightNavHighText">'+subLinks[i].topic+'</span></td>\n</tr>\n'
			}
			else{
				if ( (category == 6) & (subLinks[i].topic == 'Download Help Documentation') ){
					sNav += '<tr>\n\t<td class="contentCell"><img src="/images/transparent.gif" width="6" height="25" align="left" alt="" border="0"><a href="'+subLinks[i].href+'" '+strOnclick+'class="rightNavText">'+subLinks[i].topic+' (Adobe PDF)</a></td>\n</tr>\n'
				}
				else {
					sNav += '<tr>\n\t<td class="contentCell"><img src="/images/transparent.gif" width="6" height="16" align="left" alt="" border="0"><a href="'+subLinks[i].href+'" '+strOnclick+'class="rightNavText">'+subLinks[i].topic+'</a></td>\n</tr>\n'
				}
			}
			
			sNav += '<tr>\n\t<td class="borderCell" height="1"><img src="/images/trans_pixel.gif" height="1" width="1" alt="" border="0"></td>\n</tr>\n'
		}

		sNav+= '</table>'
	}
	else{
		if (level2Links.length)	{
			sNav = '<table border="0" cellspacing="0" cellpadding="0" width="185">\n'
			sNav += '<tr>\n\t<td class="borderCell" rowspan="100"><img src="/images/trans_pixel.gif" height="1" width="1" alt="" border="0"></td>\n'
			sNav += '\t<td class="borderCell"><img src="/images/trans_pixel.gif" height="1" width="183" alt="" border="0"></td>\n'
			sNav += '\t<td class="borderCell" rowspan="100"><img src="/images/trans_pixel.gif" height="1" width="1" alt="" border="0"></td>\n</tr>\n'
	
			for ( i = 0; i < level2Links.length; i++ )	{
				if (level2Links[i].onclick){strOnclick = 'onclick="'+Level2Links[i].onclick+'" '} else {strOnclick=''}
				sNav += '<tr>\n\t<td class="highlightCell"><img src="/images/transparent.gif" width="6" height="16" align="left" alt="" border="0"><span class="rightNavText">'+level2Links[ i ][ 0 ].title+'</span></td>\n</tr>\n'
				sNav += '<tr>\n\t<td class="borderCell" height="1"><img src="/images/trans_pixel.gif" height="1" width="1" alt="" border="0"></td>\n</tr>\n'
				
				for ( j = 1; j < level2Links[ i ].length; j++ )	{
					sNav += '<tr>\n\t<td class="contentCell"><img src="/images/transparent.gif" width="6" height="16" align="left" alt="" border="0"><a href="'+level2Links[ i ][ j ].href+'" '+strOnclick+'class="rightNavText">'+level2Links[ i ][ j ].title+'</a></td>\n</tr>\n'
					sNav += '<tr>\n\t<td class="borderCell" height="1"><img src="/images/trans_pixel.gif" height="1" width="1" alt="" border="0"></td>\n</tr>\n'
				}
			}
			sNav += '</table>'
		}	
	}		
	return sNav
}


function buildTopNav(){  // buildTopNav function

	var tNav = ''

	if (topLinks.length){

		var tArea = ''
		var tLink = ''

		switch(category) {
			case 1:
				tArea = 'Research';
				tLink = '/1_researchanalysis/research_overview.html'
			break;
			case 2:
				tArea = 'Community';
				tLink = '/2_events/community/community_overview.html'
			break;
			case 3:
				tArea = 'Consulting';
				tLink = '/3_consulting_services/consulting_overview.html'
			break;		
			case 4:
				tArea = 'Measurement';
				tLink = '/4_decision_tools/measurement/measurement_overview.html'
			break;		
			case 5:
				tArea = 'About Gartner';
				tLink = '/5_about/company_information/41a.html'
			break;
			case 6:
				tArea = 'Help';
				tLink = '/6_help/help_overview.html'
			break;
			case 7:
			break;	
			case 8:
				tArea = 'News';
				tLink = '/5_about/news/news_overview.html'
			break;
		} //end switch
			
		tNav += '\t\t<table border="0" cellspacing="0" cellpadding="0">\n'
		tNav += '\t\t\t<tr>\n'
		tNav += '\t\t\t\t<td height="20"><img src="/images/trans_pixel.gif" width="20" height="1" alt="" border="0"></td>\n'
			
		if (category != 7){	
			tNav += '\t\t\t\t<td valign="middle" class="crumbBold"> <a class="topNavText" href="'+tLink+'">'+tArea+'</a> </td>\n'
			for (i = 0; i < topLinks.length; i++){
				tNav += '\t\t\t\t<td valign="middle">&nbsp;&nbsp;<img src="/images/breadcrumbs_arrow_071201.gif" width="16" height="17" alt="" border="0">&nbsp;&nbsp;</td>'
				
				if (topLinks[i].high){
					tNav += '<td valign="middle" class="crumbNorm">'+topLinks[i].topic+'</td>'
				}
				else{
					tNav += '<td valign="middle" class="crumbNorm"> <a class="topNavText" href="'+topLinks[i].href+'">'+topLinks[i].topic+'</a> </td>'
				}
			} // end for	
		} //end if 
		else {
			tNav += '<td valign="middle" class="crumbBold">'+topLinks[0].topic+'</td>'
			for (i = 1; i < topLinks.length; i++){
				tNav += '\t\t\t\t<td valign="middle">&nbsp;&nbsp;<img src="/images/breadcrumbs_arrow_071201.gif" width="16" height="17" alt="" border="0">&nbsp;&nbsp;</td>'
				if (topLinks[i].high){
					tNav += '<td valign="middle" class="crumbNorm">'+topLinks[i].topic+'</td>'
				}
				else{
					tNav += '<td valign="middle" class="crumbNorm"> <a class="topNavText" href="'+topLinks[i].href+'">'+topLinks[i].topic+'</a> </td>'
				}
					
			} // end for
		
		}
		tNav += '\t\t\t</tr>\n'
		tNav += '\t\t</table>\n'
	} //end if

	return tNav
	
} // end buildTopNav	
