var fade_in = 0;
var ie = navigator.userAgent.toLowerCase().indexOf("msie")>-1 && navigator.userAgent.toLowerCase().indexOf("opera")< 0;

<!-- ************************************************** -->

function InitPage()
{
	FadeIn();
	ActivateHilightImages();
	ActivateHilightTableRows();
}

<!-- ************************************************** -->

function FIND(item) 
{
	if (window.mmIsOpera) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

<!-- ************************************************** -->

function GetQueryValue (query_name)
{
	var result = "";
	var url_str = document.location.href;
	var query_pos = url_str.indexOf ("?") + 1;
	if (query_pos >= 0)
	{
		var query_str = url_str.substr (query_pos);
		
		if (query_name != "")
		{
			var query_collection = query_str.split ("&");
			var single_query_str;
			var single_query;
			var query_val;
			var found = false;
			
			for (i = 0; i < query_collection.length && !found; i++)
			{
				single_query= query_collection [i].split ("=");
				if (single_query[0] == query_name)
				{
					query_val = single_query[1] + "";
					if (query_val != "undefined")
					{
						result = query_val;
					}
					found = true;
				}
			}
		}
		else
		{
			result = query_str;
		}
		return unescape (result);
	}
}

<!-- ************************************************** -->

function ToggleDiv (div_name)
{
	var obj_div = FIND (div_name);
	if (obj_div)
	{
		if (obj_div.style.visibility != "visible")
		{
			obj_div.style.visibility = "visible";
			obj_div.style.display = "block";
		}
		else
		{
			obj_div.style.visibility = "hidden";
			obj_div.style.display = "none";
		}
	}
}

<!-- ************************************************** -->

function ShowDiv (div_name)
{
	var obj_div = FIND (div_name);
	if (obj_div)
	{
		obj_div.style.visibility = "visible";
		obj_div.style.display = "block";
	}
}

<!-- ************************************************** -->

function HideDiv (div_name)
{
	var obj_div = FIND (div_name);
	if (obj_div)
	{
		obj_div.style.visibility = "hidden";
		obj_div.style.display = "none";
	}
}

<!-- ************************************************** -->

var ie_curtain_opacity = 100;
var ie_curtain_fade_speed = 6;
var other_curtain_height = 504;
var other_curtain_fade_speed = 6;

function FadeIn()
{
	var obj_curtain = FIND ("curtain");

	if (fade_in)
	{	
		if (ie)
		{
			if (obj_curtain)
			{
				if (ie_curtain_opacity >= 0)
				{
					obj_curtain.style.filter = "Alpha(opacity=" + ie_curtain_opacity + ", finishopacity=0, style=0)";
					ie_curtain_opacity -= ie_curtain_fade_speed;
					window.setTimeout ("FadeIn()", 1);
				}	
				
				if (ie_curtain_opacity <= 0)
				{
					HideDiv ("curtain");
				}
			}
		}	
		else
		{
			if (obj_curtain)
			{
				if (other_curtain_height >= 0)
				{
					obj_curtain.style.height = other_curtain_height;
					other_curtain_height -= other_curtain_fade_speed;
					window.setTimeout ("FadeIn()", 1);
				}
				
				if (other_curtain_height <= 0)
				{
					HideDiv ("curtain");
				}
			}
		}	
	}
	else
	{
		HideDiv ("curtain");
	}
}

<!-- ************************************************** -->

function SetBGImage (object_id, img_name)
{
	FIND (object_id).style.backgroundImage = "url(" + img_name + ")";
}

<!-- ************************************************** -->

function ZeigeProjekt (project_id)
{
	window.location.href = "projekt_" + project_id + ".html";
}

<!-- ************************************************** -->

function ZeigeHaus (house_id)
{
	window.location.href = "domizil_" + house_id + ".html";
}

<!-- ************************************************** -->
var old_small_image_obj = null;
var old_small_image_src = "";

function HandleSmallImage (small_image_obj)
{
	if (old_small_image_obj != null)
	{
		HilightImage (old_small_image_obj, true);
	}
	
	old_small_image_obj = small_image_obj;
	old_small_image_src = small_image_obj.src + "";
}

<!-- ************************************************** -->

function DeactSmallImage()
{
	HilightImage (old_small_image_obj, true);
	old_small_image_obj = null;
	old_small_image_src = "";
}

<!-- ************************************************** -->

function ShowLargeImage (small_image_obj)
{
	if (old_small_image_obj != small_image_obj)
	{
		HandleSmallImage (small_image_obj);
		var img_name = small_image_obj.src;
		img_name = img_name.replace ("_s.", "_l.");
		img_name = img_name.replace ("_m.", "_l.");
		FIND ('main_area_image').src = img_name;
	}
	ShowDivOnly ("large_image_container", "object_info");
	SetFatOnly ('', 'exclusive_text');
}

<!-- ************************************************** -->

function ChangeLargeImage (small_image_obj)
{
	if (old_small_image_obj != small_image_obj)
	{
		HandleSmallImage (small_image_obj);
		var img_name = small_image_obj.src;
		img_name = img_name.replace ("_s.", "_l.");
		img_name = img_name.replace ("_m.", "_l.");
		var bgobj = FIND ('main_area_complete');
		if (bgobj)
		{
			bgobj.style.backgroundImage = "url(" + img_name + ")";
		}
	}

}

<!-- ************************************************** -->

function ShowLargePlan (small_image_obj, large_image_name)
{
	if (old_small_image_obj != small_image_obj)
	{
		HandleSmallImage (small_image_obj);
		FIND ('main_area_image').src = large_image_name;
	}
	ShowDivOnly ("large_image_container", "object_info");
	SetFatOnly ('', 'exclusive_text');
}

<!-- ************************************************** -->

function HilightImage (img_obj, with_old)
{
	if (img_obj)
	{
		var source = img_obj.src + "";
		var new_source;
		var pos_ext = source.lastIndexOf (".");
		var pos_act = source.lastIndexOf ("_bw");
		
		if (pos_act != -1)
		{
			new_source = source.substr (0, pos_act) + source.substr (pos_ext);
			img_obj.src = new_source;
		}
		else
		{
			if (old_small_image_obj != img_obj || with_old)
			{
				new_source = source.substring (0, pos_ext) + "_bw" + source.substring (pos_ext);
				img_obj.src = new_source;
			}
		}
	}	
}

<!-- ************************************************** -->

function HilightThisImage()
{
	HilightImage (this);
}

<!-- ************************************************** -->

function ActivateHilightImages()
{	
	var allObjects = document.getElementsByTagName ('img');
	var ObjClass;

	for (i = 0; i < allObjects.length; i++)
	{
		ObjClass = allObjects[i].className + "";
		if (ObjClass.indexOf ("hilight") != -1)
		{
			allObjects[i].onmouseover = HilightThisImage;
			allObjects[i].onmouseout = HilightThisImage;
		}
	}
}

<!-- ************************************************** -->

function HilightThisDataLine (activate, tr_obj)
{
	tr_obj.bgColor = activate ? '#ffffff' : '#f2f2f2';
	
	var allObjects = tr_obj.getElementsByTagName ('img');
	var ObjClass;

	for (i = 0; i < allObjects.length; i++)
	{
		ObjClass = allObjects[i].className + "";
		if (ObjClass.indexOf ("passivelight") != -1)
		{
			HilightImage (allObjects[i]);
		}
	}
}

<!-- ************************************************** -->

function ActivateHilightTableRows()
{	
	var allObjects = document.getElementsByTagName ('tr');
	var ObjClass;

	for (i = 0; i < allObjects.length; i++)
	{
		ObjClass = allObjects[i].className + "";
		if (ObjClass.indexOf ("hilight") != -1)
		{
			allObjects[i].onmouseover = function() { HilightThisDataLine (true, this) };
			allObjects[i].onmouseout = function() { HilightThisDataLine (false, this) };
		}
	}
}

<!-- ************************************************** -->

function ShowDivOnly (div_name, div_category)
{
	var allObjects = document.getElementsByTagName ('div');
	var ObjClass;

	for (i = 0; i < allObjects.length; i++)
	{
		ObjClass = allObjects[i].className + "";
		if (ObjClass.indexOf (div_category) != -1)
		{
			if (allObjects[i].id == div_name)	ShowDiv (allObjects[i].id);
			else 											HideDiv (allObjects[i].id);
		}
	}
//	 SetFatOnly ('xxx', 'exclusive_text');
}

<!-- ************************************************** -->

function SetFatOnly (span_name, span_category)
{
	var allObjects = document.getElementsByTagName ('span');
	var ObjClass;

	for (i = 0; i < allObjects.length; i++)
	{
//	if (span_category == "exclusive_footer") alert (span_category);
		ObjClass = allObjects[i].className + "";
		if (ObjClass.indexOf (span_category) != -1)
		{
			if (allObjects[i].id == span_name)	SetTextFat (allObjects[i], true);
			else 											SetTextFat (allObjects[i], false);
		}
	}
}

<!-- ************************************************** -->

function SetTextFat (object, set_fat)
{
	object.style.fontWeight = (set_fat ? "bold" : "normal");
}

<!-- ************************************************** -->

function OpenWindow (win_href, win_title, win_width, win_height, win_center, with_scrollbars, win_resizable, with_bar)
{

	if (win_height > screen.availHeight - 50)
		win_height = screen.availHeight - 50;

	win_width = win_width - 0;
	if (with_scrollbars == 'true')
	{
		win_width += 20;
	}
	
	var win_flags = "width=" + win_width + ",height=" + win_height;
	win_flags += ",resizable=yes,dependent=yes";
	
	if (with_scrollbars == 'true')
	{
		win_flags += ",scrollbars=yes";
	}
	
	if (win_center)
	{
		var win_left = Math.ceil ((screen.availWidth - win_width) / 2);
		var win_top  = Math.ceil ((screen.availHeight - win_height) / 3);
		win_flags	+= ",left=" + win_left + ",top=" + win_top;
	}
	
	win_flags += ",resizable=" + ((win_resizable == "true") ? "yes" : "no");
	win_flags += ",location=" + ((with_bar == "true") ? "yes" : "no");
	win_flags += ",menubar=" + ((with_bar == "true") ? "yes" : "no");
	win_flags += ",toolbar=" + ((with_bar == "true") ? "yes" : "no");

	window.open (win_href, win_title, win_flags);
}

<!-- ************************************************** -->

function CheckWebForm (webform)
{
	var result = true;
	
	if (webform.name.value == "")
	{
		alert ("Bitte geben Sie Ihren Namen an!");
		webform.name.focus();
		result = false;
	}
	else if (webform.email.value == "")
	{
		alert ("Bitte geben Sie Ihre eMail-Adresse an!");
		webform.email.focus();
		result = false;
	}
	else if (!EmailValidator (webform.email.value))
	{
		alert ("Die eingegebene eMail-Adresse ist ungültig!");
		webform.email.focus();
		result = false;
	}

	return result;
}

<!-- ************************************************** -->

function EmailValidator (val_str)
{
	var result = true;

	if (val_str == "undefined")
	{
		result = false;
	}
	else if (!val_str || val_str == "")
	{
	}
	else
	{
		var at_pos = val_str.indexOf ("@");
		var at_dot = val_str.lastIndexOf (".");
	
		if (!CheckInvalidChars (val_str, " \t\\/#"))
			result = false;
		else
		{
			if (at_pos < 0 || at_dot < 0)
				result = false;
			else
			{
				var name_part = val_str.substring (0, at_pos);
				
				if (name_part == "" || !CheckInvalidChars (name_part, "@") || !CheckInvalidDel (name_part, ".")) 
					result = false;
				else 
				{
					var domain_part = val_str.substring (at_pos + 1, at_dot);
					
					if (name_part == "" || !CheckInvalidChars (domain_part, "@") || !CheckInvalidDel (domain_part, "."))
						result = false;
					else 
					{
						var country_part = val_str.substring (at_dot + 1);
						if (country_part == "" ||  !CheckInvalidChars (country_part, "@"))
							result = false;
					}
				}
			}
		}	
	}
	
	return result;	
}

<!-- ************************************************** -->

function CheckInvalidChars (container_str, inv_chars)
{
	var result = true;
	var count_chars = inv_chars.length;
	var i;
	
	for (i = 0; i < count_chars && result; i++)
	{
		if (container_str.indexOf (inv_chars.charAt (i)) >= 0)
		{
			result = false;
		}
	}
	
	return result;
}

<!-- ************************************************** -->

function CheckInvalidDel (container_str, delimiter_str)
{
	var result = true;
	
	var del_pos = container_str.indexOf (delimiter_str);
	if (!container_str.indexOf (delimiter_str)) result = false;
	else if (container_str.lastIndexOf (delimiter_str) == container_str.length - 1) result = false;
		
	return result;
}

