	
	/*
	INCLUDE A SCRIPT TO THE PAGE
	sp => system path : global escape var for the script path;
	n => name of the script; It can be a list.
	© Xavier Bouhours 2007
	*/

	function include(){

		
		// INIT
		
			// JS path : must be send before calling this include function.
			JSP = (JSP)? JSP : '' ;

			// array of scripts in the page
			t = document.getElementsByTagName('scr'+'ipt') ;
			
			// head tag location for new scripts
			h = document.getElementsByTagName('head')[0];
			
			// script still exist 
			var sExist=false;
			
			// arguments array
			ar = new Array;
		
			// prepare the returned text
			var concat = "";

		
		// RUN 
			
			for (var g = 0, k = arguments.length; g < k; g++) {
	        	
	        	// script url
	        	ar[g]= JSP + arguments[g]+'.js' ;
				
				// script still exist
				sExist=false;
				
				
				// script still exist ?
					for(var i=0;i<t.length;i++){
						// ADD				
						if (t[i].getAttribute('src') == ar[g]){
							sExist=true;
							return true;
							}
					}
									
				// add script	
					if(sExist==false){
						//if(jQuery){ jQuery.getScript( ar[g] );}
						//else{
							try{
					    		s = document.createElement('scr'+'ipt');
					    		s.setAttribute("type","text/javascr"+"ipt");
					    		s.setAttribute("src",ar[g]);
					    		s.setAttribute("charset","utf-8");
					    		h.appendChild(s);
					  			}
					  		catch(e){
					  			concat+= "<scr"+"ipt type=\"text/javascr"+"ipt\" charset=\"utf-8\" src=\"" + ar[g] + "\"><\/scr"+"ipt>\n" ;
					  			// explorer has a crash with many document.write, so we do it one time at the end of the list.
					    		if( g==k-1 && concat !="") document.write( concat );
					  			}
							}
						//}
				
				}
				
		
		// end function
		}
		
		
