	function getBounds(element)
	{
	  var left = element.offsetLeft;
	  var top = element.offsetTop;
	  for (var parent = element.offsetParent; parent; parent = parent.offsetParent)
	  {
	    left += parent.offsetLeft;// - parent.scrollLeft;
	    top += parent.offsetTop;// - parent.scrollTop
	  }
	  return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight};
	}
	
	window.onload = function()
	{
		all = document.all || document.getElementsByTagName( "*" );
		for( i = 0; i < all.length; i ++ )
		{		
			if( all[i].className == 'menu_link' )
			{
				p = all[i].parentNode;
				d = document.getElementById(all[i].getAttribute('id') + '_div');
				d.innerHTML = '<div style="padding:10px; width:210px">' + d.innerHTML + '</div>';
				d.style.opacity = 0.10;
				d.over = false;
				p.div = d;
				p.onmouseover = function()
					{
						this.div.over = true;
						SetPos(this.div);
						ShowSub(this.div);
					}
					
				p.onmouseout = function()
					{
						this.div.over = false;
						HideSub(this.div);
					}
				
				d.style.display = 'none';
			}
			
			if( all[i].className == 'sub_menu' )
			{
				all[i].onmouseout = function()
					{
						this.over = false;
						HideSub(this);
					}
					
				all[i].onmouseover = function()
					{
						this.over = true;
						ShowSub(this);
					}
			}
		}
	
	}
	
	function SetPos( block )
	{
		bound = getBounds(block.parentNode);
		block.style.top = (bound.top + bound.height) + "px";
		block.style.left = (bound.left - 10 ) + "px";	
	}
	
	function HideSub( div )
	{	
		if( div.over ) return;
				
		div.style.zIndex = 10;
		op = (div.style.opacity)?parseFloat(div.style.opacity):parseInt(div.style.filter)/100;
		
		op = op - 0.05;
		div.style.opacity = op;
		div.style.filter='alpha(opacity='+op*100+')';		
		if( op > 0.15 )
		{
			
			setTimeout( function(){ HideSub(div); }, 10 );
		}else
		{
			div.style.display = 'none';
		}
	}
	
	function ShowSub( div )
	{
		if( !div.over ) return;
				
		div.style.zIndex = 20;
		div.style.display = 'block';
		op = (div.style.opacity)?parseFloat(div.style.opacity):parseInt(div.style.filter)/100;
		
		op = op + 0.05;
		
		div.style.opacity = op;
		div.style.filter='alpha(opacity='+op*100+')';
		if( op < 1.0 )
		{
			setTimeout( function(){ ShowSub(div); }, 10 );
		}else
		{
			div.style.opacity = 1;
		}
	}

	function ImageId( src )
	{
		var id = '';
		var pos = 0;
		var flag = true;

		while(true)
		{
				if( src.substring(pos, pos+1) == '_' )
				{
					break;
				}
					
				if( src.substring(pos, pos+1) == '/' )
					id = '';
				else
					id = id + src.substring(pos, pos+1);
					
				pos=pos+1;
		}
		return id;
	}

	function RImage()
	{
		var id = ImageId(document.getElementById('gal_img').src);
		ajax_get( '/gallery/_next.htm?id=' + id ,ImageSet);
	}

	function LImage()
	{
		var id = ImageId(document.getElementById('gal_img').src);
		ajax_get( '/gallery/_prev.htm?id=' + id ,ImageSet);
	}

	function ImageView()
	{
		var src = document.getElementById('gal_img').src;
		var id = '';
		var pos = 0;
		var flag = true;

		while(true)
		{
			if( src.substring(pos, pos+1) == '_' )
			{
				break;
			}			
			id = id + src.substring(pos, pos+1);	
			pos=pos+1;
		}

		window.open( id + '.jpg' );
	}
	
	var last_obj = false;

	var def_url = '/';

	var ajax = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  ajax = new ActiveXObject("Msxml2.XMLHttp");
} catch (e) {
  try {
    ajax = new ActiveXObject("Microsoft.XMLHttp");
  } catch (e2) {
    ajax = false;
  }
}
@end @*/

	if (!ajax) 
	{
	  ajax = new XMLHttpRequest();
	}
		if(!ajax) alert('ajax is not supported!');

	function check_state()
	{
		if(ajax.readyState == 4)
		{
			if(ajax.status == 200)
				return true;
			else
				alert('incorrect request');
				return false;
		}
	}

function ImageSet()
{
//	show_waiter();
	//alert(ajax.responseText);
	if(!check_state()) return;
	document.getElementById('gal_img').src = ajax.responseText;
//	hide_waiter();
}

function def_func() {};
	
function ajax_get( url , func )
{
	ajax.open('GET', url,true);
	ajax.onreadystatechange = func;
	ajax.send(null);		
}

function ajax_post( url, data, func )
{
	ajax.open( 'POST', url, true );
	ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	ajax.onreadystatechange = func;
	ajax.send( data );
}

function evalue( e_name )
{
	return encodeURI(value( e_name ));
}
