//$Id: IncludeJS.js,v 1.1 2008/09/23 12:14:28 shanmugampl Exp $
function includeMainScripts(contextPath)
{
  var scriptsToInclude = "";
  if(parent["StateHandling.js"] != null)
  {
    return;
  }
  scriptsToInclude += getScriptInc(contextPath + "/framework/javascript/StateHandling.js");
  scriptsToInclude += getScriptInc(contextPath + "/framework/javascript/ViewUtils.js");
  scriptsToInclude += getScriptInc(contextPath + "/framework/javascript/ResponseHandling.js");
  scriptsToInclude += getScriptInc(contextPath + "/framework/javascript/DynamicContent.js");
  scriptsToInclude += getScriptInc(contextPath + "/framework/javascript/MenuAPI.js");
  scriptsToInclude += getScriptInc(contextPath + "/framework/javascript/DataVariableHandler.js");

  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/Utils.js");
  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/ComponentActions.js");
  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/ShowHideBox.js");
  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/TableHandling.js");
  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/FormHandling.js");
  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/CommonViewRowSelection.js");
  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/ListUtils.js");
  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/listColumnChooser.js");
  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/Dialog.js");
  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/Effects.js");
  
  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/TabCust.js");

  //scriptsToInclude += getScriptInc(contextPath + "/components/javascript/TableLayout.js");
  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/generatedTableScripts.js");
  scriptsToInclude += getScriptInc(contextPath + "/components/javascript/generatedMenuScripts.js");


  //scriptsToInclude += getScriptInc(contextPath + "/components/javascript/viewcreation/DO.js");
  //scriptsToInclude += getScriptInc(contextPath + "/components/javascript/viewcreation/AutoCompleteQuerySpecific.js");
  //scriptsToInclude += getScriptInc(contextPath + "/components/javascript/viewcreation/TmpTableConstants.js");

  parent.document.writeln(scriptsToInclude);
  parent["StateHandling.js"] = true;  
}


function getScriptInc(scriptFilePath)
{
   return "<script src='" + scriptFilePath + "' type='text/javascript'></script>";
}

function includeJS(scriptFilePath,win)
{
   var index = scriptFilePath.lastIndexOf('/');
   var fileName = scriptFilePath;
   if(index > -1)
   { 
     fileName = scriptFilePath.substring(index + 1);
   }
   if(parent[fileName] != null)
   {
     return;
   }
   if(parent == win)
   { //This check is done as otherwise the script loading is done in a separate thread in IE.
      parent.document.writeln(getScriptInc(scriptFilePath));
   }
   else
   {// This check is done as otherwise the ui becomes blank when trying to update the document from iframe.
      var doc = parent.document;
      includeScriptInDoc(doc,scriptFilePath);
   }
   parent[fileName] = true;
}


function includeScriptInDoc(doc,scriptFilePath)
{
   var e = doc.createElement("script");
   e.src = scriptFilePath;
   e.type="text/javascript";
   doc.getElementsByTagName("head")[0].appendChild(e);  
}


