// Table Data Show / Hide

// Span Deklarationen

var sub_st = 7;
var sub_end = 17;
/*

function onLoad()
{
	 var a = document.cookie;
			var cookiename = a.substr(0,a.search('='));
			var cookiewert = a.substr(a.search('=')+1,a.search(';'));
			// Zahl aus cookiewert slicen
				// var b  = cookiewert.slice(2);
				// String parsen to int
			//	var zahl = parseInt(b, 10);
			var slice = cookiewert.slice(0,1);
			//document.write(slice.toString());
	document.getElementById(slice).style.display = 'block';
						
}
*/
    function getIndicatorSpans() {
                var els = document.getElementsByTagName("div");
                var ar = [];
                
                for (var x = 0; x < els.length; x++) {
                    if ((els[x].className == "indicator")||(els[x].className == "indicator_sub"))
                        ar.push(els[x]);
                }
                return ar;
            }




// opens and closes all spans

function showid(id)
	{
	
	var leng = getIndicatorSpans();
	var len = leng.length;

	for (var i = 1; i < len+1; i++)
		{
			document.getElementById(i).style.display = 'none';		
		}

	
		if(document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'block';
			
			document.cookie =  'wert='+ id;
		}
	else
		{
			document.getElementById(id).style.display = 'none';	
		}
}
	

// opens and closes spans with class "indicator_sub"


function showid_sub(id)
	{
	
	var leng = getIndicatorSpans();
	var len = leng.length;

	 //document.write(len.toString());

	for (var i = 1; i < len+1; i++)
		{
			if (document.getElementById(i).className == "indicator_sub")
			{
			document.getElementById(i).style.display = 'none';	
			}
		}

		if(document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'block';
		}
	else 
		{
			document.getElementById(id).style.display = 'none';	
		}
}



// opens and closes spans with class individually


function showid_sub_2(id)
	{
	
	var leng = getIndicatorSpans();
	var len = leng.length;

	 //document.write(len.toString());

	
		if(document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'block';
		}
	else 
		{
			document.getElementById(id).style.display = 'none';	
		}
}




		
function showall()

{
	var i = sub_st;
		
	for (i ; i < sub_end+1; i++)
		{
					document.getElementById(i).style.display = 'block';					
		}
}


// Searchbar


