var reqArticlesLeft;
var reqArticlesRight;
var reqArticlesDate;

function showArticles(section, article, year, month)
{
	if (year != undefined)
	{
		year = document.getElementById('year').value;
	}
	else
	{
		year = 0;
	}

	if (month != undefined)
	{
		month = document.getElementById('month').value;
	}
	else
	{
		month = 0;
	}

	showArticlesLeft(section, article, year, month);
	showArticlesRight(section, article, year, month);
	showArticlesDate(section, article, year, month);
}

function showArticlesLeft(section, article, year, month)
{
    var url = "/include/custom/articles.php?type=0&section="+section+"&year="+year+"&month="+month+"&article="+article+"&rand="+Math.random();

	if (window.XMLHttpRequest)
	{
		reqArticlesLeft = new XMLHttpRequest();
		reqArticlesLeft.onreadystatechange = loadArticlesLeft;
		reqArticlesLeft.open("GET", url, true);
		reqArticlesLeft.send(null);
	}
	else if (window.ActiveXObject)
	{
		reqArticlesLeft = new ActiveXObject("Microsoft.XMLHTTP");
		if (reqArticlesLeft)
		{
			reqArticlesLeft.onreadystatechange = loadArticlesLeft;
			reqArticlesLeft.open("GET", url, true);
			reqArticlesLeft.send();
		}
	}
}

function showArticlesRight(section, article, year, month)
{
	var url = "/include/custom/articles.php?type=1&section="+section+"&year="+year+"&month="+month+"&article="+article+"&rand="+Math.random();

	if (window.XMLHttpRequest)
	{
		reqArticlesRight = new XMLHttpRequest();
		reqArticlesRight.onreadystatechange = loadArticlesRight;
		reqArticlesRight.open("GET", url, true);
		reqArticlesRight.send(null);
	}
	else if (window.ActiveXObject)
	{
		reqArticlesRight = new ActiveXObject("Microsoft.XMLHTTP");
		if (reqArticlesRight)
		{
			reqArticlesRight.onreadystatechange = loadArticlesRight;
			reqArticlesRight.open("GET", url, true);
			reqArticlesRight.send();
		}
	}
}

function showArticlesDate(section, article, year, month)
{
	var url = "/include/custom/articles.php?type=2&section="+section+"&year="+year+"&month="+month+"&article="+article+"&rand="+Math.random();

	if (window.XMLHttpRequest)
	{
		reqArticlesDate = new XMLHttpRequest();
		reqArticlesDate.onreadystatechange = loadArticlesDate;
		reqArticlesDate.open("GET", url, true);
		reqArticlesDate.send(null);
	}
	else if (window.ActiveXObject)
	{
		reqArticlesDate = new ActiveXObject("Microsoft.XMLHTTP");
		if (reqArticlesDate)
		{
			reqArticlesDate.onreadystatechange = loadArticlesDate;
			reqArticlesDate.open("GET", url, true);
			reqArticlesDate.send();
		}
	}
}

function loadArticlesLeft()
{
	if (reqArticlesLeft.readyState == 4)
	{
		var articles = document.getElementById('articles-1');
		articles.innerHTML = reqArticlesLeft.responseText;
	}
}

function loadArticlesRight()
{
	if (reqArticlesRight.readyState == 4)
	{
		var articles = document.getElementById('articles-2');
		articles.innerHTML = reqArticlesRight.responseText;
	}
}

function loadArticlesDate()
{
	if (reqArticlesDate.readyState == 4)
	{
		var articles = document.getElementById('articles-date');
		articles.innerHTML = reqArticlesDate.responseText;
	}
}
