/****************************************************\
| Liga UI 1.1                                        |
| Copyright by Dime 2004                             |
\****************************************************/


function MM_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

//========================================================

var pMainTable1, pMainTable2, pMainTable3, pMainTable4;
var pShHeader, pShContent;
var pShHeaderInTable, pShHeaderInTd, pShContentInTable, pShContentInTd;
var pShHeaderSp, pShContentSp;
var shTM = false;

function shReserve(spId) {
	if(!isDOM) return;
	var spSize;
	var avSpace = document.body.clientWidth - 763;
	if(avSpace >= 162) {
		spSize = (avSpace < 195) ? avSpace : 195;
		document.write('<img id="' + spId + '" src="/images/z.gif" width="' + spSize + '" height="1">');
	}
	else {
		document.write('<img id="' + spId + '" src="/images/z.gif" width="1" height="1">');
	}
}

function shContentLoad() {
	if(!isDOM) return;
	pMainTable1 = document.getElementById('mainTable1');
	pMainTable2 = document.getElementById('mainTable2');
	pMainTable3 = document.getElementById('mainTable3');
	pMainTable4 = document.getElementById('mainTable4');
	pShHeader = document.getElementById('shHeader');
	pShContent = document.getElementById('shContent');
	pShHeaderInTable = document.getElementById('shHeaderInTable');
	pShHeaderInTd = document.getElementById('shHeaderInTd');
	pShContentInTable = document.getElementById('shContentInTable');
	pShContentInTd = document.getElementById('shContentInTd');
	pShHeaderSp = document.getElementById('shHeaderSp');
	pShContentSp = document.getElementById('shContentSp');
	shContentResizeDo();
}

function shContentResize() {
	if(!isDOM) return;
	if(shTM) clearTimeout(shTM);
	shTM = setTimeout('shContentResizeDo()', 10);
}

function shContentResizeDo() {
	if(!isDOM) return;
	if(shTM) clearTimeout(shTM);
	var spSize;
	var avSpace = document.body.clientWidth - 763;
	if(avSpace >= 162) {
		spSize = (avSpace < 195) ? avSpace : 195;
		pMainTable1.style.width = pMainTable2.style.width = pMainTable3.style.width = pMainTable4.style.width = 763 + spSize;
		if(flShOut) {
			pShHeaderInTable.style.width = pShContentInTable.style.width = spSize - 9;
			pShHeaderInTd.style.width = pShContentInTd.style.width = spSize - 9;
			pShHeaderSp.width = pShContentSp.width = spSize;
			pShHeaderInTd.innerHTML = pShHeader.innerHTML;
			pShContentInTd.innerHTML = pShContent.innerHTML;
		}
		else {
			pShHeaderSp.width = pShContentSp.width = 1;
		}
	}
	else {
		if(flShOut) {
			pShHeaderInTd.innerHTML = '';
			pShContentInTd.innerHTML = '';
			pShHeaderSp.width = pShContentSp.width = 1;
			pShHeaderInTd.style.width = pShContentInTd.style.width = 1;
			pShHeaderInTable.style.width = pShContentInTable.style.width = 1;
		}
		pMainTable1.style.width = pMainTable2.style.width = pMainTable3.style.width = pMainTable4.style.width = 763;
	}
}

function shGo(obj) {
	if(!isDOM) return;
	event.cancelBubble = true;
	var objA = obj.getElementsByTagName("A");
  if(objA[0]) window.location = objA[0].href;
}

//========================================================

var mmItems = new Array();
var coMMItem = 0;
var mmTM, mmOverTM;
var mmGeneralOverId;

