function module_login_security(login_form)
{
	login_form.template_cmd_security.value = 'login_security_passed';
}
function module_newsletter(nl_form, nl_value)
{
	nl_form.template_cmd_action.value = nl_value;
	nl_form.template_cmd_security.value = 'newsletter_security_passed';
}
// show blackbox
function module_gallery_show_blackbox()
{
	document.getElementById("template_module_gallery_blackbox").style.display = "block";
}
// hide blackbox
function module_gallery_hide()
{
	document.getElementById("template_module_gallery_blackbox").style.display = "none";
	document.getElementById("template_module_gallery_picture").style.display = "none";
}
function module_newspicture_init(picture_id, news_id, picture_url, max_width, max_height)
{
	module_gallery_show_blackbox();
	http_request = getXMLHTTP();	
	
	if (!http_request){
	alert(NoXMLHTTP);
	return false;
	}

	locationWhenClickedImage = document.documentElement.scrollTop;
	if (locationWhenClickedImage == 0) {
		locationWhenClickedImage = window.pageYOffset;
	}
	if (isNaN(locationWhenClickedImage) == true) {
		locationWhenClickedImage = 0;
	}
	
	var browser_temp = navigator.userAgent.toLowerCase();
	var browser_temp = browser_temp.search("msie");
	
	
	var strURL = "/includes/asp/template_newspicture_ajax.asp?picture_id=" + picture_id + "&noCache=" + Math.random(); + "";
	http_request.onreadystatechange = function() 
	{
		if (http_request.readyState == 4) 
		{
			if (http_request.status == 200) 
			{
				var picture_container = document.getElementById("template_module_gallery_picture");
				picture_container.style.display = "block";
				var screenWidth;
				var screenHeight;
					
				if (typeof window.innerWidth != "undefined")
				{
					screenWidth = window.innerWidth;
					screenHeight = window.innerHeight;
				}
				else if (typeof document.documentElement != "undefined"
				 && typeof document.documentElement.clientWidth !=
				 "undefined" && document.documentElement.clientWidth != 0)
				{
					screenWidth = document.documentElement.clientWidth;
					screenHeight = document.documentElement.clientHeight;
					var explorer = true;
				}
				else
				{
				   screenWidth = document.getElementsByTagName("body")[0].clientWidth;
				   screenHeight = document.getElementsByTagName("body")[0].clientHeight;
				   var explorer = true;
				}
				
				var click_pos = (screenHeight + locationWhenClickedImage)
				var ajax_result = http_request.responseText.split("|"); // Split funktion
				var next_onclick = "module_newspicture_init(" + ajax_result[0] + "," + ajax_result[1] + ",'" + ajax_result[2] + "'," + ajax_result[3] + "," + ajax_result[4] + ")"
				var prev_onclick = "module_newspicture_init(" + ajax_result[5] + "," + ajax_result[6] + ",'" + ajax_result[7] + "'," + ajax_result[8] + "," + ajax_result[9] + ")"
								
				// check next picture
				if(ajax_result[0] > 0) {
					document.getElementById("template_module_gallery_navigation_next").onclick = new Function(next_onclick);
					document.getElementById("template_module_gallery_navigation_next").style.color = "#333333";
				} else {
					document.getElementById("template_module_gallery_navigation_next").style.color = "#666666";
					document.getElementById("template_module_gallery_navigation_next").onclick = "";
				}
				// check previous picture
				if(ajax_result[5] > 0) {
					document.getElementById("template_module_gallery_navigation_previous").onclick = new Function(prev_onclick);
					document.getElementById("template_module_gallery_navigation_previous").style.color = "#333333";
				} else {
					document.getElementById("template_module_gallery_navigation_previous").style.color = "#666666";
				}
				
				// max size to picture container	
				var max_picture_container_height = parseInt(screenHeight - 200);
				var max_picture_container_width = parseInt((max_picture_container_height/max_height)*max_width) - 100;	
				var gallery_absolute_container = document.getElementById("template_module_gallery_picture");
				var gallery_absolute_picture = document.getElementById("template_module_gallery_showpicture");
				var gallery_image_source = "/includes/asp/template_newspicture_streaming.asp?no_cache=" + Math.random() + "&picture_url=" + picture_url + "&max_width=" + (max_picture_container_width - 20) + "&max_height=" + (max_picture_container_height - 80)
								
				// set container properties
				gallery_absolute_container.style.position = "absolute";
				if(browser_temp > 0) // ie?
				{ gallery_absolute_container.style.top = ((screenHeight + locationWhenClickedImage * 2) - max_picture_container_height) / 2 + "px"; }
				else
				{ gallery_absolute_container.style.top = (screenHeight - max_picture_container_height) / 2 + "px"; }
				gallery_absolute_container.style.left = (screenWidth - max_picture_container_width) / 2 + "px";
				gallery_absolute_container.style.width = max_picture_container_width + "px";
				gallery_absolute_container.style.height = max_picture_container_height + "px";
				gallery_absolute_picture.style.height = (max_picture_container_height - 80) + "px";
				gallery_absolute_picture.style.backgroundImage = "url(" + gallery_image_source + ")";
				
				// adjust the blackbox after scroll
				document.getElementById("template_module_gallery_blackbox").style.height = (screenHeight + locationWhenClickedImage) + "px";
			}
		}
	}	
	document.body.style.overflow = "hidden";

	http_request.open('GET', strURL, true);
	http_request.send(null);
}
function module_gallery_init(picture_id, binding_id, picture_url, max_width, max_height)
{
	module_gallery_show_blackbox();
	http_request = getXMLHTTP();	
	
	if (!http_request){
	alert(NoXMLHTTP);
	return false;
	}

	locationWhenClickedImage = document.documentElement.scrollTop;
	if (locationWhenClickedImage == 0) {
		locationWhenClickedImage = window.pageYOffset;
	}
	if (isNaN(locationWhenClickedImage) == true) {
		locationWhenClickedImage = 0;
	}
	
	var browser_temp = navigator.userAgent.toLowerCase();
	var browser_temp = browser_temp.search("msie");
	
	
	var strURL = "/includes/asp/template_gallery_ajax.asp?binding_id=" + binding_id + "&noCache=" + Math.random(); + "";
	http_request.onreadystatechange = function() 
	{
		if (http_request.readyState == 4) 
		{
			if (http_request.status == 200) 
			{
				var picture_container = document.getElementById("template_module_gallery_picture");
				picture_container.style.display = "block";
				var screenWidth;
				var screenHeight;
					
				if (typeof window.innerWidth != "undefined")
				{
					screenWidth = window.innerWidth;
					screenHeight = window.innerHeight;
				}
				else if (typeof document.documentElement != "undefined"
				 && typeof document.documentElement.clientWidth !=
				 "undefined" && document.documentElement.clientWidth != 0)
				{
					screenWidth = document.documentElement.clientWidth;
					screenHeight = document.documentElement.clientHeight;
					var explorer = true;
				}
				else
				{
				   screenWidth = document.getElementsByTagName("body")[0].clientWidth;
				   screenHeight = document.getElementsByTagName("body")[0].clientHeight;
				   var explorer = true;
				}
				
				var click_pos = (screenHeight + locationWhenClickedImage)
				var ajax_result = http_request.responseText.split("|"); // Split funktion
				var next_onclick = "module_gallery_init(" + ajax_result[0] + "," + ajax_result[1] + ",'" + ajax_result[2] + "'," + ajax_result[3] + "," + ajax_result[4] + ")"
				var prev_onclick = "module_gallery_init(" + ajax_result[5] + "," + ajax_result[6] + ",'" + ajax_result[7] + "'," + ajax_result[8] + "," + ajax_result[9] + ")"
				var navigation_p
				
				// check next picture
				if(ajax_result[0] > 0) {
					document.getElementById("template_module_gallery_navigation_next").onclick = new Function(next_onclick);
					document.getElementById("template_module_gallery_navigation_next").style.color = "#333333";
				} else {
					document.getElementById("template_module_gallery_navigation_next").style.color = "#666666";
					document.getElementById("template_module_gallery_navigation_next").onclick = "";
				}
				// check previous picture
				if(ajax_result[5] > 0) {
					document.getElementById("template_module_gallery_navigation_previous").onclick = new Function(prev_onclick);
					document.getElementById("template_module_gallery_navigation_previous").style.color = "#333333";
				} else {
					document.getElementById("template_module_gallery_navigation_previous").style.color = "#666666";
				}
				
				// max size to picture container	
				var max_picture_container_height = parseInt(screenHeight - 200);
				var max_picture_container_width = parseInt((max_picture_container_height/max_height)*max_width) - 100;	
				var gallery_absolute_container = document.getElementById("template_module_gallery_picture");
				var gallery_absolute_picture = document.getElementById("template_module_gallery_showpicture");
				var gallery_image_source = "/includes/asp/template_gallery_streaming.asp?no_cache=" + Math.random() + "&picture_url=" + picture_url + "&max_width=" + (max_picture_container_width - 20) + "&max_height=" + (max_picture_container_height - 80)
								
				// set container properties
				gallery_absolute_container.style.position = "absolute";
				if(browser_temp > 0) // ie?
				{ gallery_absolute_container.style.top = ((screenHeight + locationWhenClickedImage * 2) - max_picture_container_height) / 2 + "px"; }
				else
				{ gallery_absolute_container.style.top = (screenHeight - max_picture_container_height) / 2 + "px"; }
				gallery_absolute_container.style.left = (screenWidth - max_picture_container_width) / 2 + "px";
				gallery_absolute_container.style.width = max_picture_container_width + "px";
				gallery_absolute_container.style.height = max_picture_container_height + "px";
				gallery_absolute_picture.style.height = (max_picture_container_height - 80) + "px";
				gallery_absolute_picture.style.backgroundImage = "url(" + gallery_image_source + ")";
				
				// adjust the blackbox after scroll
				document.getElementById("template_module_gallery_blackbox").style.height = (screenHeight + locationWhenClickedImage) + "px";
			}
		}
	}	
	document.body.style.overflow = "hidden";

	http_request.open('GET', strURL, true);
	http_request.send(null);
}

