 /// <summary>
 /// This function change the image of the node from on to off according to the action param 
 /// Node: It is possible that when mouse over occurs the image is already with the _on since
 /// in the code behind we changed the selected node to the on image.
 /// </summary>
 function SetTreeNodeImage(action)
 {      
    //Get the image we just moved over
    var oElement = event.srcElement;
    
    //Get the img object from the current item that the mouse is over or out        
    if(oElement.tagName != 'IMG')
    {
	    return;
	}	
	
	//Now change the image according to the src of the image and the action wanted		 				
	var imageName = "";
	var imageURLPrefix = oElement.src.substring(0,oElement.src.lastIndexOf("/") + 1);		    				
	
	if(action == "TurnOn")
	{		 		
	    var imageName =  oElement.src.substring(oElement.src.lastIndexOf("/") + 1,oElement.src.length);	    
	    var newImageName = "";	    
	    if(imageName.indexOf("_on") == -1)
	    {
	        newImageName = 	imageName.replace(".gif","_on.gif");   	    		    	    	    	    
	    }
	    else
	    {
	        newImageName = imageName;
	    }
	    oElement.src = imageURLPrefix + newImageName;		    
	}
	if(action == "TurnOff")
  {   
     var imageName =  oElement.src.substring(oElement.src.lastIndexOf("/") + 1,oElement.src.length);
      if(imageName.indexOf(GetLastClikedID()) == -1)
      {
         var newImageName = imageName.replace("_on",""); 
         oElement.src = imageURLPrefix + newImageName;      
       }   
   }		        
 }  
//------------------------------------------------- 
 function SetCollapseExpand(id,numberOfChilds)
{
    //Change the style of the row according to the operation
    //============================================================        
    //get start position for counting the childs
    var startIndex = parseInt(id.substring(id.indexOf("_")+ 1,id.length));                
    var objToCahngeStyle;        
   
       for(var i = startIndex + 1;i<= startIndex + numberOfChilds;i++)
       {
           //Get the object to change his style and the style of the sibling td
           var objToCahngeStyle = document.all["menuItem_" + i.toString()];                              
           objToCahngeStyle.style.display = "block";              
           objToCahngeStyle.parentElement.childNodes[0].style.display = "block";                
        }
}   
//-------------------------------------------------
function InsertHtml(sDivID, sHTML)
//       ~~~~~~~~~~
{
  var oDiv = document.getElementById(sDivID);
  oDiv.outerHTML = sHTML;    
}
//-------------------------------------------------

function InsertFlash(sDivID, sParams, sSrc, sFlashVars)
//       ~~~~~~~~~~~
{
  var oDictionary = new ActiveXObject("Scripting.Dictionary");
  oDictionary.add ("sWidth", "100%");
  oDictionary.add ("sHeight", "100%");
  oDictionary.add ("sBgColor", "");
  oDictionary.add ("sAlign", "");
  oDictionary.add ("sID", "");
  oDictionary.add ("sWmode", "");  
  oDictionary.add ("sSalign", "");  
  oDictionary.add ("sFlashVars", ""); 

  arrParams = sParams.split('&');  
    
  for (var i=0; i<arrParams.length; i++)
  {     
    oDictionary.Item(arrParams[i].split("=")[0]) = arrParams[i].split("=")[1];                
  }  
  
  if(sFlashVars != undefined)
    oDictionary.Item('sFlashVars') = sFlashVars;
  
  var oDiv = document.getElementById(sDivID);
  var sFlash = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' + 
                ' WIDTH=' + oDictionary.Item('sWidth') + ' HEIGHT=' + oDictionary.Item('sHeight') + ' id=' + oDictionary.Item('sID') + ' ALIGN=' + oDictionary.Item('sAlign') + ' VIEWASTEXT>' + 
                ' <PARAM NAME="movie" VALUE=' + sSrc + '>' + 
                ' <PARAM NAME="quality" VALUE="high">' + 
                ' <PARAM NAME="FlashVars" VALUE=' + oDictionary.Item("sFlashVars") + '>' +
                ' <PARAM NAME="bgcolor" VALUE=' + oDictionary.Item('sBgColor') + '>' + 
                ' <PARAM NAME="menu" VALUE="false">' + 
                ' <PARAM NAME="wmode" VALUE=' + oDictionary.Item('sWmode') + '>' + 
                ' <PARAM NAME="salign" VALUE=' + oDictionary.Item('sSalign') + '>' + 
                ' <EMBED src=' + sSrc + ' quality="high" bgcolor=' + oDictionary.Item('sBgColor') + ' WIDTH=' + oDictionary.Item('sWidth') + ' HEIGHT=' + oDictionary.Item('sHeight') + 
                ' NAME=' + oDictionary.Item('sID') + ' ALIGN=' + oDictionary.Item('sAlign') + ' salign=' + oDictionary.Item('sSalign') + ' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>' + 
                ' </OBJECT>';
  InsertHtml (sDivID, sFlash);    
}
//-------------------------------------------------