/**
 * @author patrick clancey
 */
/**
 * User object holds information about the user settings and session
 * @id user
 * @property {int} jsSupportLevel 
 * @return {void}
 */
var user = {
	jsSupportLevel : (function(){
		if(!document.getElementById){return 0;}
		var support = 1;
		var ua = navigator.userAgent.toLowerCase();
		var isIphone = (ua.match('iphone')||ua.match('ipod'))?true:false;
		var isWii = (ua.match('wii'))?true:false;
		if (window.XMLHttpRequest){support = 2}
		if (support==2 && (!isIphone || !isWii) ){
			support = 3;
		}
		return support;
	})()	
}

if (user.jsSupportLevel>0){
		$(document).ready(function(){
			/* add 'js' class to HTML tag */
			$('html').addClass("js");
			/* add 'img' class to HTML tag */
			(function(existingimageurl){
				var existentimg = new Image;
				existentimg.onload = function(){
					$('html').addClass("img");
					var nonexistentimg = new Image;
					nonexistentimg.onload = function(){
						$('html').removeClass("img");
					}
					nonexistentimg.src="http://void";
				}
				existentimg.src = existingimageurl || (document.images.length?document.images[0].src:'http://www.google.co.uk/images/nav_logo4.png');
			})();			
		}
	);
}
