//What is the url that hosts the widget script
	var LI20P_WIDGET_URL = 'http://shellab.com/li20pwidget/';
	//var LI20P_WIDGET_URL = 'http://l20.com/';

(function(){
	//see if we need to load the dom window script
	if (typeof fI === 'undefined') {
		fI = true;
	}
	
	//function to load the LI20P widget
	function loadLI20PWidget(){
			var script3 = document.createElement('script');
			script3.type = "text/javascript";
			script3.src = LI20P_WIDGET_URL+"scripts/LI20PWidget.js";
			document.getElementsByTagName('head')[0].appendChild(script3);
	}
	//function to load the LI20P widget wrapped in a lightbox
	function loadAllCommonScript(){
		var script2 = document.createElement('script'), loaded2 = false;
		script2.setAttribute('type', 'text/javascript');
		script2.setAttribute('src', LI20P_WIDGET_URL+'scripts/jquery.DOMWindow.js');
		//When light window is done loading
		script2.onload = script2.onreadystatechange = function() {
			var rs2 = this.readyState;
			if (rs2 && rs2!='complete' && rs2!='loaded') return;
			if (loaded2) return;
			loaded2 = true;
			document.body.removeChild(script2);
			//Load the LI20P script
			loadLI20PWidget();
		};
		document.body.appendChild(script2);
	}
	//Major cross browser issues so
	//if an error is thrown when testing for jquery (which implies no jquery in some browsers)
	//Test to see if this error is thrown
	try{
		typeof jQuery == 'undefined'
	}
	catch(err){
   		//There was an error so load jquery and everything else
   		//Load jquery
   		var script = document.createElement('script'), loaded = false;
   		script.setAttribute('type', 'text/javascript');
		script.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
		//when jquery is done...
		script.onload = script.onreadystatechange = function() {
			var rs = this.readyState;
			if (rs && rs!='complete' && rs!='loaded') return;
			if (loaded) return;
			loaded = true;
			document.body.removeChild(script);
			//Load the lightwindow
			if(fI==true){
				loadAllCommonScript();
			}else{
				loadLI20PWidget();
			}
		};
		document.body.appendChild(script);
	}
	if (typeof jQuery == 'undefined'){
	//if there was not an error jquery still might not be displayed. Some browsers don't throw an error but its still undefined
		//Load jQuery
		var script = document.createElement('script'), loaded = false;
		script.setAttribute('type', 'text/javascript');
		script.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
		//when jquery is done loading
		script.onload = script.onreadystatechange = function() {
			var rs = this.readyState;
			if (rs && rs!='complete' && rs!='loaded') return;
			if (loaded) return;
			loaded = true;
			document.body.removeChild(script);
			//Load Light Window
			if(fI==true){
				loadAllCommonScript();
			}else{
				loadLI20PWidget();
			}
		};
		document.body.appendChild(script);
	}
	else{
	//If neither of these then jquery is already loaded. Just load the other stuff
		//Load LightWindow
		if(fI==true){
			loadAllCommonScript();
		}else{
			loadLI20PWidget();
		}
	}
})();
