/*

Standaard functies bij indexpagina van sfeervanbeheer.nl

*/

function leeshtml()
{
// Kijk of er als parameter een html-bestand is meegegeven en zo ja plaats dit dan in frame home
// opstart is als volgt: index.html?pagina=bestand.html

	var code= window.location.search;
//	alert("0 code="+code+"|");
	var posP = code.indexOf("&amp;");
	if ( posP != -1 )
	{
//		alert("1 code="+code+"|");
		var a = code.substr(0, posP + 1) + code.substring(posP + 5);
		code = a;
//		alert("2 code="+code+"|");
	}
	
	// volgorde: index.html[?pagina=...[&scroll= ..][&li=.. [&re=..]]]

	var posP = code.indexOf("?pagina=");
	if ( posP != -1 )
	{
		// Er is een pagina meegegeven
		var pagina = "";
		var intscroll = "";
		var links = "";
		var rechts = "";
		var posS = code.indexOf("&scroll=");
		var posL = code.indexOf("&li=");
		var posR = code.indexOf("&re=");
		if ( (posS == -1 ) && (posL == -1 ))
		{
			pagina = code.substring(posP + 8);
//			alert("code="+code+"| pagina="+pagina+"|");
		}
		else
		{
			if (posS != -1)
			{
				// interne link aanwezig
				pagina = code.substring(posP + 8, posS);
				if (posL != -1)
				{
					// ook linkerpagina is aanwezig
					intscroll = "#"+ code.substring(posS + 8, posL);
				}
				else
				{
					// linkerpagina is niet aanwezig
					intscroll = "#"+ code.substring(posS + 8);
				}
			}
			if (posL != -1)
			{
				// linkerpagina is aanwezig
				if (posS == -1)
				{
					// geen interne link aanwezig
					pagina = code.substring(posP + 8, posL);
				}

				if (posR != -1 )
				{
					// rechterpagina is ook aanwezig
					links = code.substring(posL + 4 , posR );
				}
				else
				{
					// rechterpagina is niet aanwezig
					links = code.substring(posL + 4 );
				}
				
				if (links == "leeg")
				{
					// linkerpagina heeft speciale vulling
					top.left.location = "left.html";
				}
				else
				{
					// gebruik code van linkerpagina
					top.left.location = "staticmenuleft.html?code=" + links;
				}
	
				posR = code.indexOf("&re=");
				if (posR == -1)
				{
					// vul rechterpagina met default pagina
					top.right.location = "right.html";
				}
				else
				{
					// rechterpagina is ook aanwezig
					rechts = code.substring(posR + 4);
					if (rechts == "leeg")
					{
						// rechterpagina heeft speciale vulling
						top.right.location = "right.html";
					}
					else
					{
						if (rechts.length > 3)
						{
							// rechterpagina bevat htmlpagina ipv code
							top.right.location = rechts;   // html file
						}
						else
						{
							// rechterpagina bevat code
							top.right.location = "staticmenuright.html?code=" + rechts;
						}
					}
				}
			}
		}
		top.home.location = pagina + intscroll;
	}
	else
	{
		top.home.location = 'start.html';
	}
}
