/**
 * @author apat1k
 */

/* ------------------------ */
/*  XMLHTTPRequest Enable   */
/* ------------------------ */
function createObject()
{
	var request_type;
	var browser = navigator.appName;
	
	if(browser == "Microsoft Internet Explorer")
	{
		request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		request_type = new XMLHttpRequest();
	}
	
	return request_type;
}

var http = createObject();
//==============================================
var nocache = Math.random();  //Переменная содержит случайное число, добавляемое в запрос для предотвращения кеширования браузером запроса 

function Calendar(month,year,day_cur,month_cur,year_cur)
{
	var params = 'm=' + month + '&y=' + year + '&dc=' + day_cur + '&mc=' + month_cur + '&yc=' + year_cur + '&nocache=' + nocache;
	var loader =document.getElementById("ajax-loader"); 
	loader.style.backgroundColor = "#fff";
	loader.style.textAlign = "center";
	loader.style.padding = "40px 0";
	loader.style.margin = "5px";
	loader.innerHTML = "<img src=\"/_images/ajax-loader.gif\" width=66 height=66 border=0><br>Подождите! Идет подгрузка данных.";

	http.open("GET", "/calendar_change.php?"+params, true);
	http.onreadystatechange = CalendarReply;
	http.send(null);
}

function CalendarReply() 
{
	if (http.readyState == 4) {
	
		if (http.status == 200) {
			var response = http.responseText;
			document.getElementById("calendar").innerHTML = response;
		}
	
	}
}

//==================================================
function SetColor(type, tr) {
	if (type == 1) {
		document.getElementById(tr).style.backgroundColor = "#e9e9e2";
		return true;
	}
	if (type == 2) {
		document.getElementById(tr).style.backgroundColor = "#FFF";
		return true;
	}
	return false;			
}

function SetColorDay(type, td, tr)
{
	if (type == 1) {
		td.className = "da";
		if (tr != "")
			document.getElementById(tr).style.backgroundColor = "#e9e9e2";
		return true;
	}
	if (type == 2) {
		td.className = "d";
		if (tr != "")
			document.getElementById(tr).style.backgroundColor = "#FFF";
		return true;
	}
	return false;
}
function SetColorDayDr(type, td, tr)
{
	if (type == 1) {
		td.className = "da";
		if (tr != "")
			document.getElementById(tr).style.backgroundColor = "#e9e9e2";
		return true;
	}
	if (type == 2) {
		td.className = "dr";
		if (tr != "")
			document.getElementById(tr).style.backgroundColor = "#FFF";
		return true;
	}
	return false;
}

function GoUrl(d,month,year)
{
	location.href = "http://informpskov.ru/pskov-news-archive/"+year+"/"+month+"/"+d;
}

