// Kunstarter
function drawKunstarterDropDown(strDefaultvalue) {
	// outputting "select" element
	document.write("<div class='select findkunstart'>");
	document.write("<a href='#' id='DDKunstart' name='DDKunstart' onclick='return dropdownmenu(this,event,\"DDKunstartItems\")' onmouseout='delayhidemenu()'>");
	document.write(strDefaultvalue);	
	document.write("</a>");
	document.write("</div>");
	
	// outputting each "option" block
	document.write("<div id='DDKunstartItems' class='anylinkcss option'>");
		var c=0;
		while (c<KunstarterArr.length)
		{
			//alert(c);
			document.write("<a href='#' id='DDKunstart" + c + "' onclick='javascript: doSelect(this);' ");
			if(c != (KunstarterArr.length-2)) {
				document.write(" class='sep' ");
			}
			document.write(">" + KunstarterArr[c] + "</a>");
			c+=2;
		}
	document.write("</div>");

}

// Scener
function drawScenerDropDown(strDefaultvalue) {
	// outputting "select" element
	document.write("<div class='select findscener'>");
	document.write("<a href='#' id='DDScene' name='DDScene' onclick='return dropdownmenu(this,event,\"DDSceneItems\");' onmouseout='delayhidemenu();'>");
	document.write(strDefaultvalue);	
	document.write("</a>");
	document.write("</div>");
	
	// outputting each "option" block
	document.write("<div id='DDSceneItems' class='anylinkcss option'>");
		var c=0;
		while (c<ScenerArr.length)
		{
			//alert(c);
			document.write("<a href='#' id='DDScene" + c + "' onclick='javascript: doSelect(this);' ");
			if(c != (ScenerArr.length-2)) {
				document.write(" class='sep' ");
			}
			document.write(">" + ScenerArr[c] + "</a>");
			
			c+=2;
		}
	document.write("</div>");

}

// Forestillinger
function drawForestillingerDropDown(strDefaultvalue) {

	//alert(document.getElementById('DDScene').getAttribute("name"));
	if (document.getElementById('DDScene').getAttribute("name")!= 'activated') {
		// outputting "select" element
		document.write("<div class='select findforestillinger'>");
		//onclick='return Verifydropdownmenu(this,event,\"DDForestillingItems\")' onclick='return dropdownmenu(this,event,\"DDForestillingItems\");'
		document.write("<a href='#' id='DDForestilling' name='DDForestilling' onclick='return Verifydropdownmenu(this,event,\"DDForestillingItems\")'  onmouseout='return delayhidemenu()'>");
		document.write(strDefaultvalue);	
		document.write("</a>");
		document.write("</div>");

		
		
		drawForestillingerItems("","","","");
		
	}
	
}



function deleteForestillingerItems()
{
	var objDiv = document.getElementById("DDForestillingItems");
	if(objDiv!=null)
		objDiv.innerHTML = "";
}



function drawForestillingerItems(CurrentKunstart, CurrentScene, defaultKunstart, defaultScene)
{

	//alert(CurrentKunstart);
	//alert(CurrentScene);
	//alert(defaultKunstart);
	//alert(defaultScene);

	var strOut = "";
	var filterKunstart = false;
	var filterScene = false;
	var idKunstart, idScene
	var c=0;
	var loopflag=true;
	var EmptyResult=true;
	var objDiv = document.getElementById("DDForestillingItems");
	var SeperatorInsertedLast = false;
	
	if((CurrentKunstart!=defaultKunstart) && (CurrentKunstart!=""))
	{
		filterKunstart=true;
		c=0;
		while (c<KunstarterArr.length)
		{
			if(	KunstarterArr[c] == CurrentKunstart){
				idKunstart=KunstarterArr[c+1];
				}
			c+=2;
		}
		//alert("Valgt kunstart: " + idKunstart);
	}
		
	if((CurrentScene!=defaultScene) && (CurrentScene!=""))
	{
		c=0;
		while (c<ScenerArr.length)
		{
			if(	ScenerArr[c] == CurrentScene){
				idScene=ScenerArr[c+1];
				}
			c+=2;
		}
		filterScene=true;
		//alert("Valgt scene: " + idScene);
	}
	
	
	// outputting each "option" block

	if(objDiv == null)
		strOut = "<div id='DDForestillingItems' class='anylinkcss option'>";
	else
	{
		objDiv.innerHTML = "";
		objDiv.style.display = "block";
	}
		
	c=0;
	
	while (c<ForestillingArr.length)
	{
		
		loopflag = true;
		if(filterKunstart && (ForestillingArr[c+1]!=idKunstart))
			loopflag=false;
		if(filterScene && (ForestillingArr[c+2]!=idScene))
			loopflag=false;
		
		if(loopflag)
		{
			SeperatorInsertedLast = false;
			EmptyResult=false;
			strOut += "<a href='#' id='DDForestilling" + c + "' onclick='javascript: doSelect(this);' ";
			if(c != (ForestillingArr.length-3)) {
				strOut += " class='sep' ";
				SeperatorInsertedLast = true
			}
			strOut += ">" + ForestillingArr[c] + "</a>";
		}
		c+=3;
		loopflag=true;
	}
	
	// remove last seperator line, if nessesary
	if (SeperatorInsertedLast)
	{
		var myString = new String(strOut);
		var idxOcc= myString.lastIndexOf("class='sep'");
		var string1 = myString.substr(0, idxOcc );
		var string2 = myString.substr(idxOcc+11, myString.length - idxOcc);
		strOut = string1+string2;
		
	}
	
	if(objDiv == null)
		strOut += "</div>";
	
	// If results of combination are empty, dont show any divs...
	if(EmptyResult && objDiv != null)
	{	
		objDiv.style.display = "none";
	}
	
	//alert(strOut);
	if(objDiv == null)
		document.write(strOut);
	else
	{
		var parentobj = document.getElementById("DDForestillingItems");
		parentobj.innerHTML = strOut;
	}
}




