if(typeof(backgroundAutoFit) == 'undefined')
    backgroundAutoFit = new Object();

Object.extend(backgroundAutoFit,
{
	_imageW: null,
   	_imageH: null,
	initialize:function ()
	{
		
	},
	resize:function (e)
	{
		var ratioImg = this._imageW/this._imageH;
		var ratioDoc = document.viewport.getWidth()/document.viewport.getHeight();
		
		if(ratioImg > 1 && ratioDoc > 1 || ratioImg < 1 && ratioDoc < 1)
		{
			if(ratioDoc > ratioImg)
			{
				$('bg-image').width=document.viewport.getWidth();
				$('bg-image').height=$('bg-image').width/ratioImg;
			}
			else
			{
				$('bg-image').height=document.viewport.getHeight();
				$('bg-image').width=$('bg-image').height*ratioImg;
			}
		}
		else
		{
			if(ratioDoc > ratioImg)
			{
				$('bg-image').width=document.viewport.getWidth();
				$('bg-image').height=$('bg-image').width/ratioImg;
			}
			else
			{
				$('bg-image').height=document.viewport.getHeight();
				$('bg-image').width=$('bg-image').height*ratioImg;
			}
		
		}
	}
});

if (Prototype.Browser.IE) 
{
	
	//Event.observe(document.body, "selectstart", NullFunction, true);
	//Event.observe(document.body, "dragstart", NullFunction, true);  
	
	Event.observe(window, 'load', function() 
	{	
  		new Effect.Morph('bg-image', {style: 'opacity: 0.6',duration: 0.0});
		backgroundAutoFit._imageW= $('bg-image').width;
   		backgroundAutoFit._imageH= $('bg-image').height;
   		backgroundAutoFit.resize();
  		Event.observe(window, 'resize', backgroundAutoFit.resize.bind(backgroundAutoFit));
  		
		document.body.onmousemove = function() {if((event.target || event.srcElement).id == 'imgZoomInContainer')return false;}
		
		

	});
}


