<!-- // Coder: Reginald Armond -->
<!-- // Purpose: To provide Me with a library of commonly used functions -->

var HexDigits="0123456789ABCDEF";
var cDelim="|";
var sCookieName="LOVEYOU";
var g_ShowMenu_Last="";
var g_ShowMenu_Timeout=0;

// set the speed
// larger numbers = slower scroll
var howQuick = 10;

var beIE = document.all?true:false;
var iWhere = 0;


function oRef(sName)
{
  if(sName=="")
	return null;
  var obj=((document.all) ? document.all[sName]:(document.layers) ? document.layers[sName]:eval(sName));  
 return obj;
}

function toggle_div(sDiv)
{

var obj=oRef(sDiv);
if(obj==null)
	{
	return;	
	}

obj.style.display=(obj.style.display=="none") ? "block":"none";
}


function Show_Menu(X,Y,sDivID,bShow)
	{
	var obj=oRef(sDivID);
	if(obj==null)
		return false;
		
	// find position of the calling object
	try
		{
		obj.style.left="" + X;
		obj.style.top="" + Y;
		obj.style.display=(bShow) ? "block":"none";	
		}
	catch(E)
		{
		return false;
		}
		
	return true;
	}

function lm(o,s) // Change background of lmenu type menu
{
o.style.background=(s==0) ? 'url(content/lmnubtn_0.gif)':'url(content/lmnubtn_1.gif)';
}

function bm(o,s) // Change background of basepagemenu type menu
{
o.style.background=(s==0) ? 'url(content/mnubar_btn_0.gif)':'url(content/mnubar_btn_1.gif)';
}

// 20050405 - Vertical scroller stuff
var boxheight=150;        // BACKGROUND BOX HEIGHT IN PIXELS.
var boxwidth=120;         // BACKGROUND BOX WIDTH IN PIXELS.
var boxcolor="#FFF6e9";   // BACKGROUND BOX COLOR.
var speed=50;             // SPEED OF SCROLL IN MILLISECONDS (1 SECOND=1000 MILLISECONDS)..
var pixelstep=2;          // PIXELS "STEPS" PER REPITITION.
var godown=false;         // TOP TO BOTTOM=TRUE , BOTTOM TO TOP=FALSE

var outer,inner,elementheight,ref,refX,refY;
var w3c=(document.getElementById)?true:false;
var ns4=(document.layers)?true:false;
var ie4=(document.all && !w3c)?true:false;
var ie5=(document.all && w3c)?true:false;
var ns6=(w3c && navigator.appName.indexOf("Netscape")>=0)?true:false;

function CreateScrollerDefinition(content,iWidth,iHeight,sBackColor)
{
boxheight=iHeight;        // BACKGROUND BOX HEIGHT IN PIXELS.
boxwidth=iWidth;         // BACKGROUND BOX WIDTH IN PIXELS.
var boxcolor=sBackColor;   // BACKGROUND BOX COLOR.
var txt='';
if(ns4){
txt+='<table cellpadding=0 cellspacing=0 border=0 height='+boxheight+' width='+boxwidth+'><tr><td>';
txt+='<ilayer name="ref" bgcolor="'+boxcolor+'" width='+boxwidth+' height='+boxheight+'></ilayer>';
txt+='</td></tr></table>'
txt+='<layer name="outer" bgcolor="'+boxcolor+'" visibility="hidden" width='+boxwidth+' height='+boxheight+'>';
txt+='<layer  name="inner"  width='+(boxwidth-4)+' height='+(boxheight-4)+' visibility="hidden" left=2 top=2 >'+content+'</layer>';
txt+='</layer>';
}else{
txt+='<div id="ref" style="position:relative; width:'+boxwidth+'; height:'+boxheight+'; background-color:'+boxcolor+';" >';
txt+='<div id="outer" style="position:absolute; width:'+boxwidth+'; height:'+boxheight+'; visibility:hidden; background-color:'+boxcolor+'; overflow:hidden" >';
txt+='<div id="inner"  style="position:absolute; visibility:visible; left:2px; top:2px; width:'+(boxwidth-4)+'; overflow:hidden; cursor:default;">'+content+'</div>';
txt+='</div>';
}
return txt;
}

function getElHeight(el){
if(ns4)return (el.document.height)? el.document.height : el.clip.bottom-el.clip.top;
else if(ie4||ie5)return (el.style.height)? el.style.height : el.clientHeight;
else return (el.style.height)? parseInt(el.style.height):parseInt(el.offsetHeight);
}

function getPageLeft(el){
var x;
if(ns4)return el.pageX;
if(ie4||w3c){
x = 0;
while(el.offsetParent!=null){
x+=el.offsetLeft;
el=el.offsetParent;
}
x+=el.offsetLeft;
return x;
}}

function getPageTop(el){
var y;
if(ns4)return el.pageY;
if(ie4||w3c){
y=0;
while(el.offsetParent!=null){
y+=el.offsetTop;
el=el.offsetParent;
}
y+=el.offsetTop;
return y;
}}

function scrollbox(){
if(ns4){
inner.top+=(godown)? pixelstep: -pixelstep;
if(godown){
if(inner.top>boxheight)inner.top=-elementheight;
}else{
if(inner.top<2-elementheight)inner.top=boxheight+2;
}}else{
inner.style.top=parseInt(inner.style.top)+((godown)? pixelstep: -pixelstep)+'px';
if(godown){
if(parseInt(inner.style.top)>boxheight)inner.style.top=-elementheight+'px';
}else{
if(parseInt(inner.style.top)<2-elementheight)inner.style.top=boxheight+2+'px';
}}}

// window.onresize=function(){
// if(ns4)setTimeout('history.go(0)', 400);
// else{
// outer.style.left=getPageLeft(ref)+'px';
// outer.style.top=getPageTop(ref)+'px';
// }}

function StartVerticalScroller(){
outer=(ns4)?document.layers['outer']:(ie4)?document.all['outer']:document.getElementById('outer');
inner=(ns4)?outer.document.layers['inner']:(ie4)?document.all['inner']:document.getElementById('inner');
ref=(ns4)?document.layers['ref']:(ie4)?document.all['ref']:document.getElementById('ref');
elementheight=getElHeight(inner);
if(ns4){
outer.moveTo(getPageLeft(ref),getPageTop(ref));
outer.clip.width=boxwidth;
outer.clip.height=boxheight;
inner.top=(godown)? -elementheight : boxheight-2;
inner.clip.width=boxwidth-4;
inner.clip.height=elementheight;
outer.visibility="show";
inner.visibility="show";
}else{
outer.style.left=getPageLeft(ref)+'px';
outer.style.top=getPageTop(ref)+'px';
inner.style.top=((godown)? -elementheight : boxheight)+'px';
inner.style.clip='rect(0px, '+(boxwidth-4)+'px, '+(elementheight)+'px, 0px)';
outer.style.visibility="visible";
}
setInterval('scrollbox()',speed);
}


// 20041129 - Functions for new website

var g_Init=0;
var g_cylon_wipe=false;
var oPopWin=window.createPopup();
var g_PreviousPullDownMenu;
var g_PreviousNFO;
var g_MenuExpirationTime;

