isDOM=(document.getElementById)?true:false;
isOpera=isOpera5=window.opera && isDOM;
isMSIE=isIE=document.all && document.all.item && !isOpera;

window.onLoadListeners  = new Array();


window.onAddListener = function add(listener)   {
   if (window.onLoadListeners.length) {
       var length = window.onLoadListeners.length;
   }
   else
       var length=0;
   window.onLoadListeners[length] = listener;
}

var tempFunc = window.onload;
window.onload = function(){
	if (typeof (tempFunc) == "function"){
		try{
			tempFunc();
		} catch(e){}
	}
	for (i = 0; i<window.onLoadListeners.length; i++) {
     var func = window.onLoadListeners[i];
	 func();
   }
}

function ShowPicture(pic, w, h, title, noinfo) {
    var winW = w;
    var winH = h;

   var vieWin = window.open('', '_blank', "top=100,left=100,width="+(winW)+",height="+(winH)+",status=0");
       vieWin.document.clear();
       vieWin.document.writeln('<html>');
       vieWin.document.writeln('<head>');
       vieWin.document.writeln('<title>'+title+'</title>');
       vieWin.document.writeln('</head>');
       vieWin.document.writeln('<body bgcolor="#FFFFFF" style="margin:0px">');
       vieWin.document.writeln('<img onclick="window.close();" title="Закрыть окно" src="'+pic+'" width="'+w+'" height="'+h+'" border="0" vspace="0" style="cursor:hand;cursor:pointer;" />');
       vieWin.document.writeln('</body>');
       vieWin.document.writeln('</html>');
       vieWin.document.close();
   return false;
}

function ShowPictureWithPrint(pic, w, h, title, noinfo, print_url, print_w, print_h) {
    var winW = w;
    var winH = h*1+39;

   var vieWin = window.open('', '_blank', "top=100,left=100,width="+(winW)+",height="+(winH)+",status=0");
       vieWin.document.clear();
       vieWin.document.writeln('<html>');
       vieWin.document.writeln('<head>');
       vieWin.document.writeln('<title>'+title+'</title>');
       vieWin.document.writeln('</head>');
		 vieWin.document.writeln('<body bgcolor="#FFFFFF" style="margin:0px">');
       vieWin.document.writeln('<div style="text-align: center; padding: 8px 0px 8px 0px;"><input type="button" class="ctl" value="Версия для печати" onclick="window.open(\''+print_url+'\', \'_blank\', \'top=100,left=100,width='+(print_w)+',height='+(print_h)+',status=0\'); window.close();" /></div>');
       vieWin.document.writeln('<img onclick="window.close();" title="Закрыть окно" src="'+pic+'" width="'+w+'" height="'+h+'" border="0" vspace="0" style="cursor:hand;cursor:pointer;" />');
       vieWin.document.writeln('</body>');
       vieWin.document.writeln('</html>');
       vieWin.document.close();
   return false;
}

function ShowSlab(loc, w, h) {
   var viewWin = window.open(loc, '_blank', "top=100,left=100,width="+w+",height="+h+",status=0,scrollbars");
   return false;
}

function ShowImages(loc, w, h, scroll) {
   var viewWin = window.open(loc, '_blank', "top=100,left=100,width="+w+",height="+h+",status=0"+scroll);
   return false;
}

function checkSearch(objForm) {
    if (objForm.q.value) {
      return true;
    } else {
        alert('Необходимо заполнить поле поиска');
        return false;
    }
}

function onViewSearch(objElm) {
    if (objElm.value  == 'поиск' || objElm.value == 'Введите Ваш e-mail')
      objElm.value = '';
    return true;
}


 function disabletext(e){
    if (e && e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA' ) return false;
    return;
 }

 function disableEvent(elm) {
     if (isDOM && !isMSIE) {
        document.getElementById(elm).onmousedown=disabletext;
        document.getElementById(elm).onclick=new Function("return true");
    } else {
        document.getElementById(elm).onselectstart=new Function ("return false");
    }
 }
 
function popupDiv(id, obj, text) {
   var div = document.getElementById(id);
   if (typeof div == 'undefined')
      return false;
   if (div.style.display != 'block') {
      div.style.display = 'block';
      obj.innerHTML = 'Свернуть <img src="/image/arrow_up_open.gif" alt="" width="15" height="13">';
      
      var divs = document.getElementsByTagName('div');
      var length = divs.length;
      for (var i = 0; i < length; i++) {
         var attr = divs[i].className;
         var div_id = divs[i].getAttribute('id');
         
         if ( (div_id != id) && attr && (attr.indexOf('popup') != -1)) {
            divs[i].style.display = 'none';
            var parent = divs[i].parentNode;
            var links = parent.getElementsByTagName('a');
            for (var j = 0; j < links.length; j++) {
               var attr_click = links[j].getAttribute('onclick')+'';
               if (attr_click && attr_click.match(/popupDiv/) && (attr_click.indexOf(id) == -1)) {
                  links[j].innerHTML = '<img src="/image/arrow_down.gif" alt="" width="15" height="13">';
               }
            }
         }
      }
   }
   else {
      div.style.display = 'none';
      obj.innerHTML = text;
   }
}

