var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
	close:function()
	{
		$(".modal-window").remove();
		$(".modal-overlay").remove();
	},
	open:function()
	{
		var modal = "";
		modal += "<div class=\"modal-overlay\"></div>";
		modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px;\">";
		modal += this.content;
		modal += "</div>";

		$(this.parent).append(modal).fadeIn(200);
		$(".modal-overlay").click(function(){modalWindow.close();});
		$(".modal-window").click(function(){modalWindow.close();});
	}
};

function showPicture(picture) {
 var windowwidth = parseInt($(window).width()) - 100;
 $.get('showpicture.php', {i:picture},
    function(data){
    modalWindow.windowId = "myModal";
    modalWindow.width = windowwidth;
    modalWindow.content = data;
    modalWindow.open();
    }
 );
 return false;
}

function showArticle(idarticle) {
	$('#articlecontent').html('<p align="center" class="grey"><img src="images/ico_loading.gif" align="ABSMIDDLE"> LOADING </p>');
	$('.ali').removeClass('select');
	$('#ali_'+idarticle).addClass('select');
	$.get('article.php',{i:idarticle},
	function(data){ 
		$('#articlecontent').html(data);
		$('#articlecontent').css({top:0});
	}
	);
	$('#aprint').attr('href','article.php?i='+idarticle );
	
}

function scrollAUp() {
	var offset = $('#articlecontent').position();
	var tof = parseInt(offset.top) + 55;	
	if (tof >= 0) {
		tof = 0;
	}
	$('#articlecontent').animate({top:tof},200);
}

function scrollADown() {
	var offset = $('#articlecontent').position();
	var height = $('#articlecontent').height() - 475;
	if (height>0){
	var tof = parseInt(offset.top) - 55;	
	//alert (height+":"+tof);
	if (tof < -height) {
		tof = -height;
	}	
	$('#articlecontent').animate({top:tof},200);
	}
}