var g_vm_obj=new Array(128);
// multi level menu stuff
var g_sMenuStack=""; // menu_root;Menu1;...;MenuN
var g_MenuStackExpiration=0;

function MenuClear()
{
// clear all menus after a time out period
   if(g_MenuStackExpiration>TimeInSeconds())
   	{
	setTimeout("MenuClear()",1000);	
        return;
	}
// alert("clearing menu "+g_MenuStackExpiration+" <> "+TimeInSeconds());

    var Menu_Array=g_sMenuStack.split(";");
    var i;
    var obj;
    // hide menus below this one
    for(i=Menu_Array.length;i;i--)
       {
        obj=oRef(Menu_Array[i]);
        if(obj)
           obj.style.top=-1000;
       }
    g_sMenuStack="";     
   
}
function MenuPush(sMenuName,iX,iY,iPushLevel)
{
 // rules:
if(g_sMenuStack=="")
   g_sMenuStack=sMenuName;
 var Menu_Array=g_sMenuStack.split(";");
 if(Menu_Array.length)
    {
    var i;
    var obj;
    // hide menus below this one
    for(i=Menu_Array.length;i>=iPushLevel;i--)
       {
  	 ShowObject(Menu_Array[i],false);
       }
     g_sMenuStack="";
     for(i=0;i<iPushLevel;i++)
        {
        if(g_sMenuStack!="") 
		g_sMenuStack+=";";
        g_sMenuStack+=Menu_Array[i];		
        }
   }
     
     // show menu
     obj=oRef(sMenuName);
     if(obj)
	{
 	SetObjectXY(sMenuName,iX,iY);
	ShowObject(sMenuName,true);
        if(g_sMenuStack!="") 
		g_sMenuStack+=";";
        g_sMenuStack+=sMenuName;
        g_MenuStackExpiration=TimeInSeconds()+25; // 25 second Timeout
        MenuClear();	
	}
}

// Specific to regivision.com 
function TitleDown()
	{
	MoveObjectXY('title_main',screen.availWidth,50,200,50,500,60,1,'',0);
	MoveObjectXY('title_main_shadow',205,-100,205,55,1000,60,1,'',0);
	MoveObjectXY('title_underline',-200,50,206,50,1000,60,1,'',0);
	}
	
function TitleUp()
    {
    MoveObjectPoint('_title_main','title_main',40,50,40,-60,500,45);
    MoveObjectPoint('_title_underline','title_underline',300,45,-200,45,1000,45);
    }
//

function PMO(propname,x0,y0,x1,y1,duration,nframes)
{
// Point Movement Object

var dx=(x1-x0);
var dy=(y1-y0);
var DF=(duration/nframes);


this.pname=propname;
this.x=x0;
this.y=y0;
this.x0=x0;
this.y0=y0;
this.dx=dx;
this.dy=dy;
this.DF=DF; // delay fract
this.update=fn_update;

this.current=0;
this.completed=duration;

this.execute_when_done=""; // execute this upon completion
this.execute_when_done_delay=1000; //default 1 second wait

function fn_update()
  {
  var x;
  var y;
    
  if(this.current<this.completed)
    {
    this.x=this.x0+(this.dx*(this.current/this.completed));
    this.y=this.y0+(this.dy*(this.current/this.completed));    
    x=this.x;
    y=this.y;
    this.current+=DF;
    SetObjectXY(this.pname,x,y);
    }   
// alert("passed");
  }
}

function MoveObjectPoint(sName,sPName,x0,y0,x1,y1,delay,nframes)
{
try
    {
if(g_vm_obj.length>0)
	{
	if(g_vm_obj[sName]!=null)
	   g_vm_obj[sName]=null;
	}
    }
catch(errorObject)
   {
   }
 

g_vm_obj[sName]=new PMO(sPName,x0,y0,x1,y1,delay,nframes);

var id=setTimeout("worker_pm('"+sName+"')",g_vm_obj[sName].DF);
return true;
}

function MoveObjectPoint_Ex(sName,sPName,x0,y0,x1,y1,delay,nframes,sExecute,iExecuteDelay)
{
MoveObjectPoint(sName,sPName,x0,y0,x1,y1,delay,nframes)

g_vm_obj[sName].execute_when_done=sExecute;
g_vm_obj[sName].execute_when_done_delay=iExecuteDelay;

var id=setTimeout("worker_pm('"+sName+"')",g_vm_obj[sName].DF);
return true;
}

function SetObjectXY(sPName,x,y)
{
// alert("x="+x+", y="+y);
eval(sPName+".style.top="+y+";"+sPName+".style.left="+x+";");
}

function MoveObjectXY(sPName,x1,y1,x2,y2,dur,steps,n,sExecute,iExecuteDelay)
{
var nextx=x1+(x2-x1)*(n/steps);
var nexty=y1+(y2-y1)*(n/steps);
var nextn=(n+1);
var ndur=dur/steps;
SetObjectXY(sPName,nextx,nexty);
if(nextn<=steps)
 {
 var id=setTimeout("MoveObjectXY('"+sPName+"',"+x1+","+y1+","+x2+","+y2+","+dur+","+steps+","+nextn+",'"+sExecute+"',"+iExecuteDelay+");",ndur);
 }
else
 {
 if(sExecute!="")
  {
  var id=setTimeout(sExecute,iExecuteDelay);
  }
 }
}

function ShowObject(sPName,b)
{
var vi=(b) ? "visible":"hidden";
eval(sPName+".style.visibility='"+vi+"';");
}

function ShowMenu(sPName,x,y,b)
{
  if(sPName=="_TO")
    {
    if(TimeInSeconds()>g_ShowMenu_Timeout)
	 {
	 ShowObject(g_ShowMenu_Last,false);
         return;
	 }
    else
      {
      var id=setTimeout("ShowMenu('_TO',0,0,false);",2000);
      return;
      }
    }

  if(g_ShowMenu_Last!="")
     ShowObject(g_ShowMenu_Last,false);

  g_ShowMenu_Last="";
  if(b)
    {
    SetObjectXY(sPName,x,y);
    ShowObject(sPName,true);
    g_ShowMenu_Last=sPName;
    var id=setTimeout("ShowMenu('_TO',0,0,false);",2000);
    g_ShowMenu_Timeout=TimeInSeconds()+8;

    }
  else
    {
    ShowObject(sPName,false);
    }
}

function worker_pm(sName)
{
var vm_o=g_vm_obj[sName];
if(!vm_o)
  return;

vm_o.update();
if(vm_o.current<vm_o.completed)
  {  
  var id=setTimeout("worker_pm('"+sName+"')",vm_o.DF);  
  return;
  }
else
  {
   if(vm_o.execute_when_done!="")
        var id=setTimeout(vm_o.execute_when_done,vm_o.execute_when_done_delay);
  }

g_vm_obj[sName]=null;
}

function PDMENU(oMenu,iTopPos)
{
if(g_PreviousPullDownMenu) 
	{
	g_PreviousPullDownMenu.style.top=-1000;
	g_PreviousPullDownMenu=null;
	}	
if(oMenu)
	{
	oMenu.style.top=iTopPos;
	g_PreviousPullDownMenu=oMenu;
	g_MenuExpirationTime=TimeInSeconds()+5; // 5 second Timeout
	}
}

