window.onload = function() {
	if (!document.getElementById)
		return;
	
	var results = document.getElementById("search-results");
	if (results)
		return;
	
	var search = document.getElementById("site-search");
	var advanced = document.getElementById("site-search-advanced");
	var searchfunctions = document.getElementById("search-functions");
	
	if (!search || !advanced || !searchfunctions)
		return;
	
	advanced.style.display = 'none';
	
	var li = document.createElement('li');
	var a = document.createElement('a');
	
	a.href = "#";
	a.className = "icon open";
	a.appendChild (document.createTextNode('Avaa tarkennukset'));
	li.appendChild (a);
	searchfunctions.appendChild(li);
	
	a.onclick = function(){
		var text;
		
		if(advanced.style.display == 'none'){
			advanced.style.display = 'block';
			a.className = 'icon close';
			text = 'Sulje tarkennukset';
		}
		else{
			advanced.style.display = 'none';
			a.className = 'icon open';
			text = 'Avaa tarkennukset';		
		}
		
		a.replaceChild(document.createTextNode(text), a.firstChild);		
		a.blur();
		
		return false;
	};
};

function OpenTaskWindow(url)
{
	var newWindow = window.open(url, 'TaskWin', 'scrollbars=yes,width=575,height=540')
	newWindow.focus();
}

function OpenFlashWindow(url)
{
	var newWindow = window.open(url, 'FlashWin', 'scrollbars=yes,width=670,height=580')
	newWindow.focus();
}
