
function Config()
{
	this.spacerPath = '../images/spacer.gif';
}

config = new Config();


function transparent(element)
{
	if(/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
	{
		var src = element.src;
		if(/\.png$/.test(element.src))
		{ 
			element.src = config.spacerPath;
			if (src)
			{
				element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
			}
		}   
	}
}

var send = function(link)
{
	jQuery.ajax({
		url: 'ajax.php?module=news_calendar&date=' + jQuery("#calendar_y").val() + '.' + jQuery("#calendar_m").val() + link,
		dataType: "html",
		type: "GET",
		// data: jQuery('#').formSerialize(),
		success: function(data, textStatus)
		{
			jQuery('#calendar_div').html(data);
		},
		error: function()
		{
			jQuery("#").submit();
		}
	});
}

// TODO: center popup

function showImage(id, width, height)
{
	var result = CenterPopup(width, height);

	sDesrc = "width=" + width + ", height=" + height + ", status=no, toolbar=no, menubar=no, scrollbars=no, top=" + result['top'] + " ,left=" + result['left'] + "";
	win = window.open("/gallery.php?id=" + id, "", sDesrc);
}

function showVideo(id, width, height)
{
	var result = CenterPopup(width, height);

	sDesrc = "width=" + width + ", height=" + height + ", status=no, toolbar=no, menubar=no, scrollbars=no, top=" + result['top'] + " ,left=" + result['left'] + "";
	win = window.open("/video.php?id=" + id + "&width=" + width + "&height=" + height, "", sDesrc);
}

function PopupMessageGet(url)
{
	jQuery.ajax({
		url: url,
		dataType: "html",
		type: "GET",
		success: function(data, textStatus)
		{
			jQuery('#ajax_message').html(data);
			
			CenterItem('.centered');
		},
		error: function()
		{
			document.location.href = url;
		}
	});
}

function CloseMessage()
{
	jQuery('#ajax_message').html('');
}

function CenterPopup(width, height)
{
	var winWidth = screen.width;

	var winHeight = screen.height;

	var windowCenter = winWidth/2;

	var itemCenter = width/2;

	var theCenter = windowCenter - itemCenter;

	var windowMiddle = winHeight/2;

	var itemMiddle = height/2;

	var theMiddle = windowMiddle - itemMiddle;

	var result = {'left':theCenter, 'top':theMiddle};

	return result;
}