function addMenuItem(id, pos, lnk, txt) {
	mmItems[coMMItem] = new Array();
	mmItems[coMMItem][0] = id;
	mmItems[coMMItem][1] = layer(id);
	switch(pos) {
		case 0: document.write('<div id="' + id + 'd" style="position: absolute; top: 0px; left: 0px; width: 222px; height: 16px; cursor: hand; visibility: hidden;" onMouseOut="mmOver(this, 0); return false" onClick="mmGo(this); return false"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><img src="/images/mm-sep-0-1.gif" width="8" height="2"></td><td><img src="/images/mm-sep-0-2.gif" width="44" height="2"></td><td><img src="/images/mm-sep-0-3.gif" width="152" height="2"></td><td><img src="/images/mm-sep-0-4.gif" width="18" height="2"></td></tr><tr><td width="8" class="bgMMItemLeft"><img src="/images/mm-item-0-1.gif" width="8" height="16"></td><td width="44" class="bgMMItemLeftO"><img src="/images/mm-item-0-2-o.gif" width="44" height="16"></td><td width="152" align="left" valign="middle" class="bgMMItemO"><img src="/images/mm-bulet.gif" width="8" height="4" align="absmiddle"><a href="' + lnk + '" class="mmItemLinkO">' + txt + '</a></td><td width="18" class="bgMMItemRightO"><img src="/images/z.gif" width="1" height="1"></td></tr><tr><td><img src="/images/mm-sep-0-1.gif" width="8" height="2"></td><td><img src="/images/mm-sep-0-2.gif" width="44" height="2"></td><td><img src="/images/mm-sep-0-3.gif" width="152" height="2"></td><td><img src="/images/mm-sep-0-4.gif" width="18" height="2"></td></tr></table></div>'); break;
		case 1: document.write('<div id="' + id + 'd" style="position: absolute; top: 0px; left: 0px; width: 222px; height: 16px; cursor: hand; visibility: hidden;" onMouseOut="mmOver(this, 0); return false" onClick="mmGo(this); return false"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><img src="/images/mm-sep-1-1.gif" width="8" height="2"></td><td><img src="/images/mm-sep-1-2.gif" width="44" height="2"></td><td><img src="/images/mm-sep-1-3.gif" width="152" height="2"></td><td><img src="/images/mm-sep-1-4.gif" width="18" height="2"></td></tr><tr><td width="8" class="bgMMItemLeft"><img src="/images/mm-item-1-1.gif" width="8" height="16"></td><td width="44" class="bgMMItemLeftO"><img src="/images/mm-item-1-2-o.gif" width="44" height="16"></td><td width="152" align="left" valign="middle" class="bgMMItemO"><img src="/images/mm-bulet.gif" width="8" height="4" align="absmiddle"><a href="' + lnk + '" class="mmItemLinkO">' + txt + '</a></td><td width="18" class="bgMMItemRightO"><img src="/images/z.gif" width="1" height="1"></td></tr><tr><td><img src="/images/mm-sep-2-1.gif" width="8" height="2"></td><td><img src="/images/mm-sep-2-2.gif" width="44" height="2"></td><td><img src="/images/mm-sep-2-3.gif" width="152" height="2"></td><td><img src="/images/mm-sep-2-4.gif" width="18" height="2"></td></tr></table></div>'); break;
		case 2: document.write('<div id="' + id + 'd" style="position: absolute; top: 0px; left: 0px; width: 222px; height: 16px; cursor: hand; visibility: hidden;" onMouseOut="mmOver(this, 0); return false" onClick="mmGo(this); return false"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><img src="/images/mm-sep-2-1.gif" width="8" height="2"></td><td><img src="/images/mm-sep-2-2.gif" width="44" height="2"></td><td><img src="/images/mm-sep-2-3.gif" width="152" height="2"></td><td><img src="/images/mm-sep-2-4.gif" width="18" height="2"></td></tr><tr><td width="8" class="bgMMItemLeft"><img src="/images/mm-item-2-1.gif" width="8" height="16"></td><td width="44" class="bgMMItemLeftO"><img src="/images/mm-item-2-2-o.gif" width="44" height="16"></td><td width="152" align="left" valign="middle" class="bgMMItemO"><img src="/images/mm-bulet.gif" width="8" height="4" align="absmiddle"><a href="' + lnk + '" class="mmItemLinkO">' + txt + '</a></td><td width="18" class="bgMMItemRightO"><img src="/images/z.gif" width="1" height="1"></td></tr><tr><td><img src="/images/mm-sep-0-1.gif" width="8" height="2"></td><td><img src="/images/mm-sep-0-2.gif" width="44" height="2"></td><td><img src="/images/mm-sep-0-3.gif" width="152" height="2"></td><td><img src="/images/mm-sep-0-4.gif" width="18" height="2"></td></tr></table></div>'); break;
		case 3: document.write('<div id="' + id + 'd" style="position: absolute; top: 0px; left: 0px; width: 222px; height: 16px; cursor: hand; visibility: hidden;" onMouseOut="mmOver(this, 0); return false" onClick="mmGo(this); return false"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><img src="/images/mm-sep-0-1.gif" width="8" height="2"></td><td><img src="/images/mm-sep-0-2.gif" width="44" height="2"></td><td><img src="/images/mm-sep-0-3.gif" width="152" height="2"></td><td><img src="/images/mm-sep-0-4.gif" width="18" height="2"></td></tr><tr><td width="8" class="bgMMItemLeft"><img src="/images/mm-item-0-1.gif" width="8" height="16"></td><td width="44" class="bgMMItemLeftO"><img src="/images/mm-item-0-2-o.gif" width="44" height="16"></td><td width="152" align="left" valign="middle" class="bgMMItemO"><img src="/images/mm-bulet.gif" width="8" height="4" align="absmiddle"><a href="' + lnk + '" class="mmItemLinkO">' + txt + '</a></td><td width="18" class="bgMMItemRightO"><img src="/images/mm-item-3-4-o.gif" width="18" height="16"></td></tr><tr><td><img src="/images/mm-sep-0-1.gif" width="8" height="2"></td><td><img src="/images/mm-sep-0-2.gif" width="44" height="2"></td><td><img src="/images/mm-sep-0-3.gif" width="152" height="2"></td><td><img src="/images/mm-sep-3-4.gif" width="18" height="2"></td></tr></table></div>'); break;
	}
	coMMItem++;
}