function getXMLHTTP() {
	var http_request = false;

	if  (window.XMLHttpRequest) { // Mozilla, Safari, IE7.0+  ...
		http_request = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)  { // IE 6.0-
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				alert("Microsoft.XMLHTTP")
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
			}
		}
	}
	return http_request;
}
function tracker_expirenow()
{
	http_request = getXMLHTTP();	
	
	var strURL = "/includes/asp/template_tracker.asp?cmd=tracker_exit&nocache=" + Math.random(); + "";
	http_request.open('GET', strURL, true);
	http_request.send(null);
}

var screenWidth;
var screenHeight;
	
if (typeof window.innerWidth != "undefined")
{
	screenWidth = window.innerWidth;
	screenHeight = window.innerHeight;
}
else if (typeof document.documentElement != "undefined"
 && typeof document.documentElement.clientWidth !=
 "undefined" && document.documentElement.clientWidth != 0)
{
	screenWidth = document.documentElement.clientWidth;
	screenHeight = document.documentElement.clientHeight;
}
else
{
	screenWidth = document.getElementsByTagName("body")[0].clientWidth;
	screenHeight = document.getElementsByTagName("body")[0].clientHeight;
}

function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue, strParentType)
{
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
	var oCurrent;
	var oAttribute;
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute)))
			{
				var this_id = oCurrent.getAttribute("id");
				var this_img = "/includes/asp/template_picture_streaming.asp?case=" + strParentType + "&picture_url=" + this_id + ".jpg&max_width=" + (screenWidth - 200) + "&max_height=" + (screenHeight-200)
				document.getElementById(this_id).href = this_img;
			}
		}
	}
	return arrReturnElements;
}
// ---
if(typeof Array.prototype.push != "function"){
	Array.prototype.push = ArrayPush;
	function ArrayPush(value){
		this[this.length] = value;
	}
}
// ---
function lightbox_pictures(parent_elm, parent_type)
{
	getElementsByAttribute(document.body, "*", "boxrel", parent_elm, parent_type)
}