function OpenSearch(source, query){
		var strquery;
		
		
			
		switch(source)
		{
			case "GmbH" :
				var url = "http://gmbh-web/Search.aspx?k=" + query;
				window.open(url,'gmbhsuche','toolbar=yes,status=no,scrollbars=yes,location=no,menubar=no,directories=no,width=875,height=650');
				return;			
			case "MSWeb" :
				var url = "http://msw-sfe-05/_layouts/1033/IntranetResults.aspx?s=Search%20Intranet%2cThis%20Portal%2cMicrosoft%20Information%2cIndustries%2cInternal%20Services%2cInternational%2cProducts%2cSales%20&amp;%20Marketing%2cCompetition%2cPartners%2cTechnologies%2cTraining%2cLibrary%20Catalog%2cMicrosoft%20Images%2cMarket%20Research%2cDistribution%20Lists%2cAll%20Content%2cTestScope&pt=SDAV%3Ahref%2cContains%2cgmbhweb%2cAnd%2c&SearchPageSource=IntranetSearch&k=" + query;
				window.open(url,'gmbhsuche','toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,width=875,height=650');
				return;
		   
		   case "Sharepoint" :
				var url = "http://msweb/_layouts/1033/IntranetResults.aspx?s=Search%20Intranet%2cThis%20Portal%2cMicrosoft%20Information%2cIndustries%2cInternal%20Services%2cInternational%2cProducts%2cSales%20&amp;%20Marketing%2cCompetition%2cPartners%2cTechnologies%2cTraining%2cLibrary%20Catalog%2cMicrosoft%20Images%2cMarket%20Research%2cDistribution%20Lists%2cAll%20Content%2cTestScope&pt=SDAV%3Ahref%2cContains%2cteamemea%2cAnd%2c&SearchPageSource=IntranetSearch&k=" + query;
				window.open(url,'gmbhsuche','toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,width=875,height=650');
				return;
				
			case "LeoDictionary" :
				var url = "http://dict.leo.org/?search=" + query;
				window.open(url,'window_name','toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,width=850,height=600')
				return;
			
			case "Glossar" :
				var url = "http://briefingportal/glossar/glossar.aspx?dir=search result&search=" + query;
				window.open(url,'640x480','toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,width=600,height=510');
				return;
			
			case "MSN" :
				var url = "http://search.msn.de/results.aspx?q=" + query;
				window.open(url,'800x600','toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,width=680,height=510');
				return;
			
			default :
			strquery = "http://msw-sfe-05/_layouts/1033/IntranetResults.aspx?s=Search%20Intranet%2cThis%20Portal%2cMicrosoft%20Information%2cIndustries%2cInternal%20Services%2cInternational%2cProducts%2cSales%20&amp;%20Marketing%2cCompetition%2cPartners%2cTechnologies%2cTraining%2cLibrary%20Catalog%2cMicrosoft%20Images%2cMarket%20Research%2cDistribution%20Lists%2cAll%20Content%2cTestScope&pt=SDAV%3Ahref%2cContains%2cgmbhweb%2cAnd%2c&SearchPageSource=IntranetSearch&k=" + query; + "&s=" + source;
			window.open(strquery,'Search','');
		}
	}
	
	function prepareQuery()
		{
		
			var searchQuery = document.all.txtSearchQ.value;
			var searchSource;
			var i = document.all.ddlSearchSource.selectedIndex;
			if (i == -1)   return "";
			else  searchSource = (document.all.ddlSearchSource.options[i].value == "") ? document.all.ddlSearchSource.options[i].text : document.all.ddlSearchSource.options[i].value;
			
			if(searchQuery == "" || searchSource==""){return;}
			
			//searchSource = "GmbH";
			//searchQuery = "msdn";
			OpenSearch(searchSource, searchQuery);		
		}

	function prepareQuery_leo()
		{
		
			var searchQuery2 = document.all.txtSearchQ2.value;
						
			var searchfor = "LeoDictionary";
			OpenSearch(searchfor, searchQuery2);		
		}

function prepareQuery_glossar()
		{
		
			var searchQuery3 = document.all.txtSearchQ3.value;
						
			var searchfor2 = "Glossar";
			OpenSearch(searchfor2, searchQuery3);		
		}


// Dropdown Quicklink POP-UP



function goto(ele)
{
var i = ele.selectedIndex;
			if (i == -1 || ele.options[i].value.toString() == "")
			{   
				return "";
			}
			else 
			{
			
			var url = ele.options[i].value.toString();
			
			}
			
			window.open(url);
		
}


function getvar()
{

	var variablen = new Array();
	
	if(window.location.search != "") 
	{
		var QUERYSTRING = window.location.search
		var QUERYSTRING = QUERYSTRING.replace(/\?/,"");
		
		//trenne den querystring nach jedem & in teilstringe auf
		var teilstrings = QUERYSTRING.split("&");
		
		//durchlaufe jeden dieser teilstrings
		for (i=0;i<teilstrings.length;i++) 
			{
					//trenne den teilsring in weiteren teilstring auf,
					//trenne also variablennamen vom inhalt
					vararr = teilstrings[i].split("=");
					variablen[vararr[0]] = vararr[1];
			}
						
		
	
	var Ergebnis = variablen["id"].search(/s/);
if (Ergebnis != -1)
	{
	var erg = variablen["id"];

	
	if (erg.length == 3)
		{	
	//	alert(erg.length);
			var id_erg = erg.slice(0,2);
			showid_sub(id_erg);
		}
		else
		{
		//	alert(erg.length);
			var id_erg2 = erg.slice(0,1);
			showid_sub(id_erg2);
		}
	}
	else
	{ 
	// alert("gefunden");	
	showid(variablen["id"]);
	} 
//showid(variablen["id"]);
}



}