function mmInit() {
	var i;
	for(i = 0; i < coMMItem; i++) {
		mmItems[i][2] = layer(mmItems[i][0] + "d");
	}
}

function mmOverGo(mmOverId) {
  if(self.mmOverTM) clearTimeout(mmOverTM);
	mmGeneralOverId = mmOverId;
	mmOverTM = setTimeout("mmOverDo()", curTM);
}

function mmOverDo(mmOverId) {
  mmOver(document.getElementById(mmGeneralOverId), 0);
}

function mmOver(obj, st) {
  var i, objTemp, objX = 0, objY = 0, objA;
	if(st) {
		if(mmTM) clearTimeout(mmTM);
		for(i = 0; i < coMMItem; i++) {
			if(!mmItems[i][0]) continue;
			if(mmItems[i][0] == obj.id) {
				if(mmItems[i][2] && mmItems[i][2].isExist()) {
					mmItems[i][2].moveTo(mmItems[i][1].getAbsoluteLeft(), mmItems[i][1].getAbsoluteTop() - 2);
					mmItems[i][2].show();
				}
			}
			else {
				if(mmItems[i][2] && mmItems[i][2].isExist() && mmItems[i][2].isVisible()) {
					mmItems[i][2].hide();
				}
			}
		}
	}
	else {
		if(mmTM) clearTimeout(mmTM);
		mmTM = setTimeout(mmClose, 10);
	}
}

function mmClose(id) {
	var i;
	if(mmTM) clearTimeout(mmTM);
	for(i = 0; i < coMMItem; i++) {
		if(mmItems[i][2] && mmItems[i][2].isExist() && mmItems[i][2].isVisible()) {
			mmItems[i][2].hide();
		}
	}
}

function mmGo(obj) {
	if(!isDOM) return;
	event.cancelBubble = true;
	var objA = obj.getElementsByTagName("A");
  if(objA[0]) window.location = objA[0].href;
}

//========================================================

var smOverColorN = "#000000";
var smOverColorO = "#CEBF00";

function smOver(obj, st) {
  if(!isDOM) return;
	var i, objStyle;
	var objA = obj.getElementsByTagName("A");
	for(i = 0; i < objA.length; i++) {
		objStyle = (objA[i].style) ? objA[i].style : objA[i];
		objStyle.color = (st) ? smOverColorO : smOverColorN;
	}
}

//========================================================

var hcOverColorN = "#C7C7C7";
var hcOverColorO = "#FFA81F";
var hcOverImg = new Array();

function hcOverIngPreload(nn, norm, over) {
	hcOverImg[nn] = new Array();
	hcOverImg[nn][0] = nn;
	hcOverImg[nn][1] = new Image();
	hcOverImg[nn][1].src = norm;
	hcOverImg[nn][2] = new Image();
	hcOverImg[nn][2].src = over;
}

