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 UCaseInput(Obj) {
	Obj.value = Obj.value.toUpperCase();
	return true;
}

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 = 173;

function subMenuOver (Obj) {
	Obj.style.color = '#004D2A';
	Obj.style.fontWeight = 'bold';
	Obj.style.textDecoration = 'underline';
}

function subMenuOut (Obj) {
	Obj.style.color = '#004D2A';
	Obj.style.fontWeight = 'normal';
	Obj.style.textDecoration = 'none';
}

function mainMenuOver (Obj) {
	Obj.style.color = '#004D2A';
	Obj.style.fontWeight = 'bold';
	Obj.style.textDecoration = 'underline';
}

function mainMenuOut (Obj) {
	Obj.style.color = '#004D2A';
	Obj.style.fontWeight = 'normal';
	Obj.style.textDecoration = 'none';
}

function showInfo (Obj) {
	alert('top = ' + getAbsTopPos(Obj) + ';\n left = ' + getAbsLeftPos(Obj) + ';\nheight = ' + Obj.offsetHeight + ';\nwidth = ' + Obj.offsetWidth + ';')
}

function getAbsLeftPos(Obj) {
	if ( (Obj.offsetParent != null) && (Obj.tagName != 'BODY') ) {
		return (Obj.offsetLeft + getAbsLeftPos(Obj.offsetParent));
	}
	else {
		return Obj.offsetLeft;
	}
}

function getAbsTopPos(Obj) {
	if ( (Obj.offsetParent != null) && (Obj.tagName != 'BODY') ) {
		return (Obj.offsetTop + getAbsTopPos(Obj.offsetParent));
	}
	else {
		return Obj.offsetTop;
	}
}

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);

	MMTD = document.getElementById('MainMenu' + PID);

	Obj.style.top = getAbsTopPos(MMTD);
	Obj.style.left = getAbsLeftPos(MMTD) + MMTD.offsetWidth;

//	alert('Ok');
//	showInfo(MMTD);
	
	Obj.style.display = 'inline';
	
	for ($i = (CurrentMenuTree.length - 2); $i >= 0; $i--) {
		PID = CurrentMenuTree[$i];

		Obj = document.getElementById('PopupMenu' + PID);
		parentObj = document.getElementById('MenuTD' + PID);

		Obj.style.top = parentObj.offsetTop +	GetPxValue(document.getElementById('PopupMenu' + PopupTree[PID]).style.top) - 1;
		Obj.style.left = parentObj.offsetLeft + parentObj.offsetWidth + GetPxValue(document.getElementById('PopupMenu' + PopupTree[PID]).style.left) - 1;
//		Obj.style.left = GetPxValue(document.getElementById('PopupMenu' + PopupTree[PID]).style.left) + PopupMenuWidth;

		if (GetPxValue(Obj.style.left) > (document.body.clientWidth - PopupMenuWidth)) {
			Obj.style.left = Obj.style.left.substr(0,Obj.style.left.length-2) - PopupMenuWidth * 2;
		}

		Obj.style.display = 'inline';
		PID = PopupTree[PID];
	}
}

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 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 GetPxValue(Value) {
	if (Value.substr(Value.length-2,2) == "px") {
		return Math.round(Value.substr(0,Value.length-2));
	}
	else {
		return Value;
	}

}


/********************************************************************/
// Верхнее меню popup

var mainTableWidth = 750;
var browserName = navigator.appName;

if (browserName == "Netscape") {
v  = ".top";
l  = ".left";
dS = "document.";
sD = "";
y  = "window.pageYOffset";
iW = "window.innerWidth";
iH = "window.innerHeight";
oW = -8;
}
else {
v  = ".pixelTop";
l  = ".pixelLeft";
dS = "";
sD = ".style";
y  = "document.body.scrollTop";
iW = "document.body.clientWidth";
iH = "document.body.clientHeight";
oW = 0;
}

var dhtml         = null; // Our layer
var isOver        = true;
var myTimer       = setTimeout("HideDHTML()",300);
var intCurrent    = -1;
var intNew        = -2;