function ShowNFO(sNFO,iTop)
{
if(g_PreviousNFO)
  {
  if(g_PreviousNFO!=sNFO)
    MoveObjectXY(g_PreviousNFO,0,iTop,-(screen.width*2),iTop,500,60,1,'',0);
  }
MoveObjectXY(sNFO,0,screen.height,0,iTop,500,30,1,'',0);
g_PreviousNFO=sNFO;
}

function LogoFlip()
{
var logo_list=new Array("logo","logo2","logo","logo3");
var logo_delay=new Array(1000,1000,30000,1000);
  MoveObjectXY(logo_list[g_Init],0,40,-220,40,250,60,1,'',0);  
  g_Init=(g_Init<(logo_list.length-1)) ? (g_Init+1):0;
  MoveObjectXY(logo_list[g_Init],-220,40,0,40,250,60,1,'',0);  

  var id=setTimeout("LogoFlip()",logo_delay[g_Init]);
}

function Load_RVC_Images()
{
var image_list=new Array("asm_clip.gif","lmnubtn_1.gif","lmnubtn_0.gif","mnu_btn_smtitle.gif","mnubar_btn_0.gif","mnubar_btn_1.gif","pulldown_btn_0.gif",
                         "pulldown_btn_1.gif","rvc_logo2.gif","rvc_logo.gif","seg_ff0000.gif","seg_ffffff.gif","seg_trans.gif",
			 "geek_zone.gif","computer_shadowed.gif","top_banner.gif");
preloadImages(image_list);
}

function preloadImages(the_images_array) {

   for(var loop = 0; loop < the_images_array.length; loop++)
	
   {
 	var an_image = new Image();
	an_image.src = "content/"+the_images_array[loop];
   }
}

var g_DropMenuExpirationTime;
function DropMenu(sName,iTopPos)  // Return other menus to their starting position
{
var menu_list=new Array("service_desk_menu","products_menu","contact_menu");
var i;
var iMenuX,iMenuY;
var obj;

if(sName=="<reset>")
  {
  if(TimeInSeconds()<g_DropMenuExpirationTime)
     { 
     setTimeout("DropMenu('<reset>',125);",5000);
     return;
     }
  }

for(i=0;i<menu_list.length;i++)
  {
  obj=oRef(menu_list[i]);
  if(!obj) continue;
  iMenuX=parseInt(obj.style.left);
  iMenuY=parseInt(obj.style.top);

  if(sName==menu_list[i])
      {
      MoveObjectPoint("_"+menu_list[i],menu_list[i],iMenuX,iTopPos-(obj.clientHeight+25),iMenuX,iTopPos,125,30);  
      g_DropMenuExpirationTime=TimeInSeconds()+10;
      setTimeout("DropMenu('<reset>',125);",5000);
      }
  else
      MoveObjectPoint("_"+menu_list[i],menu_list[i],iMenuX,iMenuY,iMenuX,iTopPos-(obj.clientHeight+25),125,30);
  }
}

function HeartBeat()
{
var iCurrentTime=TimeInSeconds();
var b=0;
var obj;

// Service Menu Timeout
if(g_MenuExpirationTime)
	{
	if(iCurrentTime>g_MenuExpirationTime)
		{
		PDMENU(null,0);
		g_MenuExpirationTime=null;
		}	
	}
   
var id=setTimeout("HeartBeat()",1000); // come back here 
}

function PopWin(oWin,x,y,w,l,oStyle)
{ 
    oPopWin.document.body.innerHTML = oWin.innerHTML; 
    
    oPopWin.show(x,y, w, l,oStyle);
}

function TimeInSeconds()
{
var now=new Date;
var secs=(now.getHours()*3600);
secs+=(now.getMinutes()*60);
secs+=now.getSeconds();
return secs;
}

function HexToDec(sHex)
{
var slen=sHex.length;
var rVal=0;
var dVal=1;
for(i=slen-1;i>=0;i--) 
	{
	dOrd=HexDigits.indexOf(sHex.charAt(i));
	
        rVal+=dOrd * dVal;
        dVal<<=4;        

	}
return rVal;
}

function DecToHex(iVal)
{
var sRevHex="", sHex=0, dOrd=0;

if(!iVal) return "";

while(iVal)
	{
	dOrd=(0xF & iVal); sRevHex+=HexDigits.charAt(dOrd);
	iVal>>=4;	
	}

for(i=sRevHex.length-1;i>-1;i--) sHex+=sRevHex.charAt(i);

if(sHex.charAt(0)=="0") return sHex.substring(1,sHex.length); else return sHex;

}

function cvt_byteval_hex(bvalue)
{
if(bvalue>255) return "FF"
x=bvalue;
h0=Math.floor(x/16); 
x-=(16*h0);
h1=x;
return HexDigits.charAt(h0)+HexDigits.charAt(h1);
}

function cvt_int_bin(num,bits)
{
   var x="";
   var i;

   for(i=0;i<bits;i++) x+=(num>>i & 1) ? "1":"0";
     
   return x;
}

function cvt_bin_int(bits)
{
// bits ( string ) are in reverse order 0 1 2 3 4 ...
var i,t,v=1;
for(i=t=0;i<bits.length;i++,v=(v<<1))
	{
	t+=(bits.charAt(i)=="1") ? v:0; // Sum the bit columns
	}
return t;
}

function cvt_int_hms(i_time,fmt)
{
  var x=i_time;
  var h,m,s,post;
  h=Math.floor(x / 3600); x=(x % 3600);
  m=Math.floor(x / 60); 
  s=(x % 60);  

  m=(m<10) ? "0"+m:""+m;
  s=(s<10) ? "0"+s:""+s; 
  post="";
  // fmt=0
  if(fmt==0)   // 24:59:59 
   	{
		h=(h<10) ? "0"+h:""+h;
	}
	
  if(fmt==1)   // 12:59:59 {A|P}M
   	{
		post=(h>11) ? "P":"A";

		if(h<1) h=12;
                if(h>12) h-=12;

		if(h<10) h=" "+h;

		post+="M"
	}

    return h+":"+m+":"+s+" "+post; 
}

function cvt_hms_int(h,m,s)
{
return h*3600 + m*60 + s;
}


// COOKIE JAR

function getCookieVal (offset) 
   {
   var endstr = document.cookie.indexOf (";", offset);

   if (endstr == -1)      endstr = document.cookie.length;

   return unescape(document.cookie.substring(offset, endstr));
   }

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 "";
   }

function SetCookie (name, value) 

   {
   t=new Date();   
   t.setTime(t.getTime() +  (24 * 60 * 60 * 1000 * 365)); 	

   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires =  t; // (2 < argc) ? argv[2] : null;
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;

	path="/";

   document.cookie = name + "=" + escape (value) +
   	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
     	((path == null) ? "" : ("; path=" + path)) +
     	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");

   }



function LoadSettings(snam,sdef)
{
	X=GetCookie(snam);       
	if(X=="") X=sdef;	
return X;       
}


