﻿var UtcObj, BndObj;

function Inc(Oper) {
	switch (Oper) {
		case "H":
			S = UtcObj.id.substr(1, 2);
			ClkH(document.getElementById("H" + (++S % 24)));
			break;
		case "h":
			S = UtcObj.id.substr(1, 2);
			ClkH(document.getElementById("H" + ((--S + 24) % 24)));
			break;
		case "B":
			S = BndObj.id.substr(1, 2);
			ClkB(document.getElementById("B" + (++S % 8)));
			break;
		case "b":
			S = BndObj.id.substr(1, 2);
			ClkB(document.getElementById("B" + ((--S + 8) % 8)));
	}
}

function Over(Obj) {
	Obj.className = "undermouse";
}

function Out(Obj) {
	if (Obj.id == "Inc") {
		Obj.className = "hdr";
	} else if ((Obj == UtcObj) || (Obj == BndObj)) {
		Obj.className = "sel";
	} else {
		Obj.className = "numbers";
	}
}

function GetText(Obj) {
	return (document.getElementsByTagName("body")[0].innerText != undefined) ? Obj.innerText : Obj.textContent;
}

function ShowMap(isInit) {
	if (!(UtcObj && BndObj)) {
		return;
	}
	var Bnd = GetText(BndObj);
	if (!isInit) {
		TrackEvent('Propagation Map', 'Map Change', GetText(UtcObj) + ':00Z - ' + Bnd + 'MHz');
	}
	if (Bnd == "3.5") {
		Bnd = "03";
	} else if (Bnd == "7") {
		Bnd = "07";
	}
	document["PropMap"].src = "/muf/" + GetText(UtcObj) + "UT-" + Bnd + "MHz.gif";
}

function ClkH(Obj, isInit) {
	if (UtcObj) {
		UtcObj.className = "numbers";
	}
	Obj.className = "sel";
	UtcObj = Obj;
	ShowMap(isInit);
}

function ClkB(Obj, isInit) {
	if (BndObj) {
		BndObj.className = "numbers";
	}
	Obj.className = "sel";
	BndObj = Obj;
	ShowMap(isInit);
}

function InitMufMap() {
	var HrId = "H" + (new Date).getUTCHours();
	UtcObj = document.getElementById(HrId);
	ClkH(UtcObj, true);
	BndObj = document.getElementById("B5");
	ClkB(BndObj, true);
}
