﻿function ParseScript(control){
        if(!control){return;}
       for(var n=0;n<control.children.length;n++){
             if(control.children[n].tagName == 'SCRIPT'){
                   window.ScriptLoader.loadScript(control.children[n].innerHTML);
              }else{
                   ParseScript(control.children[n]);
             }
        }
}window.ScriptLoader =

new function(){var queuedScripts = new Array();
var currentScript = null;function onScriptLoaded(){
//Load next
doScriptLoad();
}

function onScriptError(){
//Add Support for error handlers
//Load next
doScriptLoad();} function onScriptReadyStateChange(){
    if(event.srcElement.readyState == "complete" ||event.srcElement.readyState == "loaded")
        onScriptLoaded();
}this.loadScript = function(scriptPath){
     queuedScripts.push(scriptPath);
     if(currentScript == null)
       doScriptLoad();
} //Does the actual script loading
function doScriptLoad(){
if(currentScript){currentScript.onload = onScriptLoaded; //For Mozilla/Opera
currentScript.onerror = onScriptError; //For Mozilla/Opera
currentScript.onreadystatechange = onScriptReadyStateChange; //For IE

}if(queuedScripts.length == 0)
return;currentScript = document.createElement("SCRIPT");
currentScript.onload = onScriptLoaded; //For Mozilla/Opera
currentScript.onerror = onScriptError; //For Mozilla/Opera
currentScript.onreadystatechange = onScriptReadyStateChange; //For IE

currentScript.type = "text/javascript";
currentScript.text = queuedScripts.pop();
document.getElementsByTagName('head')[0].appendChild(currentScript);
}}