var op=navigator.userAgent.indexOf('Opera')!=-1;
var mo=navigator.userAgent.indexOf('Mozilla')!=-1;
var ie=navigator.userAgent.indexOf('IE')!=-1;
var op7=navigator.userAgent.indexOf('Opera 7')!=-1;
var op8=navigator.userAgent.indexOf('Opera 8')!=-1;
  
var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);

function getRef(id) {
   if (isDOM) return document.getElementById(id);
   if (isIE4) return document.all[id];
   if (isNS4) return document.layers[id];
}

function getSty(id) { return (isNS4 ? getRef(id) : getRef(id).style);}
function resizeOp(){if(op){d=getSty('blk_frame'); d.width=128; return 1;}}

var pOn=0;
var m0=0;
var i0=0;
var i1=0;
var m0s=0;
var i0s=0;
var i1s=0;
var init=0;
var menuTimer=0;
var arSize=3;       /* This is the actual count of items in the menu array */
var menuAr = new Array(arSize);
menuAr[0] = new Array(2);
menuAr[0][0] = 0; menuAr[0][1] = 'linksp';
menuAr[1] = new Array(2);
menuAr[1][0] = 0; menuAr[1][1] = 'ideasp'; 
menuAr[2] = new Array(2);
menuAr[2][0] = 0; menuAr[2][1] = 'prev_ideas'; 

function isLit(a,i){return a[i][0];}

function divSrch(divID){for (i=0; i<arSize; i++){if (menuAr[i][1]==divID) return i;} return -1;}
function hideDv(divID){
  if (pOn==0) return 0;
  else pOn=0;
  if ((a=divSrch(divID))!=arSize){
    menuAr[a][0]=0;  
    s=getSty(divID);  
    s.visibility="hidden";
    return 1;
  }
  else return a;
}
function hideAll(){
  for (i=0; i<arSize; i++){
    if (isLit(menuAr,i)){
      s=getSty(menuAr[i][1]);
      s.visibility="hidden";
      menuAr[i][0]=0;
    }
  }
  return pOn=0;
}
function popDv(divID){
  clearTimeout(menuTimer);
  if (pOn==1) return 0;
  else (pOn=1);  
  s=getSty(divID);
  s.visibility="visible";
  return 1;
}
function popDv0(divID,tp,lft){
  hideAll();
  if (pOn==1) return 0;
  else (pOn=1);
  var dn=divSrch(divID);
  if (dn==arSize) return dn;
  else {
    menuAr[dn][0]=1;
    s=getSty(divID);
    s.top=tp;
    s.left=lft;
    s.visibility="visible";
    menuTimer=setTimeout("hideAll()", 3000);
    return 1;
  }
}
function popD(divID){
  s=getSty(divID);
  s.visibility="visible";
  return 1;
}
function hideD(divID){
  s=getSty(divID); 
  s.visibility="hidden";
  return 1;
}
function colorI(d,c){s=getSty(d); return s.background=c;} 
function chgBars(i){
	return document.getElementById("dialogue").scrolling=i;
}
/* The following code requires that the first element in each subarray indicates the element's status:
		1 = active element, uses the "current" image and does not change colors
		2 = mouseover (ON image).
		3 = mouseoff (OFF image). 
The image ordering in the array reflects this numbering.*/
var CURRENT=1;
var ON=2;
var OFF=3;
var imgArray = new Array(5);
var arrayInit = 0;
var arrayActive=0; // This indicates which array element is active or "current". The default is 0 for the welcome page.
function initArray(s1,s2){
	for (var i=0;i<s1;i++){imgArray[i]=new Array(s2);}
	imgArray[0][0]=CURRENT;
	imgArray[0][1]="img/welcome-current.jpg";
	imgArray[0][2]="img/welcome-on.jpg";
	imgArray[0][3]="img/welcome-off.jpg";
	imgArray[0][4]=document.welcome;
	imgArray[0][5]="welcome.html";
	imgArray[1][0]=OFF;
	imgArray[1][1]="img/contact-current.jpg";
	imgArray[1][2]="img/contact-on.jpg";
	imgArray[1][3]="img/contact-off.jpg";	
	imgArray[1][4]=document.contact;
	imgArray[1][5]="contactT1.html";
	imgArray[2][0]=OFF;
	imgArray[2][1]="img/search-current.jpg";
	imgArray[2][2]="img/search-on.jpg";
	imgArray[2][3]="img/search-off.jpg";
	imgArray[2][4]=document.ideas;
	imgArray[2][5]="ni/newideasT1.html";
	imgArray[3][0]=OFF;
	imgArray[3][1]="img/specials-current.jpg";
	imgArray[3][2]="img/specials-on.jpg";
	imgArray[3][3]="img/specials-off.jpg";
	imgArray[3][4]=document.specs;
	imgArray[3][5]="specialsT1.html";		
	imgArray[4][0]=OFF;
	imgArray[4][1]="img/org-current.jpg";
	imgArray[4][2]="img/org-on.jpg";
	imgArray[4][3]="img/org-off.jpg";
	imgArray[4][4]=document.org;
	imgArray[4][5]=""; 
	return arrayInit=1;
}
function menuToggle1(ofst){
	if (!arrayInit) arrayInit=initArray(imgArray,5,6);
	if (ofst==arrayActive) return 0;     // ignore it if it's "active"
	im=imgArray[ofst][4];								 //	assign the structure name to a variable
	var n = (imgArray[ofst][0]==ON?OFF:ON);
	im.src=imgArray[ofst][n];						 // assign the correct image to the structure
	return imgArray[ofst][0]=n;					 // save the state, ON or OFF
}
function clickHandler1(ofst){
	if (ofst==arrayActive) return 0;     // ignore it if it's CURRENT
	rf=imgArray[arrayActive][4];         // grab old object's identifier	
	imgArray[arrayActive][0]=OFF;        // set the old object to "off"
	rf.src=imgArray[arrayActive][OFF];   // then change the old object's image to "off"
	im=imgArray[ofst][4];								 //	assign the structure name to a variable
	im.src=imgArray[ofst][CURRENT];	     // change the clicked object's image to the CURRENT one.
	imgArray[ofst][0]=CURRENT;           // set the new object to CURRENT	
	return arrayActive=ofst;             // finally, set the "active" variable to the current object's offset
} 