function hcOver(obj, st, nn) {
  if(!isDOM) return;
	var i, objStyle;
	var objTD = obj.getElementsByTagName("TD");
	switch(nn) {
		case 1: ind1 = 3; ind2 = 4; break;
		case 2: ind1 = 2; ind2 = 3; break;
		case 3: ind1 = 3; ind2 = 2; break;
		case 4: ind1 = 2; ind2 = 1; break;
		default: return;
	}
	objStyle = (objTD[ind1].style) ? objTD[ind1].style : objTD[ind1];
	objStyle.backgroundColor = (st) ? hcOverColorO : hcOverColorN;
	objStyle = (objTD[ind2].style) ? objTD[ind2].style : objTD[ind2];
	objStyle.backgroundColor = (st) ? hcOverColorO : hcOverColorN;
	objTD[ind2].firstChild.src = (st) ? hcOverImg[nn][2].src : hcOverImg[nn][1].src;
}

function hcGo(obj) {
	if(!isDOM) return;
	event.cancelBubble = true;
	var objA = obj.getElementsByTagName("A");
  if(objA[0]) window.location = objA[0].href;
}

//========================================================


var mgOverColorN = "#000000";
var mgOverColorO = "#FFFFFF";
var mgOverBGColorN = "#D8D8D8";
var mgOverBGColorO = "#EB6B01";

function mgOver(obj, st) {
  if(!isDOM) return;
	var i, objStyle;
	var objTD = obj.getElementsByTagName("TD");
	// for metro shops
	//objStyle = (objTD[1].style) ? objTD[1].style : objTD[1];
  objStyle = (objTD[2].style) ? objTD[2].style : objTD[2];
	objStyle.color = (st) ? mgOverColorO : mgOverColorN;
	objStyle.backgroundColor = (st) ? mgOverBGColorO : mgOverBGColorN;
}

function mgGo(obj) {
	if(!isDOM) return;
	event.cancelBubble = true;
	var objA = obj.getElementsByTagName("A");
  if(objA[0]) window.location = objA[0].href;
}

//========================================================

function imageView(windowGUID, imgName, imgTitle, width, height) {
  if (width == null || width == 0) {
    width = 320;
  }
  if (height == null || height == 0) {
    height = 470;
  }
	if(!isDOM || isOpera) {
    window.open(imgName, '', 'width=' + (width + 20) + ', height='+(height + 25));
	} else {
		if(!imgTitle) imgTitle='';
		viewPhoto = window.open('', windowGUID, 'width=' + (width+20) + ', height=' + (height+25));
		viewPhoto.document.write('<html><head><title>' + imgTitle + '</title></head><body><strong style="font-family: Helvetica;">' + imgTitle + '</strong><br><table width="100%" height="100%" align="center" border="0" cellspacing="0" cellpadding="0"><tr><td width="100%" height="100%" align="center" valign="middle"><img src="' + imgName + '" border="0" alt="' + imgTitle + '"></td></tr></table></body></html>');
	}
}

