var opera=false;
var gecko=false;
var ie=false;
var safari=false;
var browser=navigator.userAgent.toLowerCase();
var ver=parseFloat(navigator.appVersion);
if(browser.indexOf('msie')!=-1) {
  ie=true;  
  if(browser.indexOf('msie 5.5')!=-1)ver=5.5;
  else if(browser.indexOf('msie 5')!=-1)ver=5;
}

if(browser.indexOf('opera')!=-1)opera=true;
if(browser.indexOf('gecko')!=-1)gecko=true;
if(browser.indexOf('safari')!=-1)safari=true;
/*
function BackgroundPNG(element,method)
{if(ie){
if (method === undefined ) method = '';
var src;
src=element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)[1];
element.style.backgroundImage='none';
element.style.filter="progid:dximagetransform.microsoft.alphaimageloader(src='"+src+"',sizingmethod="+method+")";
}}
*/
function fixPNG(element,method) {
  //Если браузер IE версии 5.5-6
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
      if (method === undefined ) method = '';
      var src;
      //
      if (element.tagName=='IMG') {//Если текущий элемент картинка (тэг IMG)
          if (/\.png$/.test(element.src)) {//Если файл картинки имеет расширение PNG
              src = element.src;
              element.src = "/images/spacer.gif"; //заменяем изображение прозрачным gif-ом
          }
      } else {//иначе, если это не картинка а другой элемент
          //если у элемента задана фоновая картинка, то присваеваем значение свойства background-шmage переменной src
          src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
          if (src) {
              src = src[1]; //берем из значения свойства background-шmage только адрес картинки
              element.runtimeStyle.backgroundImage="none"; //убираем фоновое изображение
          }
      }
      //если, src не пуст, то нужно загрузить изображение с помощью фильтра AlphaImageLoader
      if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='" + method + "')";
  }
}

function myFunc() {
            //frames["info"].location.reload(true);
            //parent.windows.location.reload();
          }

function MM_openBrWindow(theURL,winName,features) { //v2.0
  return  window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  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);

// MSIE - document.body.clientWidth, clientHeight 
// Netscape, Mozilla, Opera - innerWidth, innerHeight
 var tim; // таймер

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  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 theWindow = null;
function newWindow(meineSeite,meinName,w,h,scroll,tool) {
        LeftPosition = (screen.width) ? (screen.width-w)/2-30 : 0;
        TopPosition = (screen.height) ? (screen.height-h)/2-40 : 0;
        settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',resizable=yes,scrollbars='+scroll+',toolbar='+tool+'';
        theWindow = window.open(meineSeite,meinName,settings,true);
}

function PressButton(name) {    
    document.getElementById(name).name=name;
    document.getElementById(name).form.submit();
}

function showDIV(id) {document.getElementById(id).style.display='block';}
function hideDIV(id) {document.getElementById(id).style.display='none';}
function ShowHideDIV(id) {
	if (document.getElementById(id).style.display=='block') 
		document.getElementById(id).style.display='none'; 
	else 
		document.getElementById(id).style.display='block';
}
//function ShowHideDIV(id) {if (document.getElementById(id).style.display=='none') document.getElementById(id).style.display=='block'; else document.getElementById(id).style.display=='none';}

/*
function serialize(array) {
    out='a:'+20+":{";
    for(i in array) {
        array[i]
    }
}
*/

function CheckBox_Check(id,value) {
    obj = document.getElementById(id);
    if (!obj) return;
    if (!value) value=(obj.checked? false:true);
    obj.checked=(value? true:false);
}

function doNothing() {
}

var DivGlassID=0;
function showGlass(id,id_back) {    
    doScale(id_back);
    DivGlassID=id;
    document.getElementById(id_back).style.display="block"; 
    document.getElementById(id).style.display="block";  
}


function hideGlass(id_back) {
    document.getElementById(id_back).style.display="none";
    document.getElementById(DivGlassID).style.display="none";
}

function doScale(id) {      
    if(!ie) {       
        document.getElementById(id).style.height=document.height;   
        w=document.width;       
        if(w<800) document.getElementById(id).style.width="800px";
        else document.getElementById(id).style.width=document.width;
    }
    
    
}

function doShowInNewWindow(url,w,h) {
    window.open(url, '', 'height=' + h + ',width=' + w + ',scrollbars=1,center=yes,help=no,resizable=yes,status=no,toolbar=no');
    return false;
}

//
function Dump(d,l) {
    if ((typeof(d) == "object") && (l<=0)) return "{object}";
    var s = '';
    if (typeof(d) == "object") {
        s += typeof(d) + " {\n";
        for (var k in d) {
            for (var i=0; i<l; i++) s += "  ";
            s += k+": " + Dump(d[k],l-1);
        }
        for (var i=0; i<l-1; i++) s += "  ";
        s += "}\n"
    } else {
        s += "" + d + "\n";
    }
    return s;
}
//
function v(d,l) {
    if (l == null) l = 1;
    alert(Dump(d,l));
}
//

function pageRelocate(url) {window.location=url;}