function SaveSettings(snam,X)
{	
	 var t=new Date();
         vcount=0;
	 lastdate=GETENVSTR(X,"VD");
         
        thisdate=""+(1900+t.getYear())+"."+t.getMonth()+"."+t.getDate();
	if(lastdate!=thisdate)
		{
		VC=GETENVSTR(X,"VC");
		vcount=(VC!="") ? ParseInt(VC):1;
		vcount++;
		VC=""+vcount;
		X=SETENVSTR(X,"VC",VC);
		}
	VD=""+thisdate;
        X=SETENVSTR(X,"VD",thisdate);        
	
        SetCookie (snam,X) ;      
}

// ENV TYPE SETTINGS MANAGEMENT
function GETENVSTR(ENVSTR,SS)
{
 var spos=ENVSTR.indexOf(SS+"=");
 var slen=ENVSTR.length;

if(spos<0) return "";

var ibeg=spos+SS.length+1;
var SR="";
for(i=ibeg;(c=ENVSTR.charAt(i))!=cDelim && i<slen;i++)
	{
	SR+=c;
	}

return SR;
}

function SETENVSTR(ENVSTR,SS,NEWVAL)
{
 var spos=ENVSTR.indexOf(SS+"=");
 var slen=ENVSTR.length;

var ibeg=spos;

if(spos<0) return ENVSTR+SS+"="+NEWVAL+cDelim;

e_left=ENVSTR.substring(0,spos);

var SR="";
for(i=ibeg;(c=ENVSTR.charAt(i))!=cDelim && i<slen;i++,spos++)
	{
	SR+=c;
	}

e_right=ENVSTR.substring(spos,slen);

return e_left+SS+"="+NEWVAL+e_right;
}


function DELENVSTR(ENVSTR,SS)
{
 var spos=ENVSTR.indexOf(SS+"=");
 var slen=ENVSTR.length;

var ibeg=spos;

if(spos<0) return ENVSTR;

e_left=ENVSTR.substring(0,spos);

var SR="";
for(i=ibeg;(c=ENVSTR.charAt(i))!=cDelim && i<slen;i++,spos++)
	{
	SR+=c;
	}

e_right=ENVSTR.substring(spos+1,slen);

return e_left+e_right;
}

// Menu Stuff
var Menu_Data=0;
var Menu_E=0, Menu_N=0;
var Menu_Cols;

function MENU_DEFAULTS(sNAME, sION, sIOFF, sTEXT, sCAPTION, sTIP, sLINK,sDEST, sAON, sAOF, sWIDTH, sHEIGHT, sBGCOLOR, sFGCOLOR,sBORDER,sBEFORE,sAFTER,sMODE,sNMENU,sDFRAME)
{
Menu_sNAME=sNAME;
Menu_sION=sION;
Menu_sIOFF=sIOFF;
Menu_sTEXT=sTEXT;
Menu_sCAPTION=sCAPTION;
Menu_sTIP=sTIP;
Menu_sLINK=sLINK;
Menu_sDEST=sDEST;
Menu_sAON=sAON;
Menu_sAOF=sAOF;
Menu_sWIDTH=sWIDTH;
Menu_sHEIGHT=sHEIGHT;
Menu_sBGCOLOR=sBGCOLOR;
Menu_sFGCOLOR=sFGCOLOR;
Menu_sBORDER=sBORDER;
Menu_sBEFORE=sBEFORE;
Menu_sAFTER=sAFTER;
Menu_sMODE=sMODE;
Menu_sNMENU=sNMENU;
Menu_sDFRAME=sDFRAME;
}


function MENU_BEGIN(iNumberOfColumns)
{



  if(Menu_Data==0) 
	{
	Menu_Data=new Array();
	
	}

  Menu_E=Menu_N=0;	
  MENU_TABLE("0","2","0");
  Menu_Cols=iNumberOfColumns;
}

function MENU_CHANGE_ENTRY(iEntry, sItem, sData)
{

/*
NAME, ION, IOFF, TEXT, CAPTION, TIP, LINK, DEST, AON, AOF, WIDTH, HEIGHT,
BGCOLOR, FGCOLOR, BORDER, BEFORE, AFTER, MODE,SMENU,DFRAME
*/

if(iEntry>Menu_N) return;
var MSTR=""+Menu_Data[iEntry];
MSTR=SETENVSTR(MSTR,sItem,sData);
Menu_Data[iEntry]=MSTR;
}

function MENU_ENTRY(sName,sImage_On, sImage_Off, sText, sCaption, sTip, sLink, sDest, sActions_On ,sActions_Off, sNewMenuSource, sNewMenuFrame)
{
MENU_CHANGE_ENTRY(Menu_E,"NAME",sName);
MENU_CHANGE_ENTRY(Menu_E,"ION",sImage_On);
MENU_CHANGE_ENTRY(Menu_E,"IOFF",sImage_Off);
MENU_CHANGE_ENTRY(Menu_E,"TEXT",sText);
MENU_CHANGE_ENTRY(Menu_E,"CAPTION",sCaption);
MENU_CHANGE_ENTRY(Menu_E,"TIP",sTip);
MENU_CHANGE_ENTRY(Menu_E,"LINK",sLink);
MENU_CHANGE_ENTRY(Menu_E,"DEST",sDest);
MENU_CHANGE_ENTRY(Menu_E,"AON",sActions_On);
MENU_CHANGE_ENTRY(Menu_E,"AOFF",sActions_Off);
MENU_CHANGE_ENTRY(Menu_E,"NMENU",sNewMenuSource);
MENU_CHANGE_ENTRY(Menu_E,"DFRAME",sNewMenuFrame);

Menu_E++;
Menu_N++;
}



function MENU_TABLE(sCellPadding,sCellSpacing, sBorder,sLeftImage,sLIWidth)
{
	Menu_sCellPadding=sCellPadding;
	Menu_sCellSpacing=sCellSpacing;
	Menu_sBorder=sBorder;
        Menu_sLeftImage=sLeftImage;
	Menu_sLIWidth=sLIWidth;
}