function imageView3D(windowGUID, imgName, imgTitle, width, height) {
  if (width == null || width == 0) {
    width = 600;
  }
  if (height == null || height == 0) {
    height = 600;
  }
	if(!isDOM || isOpera) {
    window.open(imgName, '', 'width=' + (width) + ', height='+(height));
	} else {
		if(!imgTitle) imgTitle='';
		viewPhoto = window.open('', windowGUID, 'width=' + (width +25) + ', height=' + (height +25));
		viewPhoto.document.write('<html><head><title>' + imgTitle + '</title></head><body>');
    viewPhoto.document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" id='+windowGUID+' align="middle">');
    viewPhoto.document.write('<param name="allowScriptAccess" value="sameDomain" />');
    viewPhoto.document.write('<param name="movie" value="'+imgName+'.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="'+imgName+'.swf" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="'+imgName+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    viewPhoto.document.write('</object>');
		viewPhoto.document.write('</body></html>');
	}
}


function textView(windowGUID, win_text, win_title) {
  var width = 450;
  var height = 0;
  if (win_text.length < 600) {
    height = 180;
  } else if (win_text.length > 599 && win_text.length < 1000) {
    height = 230;
  } else if (win_text.length > 999 && win_text.length < 1500) {
    height = 300;
  } else {
    height = 500;
  }
  if (win_title == null) win_title = "";
  viewWindow = window.open('', windowGUID, 'width=' + (width+20) + ', height=' + (height+20));
	viewWindow.document.write('<html><head><title>' + win_title + '</title><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><link href="/css/bg.css" rel="stylesheet" type="text/css"><link href="/css/content.css" rel="stylesheet" type="text/css"></head><body><table width="100%" height="100%" align="center" border="0" cellspacing="0" cellpadding="0" class="tireCommentWindow"><tr><td width="100%" height="100%" align="left" valign="top" class="bgSRMainTD"><p style="margin: 15px">' + win_text + '</p><p align="center" style="margin: 5px"><a href="#" class="lnkTitleColor4" onClick="window.close(); return false;"><strong>Закрыть</strong></a></p></td></tr></table></body></html>');
}
//function showImage(filename, width, height) {
//  window.open(filename, "", "toolbar=no, menu=no, width="+(width+20)+", height="+(height+20)+", top=50, left=50, status=no");
//}

//========================================================

function BSMenu() {
  this.div = new Array();
  this.dcounter = 0;
}

BSM = BSMenu.prototype;

BSM.add = function(bsdObj) {
  this.div[this.dcounter++] = bsdObj;
}

BSM.render = function() {
  var bsdc, i, j, obj, ls, rs, str, resstr, arr, arItem, nstrb, nstre, coLt, coClt, coItem;
  arLt = new Array();
  arClt = new Array();
  for(bsdc = 0; bsdc < this.dcounter; bsdc++) {
    obj = this.div[bsdc];
	str = obj.lt; coLt = 0;
	nstrb = 0;
	while((nstre = str.indexOf("##", nstrb)) != -1) {
	  arLt[coLt++] = str.substring(nstrb, nstre);
	  arLt[coLt++] = str.substring(nstre, nstre + 8);
	  nstrb = nstre + 8;
	}
	arLt[coLt] = str.substring(nstrb);
	str = obj.clt; coClt = 0;
	nstrb = 0;
	while((nstre = str.indexOf("##", nstrb)) != -1) {
	  arClt[coClt++] = str.substring(nstrb, nstre);
	  arClt[coClt++] = str.substring(nstre, nstre + 8);
	  nstrb = nstre + 8;
	}
	arClt[coClt] = str.substring(nstrb);
	arr = obj.links;
	resstr = "";
    for(i = 0; i < obj.counter; i++) {
	  if(arr[i].state) {
	    arItem = arLt;
		coItem = coLt;
	  }
	  else {
	    arItem = arClt;
		coItem = coClt;
	  }
	  for(j = 0; j <= coItem; j++) {
	    switch (arItem[j]) {
		  	case '##DVID##': resstr += obj.id; break;
		  	case '##ITID##': resstr += 't' + i + obj.id; break;
		  	case '##LINK##': resstr += arr[i].url; break;
		  	case '##TEXT##': resstr += arr[i].text; break;
		  	case '##TRGT##': resstr += arr[i].target; break;
		  	default: resstr += arItem[j];
			}
	  }
    }
	str = obj.dt;
	nstrb = str.indexOf("##DVID##");
    ls = str.substring(0, nstrb);
    rs = str.substring(nstrb + 8);
    str = ls + obj.id + rs;
    nstrb = str.indexOf("##ITMS##");
    ls = str.substring(0, nstrb);
    rs = str.substring(nstrb + 8);
    str = ls + resstr + rs;
    document.write(str);
  }
}

function BSDiv(id, level, divTempl, linkTempl, curLinkTempl) {
  this.id = "d" + level + id;
  this.level = level;
  this.links = new Array();
  this.counter = 0;
  this.dt = divTempl;
  this.lt = linkTempl;
  this.clt = curLinkTempl;
}

BSD = BSDiv.prototype;

BSD.add = function(state, url, text, target) {
  this.links[this.counter++] = new BSItem(state, url, text, target);
}

BSD.itemOff = function(itm) {
  this.links[itm-1][0] = 0;
}

function BSItem(state, url, text, target) {
  this.state = state;
  this.url = url;
  this.text = text;
  this.target = (!target || target == "") ? "_top" : target;
}

BSI = BSItem.prototype;

divTempl = '<div id="##DVID##" style="position:absolute; left:1px; top:1px; z-index:30001; visibility: hidden" onMouseOver="if(mmTM) clearTimeout(mmTM); flClose=1; cancelCloseMenuLI(); return true" onMouseOut="mmOverGo(this.id.substring(2, this.id.length)); flClose=0; hideMenuLI(); return true"><table width="200" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse;">##ITMS##<tr><td class="bgDMItemLastEnd"><img src="/images/z.gif" width="1" height="3"></td></tr></table></div>';

linkTempl = '<tr><td width="100%" class="bgDMItemN" onMouseOver="this.firstChild.style.color=\'#FFFFFF\'; this.style.backgroundColor=\'#7B832A\'; return false" onMouseOut="this.firstChild.style.color=\'#454001\'; this.style.backgroundColor=\'#DFE0CC\'; return false" onClick="window.location=this.firstChild.href; return false"><a href="##LINK##" class="dmItemLinkN"><nobr>##TEXT##</nobr></a></nobr></td></tr>';

curLinkTempl = '<tr><td width="100%" class="bgDMItemLast" onMouseOver="this.firstChild.style.color=\'#FFFFFF\'; this.style.backgroundColor=\'#7B832A\'; return false" onMouseOut="this.firstChild.style.color=\'#454001\'; this.style.backgroundColor=\'#DFE0CC\'; return false" onClick="window.location=this.firstChild.href; return false"><a href="##LINK##" class="dmItemLinkN"><nobr>##TEXT##</nobr></a></nobr></td></tr>';

//========================================================

var tm, flClose = 0, coM = 0, curTM = 1000;
upMenuIni = new Array();
for(i=0; i<100; i++) {
  upMenuIni[i] = 0;
}
upMenu = new Array();
for(i=0; i<100; i++) {
  upMenu[i] = 0;
}

function initMenuLI(nm) {
  upMenuIni[coM] = new Array();
  upMenuIni[coM][0] = nm;
  coM++;
}

function renderMenuLI() {
  var i;
  for(i = 0; i < coM; i++) {
    upMenu[i] = new Array();
    upMenu[i][0] = upMenuIni[i][0];
    upMenu[i][1] = layer('d1' + upMenuIni[i][0]);
		upMenu[i][2] = layer(upMenuIni[i][0]);
  }
}

function showMenuLI(mItemName) {
  var i, p, mPosX, mPosY;
  imPos = new Array();
  for(i=0; i<coM; i++) {
		if(!upMenu[i][0]) continue;
    if(mItemName != upMenu[i][0]) {
      if(upMenu[i][1] && upMenu[i][1].isExist()) upMenu[i][1].hide();
    }
    else {
      cancelCloseMenuLI();
      if(upMenu[i][1] && upMenu[i][2] && upMenu[i][1].isExist()) {
        mPosX = upMenu[i][2].getAbsoluteLeft() + upMenu[i][2].getWidth() - 1;
        if(mPosX + upMenu[i][1].getWidth() > getWindowWidth())
          if((mPosX = getWindowWidth() - upMenu[i][1].getWidth()) < 0) mPosX = 0;
        mPosY = upMenu[i][2].getAbsoluteTop();
        if(mPosY + upMenu[i][1].getHeight() > getWindowHeight())
          if((mPosY = (imPos[1] - 24 < 0)) < 0) mPosY = 0;
        upMenu[i][1].moveTo(mPosX, mPosY);
				if(!isOpera) {
					document.getElementById('d1' + upMenu[i][0]).firstChild.width = upMenu[i][2].getWidth();
				}
        upMenu[i][1].show();
        curTM = 1000;
      }
      else {
        curTM = 0;
      }
    }
  }
}

function hideMenuLI() {
  if(self.tm) clearTimeout(tm);
  if(!flClose) tm=setTimeout("totalHideMenuLI()", curTM);
}

function totalHideMenuLI(){
  var i;
  for(i=0; i<coM; i++) {
    if(upMenu[i][1] && upMenu[i][1].isExist()) upMenu[i][1].hide();
  }
}

function cancelCloseMenuLI(){
  if(self.tm) clearTimeout(tm);
}

//========================================================


dWriteDiv = '<div id="zoomDIVfix" class="divFixSize">WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW</div>';
dWriteDiv += '<div id="zoomDIV" class="divSize" onresize="resDoc();">WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW</div>';

function resDoc() {
  var cz = Math.round(document.all.zoomDIV.offsetWidth / document.all.zoomDIVfix.offsetWidth * 100);
  if(cz > 95 && cz < 105) cz = 100;
  document.body.style.zoom = cz + "%";
}

function MM_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function checkSelectMakerForm () {
  var workForm = document.forms["select_maker"];
  if (workForm == null)
    return false;
  if (workForm.car_maker_id.value == 0) {
    alert("Пожалуйста, выберите сначала производителя автомобиля");
    workForm.car_maker_id.focus();
    return false;
  }
  return true;
}

 function checkFeedbackForm() {

   var workForm = document.forms["feedback_form"];
   if (workForm == null)
     return false;

   if (workForm.question.value.length == 0) {
     workForm.question.focus();
     return false;
   }
   return true;
 }

 function checkErrorForm() {

   var workForm = document.forms["error_form"];
   if (workForm == null)
     return false;

   if (workForm.message.value.length == 0) {
     workForm.message.focus();
     return false;
   }
   return true;
 }

 function checkOrderForm() {

   var workForm = document.forms["order_form"];
   if (workForm == null)
     return false;

   if (workForm.name.value.length == 0) {
     alert("Пожалуйста, введите Ваше имя и/или фамилию.");
     workForm.name.focus();
     return false;
   }

   if (workForm.address.value.length == 0) {
     alert("Пожалуйста, введите адрес для доставки заказанного Вами товара.");
     workForm.address.focus();
     return false;
   }

   if (workForm.email.value.length > 0) {
     if (!checkCustomerEmail(workForm.email.value)) {
       alert("Введенный Вами адрес электронной почты некорректен.");
       workForm.email.focus();
       return false;
     }
   }

   if (workForm.phone.value.length == 0) {
     alert("Пожалуйста, укажите Ваш телефон чтобы мы могли связаться с Вами для уточнения времени и адреса доставки.");
     workForm.phone.focus();
     return false;
   }
   return true;
 }

 function checkCustomerEmail(email) {
   if (!checkEmail(email)) {
     return false;
   }
   return chackForIncorrectSymbols(email);
 }


  function checkEmail(email) {
    var i = 0, coS = 0, cStr, flDot = true;
    while((i = email.indexOf('@', i + 1)) != -1) {
      coS++;
    }
    while((i = email.indexOf('.', i + 1)) != -1) {
      if(email.indexOf('.', i + 1) != -1 && (email.indexOf('.', i + 1) - i) == 1) flDot = false;
    }
    if(coS == 1 && flDot && email.indexOf(' ') == -1 && email.charAt(0) != '.') {
      var lStr = email.substring(0, email.indexOf('@'));
      var rStr = email.substring(email.indexOf('@') + 1, email.length);
      if(lStr.charAt(lStr.length - 1) != '.' && rStr.charAt(0) != '.') {
        if((coS = rStr.lastIndexOf('.')) != -1) {
          if((email.lastIndexOf('.') - email.indexOf('@')) > 1) {
            rStr = rStr.substring(coS + 1, email.length);
            if(rStr.length > 1) {
              return true;
            }
          }
        }
      }
    }
    return false;
  }

 function chackForIncorrectSymbols(value) {
   var correct_symbols = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789_-%.@";
   for (i=0; i < value.length; i++) {
     if (correct_symbols.indexOf(value.charAt(i)) != -1) {
       continue;
     } else {
       return false;
     }
   }
   return true;
 }


 function searchAtShop(id) {

   var W = 175;
   var H = 70;
   var D = 13;
   if (id == 2) {
     W = newWidth.options[newWidth.selectedIndex].value;
     H = newProfile.options[newProfile.selectedIndex].value;
     D = newRadius.options[newRadius.selectedIndex].value;
   } else {
     W = oldWidth.options[oldWidth.selectedIndex].value;
     H = oldProfile.options[oldProfile.selectedIndex].value;
     D = oldRadius.options[oldRadius.selectedIndex].value;
   }
   return location.href = "/tire-choice.htm?step=3&W="+W+"&H="+H+"&D="+D;
 }

 function calculate() {
   oldA.innerText = oldWidth.options[oldWidth.selectedIndex].value;
   newA.innerText = newWidth.options[newWidth.selectedIndex].value;
   difA.innerText = newA.innerText - oldA.innerText;

   oldC.innerText = Math.round(oldRadius.options[oldRadius.selectedIndex].value*25.4);
   newC.innerText = Math.round(newRadius.options[newRadius.selectedIndex].value*25.4);
   difC.innerText = newC.innerText - oldC.innerText;

   oldD.innerText = Math.round(oldWidth.options[oldWidth.selectedIndex].value*oldProfile.options[oldProfile.selectedIndex].value*0.02
        +oldRadius.options[oldRadius.selectedIndex].value*25.4);
   newD.innerText = Math.round(newWidth.options[newWidth.selectedIndex].value*newProfile.options[newProfile.selectedIndex].value*0.02
        +newRadius.options[newRadius.selectedIndex].value*25.4);
   difD.innerText = newD.innerText - oldD.innerText;

   oldB.innerText = Math.round((oldD.innerText - oldC.innerText)/2);
   newB.innerText = Math.round((newD.innerText - newC.innerText)/2);
   difB.innerText = newB.innerText - oldB.innerText;

   difClearense.innerText = (Math.round(newWidth.options[newWidth.selectedIndex].value*newProfile.options[newProfile.selectedIndex].value*0.02
        +newRadius.options[newRadius.selectedIndex].value*25.4)
        -Math.round(oldWidth.options[oldWidth.selectedIndex].value*oldProfile.options[oldProfile.selectedIndex].value*0.02
        +oldRadius.options[oldRadius.selectedIndex].value*25.4))/2;

    newSpeed.innerText = Math.round((Math.round(newWidth.options[newWidth.selectedIndex].value*newProfile.options[newProfile.selectedIndex].value*0.02
        +newRadius.options[newRadius.selectedIndex].value*25.4)
        /Math.round(oldWidth.options[oldWidth.selectedIndex].value*oldProfile.options[oldProfile.selectedIndex].value*0.02
        +oldRadius.options[oldRadius.selectedIndex].value*25.4))*oldSpeed.value*100)/100;
    difSpeed.innerText = Math.round((newSpeed.innerText - oldSpeed.value)*100)/100;

  }

  function validate(value) {
    var float_exp = /^\s*-?(\d+\.\d*|\d*\.\d+|\d+)\s*$/;
    if (value.search(float_exp) == -1) {
      return false;
    } else {
      var val = parseFloat(value);
      if (isNaN(val)) {
        return false;
      }
    }
    return true;
  }


  function checkValue(evt, value) {
    evt = (evt) ? evt : event;
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode == 13 && validate(value)) {
      calculate();
    }
    return true;
  }

 function checkSteelWheelForm() {
   var workForm = document.forms["select_steel_wheel"];
   if (workForm == null)
     return false;
  if (workForm.car_model_id.value == 0) {
    alert("Пожалуйста, выберите сначала модель автомобиля.");
    workForm.car_model_id.focus();
    return false;
  }
   return true;
 }

 function checkReservationForm() {

   var workForm = document.forms["res_form"];
   if (workForm == null)
     return false;

   if (workForm.name.value.length == 0) {
     alert("Пожалуйста, введите Ваше имя и/или фамилию.");
     workForm.name.focus();
     return false;
   }

   if (workForm.phone.value.length == 0) {
     alert("Пожалуйста, укажите Ваш телефон чтобы мы могли связаться с Вами для подтверждения факта резервирования.");
     workForm.phone.focus();
     return false;
   }
   return true;
 }


 function checkSHMForm() {

   var workForm = document.forms["SHM_form"];
   if (workForm == null)
     return false;

   if (workForm.name.value.length == 0) {
     alert("Пожалуйста, введите Ваше имя и/или фамилию.");
     workForm.name.focus();
     return false;
   }

   if (workForm.phone.value.length == 0) {
     alert("Пожалуйста, введите Ваш контактный телефон.");
     workForm.phone.focus();
     return false;
   }

   if (workForm.date_and_time.value.length == 0) {
     alert("Пожалуйста, укажите планируемую дату и время шиномонтажа.");
     workForm.date_and_time.focus();
     return false;
   }

   if (workForm.car_and_size.value.length == 0) {
     alert("Пожалуйста, укажите модель Вашего автомобиля и размер шин.");
     workForm.car_and_size.focus();
     return false;
   }

   if (workForm.address.value.length == 0) {
     alert("Пожалуйста, укажите адрес.");
     workForm.address.focus();
     return false;
   }

   return true;
 }

function confirmUrl(targetUrl, dlgMsg) {
  if (targetUrl == null || targetUrl == "")
    return false;
      var realDlgMsg = 'Are you sure?';
      if (dlgMsg != null && dlgMsg != "") {
        realDlgMsg = dlgMsg;
      }
    if (window.event.srcElement.tagName == "A") {
      window.event.cancelBubble = true;
      return confirm(realDlgMsg);
    }
  if (confirm(realDlgMsg)) {
    location.href = targetUrl;
    return true;
  }
  return false;
}
