
function ShowHide(divId,spanId)
{
  //Get the element style
  isDisplayed = document.getElementById(divId).style.display
  if(isDisplayed!='block')
    {
      document.getElementById(divId).style.display='block';
      document.getElementById(spanId).src=icon_path + '/v-icon_minus.png';
    }
  else
    {
      document.getElementById(divId).style.display='none';
      document.getElementById(spanId).src=icon_path + '/v-icon_plus.png';
    }
}

function Expand(divId,spanId)
{
  //Get the image src
  icon_src=icon_path + document.getElementById(spanId).src
  
  if(icon_src.indexOf("icon_expand") >= 0)
    {
      
      document.getElementById(spanId).src=icon_path + '/v-icon_collapse.png';
	  document.getElementById(spanId).title="Collapse List";
	  
	  //get all the li's in the menu
		var lis = document.getElementsByTagName('li');
		for(var i = 0;i < lis.length;i++)
		{
			//find all the li's that have the class "showHide" and are in the current cluster "cluster_id"
			if(lis[i].className.indexOf("showHideClose") >= 0 && lis[i].id.indexOf(divId +"_") >= 0)
				{
					lis[i].className="showHideActive";
				}
		}
    }
  else
    {
      
      document.getElementById(spanId).src=icon_path + '/v-icon_expand.png';
	  document.getElementById(spanId).title="Expand List";
	  //get all the li's in the menu
		var lis = document.getElementsByTagName('li');
		for(var i = 0;i < lis.length;i++)
		{
			//find all the li's that have the class "showHide" and are in the current cluster "cluster_id"
			if(lis[i].className.indexOf("showHideClose") >= 0 && lis[i].id.indexOf(divId +"_") >= 0)
				{
					
					lis[i].className="showHideOpen";
				}
				
			if(lis[i].className.indexOf("showHideActive") >= 0 && lis[i].id.indexOf(divId +"_") >= 0)
				{
					lis[i].className="showHideClose";
				}
		}
    }
}


function HideAll()
{
 var uls,i,divs,spans,imgs,imgIdStr;
 
 //Get all the ul's tags
 uls=document.getElementsByTagName('ul');
 divs=document.getElementsByTagName('div');
 spans=document.getElementsByTagName('span');
 imgs=document.getElementsByTagName('img');
 
 
 for (i = 0; i <= uls.length-1; i++)
 {
   if(uls[i].style.display=='block')
  {
    uls[i].style.display='none';
  }
 }
 
 for (i = 0; i <= divs.length-1; i++)
 {
   if(divs[i].style.display=='block')
  {
    divs[i].style.display='none';
  }
 }
 
 for (i = 0; i <= spans.length-1; i++)
 {
   if(spans[i].style.display=='block')
  {
    spans[i].style.display='none';
  }
 }
 
 //Change cluster's icons from v-icon_minus.png to v-icon_plus.png
 for (i = 0; i <= imgs.length-1; i++)
 {
   imgIdStr = imgs[i].id; 
   if ( imgIdStr.indexOf("_Plus") > -1 )
   {
		document.getElementById(imgs[i].id).src=icon_path + '/v-icon_plus.png';
   }
   
 }
 
}

//Get URL parameter's value
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( 
     aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
    return strReturn;
} 