function MENU_END()
{
var i,iCol=0;
var q='""',sq="'";

var iTotalHeight=0;
document.write('<TABLE CELLPADDING="'+Menu_sCellPadding+'" CELLSPACING="'+Menu_sCellSpacing+'" BORDER="'+Menu_sBorder+'">');

for(i=0;i<Menu_N;i++)
	{
	MSTR=""+Menu_Data[i];
	sHEIGHT=GETENVSTR(MSTR,"HEIGHT");	if(sHEIGHT=="") sHEIGHT=Menu_sHEIGHT;        
	iTotalHeight+=eval(sHEIGHT);
	}

for(i=0;i<Menu_N;i++)
	{
	MSTR=""+Menu_Data[i];
	sMODE=GETENVSTR(MSTR,"MODE");	if(sMODE=="") sMODE=Menu_sMODE;
	sNAME=GETENVSTR(MSTR,"NAME");	if(sNAME=="") sNAME=Menu_sNAME;
	sION=GETENVSTR(MSTR,"ION");		if(sION=="") sION=Menu_sION;
	sIOFF=GETENVSTR(MSTR,"IOFF");	if(sIOFF=="") sOFF=Menu_sIOFF;
	sTEXT=GETENVSTR(MSTR,"TEXT");	if(sTEXT=="") sTEXT=Menu_sTEXT;
	sCAPTION=GETENVSTR(MSTR,"CAPTION");	if(sCAPTION=="") sCAPTION=Menu_sCAPTION;
	sTIP=GETENVSTR(MSTR,"TIP");	if(sTIP=="") sTIP=Menu_sTIP;
	sLINK=GETENVSTR(MSTR,"LINK");	if(sLINK=="") sLINK=Menu_sLINK;
	sDEST=GETENVSTR(MSTR,"DEST");	if(sDEST=="") sDEST=Menu_sDEST;
	sAON=GETENVSTR(MSTR,"AON");	if(sAON=="") sAON=Menu_sAON;
	sAOF=GETENVSTR(MSTR,"AOF");	if(sAOF=="") sAOF=Menu_sAOF;
	sWIDTH=GETENVSTR(MSTR,"WIDTH");	if(sWIDTH=="") sWIDTH=Menu_sWIDTH;
	sHEIGHT=GETENVSTR(MSTR,"HEIGHT");	if(sHEIGHT=="") sHEIGHT=Menu_sHEIGHT;
	sBGCOLOR=GETENVSTR(MSTR,"BGCOLOR");	if(sBGCOLOR=="") sBGCOLOR=Menu_sBGCOLOR;
	sFGCOLOR=GETENVSTR(MSTR,"FGCOLOR");	if(sFGCOLOR=="") sFGCOLOR=Menu_sFGCOLOR;
	sBORDER=GETENVSTR(MSTR,"BORDER");	if(sBORDER=="") sBORDER=Menu_sBORDER;
	sBEFORE=GETENVSTR(MSTR,"BEFORE");	if(sBEFORE=="") sBEFORE=Menu_sBEFORE;
	sAFTER=GETENVSTR(MSTR,"AFTER");	if(sAFTER=="") sAFTER=Menu_sAFTER;
	sMODE=GETENVSTR(MSTR,"MODE");	if(sMODE=="") sMODE=Menu_sMODE;
	sNMENU=GETENVSTR(MSTR,"NMENU");	if(sNMENU=="") sNMENU=Menu_sNMENU;
	sDFRAME=GETENVSTR(MSTR,"DFRAME");	if(sDFRAME=="") sDFRAME=Menu_sDFRAME;

	if(sDFRAME!="")
		{
		sClick='onClick="parent.frames['+sDFRAME+'].location='+sq+sNMENU+sq+'";';
		}
	else
		{
		sClick='';
		}
        

	if(iCol==0) document.write('<TR>');

	if(i==0 && Menu_sLeftImage!="" && sMODE=="G") document.write('<TD BGCOLOR="'+sBGCOLOR+'" ROWSPAN="'+Menu_N+'"><IMG SRC="'+Menu_sLeftImage+'" WIDTH="'+Menu_sLIWidth+'" HEIGHT="'+iTotalHeight+'"></IMG></TD>');

	document.write('<TD BGCOLOR="'+sBGCOLOR+'">');	

	if(sMODE=="G") 
		{		
		gON='document['+sq+sNAME+sq+'].src='+sq+sION+sq+';'+sAON+';';
		gOFF='document['+sq+sNAME+sq+'].src='+sq+sIOFF+sq+';'+sAOF+';';
		if(sLINK!="") document.write('<A HREF="'+sLINK+'" TARGET="'+sDEST+'" onMouseOver="'+gON+'" onMouseOut="'+gOFF+'" '+sClick+'>');
		document.write('<IMG NAME="'+sNAME+'" SRC="'+sIOFF+'" WIDTH="'+sWIDTH+'" HEIGHT="'+sHEIGHT+'" ALT="'+sTIP+'" BORDER="0"></IMG>');
		}
	else	
		{
		if(sLINK!="") document.write('<A HREF="'+sLINK+'" TARGET="'+sDEST+'" onMouseOver="'+sAON+'" onMouseOut="'+sAOF+'" '+sClick+'>');
		document.write(sTEXT);
		}


	if(sLINK!="") document.write('</A>');
	document.write('</TD>');
        
        iCol++;

        if(iCol>=Menu_Cols || i>=Menu_N) 
		{
		document.write('</TR>');
		iCol=0;
		} 
	}

document.write('</TABLE>')
}

// Disable/assign context menu

function clickIE4()
{
if (event.button==2)
	{
	alert("IE4 Function disabled");
	return false;
	}
}

function clickNS4(e)
{
if (document.layers||document.getElementById&&!document.all)	
	{
	if (e.which==2||e.which==3)
		{
		alert("NS4 Function disabled");
		return false;
		}
	}
}

function AssignContextMenu(sContextMenuCode)
{
if (document.layers)
	{
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS4;
	}
else 
if (document.all&&!document.getElementById)
	{
	document.onmousedown=clickIE4;
	}

document.oncontextmenu=new Function(sContextMenuCode+";return false");
}

function NFO(sDocName)
{
wconfig=window.open(sDocName,
        "HandShake","resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=0,width="+(screen.width/4)+",height="+(screen.height/3)); 
}

// web Monkey stuff


function WM_swapLayerBgcolor() {
  // Make sure the browser supports DHTML.
  if(document.layers || document.all)
    with(WM_swapLayerBgcolor)
      // Loop through all arguments, two at a time.
      for(i = 0; i < (arguments.length - 1); i += 2)
  // Get an object reference and set the 
  // bgcolor according to the DOM.
  if(document.layers) 
    WM_checkIn(arguments[i]).document.bgColor = arguments[i+1];
  else if(document.all)
    WM_checkIn(arguments[i]).backgroundColor = arguments[i+1];
}

function WM_checkIn(id) {

/*
WM_checkIn()
Takes the ID of a positioned HTML element and returns an object reference.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Taylor
Author Email: taylor@wired.com
Author URL: http://www.taylor.org/

Usage: WM_checkIn('id')
*/

  // This function checks for DOM strategy, then 
  // returns an object reference.
  if (document.all) {
    return document.all[id].style;
  } else if(document.layers) {
    return document.layers[id];
  }
}

function createRequestObject() {
  
  FORM_DATA = new Object();
    // The Object ("Array") where our data will be stored.
  
  separator = ',';
    // The token used to separate data from multi-select inputs
  
  query = '' + this.location;
    // Get the current URL so we can parse out the data.
    // Adding a null-string '' forces an implicit type cast
    // from property to string, for NS2 compatibility.
    
  query = query.substring((query.indexOf('?')) + 1);
    // Keep everything after the question mark '?'.
  
  if (query.length < 1) { return false; }  // Perhaps we got some bad data?
  
  keypairs = new Object();
  numKP = 1;
    // Local vars used to store and keep track of name/value pairs
    // as we parse them back into a usable form.
    
  while (query.indexOf('&') > -1) {
    keypairs[numKP] = query.substring(0,query.indexOf('&'));
    query = query.substring((query.indexOf('&')) + 1);
    numKP++;
      // Split the query string at each '&', storing the left-hand side
      // of the split in a new keypairs[] holder, and chopping the query
      // so that it gets the value of the right-hand string.
  }

  keypairs[numKP] = query;
    // Store what's left in the query string as the final keypairs[] data.
  
  for (i in keypairs) {
    keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
      // Left of '=' is name.
    keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
      // Right of '=' is value.
    while (keyValue.indexOf('+') > -1) {
      keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
        // Replace each '+' in data string with a space.
    }
    
    keyValue = unescape(keyValue);
      // Unescape non-alphanumerics
      
    if (FORM_DATA[keyName]) {
      FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
        // Object already exists, it is probably a multi-select input,
        // and we need to generate a separator-delimited string
        // by appending to what we already have stored.
    } else {
      FORM_DATA[keyName] = keyValue;
        // Normal case: name gets value.
    }
  }

  return FORM_DATA;
}

