function writeMenu( data, class_name) { o = eval( class_name+"=new Menu( '"+class_name+"');"); o.menuDef = data["items"]; var _Menu_PreloadImages = new Array(); i = 0; for ( i2 in data["preload"]) { _Menu_PreloadImages[i] = new Image(); _Menu_PreloadImages[i++].src = data["preload"][i2]; } o.e_gif = data["e_gif"]; o.printMenu(); } function Menu_setStatus( p, v){this.menu_items = this.menu_items.substr( 0, p) + v + this.menu_items.substr( p-(-1));this.setCookie( this.name+"menu_items", this.menu_items);} function Menu_getStatus( p){ return this.menu_items.substr( p, 1);} function Menu_setCookie(name, value){var curCookie = name + "=" + escape(value);document.cookie = curCookie} function Menu_getCookie(name){var prefix = name + "=";var cookieStartIndex = document.cookie.indexOf(prefix);if (cookieStartIndex == -1) return null;var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length;return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));} function Menu_changeColor( color, k){c = this.getRGB( color);c[0] = c[0]*k;c[1] = c[1]*k;c[2] = c[2]*k;return this.makeRGB( c);}; function Menu_toHex( val, max){ val=Math.ceil( val); if ( max ) val = ( val > max)?max:val;res="";while( val > 0 ){ch = val%16;val = val>>>4;res = (( ch > 9 )?String.fromCharCode( ch+55):ch) + res;}return res;}; function Menu_makeRGB( color){res="";res = "#"+this.toHex( color[0], 255);res += this.toHex( color[1], 255);return res+this.toHex( color[2], 255);}; function Menu_getRGB( color){r = parseInt( color.substr( 1,2), 16);g = parseInt( color.substr( 3,2), 16);b = parseInt( color.substr( 5,2), 16);return new Array( r, g, b);}; function Menu_strReplace(t, r, s){value = "";pos0 = 0;pos1 = 0;if ( s.length > 0 ){while( 1 ){ pos1 = s.indexOf(t, pos0);if ( pos1 < 0 ) break;value += s.substring( pos0, pos1) + r;pos0 = pos1 + t.length;}value += s.substring( pos0, s.length);}return value;} function Menu_showHide( o, type) { isEI = (document.all && navigator.userAgent.indexOf("Opera")==-1)?1:0; if ( o.style.display == "none" ) { if ( isEI ) { o.style.display = "inline"; } else { if ( type == "tr" ) o.style.display = "table-row"; else if ( type == "td" ) o.style.display = "table-cell"; } } else { o.style.display = "none"; } } function Menu_overOut( o, type, class_name) { id = o.id.substr( 0, o.id.lastIndexOf( "_")); for( i=1;i<6;i++) { if ( document.getElementById( id+"_"+i) ) document.getElementById( id+"_"+i).className = class_name; } } function Menu_mouseClick( o, num) { id = o.id.substr( 0, o.id.lastIndexOf( "_")); index = parseInt( o.id.substr( o.id.indexOf( "_")-(-1))); if ( num == 1 && this.menuDef[index]["action"] != "" ) { level = this.menuDef[index]["level"]; if ( level == 0 ) { close_index = 0; while( 1 ) { cur=this.menuDef[close_index]; if ( !cur ) break; if ( this.getStatus( close_index) == 1 && cur["level"] != 0 ) this.close( close_index); else if ( cur["level"] == 0 ) { try{ document.images[this.name+"_"+close_index+"_button"].src = this.menuDef[close_index]["but_icon_close"]; } catch ( e) {} } close_index++; } } index_top = index; while( 1 ) { index++; cur=this.menuDef[index]; if ( !cur || cur["level"] == level ) break; this.open( index); } eval( this.menuDef[index_top]["action"] ); } else num = 2; if ( num == 2 && this.menuDef[index-(-1)] && (this.menuDef[index-(-1)]["level"] == this.menuDef[index]["level"]-(-1)) ) { but = document.images[id.substr( 0, id.lastIndexOf( "_"))+"_button"]; opn = (this.getStatus( index-(-1))==1)?true:false; if ( opn ) but.src = this.menuDef[index]["but_icon_close"]; else but.src = this.menuDef[index]["but_icon_open"]; level = this.menuDef[index]["level"]; index++; t = 1; close_index = 0; while( 1 ) { cur=this.menuDef[close_index]; if ( !cur ) break; if ( this.getStatus( close_index) == 1 && cur["level"] != 0 ) { this.timeoutIds[close_index] = setTimeout( this.name+".close( '"+close_index+"');", this.timeout*t); t++; } else if ( cur["level"] == 0 ) { try{ document.images[this.name+"_"+close_index+"_button"].src = this.menuDef[close_index]["but_icon_close"]; } catch ( e) {} } close_index++; } t = 1; while( 1 ) { cur=this.menuDef[index]; if ( !cur || cur["level"] == level ) break; clearTimeout( this.timeoutIds[index]); if ( cur["level"] != level-(-1) && !opn ) { index++; continue;}; if ( opn ) if ( this.getStatus( index) == 1 ) this.timeoutIds[index] = setTimeout( this.name+".close( '"+index+"');", this.timeout*t); else t--; else if ( this.getStatus( index) == 0 ) this.timeoutIds[index] = setTimeout( this.name+".open( '"+index+"');", this.timeout*t); else t--; index++; t++; } } } function Menu_open( id) { if ( this.getStatus( id) == 1 ) return; this.showHide( document.getElementById( this.name+"_"+id+"_main"), "tr"); this.setStatus( id, "1"); } function Menu_close( id) { if ( this.getStatus( id) == 0 ) return; img = this.name+"_"+id+"_button"; but = document.images[img]; if ( but )but.src = this.menuDef[id]["but_icon_close"]; this.showHide( document.getElementById( this.name+"_"+id+"_main"), "tr"); this.setStatus( id, "0"); } function Menu_printMenu() { var mDef = this.menuDef; //this.setCookie( this.name+"menu_items", "") this.menu_items = this.getCookie( this.name+"menu_items"); for ( var i in mDef) this.menuDefLen++; if ( !this.menu_items || ( this.menu_items.length != this.menuDefLen ) ) { this.menu_items = ""; for ( i in mDef) this.menu_items += (mDef[i]['level']==0)?'1':'0'; } this.setCookie( this.name+"menu_items", this.menu_items); var mouse_move = "onMouseOver=\"$$name$$.overOut( this, 'over', '$$class_over$$');\" onMouseOut=\"$$name$$.overOut( this, 'out', '$$class$$');\""; var menu = ""; for( var i in mDef) { var cur = mDef[i]; if ( typeof( cur["is_open"]) != "undefined" ) { var i2 = 0; while( typeof( mDef[i2]) != "undefined" ) { if ( mDef[i2]["level"] > cur["level"] ) { this.setStatus( i2, 0); } i2++; } i2 = i-(-1); while( typeof( mDef[i2]) != "undefined" && mDef[i2]["level"] > cur["level"] ) { this.setStatus( i2, 1); i2++; } } if ( mDef[i-(-1)] ) var next = mDef[i-(-1)]; else next = 0; var dark_color = this.changeColor( cur["bgcolor"], 0.5); var light_color = this.changeColor( cur["bgcolor"], 1.2); var opn = ( mDef[i-(-1)] && (mDef[i-(-1)]["level"] == mDef[i]["level"]-(-1)) && this.getStatus( i-(-1))==1)?true:false; if ( cur["level"] == 0 ) { tr = this.menuTr; if ( next && cur["level"] < next["level"] ) { tr = this.strReplace( "$$button$$", "\
| $$content$$ | \