
/* Comm Func */
var MainClkDiv;


var PulsF1 = "";
var PulsF2 = "";
function jfPuls() {

	clearTimeout(PulsTm);

	if (PulsF1 != "") {
		PulsF1();
	};
	if (PulsF2 != "") {
		PulsF2();
	};

	PulsTm = setTimeout("jfPuls()", 1000);
}
PulsTm = setTimeout("jfPuls()", 1000);


var MMObj = "";
function jfMMove() {
//	if (MMObj != "") {
//		MMObj.style.left = event.x + 15;
//		MMObj.style.top = event.y;
//	};
}


function jfAClick() {
	document.getElementById("Mainbody").style.cursor = "url(dload.cur)";
//	document.getElementById("Mainbody").style.cursor = "progress";
//dy = document.getElementById("MainBody").scrollTop;
//	MMObj = mi_1;
//	MMObj.style.left = event.x + 15;
//	MMObj.style.top = event.y;
//	MMObj.style.visibility = "visible";
}


var OnldFName = "";
function jf_OnldBody(iFName) {

	if (iFName != "") {
		iFName();
	};
}

function jfSubmitForm(iFrm) {

	document.getElementById(iFrm).submit();
}

function jfImgOnLoad(pImgNm, pMaxW) {
//alert(pImgNm);

	pImg = document.getElementById(pImgNm);
//alert(pImg.id + "-" + pImg.width);

	if (pImg.width <= 0) {
		setTimeout("jfImgOnLoad(\"" + pImgNm + "\", " + pMaxW + ")", 100);
		return;
	};

	if (pImg.width > pMaxW) {
		pImg.width = pMaxW;
	};
	pImg.style.visibility = "visible";
}

function jfWinOpenS(pUrl) {
	window.open(pUrl, "_blank");
}

function jfWinLoc(pLoc) {
	document.location = pLoc + "";
}

function jfWinOpen(pUrl, pW, pH, pName, pPrm) {

	var wPrm, ws, wt, wl;

	wPrm = pPrm;
	if (wPrm == "default") {
		wPrm = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes";
	};

	if (pW == 0) {
		pW = (screen.width * 2) / 3;
		pH = (pW * 3) / 4;
	};

	wl = (screen.width - pW) / 2;
	wt = (screen.height - pH) / 2;

	ws = "width=" + pW + ",height=" + pH + ",left=" + wl + ",top=" + wt;
	if (wPrm == "") {
		wPrm = ws;
	} else {
		wPrm = ws + "," + wPrm;
	};

//	window.showModelessDialog(pUrl);
	window.open(pUrl, pName, wPrm);
}

function jfRound(iNumb, iDgt) {

	var wi;

	wi = Math.pow(10, iDgt);
	return Math.round(iNumb * wi) / wi;
}

function jfTimeStr(iSec) {

	var wM, wS, wMs, wSs;

	wM = Math.floor(iSec / 60);
	wS = iSec - (wM * 60);

	wMs = wM + "";
	if (wMs.length <= 1) {
		wMs = "0" + wMs;
	};

	wSs = wS + "";
	if (wSs.length <= 1) {
		wSs = "0" + wSs;
	};

	return wMs + ":" + wSs;
}
/****************/


/* Таймер обновления */

//var CurTimer = null;
var CurRldTm = 0;

function AutoRld() {

//	clearTimeout(CurTimer);

	CurRldTm--;
	clk.innerText = "[" + jfTimeStr(CurRldTm) + "]";

	if (CurRldTm <= 0) {
		PulsF2 = "";
		aRld.click();
		return;
	};

//	CurTimer = setTimeout("AutoRld()", 1000);
}

function tRldChg(iTim) {

	if (iTim > 0) {
		CurRldTm = iTim * 60;
		clk.innerText = "[" + jfTimeStr(CurRldTm) + "]";
//		clearTimeout(CurTimer);
//		CurTimer = setTimeout("AutoRld()", 1000);
		PulsF2 = AutoRld;
	} else {
		CurRldTm = 0;
		clk.innerText = "";
//		clearTimeout(CurTimer);
		PulsF2 = "";
	};
}
/****************/


/* Часы */
var ClkPFlg = 1;
function jfMClk() {

	ws = "Сегодня ";

	w = "";
	i = MDate.getDay();
	if (i == 0) {
		w = "воскресенье";
	} else if (i == 1) {
		w = "понедельник";
	} else if (i == 2) {
		w = "вторник";
	} else if (i == 3) {
		w = "среда";
	} else if (i == 4) {
		w = "четверг";
	} else if (i == 5) {
		w = "пятница";
	} else if (i == 6) {
		w = "суббота";
	}
	ws = ws + w + ", " + MDate.getDate() + " ";

	w = "";
	i = MDate.getMonth();
	if (i == 0) {
		w = "января";
	} else if (i == 1) {
		w = "февраля";
	} else if (i == 2) {
		w = "марта";
	} else if (i == 3) {
		w = "апреля";
	} else if (i == 4) {
		w = "мая";
	} else if (i == 5) {
		w = "июня";
	} else if (i == 6) {
		w = "июля";
	} else if (i == 7) {
		w = "августа";
	} else if (i == 8) {
		w = "сентября";
	} else if (i == 9) {
		w = "октября";
	} else if (i == 10) {
		w = "ноября";
	} else if (i == 11) {
		w = "декабря";
	};

	if (MDate.getHours() < 10) {
		h = "0" + MDate.getHours();
	} else {
		h = "" + MDate.getHours();
	};
	if (MDate.getMinutes() < 10) {
		m = "0" + MDate.getMinutes();
	} else {
		m = "" + MDate.getMinutes();
	};

	if (ClkPFlg == 1) {
		ws = ws + w + " " + (MDate.getYear() + 0) + " года, " + h + ":" + m;
		ClkPFlg = 0;
	} else {
		ws = ws + w + " " + (MDate.getYear() + 0) + " года, " + h + ":" + m + ".";
		ClkPFlg = 1;
	};


	MainClkDiv.innerText = ws;
//	document.getElementById("mainclkid").innerText = ws;
//	MainClk.innerText = ws;

	MDate.setTime(MDate.getTime() + 1000);
}
/****************/