FORM_DATA = createRequestObject();
  // This is the array/object containing the GET data.
  // Retrieve information with 'FORM_DATA [ key ] = value'.

function CreateScrollerDef(iX,iY,iWidth,iHeight,sName,sBackColor)
{
var sD;
sD="<div id='"+sName+"' style='position: absolute; top: "+iY+"px; left: "+iX+"px; width: "+iWidth+"; height: "+iHeight+"; background: "+sBackColor+"; overflow:hidden;'>";
sD+="<div id='"+sName+"_content' style='position: relative; top: "+iHeight+"px; left: 0px;'>";

return sD;
}


function StartScroller(sName,iDuration,sExecuteWhenDone,iExecuteWhenDoneDelay)
{
var obj_box=oRef(sName);
if(!obj_box) return false;
obj=oRef(sName+"_content");
if(!obj) return false;
var b=MoveObjectPoint('_'+sName,sName+'_content',0,parseInt(obj_box.style.height),0,-(obj.offsetHeight+20),iDuration,iDuration/2);
if(b)
  {
  var oo=g_vm_obj["_"+sName];
  oo.execute_when_done=sExecuteWhenDone+";StartScroller('"+sName+"',"+iDuration+",\""+sExecuteWhenDone+"\","+iExecuteWhenDoneDelay+")";
  oo.execute_when_done_delay=iExecuteWhenDoneDelay;
  }

//  setTimeout("StartScroller('"+sName+"',"+iDuration+")",iDuration+2000);
}


function scrollBackGround(){
  if (beIE){
     iWhere = iWhere + 1;
     if (iWhere > 1000000) iWhere = 1;
     document.body.style.backgroundPosition = "0 " + iWhere;
     window.setTimeout("scrollBackGround()",howQuick);
  }
}


