// used to add flash movies with javascript
IncludeJavaScript("../js/swfobject.js");
// helpful date format stuff
IncludeJavaScript("../js/formatDate.js");
// include the base 64 encoding stuff
IncludeJavaScript("../js/base64.js");
// handles messages from server
IncludeJavaScript("../Widgets/WidgetHandler.js");
// functions used by the widgets
IncludeJavaScript("../Widgets/BaseWidget.js");
// needed by ajax    
IncludeJavaScript("../js/browserDetection.js");
// functions used by the widgets
IncludeJavaScript("../js/ajax.js ");
// functions used by the widgets
IncludeJavaScript("../js/jquery-1.2.6.js");
// functions used by the widgets
IncludeJavaScript("../js/silverlight.js");
// text decorater
IncludeJavaScript("../js/textDictionary.js");
// slider code
IncludeJavaScript("../js/slider.js");

function AddWidget(path, params)
{       
    var pathData = path.split("/");
    var data = params.split(";");  
    var ctrlName=pathData[pathData.length-1];
    
    // create a div to hold the widget if it doesn't already exist
    if (document.getElementById(data[1])==null)
    {         
        document.write("<div id='"+data[1]+"'></div>");    
    }    
    
    // include the js file that holds the
    IncludeWidgetScript(path, ctrlName, params);     
}

function IncludeJavaScript(jsFile)
{    
    document.write("<script language='javascript' type='text/javascript' src='"+jsFile+"'></script>");
}

function IncludeWidgetScript(jsFile, ctrlName, params)
{   
    var headID = document.getElementsByTagName("head")[0];         

    var pArray = new Array();
    if (widgetsAdded[ctrlName]!=null)
    {    
        pArray = widgetsAddedArray[ctrlName];                
    }
    
    pArray.push(params);
    
    widgetsAdded[ctrlName] = params;
    widgetsAddedArray[ctrlName] = pArray;
    
    var newScript = document.createElement('script');
    newScript.type = 'text/javascript';    

    newScript.src = jsFile;
      
    headID.appendChild(newScript);

}