var ns4 = (document.layers)? true:false
var ie4 = (document.all)? true:false

if ((ns4) || (ie4)) {
} else {
	PopUp = no_PopUp;
}

function no_PopUp() {
	return true;
}


function PopUp() {
	clearTimeout(myTimer);
	intNew = arguments[0]

	if ( intCurrent != intNew ) {
		intCurrent = intNew;
	
		// Load defaults to runtime.
		var m_frame     = self;
		var m_border    = "0";
		var m_fgcolor   = "BGCOLOR=\"#FFF2C0\"";
		var m_bgcolor   = "BGCOLOR=\"#FFF2C0\"";
		var m_height    = "HEIGHT=" + gHeight[intNew];
		var m_width     = "WIDTH=" + gWidth[intNew];
		var m_text      = DHTML_texts[intNew];
	
		var layerhtml = "<TABLE " + m_width + " BORDER=0 CELLPADDING=" + m_border +
								" CELLSPACING=0 " + m_bgcolor + " " + m_height + "><TR><TD align=left>" + 
								"<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 " + m_fgcolor + 
								" " + m_height + ">" + 
								m_text + "</TABLE></TD></TR></TABLE>";	
			
		if (ns4) { dhtml = m_frame.document.DHTLMenu; }
		if (ie4) { dhtml = m_frame.DHTLMenu.style; }
		
		SetPosition(intNew);
		dhtml.onmouseover = OverDHTML;
		dhtml.onmouseout = OutDHTML;
		OverDHTML();
		
	  if (ns4) {
		  var lyr = dhtml.document

		  lyr.write(layerhtml);
		  lyr.close();
		  dhtml.visibility = "show";
		}
		else if (ie4) {
			m_frame.document.all["DHTLMenu"].innerHTML = layerhtml;
			dhtml.visibility = "visible";
		}
		
		return true;
	}
}

function SetPosition(id) {
	var j = eval(iW);
	var posX = 0;
	var posY = 0;
	
	if (j <= mainTableWidth) { j = 2 }
	else { j = ((j - mainTableWidth) / 2) + oW; }
	
	if (j < 2 ) { j = 2; }
	posX = gposX[id] + j;
	
	
	var j1 = eval(iH);
	var j2 = eval(y);
	var j3 = j1 + j2;
	var j4 = gposY[id];
	var j5 = j1 + j2 - j4;
	var j6 = gHeight[id];
	var j7 = j4 - j2;
  var j8 = j4;
	
	if ((j5 < j6) && (j5 < j7)) { j8 = j4 - j6 - 30; }
	if (j8 < 0) { j8 = 0 }
	
	posY = j8;
	
	dhtml.left = posX
  dhtml.top = posY
}

function HideDHTML() {
	if (!isOver) { 
		intCurrent = -2;
		if (ns4) { dhtml.visibility = "hide" }
		else if (ie4) { dhtml.visibility = "hidden" }
	}
}

function OverDHTML() { 
	clearTimeout(myTimer); 
	isOver = true; 
}

function OutDHTML() { 
	clearTimeout(myTimer);
	isOver = false; 
	myTimer = setTimeout("HideDHTML()",100);
}

function getUrlFromMap(urlNumber) {
		if(urlNumber == 0) {
			location.href = "index.cfm?tid=10";
		} else if(urlNumber == 1) {
			location.href = "index.cfm?tid=11";
		} else if(urlNumber == 2) {
			location.href = "index.cfm?tid=12";
		} else if(urlNumber == 3) {
			location.href = "index.cfm?tid=80";
		} else if(urlNumber == 4) {
			location.href = "index.cfm?tid=56";
		} else if(urlNumber == 5) {
			location.href = "index.cfm?tid=57";
		} else if(urlNumber == 6) {
			location.href = "index.cfm?tid=58";
		}
		else if(urlNumber == 7) {
			location.href = "index.cfm?tid=114";
		}
                
	}
function openFullMap() {
		window.open('index.cfm?id=195', '1','width=540,height=380');

	}
	
function openFullMapEng() {
		window.open('/index.cfm?id=204', '1','width=540,height=380');

	}
	
	