function MyCalen()
{
this.header="";
this.footer="";

this.classname_header="cal_header";
this.classname_footer="cal_footer";

this.dow_label=new Array(6);
this.classname_currentdow_label="cal_currentdowlabel";
this.classname_normaldow_label="cal_normaldowlabel";
this.classname_background="cal_background";
this.classname_dow_background="cal_dowbackground";
this.classname_normalday="cal_normalday";
this.classname_otherday="cal_otherday";
this.classname_currentday="cal_currentday";
this.classname_specificday=new Array(32);
this.desctiption=new Array(32);
this.event_text=null;
this.specific_events=null;
this.default_events=null;

	// interface
this.Set_Default_Events=setdefaultevents; // EventName,EventScript -> "","" clear all
this.Set_Specific_Events=setspecificevents; // yy,mm,dd,EventName,EventScript -> yy,mm,dd,"","" clear for that day
this.Get_Specific_Events=getspecificevents; // yy,mm,dd
this.Set_ClassName_NormalDay=setclassnamenormalday; // S
this.Set_ClassName_OtherDay=setclassnameotherday; // S
this.Set_ClassName_CurrentDay=setclassnamecurrentday; // S
this.Set_ClassName_SpecificDay=setclassnamespecificday; // dayno,S
this.Set_ClassName_Background=setclassnamebackground; // S
this.Set_ClassName_DOW_Background=setclassnamedowbackground; // S
this.Set_ClassName_CurrentDOW_Label=setclassnamecurrentdowlabel; // S
this.Set_ClassName_NormalDOW_Label=setclassnamenormaldowlabel; // S
this.Set_Description=setdescription; // S
this.Set_On_MouseOver=setonmouseover; // dayno,S
this.Set_On_Click=setonclick; // dayno,S
this.Set_DOW_Label=setdowlabel; // dayno,S
this.Set_Date=setdate; // yy,mm,dd -> 0,0,0 = current
this.Get_Date_DOW=getdatedow; // dd -> yy,mm,dd must have been previously set using Set_Date
this.Get_Month_Days=getmonthdays; // mm -> call Set_Date first, returns days in month

this.Add_Event_Text=addeventtext; // yy,mm,dd,S -> add event for specific day to show on calendar
this.Get_Event_Text=geteventtext; // yy,mm,dd -> retrieve event text for a specific day
this.Set_Header=setheader; // S
this.set_Footer=setfooter; // S
this.Set_ClassName_Header=setclassnameheader; // S
this.Set_ClassName_Footer=setclassnamefooter; // S


this.ToString=tostring; // output the calendar


this.mm=1;
this.dd=1;
this.yy=2009;

this.dow_label[0]="Sun";
this.dow_label[1]="Mon";
this.dow_label[2]="Tue";
this.dow_label[3]="Wed";
this.dow_label[4]="Thu";
this.dow_label[5]="Fri";
this.dow_label[6]="Sat";

function setdate(yy,mm,dd)
	{
	var now=new Date;
	if(yy==0 && mm==0 && dd==0)
		{		
		now=new Date;
		}
	else
		{		
		now.setFullYear(yy);
		now.setMonth(mm-1);
		now.setDate(dd);
		}
		
	this.yy=now.getFullYear();
	this.mm=now.getMonth()+1;
	this.dd=now.getDate();
	

	}

function setclassnamecurrentdowlabel(S)
	{
	this.classname_currentdow_label=S;
	}
	
function setclassnamenormaldowlabel(S)
	{
	this.classname_normaldow_label=S;
	}

function setdowlabel(dayno,S)
	{
	if(dayno<0 || dayno>6)
		return;
	this.dow_label[dayno]=S;
	}

function setonclick(dayno,S)
	{
	if(dayno<1 || dayno>31)
		return;
	this.on_click[dayno]=S;
	}

function setonmouseover(dayno,S)
	{
	if(dayno<1 || dayno>31)
		return;
	this.on_mouseover[dayno]=S;
	}


function setdescription(dayno,S)
	{
	if(dayno<1 || dayno>31)
		return;
	this.description[dayno]=S;
	}


function setclassnamespecificday(dayno,S)
	{
	if(dayno<1 || dayno>31)
		return;
	this.classname_specificday[dayno]=S;
	}
	
function setclassnameotherday(S)
	{
	this.classname_otherday=S;
	}


function setclassnamenormalday(S)
	{
	this.classname_normalday=S;
	}
	
function setclassnamecurrentday(S)
	{
	this.classname_currentday=S;
	}
	
function setclassnamebackground(S)
	{
	this.classname_background=S;
	}	
	
function setclassnamedowbackground(S)
	{
	this.classname_dow_background=S;
	}		
	
function getdatedow(dd)
	{
	var now=new Date;
	now.setFullYear(this.yy);
	now.setMonth(this.mm-1);
	now.setDate(dd);
	
	return now.getDay();
	}
	
function getmonthdays(mm)
	{
	var IsLeap=((this.yy%4)+(this.yy%100)+(this.yy%400))==0 ? 1:0;
	var days=31;
	if(mm==2)
		days=(IsLeap) ? 29:28;
	else
		{
		if(mm==4 || mm==6 || mm==9 || mm==11)
			days=30;
		}
		
	return days;
	}
	
function addeventtext(yy,mm,dd,S)
	{
	if(!this.event_text)
		this.event_text=new Array();  // years
	var cell_year=this.event_text;
	if(!cell_year[yy])
		cell_year[yy]=new Array(); // year within years
		
	var cell_month=cell_year[yy];
	if(!cell_month[mm])
		cell_month[mm]=new Array(); // month within year within years
		
	var cell_day=cell_month[mm];
	if(!cell_day)
		cell_day=new Array(); // day within month within year within years
	
	if(!cell_day[dd])
		cell_day[dd]=S; // assign
	else
		cell_day[dd]+=S; // append if exists	
	
		
	// this text is subjected to a search/replace operation
	/*
	{{dayno}} = day number
	*/
	}
	
function geteventtext(yy,mm,dd)
	{
	if(!this.event_text)
		return null;

	var cell_year=this.event_text;
	if(!cell_year[yy])
		return null;


	var cell_month=cell_year[yy];
	if(!cell_month[mm])
		return null;


	var cell_day=cell_month[mm];
	if(!cell_day[dd])
		return null;
	
	return cell_day[dd];
	}

function tostring()
	{
	var S;
	var X;
	var iStartDOW=this.Get_Date_DOW(1);
	var iCurrentWeekday=this.Get_Date_DOW(this.dd);
	var iLastDay=this.Get_Month_Days(this.mm);
	var iPM;
	var i;
	var daynum;
	var day_event_text;
	var iRemain=1;
	
	iPM=this.mm-1;
	if(iPM<1) 
		iPM=12;	

		
	iPM=(this.Get_Month_Days(iPM)-iStartDOW)+1;	
	
	S="<div"; // background div
	if(this.classname_background!="")
		S+=' class="'+this.classname_background+'"';
	S+=">";
	
	if(this.header!="")
		{
		if(this.classname_header!="")
		   S+='<div class="'+this.classname_header+'">';
		   
		S+=this.header;
		if(this.classname_header!="")
		   S+='</div>';
		}
	
	S+="<div"; // dow background	
		
	if(this.classname_dow_background!="")
		S+=' class="'+this.classname_dow_background+'"';
		
	S+=">";		
	
	for(i=0;i<7;i++)
		{
		sclass=(i!=(iCurrentWeekday)) ? this.classname_normaldow_label:this.classname_currentdow_label;
			
		S+='<a href="javascript:;" class="'+sclass+'">';
		if(this.dow_label[i])
			S+=this.dow_label[i];
		S+="</a>";
		}		
	
	
	S+="</div><br>"; // dow background div
		
	for(daynum=0,i=0;i<42;i++)
		{
		
		if(i>=iStartDOW && daynum<iLastDay)
			{
			daynum++;
			
			day_event_text=this.Get_Event_Text(this.yy,this.mm,daynum);
			if(!day_event_text)			
				X="" + daynum;
			else
				{
				X=ReplaceAll(day_event_text,"{{dayno}}",""+daynum);
				}
			}
		else
		if(i<iStartDOW)
			{
			X=""+iPM;
			iPM++;
			}
		else
			{
			X=""+iRemain;
			iRemain++;
			}

		
		sclass=(daynum!=this.dd) ? this.classname_normalday:this.classname_currentday;
		if(i<iStartDOW || iRemain>1)
			sclass=this.classname_otherday;
			
		sevents=this.Get_Specific_Events(this.yy,this.mm,daynum); // onevents
		sevents=(this.default_events!=null) ? this.default_events:null;
		
		S+='<a href="javascript:;" class="'+sclass+'"';
		if(sevents!=null)
			S+=sevents;
		
		S+=">";
		S+=X;
		S+="</a>";
		}		
		
	if(this.footer!="")
		{
		if(this.classname_footer!="")
		   S+='<div class="'+this.classname_footer+'">';		   
		S+=this.footer;
		if(this.classname_footer!="")
		   S+='</div>';
		}

	
	S+="</div>"; // background div
	
	return S;
	}
	
	
function setheader(S)
	{
	this.header=S;
	}
function setfooter(S)
	{
	this.footer=S;
	}


function setclassnameheader(S)
	{
	this.classname_header;
	}
	
function setclassnamefooter(S)
	{
	this.classname_footer;
	}
	
function setdefaultevents(EventName,EventScript) // EventName,EventScript -> "","" clear all
	{
	if(EventName=="")
		{
		this.default_events=null;
		return;
		}
	if(this.default_events!=null)
		this.default_events+=" ";
	this.default_events+=EventName;
	this.default_events+="=";
	this.default_events+='"';
	this.default_events+=EventScript;
	this.default_events+='"';	
	}
function setspecificevents(yy,mm,dd,EventName,EventScript) // yy,mm,dd,EventName,EventScript -> yy,mm,dd,"","" clear for that day
	{
		
	var S;
	if(!this.specific_events)
		this.specific_events=new Array();  // years
	var cell_year=this.event_text;
	if(!cell_year[yy])
		cell_year[yy]=new Array(); // year within years
		
	var cell_month=cell_year[yy];
	if(!cell_month[mm])
		cell_month[mm]=new Array(); // month within year within years
		
	var cell_day=cell_month[mm];
	if(!cell_day)
		cell_day=new Array(); // day within month within year within years
		
	if(EventName=="")
		S=null;
	else
		{		
		S+=EventName;
		S+="=";
		S+='"';
		S+=EventScript;
		S+='"';
		}
	
	if(!cell_day[dd])
		cell_day[dd]=S; // assign
	else
		cell_day[dd]+=S; // append if exists	
	}
	
function getspecificevents(yy,mm,dd)
	{
	if(!this.specific_events)
		return null;

	var cell_year=this.specific_events;
	if(!cell_year[yy])
		return null;


	var cell_month=cell_year[yy];
	if(!cell_month[mm])
		return null;


	var cell_day=cell_month[mm];
	if(!cell_day[dd])
		return null;
	
	return cell_day[dd];
	}

}

// NEW COOKIE STUFF

function CookieJar(sName)
	{
	this.name_cookiejar=sName;
	this.separator_item=";";
	this.separator_keyvalue="=";
	this.cookie_values=null;
	
	// interface
	this.Load=loadvalues; // load values from name_cookiejar
	this.Save=savevalues; // save values from name_cookiejar
	this.Value=getkeyvalue; // sKey
	this.Set=setkeyvalue;   // sKey, sValue	
	
	// Basic functions
	
	this.SetCookie=basicsetcookie; // sName,sValue
	this.GetCookie=basicgetcookie; // sName
	this.getCookieVal=basicgetcookieval; // offset
	
	
	function basicgetcookieval (offset) 
   {
   var endstr = document.cookie.indexOf (";", offset);

   if (endstr == -1)      endstr = document.cookie.length;

   return unescape(document.cookie.substring(offset, endstr));
   }

function basicgetcookie (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 this.getCookieVal (j);

      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0)       break; 
      }

   return "";
   }

