function template_printpage(page_id, popup_width) {
	var intWidth = parseInt(popup_width);
	var intHeight = 600;
	var intLeft = (screen.availWidth - intWidth - 10) / 2;
	var intTop  = (screen.availHeight - intHeight - 29) / 2;
	objWin = window.open("/includes/pages/module_print.asp?page_id=" + page_id, 'ViewPopup', 'left=' + intLeft + ',top=' + intTop + ',width=' + intWidth + ',height=' + intHeight + ',menubar=no,toolbar=no,location=no,status=yes,scrollbars=no,resizable=no');
}

function lightbox_maxwidth() {
	return document.documentElement.clientWidth;
}
function lightbox_maxheight() {
	return document.documentElement.clientHeight;
}
function lightbox_pictures()
{
	var elm_container = document.getElementById("t04_template_contentarea");
	if(elm_container) {
		var arr_elements = elm_container.getElementsByTagName("a");
		for(var i=0; i<arr_elements.length; i++){
			current_elm = arr_elements[i];
			current_rel = current_elm.getAttribute("rel");
			if(current_rel != null) {
				if(current_rel.indexOf("lightbox") == 0) {
					var this_id = current_elm.getAttribute("id");
					var this_img = "/files/gallery/" + this_id + "/" + (lightbox_maxwidth()-200) + "/" + (lightbox_maxheight()-200) + "/"
					this_img = this_img.replace("img_","")
					document.getElementById(this_id).href = this_img;					
				}
			}
		}
	}
}
function critical_message() {
	var msg = document.getElementById("critical_warning");
	if(msg) {
		$(msg).fadeOut(1000).fadeIn(1000)
		$(msg).animate({top: "50px"}, 1000);
		$(msg).animate({top: "0px"}, 750);
	}
}
function validate_buy(f,url) {
	if(f.order_firstname.value.length == 0) {
		alert("Du skal angive dit fornavn");
	} else if(f.order_surname.value.length == 0) {
		alert("Du skal angive dit efternavn!");
	} else if(f.order_address.value.length == 0) {
		alert("Du skal angive din adresse!");
	} else if(f.order_zipno.value.length == 0) {
		alert("Du skal angive dit postnummer!");
	} else if(f.order_cityname.value.length == 0) {
		alert("Du skal angive din by!");
	} else if(f.order_phone.value.length == 0) {
		alert("Du skal angive dit telefonnummer!");
	} else if(valEmail(f.order_email.value) == false) {
		alert("Du skal angive en gyldig e-mail adresse!");
	} else {
		f.action = url;
		f.submit();
	}	
}
function valEmail(streng) {
	var regMail = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	return regMail.test(streng)
}
var popupWindow;
function openPopup(url,w,h) {
	x = screen.width/2-w/2;
	y = screen.height/2-h/2;
	if (popupWindow) popupWindow.close();
    popupWindow=window.open(url,'ny','toolbar=no,copyhistory=no,location=yes,' + 'directories=no,status=yes,menubar=no,scrollbars=yes,' +'resizable=no,width=' + w + ',height=' + h + ',top=' + y +',left=' + x);
}