// 22/09/2008 R Norton-Hall
// USED FOR LOADING SCRIPTS AS PAGE LOADS
// ++ REQUIRES ++ var scriptsForLoading	= './scripts/basefunctions.js,./scripts/loginMaster.js,./scripts/mainStore.js'; // scripts to load

// function scriptsToLoad(scriptsForLoading) - loads one or more scripts seperated by a ,
// function dhtmlLoadScript(url) - loads scripts and writes them to the head of the page
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// staticLoadScript("static_way.js");
/*
must be called while the HTML page is being created, as it uses document.write() in order to create the <script> tag which imports the external JavaScript file. If you called staticLoadScript() after the page is loaded, it would clobber the contents of the page, as document.write() would overwrite the document's HTML content.
*/
	function staticLoadScript(url)
	{
	   document.write('<script src="', url, '" type="text/JavaScript"><\/script>');
	}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// dhtmlLoadScript("dhtml_way.js");
// used by scripts to run on page load
	function dhtmlLoadScript(url)
	{
		var fileType = url.split(".").pop(); // get file type by splitting path string and returning last element
		//alert(fileType);
		
		if (document.getElementById(url)) 
		{ // Already exists
	    	return;
	   	}
	   	
		// alert('Called Me Fourth');
		if(fileType=='js')
		{
		 	var script = document.createElement("script");
		  	script.src = url;
		  	script.id = url;
		  	script.type="text/javascript";
		  	document.getElementsByTagName("head")[0].appendChild(script);
		  	// alert('made'+url);
		}else if (fileType=='css')
		{
			var style = document.createElement("link")
			style,rel = "stylesheet";
  			style.type = "text/css";
  			style.href = url;
		}
	}
	
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
// loads one or more scripts seperated by a ,
	function scriptsToLoad(scriptsForLoading){
		var scripts = scriptsForLoading.split(",");
		
		if(scripts.length)
		{
			for(i=0;i<=scripts.length;i++)
			{
				if(scripts[i])
				{
		//			alert('Called Me Thrice');
		//			alert(scripts[i]);
					dhtmlLoadScript(scripts[i]);
				}
			}
		}
	}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++