function replace_H1()
{
	headlines = document.getElementsByTagName("h1");
	for(h in headlines)
	{
		if(headlines[h].className == "headline_image")
		{
			// später mit ajax wegen special chars
			rnd_id = Math.round(Math.random()*100);
			headlines[h].id = "h1_"+rnd_id;
			loadPage("ajax/hl_content.ajax.php?hl="+makeValidString(headlines[h].innerHTML), "h1_"+rnd_id);
			/*
			hl_img			= document.createElement("img");
			hl_img.src		= "h1_img.php?hl="+headlines[h].innerHTML;
			hl_img.alt		= headlines[h].innerHTML;
			hl_img.border	= 0;
			headlines[h].parentNode.insertBefore(hl_img, headlines[h]);
			headlines[h].parentNode.insertBefore(document.createElement("br"), headlines[h]);
			headlines[h].parentNode.removeChild(headlines[h]);
			*/
			
		}
		else if(headlines[h].className == "hl_right_SB")
		{
			hl_img			= document.createElement("img");
			hl_img.src		= "img/hl_right_Social_Bookmarks.png";
			hl_img.alt		= headlines[h].innerHTML;
			hl_img.border	= 0;
			headlines[h].innerHTML = "";
			headlines[h].appendChild(hl_img);
		}
		else if(headlines[h].className == "hl_left")
		{
			
		}
	}
}

function makeValidString(inp)
{
	inp = inp.replace(/Ä/g, "&Auml;");
	inp = inp.replace(/ä/g, "&auml;");
	inp = inp.replace(/Ö/g, "&Ouml;");
	inp = inp.replace(/ö/g, "&ouml;");
	inp = inp.replace(/Ü/g, "&Uuml;");
	inp = inp.replace(/ü/g, "&uuml;");
	inp = inp.replace(/ß/gi, "&szlig;");
	inp = inp.replace(/€/gi, "&euro;");
	inp = inp.replace(/ß/gi, "&szlig;");
	// inp = inp.replace(/\"/gi, "&quot;");
	
	inp = inp.replace(/\?/gi, "**QUESTIONMARK**");
	inp = inp.replace(/=/gi, "**EQUAL**");
	inp = inp.replace(/&/gi, "**AND**");
	inp = inp.replace(/#/gi, "**RAUTE**");
	inp = inp.replace(/\+/gi, "**PLUS**");
	// alert(inp);
	return inp;
}

function $(id) { return document.getElementById(id); }
function preloadImages()
{
	myimages = new Array();
	for (i=0;i<preloadImages.arguments.length;i++)
	{
		myimages[i]=new Image()
		myimages[i].src = preloadImages.arguments[i]
	}
}
var lastopen = "<?php echo(str_replace("/", "-", substr(strstr($load, '/'), 1))); ?>";

function mainmenimg(i, e)
{
	document.getElementById(e).src = i;
}


function opensub_fnc(subid)
{
	path = subid;
	parts = path.split("-");
	new_path = "";
	for(p=0; p<parts.length; p++)
	{
		if(new_path != "") new_path += "-";
		new_path += parts[p];
		class_add = "";
		// if(new_path.split("-").length>2) class_add = "_gt_2";
		// alert(new_path);
		if($("sub_"+new_path+"-"))
		{
			$("sub_"+new_path+"-").style.display = "";
			$("sub_"+new_path+"-").className = "sub_nav_normal";
		}
		if($(new_path))
		{
			// $(new_path).className = "subnav_active"+class_add;
			$(new_path).className = "sub_nav_active";
			
			// alert(new_path+" known");
		}
	}
}
function closesub_fnc(subid)
{
	path = subid;
	parts = path.split("-");
	new_path = "";
	for(p=0; p<parts.length; p++)
	{
		if(new_path != "") new_path += "-";
		new_path += parts[p];
		class_add = "";
		// if(new_path.split("-").length>2) class_add = "_gt_2";
		// alert(new_path);
		if($("sub_"+new_path+"-"))
		{
			$("sub_"+new_path+"-").style.display = "none";
		}
		if($(new_path))
		{
			// $(new_path).className = "subnav_normal"+class_add;
			$(new_path).className = "";
			// alert(new_path+" known");
		}
	}
}
function opensub(subid)
{
	if(lastopen != false) closesub_fnc(lastopen);
	opensub_fnc(subid);
	lastopen = subid;
}
function in_array(xstr, xarr)
{
	for(a in xarr)
	{
		// alert(xarr[a] + " ?= " + xstr);
		if(xarr[a] == xstr) return true;
	}
	return false;
}

function open_callback()
{
	if($('callback_box').style.display=='none')
	{
		$('callback_box').style.display='';
		window.location.hash = "#callback";
	}
	else
	{
		$('callback_box').style.display='none';
	}
}
function open_empfehlen()
{
	if($('empfehlen_box').style.display=='none')
	{
		$('empfehlen_box').style.display='';
		window.location.hash = "#empfehlen";
	}
	else
	{
		$('empfehlen_box').style.display='none';
	}
}

function search_keyword_suggestion_X(fld, _target)
{
	_standard_value = "";
	args = search_keyword_suggestion.arguments
	if(args.length > 2) _standard_value = args[2];
	if(fld.value.length > 2 && fld.value != _standard_value)
	{
		loadPage('ajax/search_keyword_suggestion.ajax.php?keyword='+fld.value+"&target="+_target+"&field="+fld.id, _target);
		
	}
	else
	{
		document.getElementById(_target).style.display='none';
	}
}

function search_keyword_suggestion(_standard_value)
{
	fld = $('search');
	_target = "keywordsuggestion";
	if(fld.value.length > 2 && fld.value != _standard_value)
	{
		loadPage('ajax/search_keyword_suggestion.ajax.php?keyword='+fld.value+"&target="+_target+"&field="+fld.id, _target);
		
	}
	else
	{
		document.getElementById(_target).style.display='none';
	}
	sug_delay = null;
}
sug_delay = null;
function start_keyword_suggestion(_standard_value)
{
	if(sug_delay != null) window.clearTimeout(sug_delay);
	sug_delay = window.setTimeout("search_keyword_suggestion('"+_standard_value+"')", 500);
}
