includes/clientside/static/dropdown.js
changeset 1227 bdac73ed481e
parent 865 7f8262b2004a
child 1254 221d14331ebe
equal deleted inserted replaced
1226:de56132c008d 1227:bdac73ed481e
    32 var jBox_opacity = 100;
    32 var jBox_opacity = 100;
    33 
    33 
    34 // Adds the jBox CSS to the HTML header. Called on window onload.
    34 // Adds the jBox CSS to the HTML header. Called on window onload.
    35 var jBoxInit = function()
    35 var jBoxInit = function()
    36 {
    36 {
    37   setTimeout('jBoxBatchSetup();', 200);
    37 	setTimeout('jBoxBatchSetup();', 200);
    38 }
    38 }
    39 addOnloadHook(jBoxInit);
    39 addOnloadHook(jBoxInit);
    40 
    40 
    41 // Initializes each menu.
    41 // Initializes each menu.
    42 function jBoxBatchSetup()
    42 function jBoxBatchSetup()
    43 {
    43 {
    44   if ( KILL_SWITCH )
    44 	if ( KILL_SWITCH )
    45     return false;
    45 		return false;
    46   var menus = document.getElementsByClassName('div', 'menu_nojs');
    46 	var menus = document.getElementsByClassName('div', 'menu_nojs');
    47   if ( menus.length > 0 )
    47 	if ( menus.length > 0 )
    48   {
    48 	{
    49     for ( var i in menus )
    49 		for ( var i in menus )
    50     {
    50 		{
    51       if ( typeof(menus[i]) != 'object')
    51 			if ( typeof(menus[i]) != 'object')
    52         continue; // toJSONString() compatibility
    52 				continue; // toJSONString() compatibility
    53       jBoxSetup(menus[i]);
    53 			jBoxSetup(menus[i]);
    54     }
    54 		}
    55   }
    55 	}
    56 }
    56 }
    57 
    57 
    58 // Initializes a div with a jBox menu in it.
    58 // Initializes a div with a jBox menu in it.
    59 function jBoxSetup(obj)
    59 function jBoxSetup(obj)
    60 {
    60 {
    61   $dynano(obj).addClass('menu');
    61 	$dynano(obj).addClass('menu');
    62   removeTextNodes(obj);
    62 	removeTextNodes(obj);
    63   
    63 	
    64   for ( var i = 0; i < obj.childNodes.length; i++ )
    64 	for ( var i = 0; i < obj.childNodes.length; i++ )
    65   {
    65 	{
    66     /* normally this would be done in about 2 lines of code, but javascript is so picky..... */
    66 		/* normally this would be done in about 2 lines of code, but javascript is so picky..... */
    67     if ( obj.childNodes[i] )
    67 		if ( obj.childNodes[i] )
    68     {
    68 		{
    69       if ( obj.childNodes[i].tagName )
    69 			if ( obj.childNodes[i].tagName )
    70       {
    70 			{
    71         if ( obj.childNodes[i].tagName == 'A' )
    71 				if ( obj.childNodes[i].tagName == 'A' )
    72         {
    72 				{
    73           // if ( is_Safari ) alert('It\'s an A: '+obj);
    73 					// if ( is_Safari ) alert('It\'s an A: '+obj);
    74           if ( obj.childNodes[i].nextSibling )
    74 					if ( obj.childNodes[i].nextSibling )
    75           {
    75 					{
    76             // alert("Next sibling: " + obj.childNodes[i].nextSibling);
    76 						// alert("Next sibling: " + obj.childNodes[i].nextSibling);
    77             if ( obj.childNodes[i].nextSibling.tagName )
    77 						if ( obj.childNodes[i].nextSibling.tagName )
    78             {
    78 						{
    79               if ( obj.childNodes[i].nextSibling.tagName == 'UL' || ( obj.childNodes[i].nextSibling.tagName.toLowerCase() == 'div' && obj.childNodes[i].nextSibling.className == 'submenu' ) )
    79 							if ( obj.childNodes[i].nextSibling.tagName == 'UL' || ( obj.childNodes[i].nextSibling.tagName.toLowerCase() == 'div' && obj.childNodes[i].nextSibling.className == 'submenu' ) )
    80               {
    80 							{
    81                 // Calculate height
    81 								// Calculate height
    82                 var ul = obj.childNodes[i].nextSibling;
    82 								var ul = obj.childNodes[i].nextSibling;
    83                 domObjChangeOpac(0, ul);
    83 								domObjChangeOpac(0, ul);
    84                 ul.style.display = 'block';
    84 								ul.style.display = 'block';
    85                 ul.style.zIndex = getHighestZ() + 2;
    85 								ul.style.zIndex = getHighestZ() + 2;
    86                 var links = ul.getElementsByTagName('a');
    86 								var links = ul.getElementsByTagName('a');
    87                 for ( var j = 0; j < links.length; j++ )
    87 								for ( var j = 0; j < links.length; j++ )
    88                 {
    88 								{
    89                   links[j].onmouseup = function()
    89 									links[j].onmouseup = function()
    90                   {
    90 									{
    91                     var ul = this;
    91 										var ul = this;
    92                     while ( ul.tagName != 'UL' && ul.tagName != 'DIV' && ul.tagName != 'BODY' )
    92 										while ( ul.tagName != 'UL' && ul.tagName != 'DIV' && ul.tagName != 'BODY' )
    93                       ul = ul.parentNode;
    93 											ul = ul.parentNode;
    94                     if ( ul.tagName == 'BODY' )
    94 										if ( ul.tagName == 'BODY' )
    95                       return false;
    95 											return false;
    96                     jBoxHideMenu(ul.previousSibling, ul);
    96 										jBoxHideMenu(ul.previousSibling, ul);
    97                   }
    97 									}
    98                 }
    98 								}
    99                 var dim = fetch_dimensions(ul);
    99 								var dim = fetch_dimensions(ul);
   100                 if ( !ul.id )
   100 								if ( !ul.id )
   101                   ul.id = 'jBoxmenuobj_' + Math.floor(Math.random() * 10000000);
   101 									ul.id = 'jBoxmenuobj_' + Math.floor(Math.random() * 10000000);
   102                 jBoxMenuHeights[ul.id] = parseInt(dim['h']) - 2; // subtract 2px for border width
   102 								jBoxMenuHeights[ul.id] = parseInt(dim['h']) - 2; // subtract 2px for border width
   103                 
   103 								
   104                 if ( dim['w'] + $dynano(ul).Left() > getWidth() || $dynano(ul).hasClass('jbox_right') )
   104 								if ( dim['w'] + $dynano(ul).Left() > getWidth() || $dynano(ul).hasClass('jbox_right') )
   105                 {
   105 								{
   106                   $dynano(ul).addClass('jbox_right');
   106 									$dynano(ul).addClass('jbox_right');
   107                   ul.jbox_width = $dynano(ul).Width();
   107 									ul.jbox_width = $dynano(ul).Width();
   108                 }
   108 								}
   109                 
   109 								
   110                 ul.style.display = 'none';
   110 								ul.style.display = 'none';
   111                 domObjChangeOpac(100, ul);
   111 								domObjChangeOpac(100, ul);
   112                 
   112 								
   113                 // Setup events
   113 								// Setup events
   114                 obj.childNodes[i].onmouseover = function()  { jBoxOverHandler(this); };
   114 								obj.childNodes[i].onmouseover = function()  { jBoxOverHandler(this); };
   115                 obj.childNodes[i].onmouseout = function(e)  { jBoxOutHandler(this, e); };
   115 								obj.childNodes[i].onmouseout = function(e)  { jBoxOutHandler(this, e); };
   116                 obj.childNodes[i].nextSibling.onmouseout = function(e)  { jBoxOutHandler(this, e); };
   116 								obj.childNodes[i].nextSibling.onmouseout = function(e)  { jBoxOutHandler(this, e); };
   117                 if ( is_iPhone )
   117 								if ( is_iPhone )
   118                 {
   118 								{
   119                   obj.childNodes[i].onclick = function()  { jBoxOverHandler(this); return false; };
   119 									obj.childNodes[i].onclick = function()  { jBoxOverHandler(this); return false; };
   120                 }
   120 								}
   121               }
   121 							}
   122             }
   122 						}
   123           }
   123 					}
   124         }
   124 				}
   125       }
   125 			}
   126     }
   126 		}
   127   }
   127 	}
   128 }
   128 }
   129 
   129 
   130 // Called when user hovers mouse over a submenu
   130 // Called when user hovers mouse over a submenu
   131 function jBoxOverHandler(obj)
   131 function jBoxOverHandler(obj)
   132 {
   132 {
   133   // if ( is_Safari )
   133 	// if ( is_Safari )
   134   //   alert('Safari and over');
   134 	//   alert('Safari and over');
   135   // Random ID used to track the object to perform on
   135 	// Random ID used to track the object to perform on
   136   var seed = Math.floor(Math.random() * 1000000);
   136 	var seed = Math.floor(Math.random() * 1000000);
   137   jBoxObjCache[seed] = obj;
   137 	jBoxObjCache[seed] = obj;
   138   
   138 	
   139   // Sleep for a (little more than a tenth of a) second to see if the user really wants the menu to expand
   139 	// Sleep for a (little more than a tenth of a) second to see if the user really wants the menu to expand
   140   setTimeout('if(isOverObj(jBoxObjCache['+seed+'], false, false)) jBoxOverHandlerBin(jBoxObjCache['+seed+']);', 150);
   140 	setTimeout('if(isOverObj(jBoxObjCache['+seed+'], false, false)) jBoxOverHandlerBin(jBoxObjCache['+seed+']);', 150);
   141 }
   141 }
   142 
   142 
   143 // Displays a menu.
   143 // Displays a menu.
   144 function jBoxOverHandlerBin(obj)
   144 function jBoxOverHandlerBin(obj)
   145 {
   145 {
   146   var others = obj.parentNode.getElementsByTagName('ul');
   146 	var others = obj.parentNode.getElementsByTagName('ul');
   147   for ( var i in others )
   147 	for ( var i in others )
   148   {
   148 	{
   149     if(typeof(others[i]) == 'object')
   149 		if(typeof(others[i]) == 'object')
   150     {
   150 		{
   151       others[i].style.display = 'none';
   151 			others[i].style.display = 'none';
   152       $dynano(others[i].previousSibling).rmClass('liteselected');
   152 			$dynano(others[i].previousSibling).rmClass('liteselected');
   153     }
   153 		}
   154   }
   154 	}
   155   var others = obj.parentNode.getElementsByTagName('div');
   155 	var others = obj.parentNode.getElementsByTagName('div');
   156   for ( var i in others )
   156 	for ( var i in others )
   157   {
   157 	{
   158     if(typeof(others[i]) == 'object')
   158 		if(typeof(others[i]) == 'object')
   159     {
   159 		{
   160       if ( others[i].className == 'submenu' )
   160 			if ( others[i].className == 'submenu' )
   161       {
   161 			{
   162         others[i].style.display = 'none';
   162 				others[i].style.display = 'none';
   163         $dynano(others[i].previousSibling).rmClass('liteselected');
   163 				$dynano(others[i].previousSibling).rmClass('liteselected');
   164       }
   164 			}
   165     }
   165 		}
   166   }
   166 	}
   167   if(obj.nextSibling.tagName.toLowerCase() == 'ul' || ( obj.nextSibling.tagName.toLowerCase() == 'div' && obj.nextSibling.className == 'submenu' ))
   167 	if(obj.nextSibling.tagName.toLowerCase() == 'ul' || ( obj.nextSibling.tagName.toLowerCase() == 'div' && obj.nextSibling.className == 'submenu' ))
   168   {
   168 	{
   169     $dynano(obj).addClass('liteselected');
   169 		$dynano(obj).addClass('liteselected');
   170     //obj.className = 'liteselected';
   170 		//obj.className = 'liteselected';
   171     var ul = obj.nextSibling;
   171 		var ul = obj.nextSibling;
   172     var dim = fetch_dimensions(obj);
   172 		var dim = fetch_dimensions(obj);
   173     var off = fetch_offset(obj);
   173 		var off = fetch_offset(obj);
   174     var dimh = parseInt(dim['h']);
   174 		var dimh = parseInt(dim['h']);
   175     var offtop = parseInt(off['top']);
   175 		var offtop = parseInt(off['top']);
   176     var top = dimh + offtop;
   176 		var top = dimh + offtop;
   177     if ( $dynano(ul).hasClass('jbox_right') )
   177 		if ( $dynano(ul).hasClass('jbox_right') )
   178     {
   178 		{
   179       left = $dynano(obj).Left() + $dynano(obj).Width() - ul.jbox_width; // ( link left + link width ) - ul width
   179 			left = $dynano(obj).Left() + $dynano(obj).Width() - ul.jbox_width; // ( link left + link width ) - ul width
   180     }
   180 		}
   181     else
   181 		else
   182     {
   182 		{
   183       left = off['left'];
   183 			left = off['left'];
   184     }
   184 		}
   185     if ( jBox_slide_enable )
   185 		if ( jBox_slide_enable )
   186     {
   186 		{
   187       domObjChangeOpac(0, ul);
   187 			domObjChangeOpac(0, ul);
   188     }
   188 		}
   189     ul.style.left = left + 'px';
   189 		ul.style.left = left + 'px';
   190     ul.style.top = top + 'px';
   190 		ul.style.top = top + 'px';
   191     ul.style.clip = 'rect(auto,auto,auto,auto)';
   191 		ul.style.clip = 'rect(auto,auto,auto,auto)';
   192     ul.style.overflow = 'visible';
   192 		ul.style.overflow = 'visible';
   193     ul.style.display = 'block';
   193 		ul.style.display = 'block';
   194     if ( jBox_slide_enable )
   194 		if ( jBox_slide_enable )
   195     {
   195 		{
   196       slideOut(ul);
   196 			slideOut(ul);
   197     }
   197 		}
   198     else
   198 		else
   199     {
   199 		{
   200       domObjChangeOpac(100, ul);
   200 			domObjChangeOpac(100, ul);
   201     }
   201 		}
   202   }
   202 	}
   203 }
   203 }
   204 
   204 
   205 function jBoxOutHandler(obj, event)
   205 function jBoxOutHandler(obj, event)
   206 {
   206 {
   207   var seed = Math.floor(Math.random() * 1000000);
   207 	var seed = Math.floor(Math.random() * 1000000);
   208   var seed2 = Math.floor(Math.random() * 1000000);
   208 	var seed2 = Math.floor(Math.random() * 1000000);
   209   jBoxObjCache[seed] = obj;
   209 	jBoxObjCache[seed] = obj;
   210   jBoxObjCache[seed2] = event;
   210 	jBoxObjCache[seed2] = event;
   211   setTimeout('jBoxOutHandlerBin(jBoxObjCache['+seed+'], jBoxObjCache['+seed2+']);', 750);
   211 	setTimeout('jBoxOutHandlerBin(jBoxObjCache['+seed+'], jBoxObjCache['+seed2+']);', 750);
   212 }
   212 }
   213 
   213 
   214 function jBoxOutHandlerBin(obj, event)
   214 function jBoxOutHandlerBin(obj, event)
   215 {
   215 {
   216   var caller = obj.tagName.toLowerCase();
   216 	var caller = obj.tagName.toLowerCase();
   217   if(caller == 'a')
   217 	if(caller == 'a')
   218   {
   218 	{
   219     a = obj;
   219 		a = obj;
   220     ul = obj.nextSibling;
   220 		ul = obj.nextSibling;
   221   }
   221 	}
   222   else if(caller == 'ul' || caller == 'div')
   222 	else if(caller == 'ul' || caller == 'div')
   223   {
   223 	{
   224     a = obj.previousSibling;
   224 		a = obj.previousSibling;
   225     ul = obj;
   225 		ul = obj;
   226   }
   226 	}
   227   else
   227 	else
   228   {
   228 	{
   229     return false;
   229 		return false;
   230   }
   230 	}
   231   
   231 	
   232   if (!isOverObj(a, false, event) && !isOverObj(ul, true, event))
   232 	if (!isOverObj(a, false, event) && !isOverObj(ul, true, event))
   233   {
   233 	{
   234     jBoxHideMenu(a, ul);
   234 		jBoxHideMenu(a, ul);
   235   }
   235 	}
   236   
   236 	
   237   return true;
   237 	return true;
   238 }
   238 }
   239 
   239 
   240 function jBoxHideMenu(a, ul)
   240 function jBoxHideMenu(a, ul)
   241 {
   241 {
   242   $dynano(a).rmClass('liteselected');
   242 	$dynano(a).rmClass('liteselected');
   243     
   243 		
   244   if ( jBox_slide_enable )
   244 	if ( jBox_slide_enable )
   245   {
   245 	{
   246     slideIn(ul);
   246 		slideIn(ul);
   247   }
   247 	}
   248   else
   248 	else
   249   {
   249 	{
   250     ul.style.display = 'none';
   250 		ul.style.display = 'none';
   251   }
   251 	}
   252 }
   252 }
   253 
   253 
   254 // Slide an element downwards until it is at full height.
   254 // Slide an element downwards until it is at full height.
   255 // First parameter should be a DOM object with style.display = block and opacity = 0.
   255 // First parameter should be a DOM object with style.display = block and opacity = 0.
   256 
   256 
   257 var sliderobj = new Object();
   257 var sliderobj = new Object();
   258 
   258 
   259 function slideOut(obj)
   259 function slideOut(obj)
   260 {
   260 {
   261   if ( jBoxSlideBlocker[obj.id] )
   261 	if ( jBoxSlideBlocker[obj.id] )
   262     return false;
   262 		return false;
   263   
   263 	
   264   jBoxSlideBlocker[obj.id] = true;
   264 	jBoxSlideBlocker[obj.id] = true;
   265   
   265 	
   266   if ( slide_speed == -1 )
   266 	if ( slide_speed == -1 )
   267   {
   267 	{
   268     obj.style.display = 'block';
   268 		obj.style.display = 'block';
   269     return false;
   269 		return false;
   270   }
   270 	}
   271   
   271 	
   272   var currentheight = 0;
   272 	var currentheight = 0;
   273   var targetheight = jBoxMenuHeights[obj.id];
   273 	var targetheight = jBoxMenuHeights[obj.id];
   274   var inertiabase = inertia_base;
   274 	var inertiabase = inertia_base;
   275   var inertiainc = inertia_inc;
   275 	var inertiainc = inertia_inc;
   276   slideStep(obj, 0);
   276 	slideStep(obj, 0);
   277   domObjChangeOpac(100, obj);
   277 	domObjChangeOpac(100, obj);
   278   obj.style.overflow = 'hidden';
   278 	obj.style.overflow = 'hidden';
   279   
   279 	
   280   // Don't edit past here
   280 	// Don't edit past here
   281   var timercnt = 0;
   281 	var timercnt = 0;
   282   
   282 	
   283   var seed = Math.floor(Math.random() * 1000000);
   283 	var seed = Math.floor(Math.random() * 1000000);
   284   sliderobj[seed] = obj;
   284 	sliderobj[seed] = obj;
   285   
   285 	
   286   var framecnt = 0;
   286 	var framecnt = 0;
   287   
   287 	
   288   while(true)
   288 	while(true)
   289   {
   289 	{
   290     framecnt++;
   290 		framecnt++;
   291     timercnt += ( 100 - slide_speed );
   291 		timercnt += ( 100 - slide_speed );
   292     inertiabase += inertiainc;
   292 		inertiabase += inertiainc;
   293     currentheight += inertiabase;
   293 		currentheight += inertiabase;
   294     if ( currentheight > targetheight )
   294 		if ( currentheight > targetheight )
   295       currentheight = targetheight;
   295 			currentheight = targetheight;
   296     setTimeout('slideStep(sliderobj['+seed+'], '+currentheight+', '+targetheight+');', timercnt);
   296 		setTimeout('slideStep(sliderobj['+seed+'], '+currentheight+', '+targetheight+');', timercnt);
   297     if ( currentheight >= targetheight )
   297 		if ( currentheight >= targetheight )
   298       break;
   298 			break;
   299   }
   299 	}
   300   timercnt = timercnt + ( 100 - slide_speed );
   300 	timercnt = timercnt + ( 100 - slide_speed );
   301   setTimeout('jBoxSlideBlocker[sliderobj['+seed+'].id] = false;', timercnt);
   301 	setTimeout('jBoxSlideBlocker[sliderobj['+seed+'].id] = false;', timercnt);
   302   var opacstep = jBox_opacity / framecnt;
   302 	var opacstep = jBox_opacity / framecnt;
   303   var opac = 0;
   303 	var opac = 0;
   304   var timerstep = 0;
   304 	var timerstep = 0;
   305   domObjChangeOpac(0, obj);
   305 	domObjChangeOpac(0, obj);
   306   while(true)
   306 	while(true)
   307   {
   307 	{
   308     timerstep += ( 100 - slide_speed );
   308 		timerstep += ( 100 - slide_speed );
   309     opac += opacstep;
   309 		opac += opacstep;
   310     setTimeout('domObjChangeOpac('+opac+', sliderobj['+seed+']);', timerstep);
   310 		setTimeout('domObjChangeOpac('+opac+', sliderobj['+seed+']);', timerstep);
   311     if ( opac >= jBox_opacity )
   311 		if ( opac >= jBox_opacity )
   312       break;
   312 			break;
   313   }
   313 	}
   314 }
   314 }
   315 
   315 
   316 function slideIn(obj)
   316 function slideIn(obj)
   317 {
   317 {
   318   if ( obj.style.display != 'block' )
   318 	if ( obj.style.display != 'block' )
   319     return false;
   319 		return false;
   320   
   320 	
   321   if ( jBoxSlideBlocker[obj.id] )
   321 	if ( jBoxSlideBlocker[obj.id] )
   322     return false;
   322 		return false;
   323   
   323 	
   324   jBoxSlideBlocker[obj.id] = true;
   324 	jBoxSlideBlocker[obj.id] = true;
   325   
   325 	
   326   var targetheight = 0;
   326 	var targetheight = 0;
   327   var dim = fetch_dimensions(obj);
   327 	var dim = fetch_dimensions(obj);
   328   var currentheight = jBoxMenuHeights[obj.id];
   328 	var currentheight = jBoxMenuHeights[obj.id];
   329   var origheight = currentheight;
   329 	var origheight = currentheight;
   330   var inertiabase = inertia_base;
   330 	var inertiabase = inertia_base;
   331   var inertiainc = inertia_inc;
   331 	var inertiainc = inertia_inc;
   332   domObjChangeOpac(100, obj);
   332 	domObjChangeOpac(100, obj);
   333   obj.style.overflow = 'hidden';
   333 	obj.style.overflow = 'hidden';
   334   
   334 	
   335   // Don't edit past here
   335 	// Don't edit past here
   336   var timercnt = 0;
   336 	var timercnt = 0;
   337   
   337 	
   338   var seed = Math.floor(Math.random() * 1000000);
   338 	var seed = Math.floor(Math.random() * 1000000);
   339   sliderobj[seed] = obj;
   339 	sliderobj[seed] = obj;
   340   
   340 	
   341   var framecnt = 0;
   341 	var framecnt = 0;
   342   
   342 	
   343   for(var j = 0;j<100;j++) // while(true)
   343 	for(var j = 0;j<100;j++) // while(true)
   344   {
   344 	{
   345     framecnt++;
   345 		framecnt++;
   346     timercnt = timercnt + ( 100 - slide_speed );
   346 		timercnt = timercnt + ( 100 - slide_speed );
   347     inertiabase = inertiabase + inertiainc;
   347 		inertiabase = inertiabase + inertiainc;
   348     currentheight = currentheight - inertiabase;
   348 		currentheight = currentheight - inertiabase;
   349     if ( currentheight < targetheight )
   349 		if ( currentheight < targetheight )
   350       currentheight = targetheight;
   350 			currentheight = targetheight;
   351     setTimeout('slideStep(sliderobj['+seed+'], '+currentheight+');', timercnt);
   351 		setTimeout('slideStep(sliderobj['+seed+'], '+currentheight+');', timercnt);
   352     if ( currentheight <= targetheight )
   352 		if ( currentheight <= targetheight )
   353       break;
   353 			break;
   354   }
   354 	}
   355   timercnt += ( 100 - slide_speed );
   355 	timercnt += ( 100 - slide_speed );
   356   setTimeout('sliderobj['+seed+'].style.display="none";sliderobj['+seed+'].style.height="'+origheight+'px";jBoxSlideBlocker[sliderobj['+seed+'].id] = false;', timercnt);
   356 	setTimeout('sliderobj['+seed+'].style.display="none";sliderobj['+seed+'].style.height="'+origheight+'px";jBoxSlideBlocker[sliderobj['+seed+'].id] = false;', timercnt);
   357   
   357 	
   358   var opacstep = jBox_opacity / framecnt;
   358 	var opacstep = jBox_opacity / framecnt;
   359   var opac = jBox_opacity;
   359 	var opac = jBox_opacity;
   360   var timerstep = 0;
   360 	var timerstep = 0;
   361   domObjChangeOpac(100, obj);
   361 	domObjChangeOpac(100, obj);
   362   while(true)
   362 	while(true)
   363   {
   363 	{
   364     timerstep += ( 100 - slide_speed );
   364 		timerstep += ( 100 - slide_speed );
   365     opac -= opacstep;
   365 		opac -= opacstep;
   366     setTimeout('domObjChangeOpac('+opac+', sliderobj['+seed+']);', timerstep);
   366 		setTimeout('domObjChangeOpac('+opac+', sliderobj['+seed+']);', timerstep);
   367     if ( opac <= 0 )
   367 		if ( opac <= 0 )
   368       break;
   368 			break;
   369   }
   369 	}
   370   
   370 	
   371 }
   371 }
   372 
   372 
   373 function slideStep(obj, height, maxheight)
   373 function slideStep(obj, height, maxheight)
   374 {
   374 {
   375   obj.style.height = height + 'px';
   375 	obj.style.height = height + 'px';
   376   //obj.style.clip = 'rect(3px,auto,'+maxheight+'px,auto)';
   376 	//obj.style.clip = 'rect(3px,auto,'+maxheight+'px,auto)';
   377   obj.style.overflow = 'hidden';
   377 	obj.style.overflow = 'hidden';
   378   //obj.style.clip = 'rect('+height+'px,0px,'+maxheight+'px,auto);';
   378 	//obj.style.clip = 'rect('+height+'px,0px,'+maxheight+'px,auto);';
   379 }
   379 }
   380 
   380 
   381 function isOverObj(obj, bias, event)
   381 function isOverObj(obj, bias, event)
   382 {
   382 {
   383   var fieldUL = new Object();
   383 	var fieldUL = new Object();
   384   var dim = fetch_dimensions(obj);
   384 	var dim = fetch_dimensions(obj);
   385   var off = fetch_offset(obj);
   385 	var off = fetch_offset(obj);
   386   fieldUL['top'] = off['top'];
   386 	fieldUL['top'] = off['top'];
   387   fieldUL['left'] = off['left'];
   387 	fieldUL['left'] = off['left'];
   388   fieldUL['right'] = off['left'] + dim['w'];
   388 	fieldUL['right'] = off['left'] + dim['w'];
   389   fieldUL['bottom'] = off['top'] + dim['h'];
   389 	fieldUL['bottom'] = off['top'] + dim['h'];
   390   
   390 	
   391   var mouseY_local = mouseY + getScrollOffset();
   391 	var mouseY_local = mouseY + getScrollOffset();
   392   
   392 	
   393   // document.getElementById('debug').innerHTML = '<br />Mouse: x: '+mouseX+', y:' + mouseY + '<br />' + document.getElementById('debug').innerHTML;
   393 	// document.getElementById('debug').innerHTML = '<br />Mouse: x: '+mouseX+', y:' + mouseY + '<br />' + document.getElementById('debug').innerHTML;
   394   
   394 	
   395   if(bias)
   395 	if(bias)
   396   {
   396 	{
   397     if ( ( mouseX < fieldUL['left'] + 2 || mouseX > fieldUL['right']  - 5 ) ||
   397 		if ( ( mouseX < fieldUL['left'] + 2 || mouseX > fieldUL['right']  - 5 ) ||
   398          ( mouseY_local < fieldUL['top']  - 2 || mouseY_local > fieldUL['bottom'] - 2 ) )
   398  				( mouseY_local < fieldUL['top']  - 2 || mouseY_local > fieldUL['bottom'] - 2 ) )
   399     {
   399 		{
   400        return false;
   400  			return false;
   401     }
   401 		}
   402   }
   402 	}
   403   else
   403 	else
   404   {
   404 	{
   405     if ( ( mouseX < fieldUL['left'] || mouseX > fieldUL['right']  ) ||
   405 		if ( ( mouseX < fieldUL['left'] || mouseX > fieldUL['right']  ) ||
   406          ( mouseY_local < fieldUL['top']  || mouseY_local > fieldUL['bottom'] ) )
   406  				( mouseY_local < fieldUL['top']  || mouseY_local > fieldUL['bottom'] ) )
   407        return false;
   407  			return false;
   408   }
   408 	}
   409      
   409  		
   410   return true;
   410 	return true;
   411 }
   411 }
   412 
   412 
   413 function jBoxGarbageCollection(e)
   413 function jBoxGarbageCollection(e)
   414 {
   414 {
   415   setMousePos(e);
   415 	setMousePos(e);
   416   var menus = document.getElementsByClassName('div', 'menu');
   416 	var menus = document.getElementsByClassName('div', 'menu');
   417   if ( menus.length > 0 )
   417 	if ( menus.length > 0 )
   418   {
   418 	{
   419     for ( var i in menus )
   419 		for ( var i in menus )
   420     {
   420 		{
   421       if ( typeof(menus[i]) != 'object')
   421 			if ( typeof(menus[i]) != 'object')
   422         continue; // toJSONString() compatibility
   422 				continue; // toJSONString() compatibility
   423       var uls = menus[i].getElementsByTagName('ul');
   423 			var uls = menus[i].getElementsByTagName('ul');
   424       if ( uls.length > 0 )
   424 			if ( uls.length > 0 )
   425       {
   425 			{
   426         for ( var j = 0; j < uls.length; j++ )
   426 				for ( var j = 0; j < uls.length; j++ )
   427         {
   427 				{
   428           if ( !isOverObj(uls[j], false, e) )
   428 					if ( !isOverObj(uls[j], false, e) )
   429           {
   429 					{
   430             $dynano(uls[j].previousSibling).rmClass('liteselected');
   430 						$dynano(uls[j].previousSibling).rmClass('liteselected');
   431             //uls[j].style.display = 'none';
   431 						//uls[j].style.display = 'none';
   432             slideIn(uls[j]);
   432 						slideIn(uls[j]);
   433           }
   433 					}
   434         }
   434 				}
   435       }
   435 			}
   436       var uls = getElementsByClassName(menus[i], 'divs', 'submenu');
   436 			var uls = getElementsByClassName(menus[i], 'divs', 'submenu');
   437       if ( uls.length > 0 )
   437 			if ( uls.length > 0 )
   438       {
   438 			{
   439         for ( var j = 0; j < uls.length; j++ )
   439 				for ( var j = 0; j < uls.length; j++ )
   440         {
   440 				{
   441           if ( !isOverObj(uls[j], false, e) )
   441 					if ( !isOverObj(uls[j], false, e) )
   442           {
   442 					{
   443             $dynano(uls[j].previousSibling).rmClass('liteselected');
   443 						$dynano(uls[j].previousSibling).rmClass('liteselected');
   444             //uls[j].style.display = 'none';
   444 						//uls[j].style.display = 'none';
   445             slideIn(uls[j]);
   445 						slideIn(uls[j]);
   446           }
   446 					}
   447         }
   447 				}
   448       }
   448 			}
   449     }
   449 		}
   450   }
   450 	}
   451 }
   451 }
   452 
   452 
   453 document.onclick = jBoxGarbageCollection;
   453 document.onclick = jBoxGarbageCollection;
   454 
   454 
   455 var getElementsByClassName = function(parent, type, cls) {
   455 var getElementsByClassName = function(parent, type, cls) {
   456   if(!type)
   456 	if(!type)
   457     type = '*';
   457 		type = '*';
   458   ret = new Array();
   458 	ret = new Array();
   459   if ( !parent )
   459 	if ( !parent )
   460     return ret;
   460 		return ret;
   461   el = parent.getElementsByTagName(type);
   461 	el = parent.getElementsByTagName(type);
   462   for ( var i = 0; i < el.length; i++ )
   462 	for ( var i = 0; i < el.length; i++ )
   463   {
   463 	{
   464     if ( typeof(el[i]) != 'object')
   464 		if ( typeof(el[i]) != 'object')
   465       continue; // toJSONString() compatibility
   465 			continue; // toJSONString() compatibility
   466     if(el[i].className)
   466 		if(el[i].className)
   467     {
   467 		{
   468       if(el[i].className.indexOf(' ') > 0)
   468 			if(el[i].className.indexOf(' ') > 0)
   469       {
   469 			{
   470         classes = el[i].className.split(' ');
   470 				classes = el[i].className.split(' ');
   471       }
   471 			}
   472       else
   472 			else
   473       {
   473 			{
   474         classes = new Array();
   474 				classes = new Array();
   475         classes.push(el[i].className);
   475 				classes.push(el[i].className);
   476       }
   476 			}
   477       if ( in_array(cls, classes) )
   477 			if ( in_array(cls, classes) )
   478         ret.push(el[i]);
   478 				ret.push(el[i]);
   479     }
   479 		}
   480   }
   480 	}
   481   return ret;
   481 	return ret;
   482 }
   482 }
   483 
   483 
   484 document.getElementsByClassName = function(type, cls) {
   484 document.getElementsByClassName = function(type, cls) {
   485   return getElementsByClassName(document, type, cls);
   485 	return getElementsByClassName(document, type, cls);
   486 }
   486 }
   487 
   487 
   488 function setMousePos(event)
   488 function setMousePos(event)
   489 {
   489 {
   490   if(IE)
   490 	if(IE)
   491   {
   491 	{
   492     if(!event)
   492 		if(!event)
   493     {
   493 		{
   494       event = window.event;
   494 			event = window.event;
   495     }
   495 		}
   496     clX = event.clientX;
   496 		clX = event.clientX;
   497     if ( document.body )
   497 		if ( document.body )
   498       sL  = document.body.scrollLeft;
   498 			sL  = document.body.scrollLeft;
   499     else
   499 		else
   500       sL  = 0;
   500 			sL  = 0;
   501     mouseX = clX + sL;
   501 		mouseX = clX + sL;
   502     mouseY = event.clientY + ( document.body ? document.body.scrollTop : 0 );
   502 		mouseY = event.clientY + ( document.body ? document.body.scrollTop : 0 );
   503     return;
   503 		return;
   504   }
   504 	}
   505   if( typeof(event.clientX) == 'number' )
   505 	if( typeof(event.clientX) == 'number' )
   506   {
   506 	{
   507     mouseX = event.clientX;
   507 		mouseX = event.clientX;
   508     mouseY = event.clientY;
   508 		mouseY = event.clientY;
   509     return;
   509 		return;
   510   }
   510 	}
   511   else if( typeof(event.layerX) == 'number' )
   511 	else if( typeof(event.layerX) == 'number' )
   512   {
   512 	{
   513     mouseX = event.layerX;
   513 		mouseX = event.layerX;
   514     mouseY = event.layerY;
   514 		mouseY = event.layerY;
   515     return;
   515 		return;
   516   }
   516 	}
   517   else if( typeof(event.offsetX) == 'number' )
   517 	else if( typeof(event.offsetX) == 'number' )
   518   {
   518 	{
   519     mouseX = event.offsetX;
   519 		mouseX = event.offsetX;
   520     mouseY = event.offsetY;
   520 		mouseY = event.offsetY;
   521     return;
   521 		return;
   522   }
   522 	}
   523   else if( typeof(event.screenX) == 'number' )
   523 	else if( typeof(event.screenX) == 'number' )
   524   {
   524 	{
   525     mouseX = event.screenX;
   525 		mouseX = event.screenX;
   526     mouseY = event.screenY;
   526 		mouseY = event.screenY;
   527     return;
   527 		return;
   528   }
   528 	}
   529   else if( typeof(event.x) == 'number' )
   529 	else if( typeof(event.x) == 'number' )
   530   {
   530 	{
   531     mouseX = event.x;
   531 		mouseX = event.x;
   532     mouseY = event.y;
   532 		mouseY = event.y;
   533     return;
   533 		return;
   534   }
   534 	}
   535 }
   535 }
   536 
   536 
   537 document.onmousemove = function(e)
   537 document.onmousemove = function(e)
   538 {
   538 {
   539   setMousePos(e);
   539 	setMousePos(e);
   540 };
   540 };
   541 
   541 
   542 function removeTextNodes(obj)
   542 function removeTextNodes(obj)
   543 {
   543 {
   544   if(obj)
   544 	if(obj)
   545   {
   545 	{
   546     if(typeof(obj.tagName) != 'string' || ( String(obj) == '[object Text]' && is_Safari ) )
   546 		if(typeof(obj.tagName) != 'string' || ( String(obj) == '[object Text]' && is_Safari ) )
   547     {
   547 		{
   548       if ( ( obj.nodeType == 3 && obj.data.match(/^([\s]*)$/ig) ) ) //  || ( typeof(obj.innerHTML) == undefined && is_Safari ) ) 
   548 			if ( ( obj.nodeType == 3 && obj.data.match(/^([\s]*)$/ig) ) ) //  || ( typeof(obj.innerHTML) == undefined && is_Safari ) ) 
   549       {
   549 			{
   550         obj.parentNode.removeChild(obj);
   550 				obj.parentNode.removeChild(obj);
   551         return;
   551 				return;
   552       }
   552 			}
   553     }
   553 		}
   554     if(obj.firstChild)
   554 		if(obj.firstChild)
   555     {
   555 		{
   556       for(var i = 0; i < obj.childNodes.length; i++)
   556 			for(var i = 0; i < obj.childNodes.length; i++)
   557       {
   557 			{
   558         removeTextNodes(obj.childNodes[i]);
   558 				removeTextNodes(obj.childNodes[i]);
   559       }
   559 			}
   560     }
   560 		}
   561   }
   561 	}
   562 }
   562 }
   563 
   563