function basicsetcookie (name, value) 

   {
   t=new Date();   
   t.setTime(t.getTime() +  (24 * 60 * 60 * 1000 * 365)); 	

   var argv = basicsetcookie.arguments;
   var argc = basicsetcookie.arguments.length;
   var expires =  t; // (2 < argc) ? argv[2] : null;
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;

	path="/";

   document.cookie = name + "=" + escape (value) +
   	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
     	((path == null) ? "" : ("; path=" + path)) +
     	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");

   }

	
	
	function loadvalues()
		{
		var sCookie=this.GetCookie(this.name_cookiejar);
		if(sCookie=="")
			return;
		if(this.cookie_values==null)
			this.cookie_values=new Array();
			
		var aKV=sCookie.split(this.separator_item);
		var i;
		var kv;
		for(i=0;i<aKV.length;i++)
			{
			kv=aKV[i].split(this.separator_keyvalue);
			this.cookie_values[kv[0]]=kv[1];
			}		
		}
		
	function savevalues()
		{
		if(this.cookie_values==null)
		 	return;
		var i;
		var sCookie="";
		for(i in this.cookie_values)
			{
			if(sCookie!="")
				sCookie+=this.separator_item;
			sCookie+=i;
			sCookie+=this.separator_keyvalue;
			sCookie+=this.cookie_values[i];
			}
		this.SetCookie(this.name_cookiejar,sCookie);
		}
		
	function getkeyvalue(sKey)
		{
		var sValue;
		if(this.cookie_values==null)
			return "";
		return (this.cookie_values[sKey]!=null) ? this.cookie_values[sKey]:"";
		}
		
	function setkeyvalue(sKey, sValue)
		{
		if(this.cookie_values==null)
			this.cookie_values=new Array();
		
		this.cookie_values[sKey]=sValue;
		return true;
		}
	}
	
	
	// Div_Tree
function Div_Tree(sObjectName) // (or Simple menu manager)
	{
	this.m_tree=null;	 // div Family Tree
	this.m_index=null; // Main div index for fast searches
	this.m_name=sObjectName; // object's instantiation name ( for timer callback )
	this.m_timeout=0; // Div Touch Timeout Time
	this.m_hTimeout=0;
	// Interface
	this.AddPath=fn_addpath; // S -> Path of Div Ientifiers
	this.HideChildren=fn_hidechildren; // sDivID,iDepth
	this.ShowChildren=fn_showchildren; // sDivID,iDepth,bFlowRight
	this.ShowDiv=fn_showdiv; // X,Y,sDivID,bShow	
	this.Touch=fn_touch; // sets/resets the hide all divs timer
	this.UnTouch=fn_untouch; // sets/resets the hide all divs timer
	this.HideAll=fn_hideall;
	this.SetTimeout=fn_settimeout; // MS
	this.bHideAll_Enabled=true;
	
	// implementation
	
	function fn_settimeout(MS)
		{
		this.m_timeout=MS;
		}
	
	function fn_untouch()
		{
		this.bHideAll_Enabled=true;
		}
	
	function fn_touch()
		{
		if(this.m_hTimeout!=0)
			{
			clearTimeout(this.m_hTimeout);
			this.m_hTimeout=0;
			}
		if(this.m_timeout>0)
			this.m_hTimeout=setTimeout(this.m_name+".HideAll()",this.m_timeout);
		this.bHideAll_Enabled=false;
		}
	
	function fn_hideall()
		{
		var idx;
		if(this.bHideAll_Enabled==false)
			{
			if(this.m_hTimeout!=0)
				{
				clearTimeout(this.m_hTimeout);
				this.m_hTimeout=0;
				}
			if(this.m_timeout>0)
				this.m_hTimeout=setTimeout(this.m_name+".HideAll()",this.m_timeout);
			return;
			}
	
		for(idx in this.m_index)
			{
			try
				{
				obj=ObjectRef(idx);
				if(obj!=null)
					obj.style.display="none";
				}
			catch(E)
				{
				}
			}	
		}
	
	function fn_addpath(S)
		{
		if(this.m_index==null)
			this.m_index=new Array();
		if(this.m_tree==null)
			{
			this.m_tree=new Array();
			this.m_tree["name"]="root";
			this.m_tree["parent"]=null;
			}
			
		var aPath=S.split("/");
		var i;
		var pX=this.m_tree;
		var pNode;
		var pPrev=null;
		
		var pParent=pX;
		
		for(i=0;i<aPath.length;i++)
			{
			if(pX[aPath[i]]==null) // add new branch
				{
				pX[aPath[i]]=new Array();				
				pNode=pX[aPath[i]];
				this.m_index[aPath[i]]=pNode; // Index to node				
				pNode["parent"]=pParent; // Node Parent
				pNode["name"]=aPath[i]; // Node Name
				pNode["next"]=new Array();				
				}
			else
				{
				pNode=pX[aPath[i]];
				}
			pParent=pNode;
			pX=pNode["next"]; // Descend
			}
			
		return true;		
		}
		
	function fn_set_child_visibility(sDiv,iDepth,bVisible)
		{
		if(iDepth==0)
			return 0;
		var pX=this.m_index[sDiv];
		if(pX==null)
			return 0;
		var iCount=iDepth;
		var obj;
		var i;
		while(pX!=null)
			{
			obj=ObjectRef(pX["name"]);
			if(obj!=null)
				{
				try
					{
					obj.style.display=(bVisible) ? "block":"none";
					}
				catch(e)
					{
					}
				}
			this.fn_set_child_visibility(i,iCount,bVisible);
			pX=pX["next"];
			}
		iCount-=(iCount) ? 1:0;				
		return iCount;
		}
		
	function fn_hidechildren(sDiv,iDepth)
		{
		return this.fn_set_child_visibility(sDiv,iDepth,false);
		}
		
	function fn_showchildren(sDiv,iDepth)
		{
		return this.fn_set_child_visibility(sDiv,iDepth,true);
		}
		
	function fn_showdiv(X,Y,sDivID,bShow)
	{
	var obj=ObjectRef(sDivID);
	if(obj==null)
		return false;		
	// find position of the calling object
	try
		{
		obj.style.left="" + X;
		obj.style.top="" + Y;
		obj.style.display=(bShow) ? "block":"none";	
		}
	catch(E)
		{
		return false;
		}
		
	// Find the path back to the parent
	var sPath;
	var pX=this.m_index[sDivID];
	if(pX==null)
		return false;		

	var sPath="";
	var i=0;
	
	// build path to the root
	while(pX!=null)
		{
		if(sPath!="")
			sPath+="/";			
		sPath+=pX["name"]; //		
		pX=pX["parent"];
		i++;
		}
		
	// Show Only this path, hide everything else
	var idx;
	
	for(idx in this.m_index)
		{
		try
			{
			obj=ObjectRef(idx);
			if(obj!=null)
				obj.style.display=(sPath.indexOf(idx)>-1) ? "block":"none";		
			}
		catch(E)
			{
			}
		}	
		
	this.Touch();	// Set Hide All Timeout
	return true;
	}

	}

// Div_Tree