function cAjaxImageMapping()
{
	var t = this;
	t.hOutNode = $("#http_response");
	t.aCashed = new Array();
	
	t.Init = function()
	{
		try {
			if( !t.hOutNode ) return false;
			
			$("[@usemap]") 
			.each( 
				function()
				{ 
					$("map[@name='" + $(this) .attr("usemap") .substr(1) + "']")
					.children("area[@href]") .not( "[@href=#]" ) .mouseover(
						function() 
						{
							var sUrl = $(this) .attr("href");
							var aParams = sUrl .split('?', 2);
							if( !aParams[0].length ) return true;
							
							$(t.hOutNode) .html( "Загрузка ..." );
							t.Show();
							if( t.Cashed( sUrl ) ) {
								$(t.hOutNode) 
									.html( t.LoadCashe( sUrl ) );
								return false;
							}
							
							$.post( 
								aParams[0],
								aParams[1],
								function( sResponseText )
								{
									if( !t.Cashed( sUrl ) ) t.Cashe( sUrl, sResponseText );
									$(t.hOutNode) .html( sResponseText );
								}
							);
							return false;	
						}						
					) .click( 
						function() 
						{
							return false;
						}
					); 
				}
			);
			return true;
		} catch(e){
			return false;
		}
	}
	
	t.Cashe = function( sUrl, sResponseText ) 
	{
		if( t.Cashed( sUrl ) ) return;
		t.aCashed[ t.aCashed.length ] = {
			url	:	sUrl,
			text:	sResponseText
		};	
	}
	t.Cashed = function( sUrl ) 
	{
		for( var i=0; i<t.aCashed.length; i++ )
			if( t.aCashed[ i ].url == sUrl ) return true;
		return false;
	}
	t.LoadCashe = function( sUrl ) 
	{
		for( var i=0; i<t.aCashed.length; i++ )
			if( t.aCashed[ i ].url == sUrl ) return t.aCashed[ i ].text;
		return "";
	}
	t.Hide = function()
	{
		$(t.hOutNode).hide();
	}
	t.Show = function()
	{
		$(t.hOutNode).show();
	}
	
	t.Hide();
	t.Init();	
}
$(document).ready( function() {
	AjaxImageMapping = new cAjaxImageMapping();
});