/**
* Fullscreenr - lightweight full screen background jquery plugin
* By Jan Schneiders
* Version 1.0
* www.nanotux.com
**/
(function($){
	$.fn.fullscreenr = function(options) {
		//if(options.height === undefined) alert('Please supply the background image height, default values will now be used. These may be very inaccurate.');
		//if(options.width === undefined) alert('Please supply the background image width, default values will now be used. These may be very inaccurate.');
		if(options.bgID === undefined) alert('Please supply the background image ID, default #bgimg will now be used.');
		var defaults = { width: 0,  height: 0, bgID: '' };
		var options = $.extend({}, defaults, options);
		$(document).ready(function() { $(options.bgID).fullscreenrResizer(options);	});
		$(window).bind("resize", function() { $(options.bgID).fullscreenrResizer(options); });
		return this;		
	};
	$.fn.fullscreenrResizer = function(options) {
		// Set bg size
		//var ratio = options.height / options.width;
		ratio =  $(this).height()/ $(this).width();
		// Get browser window size
		//Gather browser and current image size
		//IE& HACK
		L_min=960;
		H_min=600;
		offsetX=0;
		offsetY=0;
		if($(window).width()<L_min){
			offsetX= L_min-$(window).width();
			}
		if($(window).height()<H_min){
			offsetY= H_min-$(window).height();
			}
		
		var browserwidth = $(window).width()+offsetX;
		var browserheight = $(window).height()+offsetY;//getSize();
		// Scale the image
		if ((browserheight/browserwidth) > ratio){
		    $(this).height(browserheight);
		    $(this).width(browserheight / ratio);
		} else {
		    $(this).width(browserwidth);
		    $(this).height(browserwidth * ratio);
		}
		// Center the image
		$(this).css('left', (browserwidth - $(this).width())/2);
		$(this).css('top', (browserheight - $(this).height())/2);
		return this;
	};
})(jQuery);

function getSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}
/*
function IEFix(div){
	
	scroll_left=$(window).scrollLeft();
	$("#sfondo").css('margin-left', scroll_left);
	scroll_top=$(window).scrollTop();
	$("#sfondo").css('margin-top', scroll_top);
	
	};
*/