function OpenSelected(str, n)
{
  
  var id = str;
  var checkID = id.substr(0,1);
  
  //find and display the links from the menu "Topic"
  if (checkID == "c")
  {
	  
	var cluster_id = id.substr(0,2);
	
	
	//remove the added "c" from the id
	var CutFrom = str.indexOf("_") + 1;
	
    var id = id.substr(CutFrom,id.length);

    
    var level_array = id.split(".")
    var str_id = ""
    var display_id = ""
    for(i = 0; i < level_array.length-1; i++)
    {
      
      str_id = str_id + level_array[i] + "."
      display_id = str_id.substr(0,str_id.length-1);
      document.getElementById(cluster_id + "_UL" + display_id).style.display='block';
	  document.getElementById(cluster_id + "_Plus" + display_id).src=icon_path + '/v-icon_minus.png';
    }
    
    //mark the selected link
	
    if (document.getElementById(cluster_id + "_" + id))
    {
      document.getElementById(cluster_id + "_" + id).className="selected";
	  //document.getElementById(cluster_id + "_" + id).title="Selected Item"
    } 
	
	//change expand's style from none to block
	
	if (eval(level_array[0])>n)
	{
		
		//get all the li's in the menu
		var lis = document.getElementsByTagName('li');
		for(var i = 0;i < lis.length;i++)
		{
			//find all the li's that have the class "showHide" and are in the current cluster "cluster_id"
			if(lis[i].className.indexOf("showHideClose") >= 0 && lis[i].id.indexOf(cluster_id +"_") >= 0)
				{
					lis[i].className="showHideActive";
				}
		}
		
		document.getElementById(cluster_id + "_icon").src=icon_path + '/v-icon_collapse.png';
		document.getElementById(cluster_id + "_icon").title="Collapse List";
			
	 }
  }  
  
  //find and display the links from all the other menus
  
  if (checkID == "f")
  {
	
	var facet_array = str.split(".")
	
	//remove the added "f" from the id
    var facetid = facet_array[1];
	
    //if the link selected's style = display:none 
    if (eval(facetid)>n)
    {
		
      document.getElementById("expand_" + facet_array[0]).style.display='block';
      document.getElementById("icon_" + facet_array[0]).src=icon_path + '/v-icon_collapse.png';
    }
   
    //mark the selected link
    if (document.getElementById(str))
    {
	  	
      document.getElementById(str).className="selected";
    }
  }
  displayCF();
}
function displayCF()
{
  var clusterPane = document.getElementById("contentwrap_clustering");
  if (clusterPane) {
    clusterPane.className = "showCluster";
  }
}
function OpenSelected(str, n)
{
  
  var id = str;
  var checkID = id.substr(0,1);
  
  //find and display the links from the menu "Topic"
  if (checkID == "c")
  {
	  
	var cluster_id = id.substr(0,2);
	
	
	//remove the added "c" from the id
	var CutFrom = str.indexOf("_") + 1;
	
    var id = id.substr(CutFrom,id.length);

    
    var level_array = id.split(".")
    var str_id = ""
    var display_id = ""
    for(i = 0; i < level_array.length-1; i = i + 1)
    {
      
      str_id = str_id + level_array[i] + "."
      display_id = str_id.substr(0,str_id.length-1);
      if(document.getElementById(cluster_id + "_UL" + display_id) != null){
          document.getElementById(cluster_id + "_UL" + display_id).style.display='block';
	  document.getElementById(cluster_id + "_Plus" + display_id).src=icon_path + '/v-icon_minus.png';
      }
    }
    
    //mark the selected link
	
    if (document.getElementById(cluster_id + "_" + id))
    {
      document.getElementById(cluster_id + "_" + id).className="selected";
	  //document.getElementById(cluster_id + "_" + id).title="Selected Item"
    } 
	
	//change expand's style from none to block
	
	if (eval(level_array[0])>n)
	{
		
		//get all the li's in the menu
		var lis = document.getElementsByTagName('li');
		for(var i = 0;i < lis.length;i = i + 1)
		{
			//find all the li's that have the class "showHide" and are in the current cluster "cluster_id"
			if(lis[i].className.indexOf("showHideClose") >= 0 && lis[i].id.indexOf(cluster_id +"_") >= 0)
				{
					lis[i].className="showHideActive";
				}
		}
		
		document.getElementById(cluster_id + "_icon").src=icon_path + '/v-icon_collapse.png';
		document.getElementById(cluster_id + "_icon").title="Collapse List";
			
	 }
  }  
  
  //find and display the links from all the other menus
  
  if (checkID == "f")
  {
	
	var facet_array = str.split(".")
	
	//remove the added "f" from the id
    var facetid = facet_array[1];
	
    //if the link selected's style = display:none 
    if (eval(facetid)>n)
    {
		
      document.getElementById("expand_" + facet_array[0]).style.display='block';
      document.getElementById("icon_" + facet_array[0]).src=icon_path + '/v-icon_collapse.png';
    }
   
    //mark the selected link
    if (document.getElementById(str))
    {
	  	
      document.getElementById(str).className="selected";
    }
  }
  displayCF();
}

