KazSymbolsCodes = new Array();
KazSymbolsCodes[0]  = 1240;
KazSymbolsCodes[1]  = 1241;
KazSymbolsCodes[2]  = 1030;
KazSymbolsCodes[3]  = 1110;
KazSymbolsCodes[4]  = 1186;
KazSymbolsCodes[5]  = 1187;
KazSymbolsCodes[6]  = 1170;
KazSymbolsCodes[7]  = 1171;
KazSymbolsCodes[8]  = 1198;
KazSymbolsCodes[9]  = 1199;
KazSymbolsCodes[10] = 1200;
KazSymbolsCodes[11] = 1201;
KazSymbolsCodes[12] = 1178;
KazSymbolsCodes[13] = 1179;
KazSymbolsCodes[14] = 1256;
KazSymbolsCodes[15] = 1257;
KazSymbolsCodes[16] = 1210;
KazSymbolsCodes[17] = 1211;

function KazCodes2Symbols (Str) {
	for (var i = 0; i < KazSymbolsCodes.length; i++) {
		kazSymbol = String.fromCharCode(KazSymbolsCodes[i]);
		eval('Str = Str.replace(/&#' + KazSymbolsCodes[i] + ';/g, kazSymbol);');
		eval('Str = Str.replace(/&##' + KazSymbolsCodes[i] + ';/g, kazSymbol);');
	}
	return Str;
}

/*
 * Функция заменяем все специфические символы казахского алфавита
 * на их коды. В качестве входного параметра необходимо передать
 * INPUT-объект, где и произойдет замена символов.
 */
function ChangeKazSymbols(Obj) {
	origin_str = Obj.value;
	new_str = "";
	for (var i = 0; i < origin_str.length; i++) {
	
		switch (origin_str.charCodeAt(i)) {
		
			case 1240 :		// Э
				new_str = new_str + "&#1240;";
				break;
		
			case 1241 :		// э
				new_str = new_str + "&#1241;";
				break;
		
			case 1030 :		// I
				new_str = new_str + "&#1030;";
				break;
		
			case 1110 :		// i
				new_str = new_str + "&#1110;";
				break;
		
			case 1186 :		// Н,
				new_str = new_str + "&#1186;";
				break;
		
			case 1187 :		// н,
				new_str = new_str + "&#1187;";
				break;
		
			case 1170 :		// Г-
				new_str = new_str + "&#1170;";
				break;
		
			case 1171 :		// г-
				new_str = new_str + "&#1171;";
				break;
		
			case 1198 :		// Y
				new_str = new_str + "&#1198;";
				break;
		
			case 1199 :		// y
				new_str = new_str + "&#1199;";
				break;
		
			case 1200 :		// Y-
				new_str = new_str + "&#1200;";
				break;
		
			case 1201 :		// y-
				new_str = new_str + "&#1201;";
				break;
		
			case 1178 :		// K,
				new_str = new_str + "&#1178;";
				break;
		
			case 1179 :		// k,
				new_str = new_str + "&#1179;";
				break;
		
			case 1256 :		// O-
				new_str = new_str + "&#1256;";
				break;
		
			case 1257 :		// o-
				new_str = new_str + "&#1257;";
				break;
		
			case 1210 :		// H
				new_str = new_str + "&#1210;";
				break;
		
			case 1211 :		// h
				new_str = new_str + "&#1211;";
				break;
/*			
			case 39 :		// '
				new_str = new_str + " ";
				break;
*/			
			default : new_str = new_str + origin_str.charAt(i);
		}
	}
	Obj.value = new_str;
	return true;
}

/*
 * Настройки и фукнции для меню
 */
	PopupMenuWidth = 154;
	MainMenuHeight = 20;

function GetPxValue(Value) {
	if (Value.substr(Value.length-2,2) == "px") {
		return Math.round(Value.substr(0,Value.length-2));
	}
	else {
		return Value;
	}

}

function HidePopupTree(PID) {
	RealPID = PID;
	while (PopupTree[PID] != 0) {
		Obj = document.getElementById('PopupMenu' + PID);
		Obj.style.display = 'none';
		PID = PopupTree[PID];
	}

	Obj = document.getElementById('PopupMenu' + PID);
	Obj.style.display = 'none';
	
	for ($i = 0; $i < Popups.length; $i++) {
		if (PopupTree[Popups[$i]] == RealPID) {
			Obj = document.getElementById('PopupMenu' + Popups[$i]);
			Obj.style.display = 'none';
		}
	}

}


function HidePopup(PID) {
	if (PID == 'all') {
		for ($i = 0; $i < Popups.length; $i++) {
			Obj = document.getElementById('PopupMenu' + Popups[$i]);
			Obj.style.display = 'none';
		}
	}
	else {
		Obj = document.getElementById('PopupMenu' + PID);

		if (HidePopup_ID != 0) {
			clearInterval(HidePopup_ID);
		}
	
		HidePopup_ID = setInterval("HidePopupTree(" + PID + ");",500);
	}
}

function ShowPopup(PID) {
	if (HidePopup_ID != 0) {
		clearInterval(HidePopup_ID);
	}
	
	if (ShowPopup_ID != 0) {
		clearInterval(ShowPopup_ID);
	}

	HidePopup('all');

	CurrentMenuTree = new Array;
	CurrentMenuTree[0] = PID;
	$i = 1;

	while (PopupTree[PID] != 0) {
		CurrentMenuTree[$i] = PopupTree[PID];
		$i++;
		PID = PopupTree[PID];
	}
	$i--;
	PID = CurrentMenuTree[$i];

	Obj = document.getElementById('PopupMenu' + PID);

	Obj.style.top = document.getElementById('MMTD').offsetTop + MainMenuHeight;
	Obj.style.left = document.getElementById('MainMenu' + PID).offsetLeft;
	
	Obj.style.display = 'inline';
	
	for ($i = (CurrentMenuTree.length - 2); $i >= 0; $i--) {
		PID = CurrentMenuTree[$i];

		Obj = document.getElementById('PopupMenu' + PID);

		Obj.style.top = document.getElementById('MenuTD' + PID).offsetTop + GetPxValue(document.getElementById('PopupMenu' + PopupTree[PID]).style.top) - 1;
		Obj.style.left = GetPxValue(document.getElementById('PopupMenu' + PopupTree[PID]).style.left) + PopupMenuWidth;

/*
		if (GetPxValue(Obj.style.left) > (document.body.clientWidth - PopupMenuWidth)) {
*/
		if (GetPxValue(Obj.style.left) > (780 - PopupMenuWidth)) {
			Obj.style.left = Obj.style.left.substr(0,Obj.style.left.length-2) - PopupMenuWidth * 2;
		}

		Obj.style.display = 'inline';
		PID = PopupTree[PID];
	}
}

function ChangeMenuTDStyle(Obj, Set, LinkID) {
	if (Set) {
		Obj.style.background = "#7B97C7";
		LinkObj = document.getElementById('TDMenuLink' + LinkID);
		LinkObj.style.color = "#ffffff";
//		alert(Obj.elements.length);
	}
	else {
		Obj.style.background = "#D3DCEC";
		LinkObj = document.getElementById('TDMenuLink' + LinkID);
		LinkObj.style.color = "#2453A2";
	}
}

function openNewWindow(URL, WindowName) {
    window.open(URL,WindowName,"width=833,height=365,copyhistory=no,directories=no,location=no,menubar=no,resizable=yes,scrollbars=auto,status=no,toolbar=no");
}