﻿$(document).ready(function()
{
	$(".img-replace").each(function(index, element)
	{
		var text = $(element).text();
		var classText = $(element).attr("class");
		var img = new Image();
		var src = "/Images/CustomFont.aspx?text=" + text;
		var sizeRegex = new RegExp("size([0-9]+)");
		if(sizeRegex.test(classText))
			src += "&size=" + sizeRegex.exec(classText)[1];
		img.src = src;
		$(element).html(img);
	});

	$(".mail-replace").each(function(index, element)
	{
		var text = $(element).text();		
		var mailAddress = text.replace(/^([^ ]*)\sat\s([^ ]*)\sdot\s(.*)$/, "$1@$2.$3");
		$(element).html($("<a></a>").text(mailAddress).attr("href", "mailto:" + mailAddress));
	});
});

function ShowPopup(title, url)
{

	$("#divPopupBoxContent").css("display", "block").load(url, function()
	{
		$('body').css(
		{
			'overflow': 'hidden'
		});
		//alert(window.pageYOffset);
		$('#overlayscreen').css(
		{
			opacity: 0.7,
			'width': $(window).width(),
			'height': $(window).height(),
			'top': getScrollTop()//document.documentElement.scrollTop

		}).fadeIn("slow");
		$("#hdrPopupBox").text(title);
		$('#popupbox').css(
		{
			top: getScrollTop() + (($(window).height() / 2) - ($("#popupbox").height() / 2))
		}).fadeIn("slow", function()
		{
			$("#divPopupBoxContent form input:first").focus();
		});
	});
}

function HidePopup()
{
	$("div#popupbox").fadeOut("slow");
	$('div#overlayscreen').fadeOut("slow", function()
	{
		$('body').css('overflow', 'auto');
	});
}

function getScrollTop()
{
	var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;

	return h ? h : 0;
}