function setLang(lang){
	document.cookie= "mishaLang=" +escape(lang);
}

function preloadImage(){
	MM_preloadImages('images/mondo/mondo.jpg','images/mondo/europa.jpg','images/mondo/asia.jpg','images/mondo/africa.jpg','images/mondo/america.jpg','images/mondo/americalatina.jpg','images/mondo/oceania.jpg');	
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function noteLegali(){
		var win = window.open('noteLegali.php', '','width=570, height=300, top=150, left=150, toolbar=no, location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
		win.focus();
}

function credits(){
		var win = window.open('credits.php', '','width=570, height=300, top=150, left=150, toolbar=no, location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
		win.focus();
}

/******************************************************
	* jQuery plug-in
	* Easy Background Image Resizer
	* Developed by J.P. Given (http://johnpatrickgiven.com)
	* Useage: anyone so long as credit is left alone
******************************************************/

var containerObj;

(function($) {
	// plugin definition
	$.fn.ezBgResize = function(options) {
		// First position object
		containerObj = this;
		
		containerObj.css("visibility","hidden");
		
		containerObj.children('img').load(function() {
			resizeImage();
		});
		
		$(window).bind("resize",function() {
			resizeImage();
		});
		
	};
	
	function resizeImage() {
		containerObj.css("position","fixed");
		
		containerObj.css("top","0px");
		containerObj.css("left","0px");
		containerObj.css("z-index","-1");
		containerObj.css("overflow","hidden");
		
		// Set obj to the width and height of window
		containerObj.css("width",getWindowWidth() + "px");
		containerObj.css("height",getWindowHeight() + "px");
		
		// Resize the img object to the proper ratio of the window.
		var iw = containerObj.children('img').width();
		var ih = containerObj.children('img').height();
		if (getWindowWidth() > getWindowHeight()) {
			if (iw > ih) {
				var fRatio = iw/ih;
				containerObj.children('img').css("width",getWindowWidth() + "px");
				containerObj.children('img').css("height",Math.round(getWindowWidth() * (1/fRatio)));

				var newIh = Math.round(getWindowWidth() * (1/fRatio));

				if(newIh < getWindowHeight()) {
					var fRatio = ih/iw;
					containerObj.children('img').css("height",getWindowHeight());
					containerObj.children('img').css("width",Math.round(getWindowHeight() * (1/fRatio)));
				}
			} else {
				var fRatio = ih/iw;
				containerObj.children('img').css("height",getWindowHeight());
				containerObj.children('img').css("width",Math.round(getWindowHeight() * (1/fRatio)));
			}
		} else {
			var fRatio = ih/iw;
			containerObj.children('img').css("height",getWindowHeight());
			containerObj.children('img').css("width",Math.round(getWindowHeight() * (1/fRatio)));
		}
		containerObj.css("visibility","visible");
	}
	
	// private function for debugging
	function debug($obj) {
		if (window.console && window.console.log) {
			window.console.log('Window Width: ' + $(window).width());
			window.console.log('Window Height: ' + $(window).height());
		}
	};
	
	// Dependable function to get Window Height
	function getWindowHeight() {
		var windowHeight = 0;
		if (typeof(window.innerHeight) == 'number') {
			windowHeight = window.innerHeight;
		}
		else {
			if (document.documentElement && document.documentElement.clientHeight) {
				windowHeight = document.documentElement.clientHeight;
			}
			else {
				if (document.body && document.body.clientHeight) {
					windowHeight = document.body.clientHeight;
				}
			}
		}
		return windowHeight;
	};
	
	// Dependable function to get Window Width
	function getWindowWidth() {
		var windowWidth = 0;
		if (typeof(window.innerWidth) == 'number') {
			windowWidth = window.innerWidth;
		}
		else {
			if (document.documentElement && document.documentElement.clientWidth) {
				windowWidth = document.documentElement.clientWidth;
			}
			else {
				if (document.body && document.body.clientWidth) {
					windowWidth = document.body.clientWidth;
				}
			}
		}
		return windowWidth;
	};
})(jQuery);
