isDOM=document.getElementById //DOM1 browser (MSIE 5+, Netscape 6, Opera 5+)
isOpera=isOpera5=window.opera && isDOM //Opera 5+
isOpera6=isOpera && window.print //Opera 6+
isOpera7=isOpera && document.readyState //Opera 7+
isMSIE=document.all && document.all.item && !isOpera //Microsoft Internet Explorer 4+
isMSIE5=isDOM && isMSIE //MSIE 5+
isNetscape4=document.layers //Netscape 4.*
isMozilla=isDOM && navigator.appName=="Netscape" //Mozilla или Netscape 6.*

function clearText(thefield) {
    if (thefield.defaultValue==thefield.value) { thefield.value = ""; }
} 


function print_r(obj) {
  var allProp = '';
  for (var i in obj) {
    allProp = allProp+"["+i+" = "+obj[i]+"] ";
  }
  alert(allProp);
}

if (moz) {
        extendElementModel();
        extendEventObject();
        emulateEventHandlers(["mousemove", "mousedown", "mouseup"]);
}

function initScroller() {
    if (window.document.body.clientHeight && window.document.body.scrollHeight) {
        var docAvail  = window.document.body.clientHeight;
        var docInNeed = window.document.body.scrollHeight;

        if (docInNeed<=docAvail) {
            if (window.document.getElementById("goOnTop1")) {
                window.document.getElementById("goOnTop1").style.display = "none";
                window.document.getElementById("goOnTop2").style.display = "none";
                window.document.getElementById("goOnTop3").style.display = "none";
            }
        }
    }
}

// function for popup ---------------------------
function advOpen(openUrl, openWidth, openHeight, openSwitch) {
    var srw = screen ? (screen.width-50)    : 750;
    var srh = screen ? (screen.height-36)   : 564;
    var openScroll  = "0";

    if ((openWidth>srw) || (openHeight>srh)) {
        openScroll  = "1";
        if (openHeight>srh) { openWidth  = openWidth+16; openHeight = srh-50; }
        if (openWidth>srw)  { openHeight = openHeight+16; openWidth = srw-50; }
    }
    
    srw     = (srw - openWidth)/2;
    srh     = (srh - openHeight)/5;
    
    openParameters  = "left="+srw+",top="+srh+",outerHeight=0,innerWidth,width="+openWidth+",innerHeight,height="+openHeight+",scrollbars="+openScroll+",titlebar=1,resizable=0";    
    switch(openSwitch) {
        case "print":   openParameters  = "left="+srw+",top="+srh+",outerHeight=0,innerWidth,width="+openWidth+",innerHeight,height="+openHeight+",scrollbars=1,titlebar=1,resizable=0,menubar=1"; break;
    }
    var openPopup   = open(openUrl, '', openParameters);
    return false;
}

// functions for layers -------------------------
function layerStyle(layerObject){
  if(layerObject.style) return layerObject.style //доступ через style
  return layerObject //доступ без style
}
function layer(layerName){
  if(document.getElementById) return document.getElementById(layerName)
  if(document.all) return document.all[layerName]
  if(document.layers) return document.layers[layerName]
  return null
}

function printPage() {
  var pr = (window.print) ? 1 : 0;
  if (pr) // NS4, IE5
    window.print()
  else if (da && !mac) // IE4 (Windows)
    vbPrintPage()
  else // muut
    alert("Can't Print");
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

