var NN = false;
var IE = false;
var NN6 = false;

function init() {
var b = getBrowserInfo();
IE =  (b.type == 'IE' || b.type == 'Opera')?1:0;
NN =  (b.type == 'Netscape' && b.version < 6)?1:0;
NN6 = (b.type == 'Netscape' && b.version >= 6)?1:0;
NN6 = (IE)?0:NN6;
}

function getBrowserInfo() {
 var t,v = undefined;
 if (window.opera) t = 'Opera';
 else if (document.all) {
  t = 'IE';
  var nv = navigator.appVersion;
  var s = nv.indexOf('MSIE')+5;
  v = nv.substring(s,s+1);
 }
 else if (navigator.appName) t = 'Netscape';
 return {type:t,version:v};
}

function bookmark(a){
 var url = window.document.location;
 var title = window.document.title;
 var b = getBrowserInfo();
 if (b.type == 'IE' && 7 > b.version && b.version >= 4) window.external.AddFavorite(url,title);
 else if (b.type == 'Opera') {
  a.href = url;
  a.rel = "sidebar";
  a.title = url+','+title;
  return true;
 }
 else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
 else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
 return false;
}

// ===================================================================================================

function Flip (cImgName, cFileName, iOver) {
  if (document.images) document.images[cImgName].src = "/img/" + cFileName + (iOver ? "x" : "") + ".gif";
}

function show (name) {
  if (NN) {document.layers[name].visibility = "show"}
  else if (NN6) {document.getElementById(name).style.visibility = "visible"}
  else {document.all[name].style.visibility = "visible"}
}

function hide (name) {
  if (NN) {document.layers[name].visibility = "hide"}
  else if (NN6) {document.getElementById(name).style.visibility = "hidden"}
  else {document.all[name].style.visibility = "hidden"}
}

function ShowPage (cNamePage, nWidth, nHeight, strParam) {
  nLeft= (screen.width - nWidth) / 2;
  nTop= (screen.height - nHeight) / 2;
  if (IE) window.open (cNamePage, 'NewPage', 'top=' + nTop+ ', left=' + nLeft + ', width=' + nWidth + ', height=' + nHeight + ', ' + strParam); else window.open (cNamePage);
}

function ShowEasyWin (cURL, nX, nY) {
   var b = getBrowserInfo();
   var nTop = (b.type == 'Opera')?55:35;
   var posX = Math.round ((screen.width - nX) / 2);
   var posY = Math.round ((screen.height - nY - nTop) / 2);
   var XYCode = (NN)? "screenX="+posX+",screenY="+posY : "left="+posX+",top="+posY;
   pictWindow = window.open (cURL, "Picture", "resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no,width="+nX+",height="+nY+"," + XYCode);
   pictWindow.focus ();
   return false;
}

function ShowJustWin (cURL, nX, nY) {
   var b = getBrowserInfo();
   var nTop = (b.type == 'Opera')?55:35;
   var posX = Math.round ((screen.width - nX) / 2);
   var posY = Math.round ((screen.height - nY - nTop) / 2);
   var XYCode = (NN)? "screenX="+posX+",screenY="+posY : "left="+posX+",top="+posY;
   pictWindow = window.open (cURL, "Picture", "resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no,statusbar=no,width="+nX+",height="+nY+"," + XYCode);
   pictWindow.focus ();
   void (0);
}


// ===================================================================================================

function go2 (url)
{
  if (opener){
    if (opener.closed)
      window.open (url, "");
    else
      opener.location.href = url;
    self.close();
    return false;
  }
  return true;
}

function ShiftBack (name, cNewPos) {
  document.getElementById(name).style.backgroundPosition = cNewPos
}

function noService ()
{
  alert ('Сервис находится в состоянии разработки.')
}
