var ie = 0;
var ie6 = 0;
//----------------------------------------------------------------------------
function PreloadImages() {
	var ArrImg = new Array('citata.gif','map_big.gif','map_print.jpg','tooltip.gif','various/menu_hover5.gif','various/menu_hover7.gif','various/menu_hover9.gif','various/menu_hover12.gif','various/menu_hover13.gif','various/menu_hover14.gif','various/menu_hover15.gif','various/menu_hover16.gif','various/menu_hover17.gif','various/menu_hover18.gif');
  for (var i=0; i<ArrImg.length; i++) {
		var img = new Image();
		img.src = '/images/'+ArrImg[i];
  }
}
//----------------------------------------------------------------------------
function StylePrintOn(site) {
  if (site == null) {
    var vers_name = "Полная версия";
    var js = "javascript:StylePrintOff()";
  } else {
    var vers_name = "For screen";
    var js = "javascript:StylePrintOff(2)";
  }
  var inHead = document.documentElement.firstChild.childNodes;
  for (i=0; i<inHead.length; i++) {
  	if (inHead[i].nodeName == 'LINK') {
  		str = inHead[i].getAttribute("href");
  		str = str.substring(str.length-8);
  		if (str == "null.css") {inHead[i].setAttribute("href","/include/print.css");}
  	}
  }
  var obj = document.getElementById("switch_style");
  obj.innerHTML = vers_name;
  obj.setAttribute("href",js);

}
//----------------------------------------------------------------------------
function StylePrintOff(site) {
  if (site == null) {
    var vers_name = "Версия для печати";
    var js = "javascript:StylePrintOn()";
  } else {
    var vers_name = "For print";
    var js = "javascript:StylePrintOn(2)";
  }
  var inHead = document.documentElement.firstChild.childNodes;
  for (i=0; i<inHead.length; i++) {
  	if (inHead[i].nodeName == 'LINK') {
  		str = inHead[i].getAttribute("href");
  		str = str.substring(str.length-9);
  		if (str == "print.css") {inHead[i].setAttribute("href","/include/null.css");}
  	}
  }
  var obj = document.getElementById("switch_style");
  obj.innerHTML = vers_name;
  obj.setAttribute("href",js);
}
//----------------------------------------------------------------------------
function ShowMenuCitata(o,str,xx,yy) {
	var obj = document.getElementById('ahover');
	if (xx && yy) {
    obj.style.right = xx +'px';
    obj.style.top = yy +'px';		
	} else {
		obj.style.top = (absPosition(o).y - 90) +'px';
	};
  obj.innerHTML = str;
  obj.style.display = 'block';
}
//----------------------------------------------------------------------------
function ShowCitata(o,str,xx,yy) {
	if (!xx) {xx = 0};
	if (!yy) {yy = 20};
  var obj = document.getElementById('citata');
  obj.style.top = (absPosition(o).y + yy) +'px';
  obj.style.left = (absPosition(o).x + xx) +'px';
  obj.innerHTML = str;
  obj.style.display = 'block';
}
//----------------------------------------------------------------------------
function ShowBlockSlowly(i) {
  var obj = document.getElementById('map_big');
  obj.style.width = i + 'px';
  obj.style.display = 'block';
  if (i>860) {return;}
  i+=20;
  setTimeout("ShowBlockSlowly("+i+")",10);
}
//----------------------------------------------------------------------------
function ShowBlock(div) {
  var obj = document.getElementById(div);
  obj.style.display = 'block';
}
//----------------------------------------------------------------------------
function HideBlock(id_block) {
  var obj = document.getElementById(id_block);
  obj.style.display = 'none';
}
//----------------------------------------------------------------------------
function absPosition(obj) {
  var x = y = 0;
  while(obj) {
        x += obj.offsetLeft;
        y += obj.offsetTop;
        obj = obj.offsetParent;
  }
  return {x:x, y:y};
}
//- Подсветка невведенных окошек ----------------------------------------------
var o;
var o_color = 'red';
var counter = 1;
//----------------------------------------------------------------------------
function CheckRequared(o_frm,vars) {
  for (var k in vars) {
    if (o_frm[vars[k]].value) {continue;}
    o = o_frm[vars[k]];
    if (!o.type || o.type == 'file') {continue;}
    counter = 1;
    o_color = 'red';
    o.value = ' Введите данные';
    o.focus();
    setTimeout("ChangeBg()",10);
    return false;
  }
  return true;
}
//----------------------------------------------------------------------------
function ChangeBg() {
  counter++;
  if (counter > 8) {o.value = ''; return;}
  o_color = (o_color == 'red') ? 'white' : 'red';
  o.style.background = o_color;
  setTimeout("ChangeBg()",300)
}
//----------------------------------------------------------------------------
function bookmark() {
  var title = "Media Com.pass";
  var url = "http://www.mcompass.ru/";
  if (window.sidebar) {window.sidebar.addPanel(title, url, "");}
//  else if (window.opera && window.print) {
//                    var elem = document.createElement('a');
//                    elem.setAttribute('href',url);
//                    elem.setAttribute('title',title);
//                    elem.setAttribute('rel','sidebar');
//                    elem.click();
//        }
  else if (document.all) {window.external.AddFavorite(url, title);}
  else {alert("Попробуйте добавить вручную");}
  return false;
}
//----------------------------------------------------------------------------
function PrintMap() {
  var url_map = "http://www.mcompass.nktp.ru/map_print.html";
  var ww = window.open(url_map,'','',false);
}
//-----------------------------------------------

