DOM = document.getElementById;
var is_nn4 = document.layer;
var is_nn6 = Mozilla = (navigator.appName == "Netscape") && DOM;
var is_nn7 = navigator.userAgent.indexOf("Netscape/7") >= 0;
var is_op5 = window.opera && DOM;
var is_op6 = is_op5 && window.print;
var is_op7 = is_op5 && navigator.userAgent.indexOf("Opera 7") >= 0;
var is_op8 = navigator.userAgent.indexOf("Opera/8") >= 0;
var is_op9 = navigator.userAgent.indexOf("Opera/9") >= 0;
var is_op10 = navigator.userAgent.indexOf("Opera/10") >= 0;
var is_nn = is_nn4 || is_nn6 || is_nn7;
var is_op = is_op5 || is_op6 || is_op7 || is_op9 || is_op10;
var is_ie = document.all && !is_op5;
var is_ff = navigator.userAgent.indexOf("Firefox") >= 0;

var img_home1 = new Image(24, 24);
    img_home1.src = "/images/home1.gif";
var img_home2 = new Image(24, 24);
    img_home2.src = "/images/home2.gif";
var img_mail1 = new Image(24, 24);
    img_mail1.src = "/images/mail1.gif";
var img_mail2 = new Image(24, 24);
    img_mail2.src = "/images/mail2.gif";
var img_rss1 = new Image(24, 24);
    img_rss1.src = "/images/rss1.gif";
var img_rss2 = new Image(24, 24);
    img_rss2.src = "/images/rss2.gif";	
var img_load = new Image(100, 100);
    img_load.src = "/images/load.gif";	
	
function getRandomStr() {
  var str = '';
  for (i=1; i<=8; i++) str = str+String.fromCharCode(Math.floor(Math.random()*26)+65);
  return str;
}
function fieldMaxlen(field, maxlen) {
  rec = field.value;
  strlength= rec.length;
  if (strlength > maxlen) {
    field.value=rec.substring(0, maxlen);
    field.focus();
  }
}
function getDocumentWidth() {
  return (document.body.scrollWidth > document.body.offsetWidth) ? document.body.scrollWidth : document.body.offsetWidth-20;
}  
function getDocumentHeight() {
  return (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight;
}
function getClientWidth() {
  return self.innerWidth ? self.innerWidth : (document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth);
}
function getClientHeight() {
  return self.innerHeight ? self.innerHeight : (document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight);
}
function getBodyScrollTop() {
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}
function imgDivShow(im, comment) {  
  cw = getClientWidth();  
  ch = getClientHeight();   
  prvLr = document.getElementById('prvDiv');
  prvLr.style.display = 'none';      
  bgLr = document.getElementById('bgDiv');    
  if (is_ie) {
    bgLr.style.height = getDocumentHeight();	
    if (ieHack = document.getElementById('selIeHack')) ieHack.style.visibility = 'hidden';
  }
  imgID = document.getElementById('imgIDiv');  
  imgID.src = '/images/blank.gif';
  imgLr = document.getElementById('imgDiv');    
  imgLr.style.width = 100+'px'; 
  imgLr.style.height = 100+'px';   
  imgLr.style.left = (parseInt(cw/2)-50)+'px';   
  imgLr.style.top = (getBodyScrollTop()+parseInt(ch/2)-50)+'px';  
  imgLr.style.background = 'none';  
  imgLr.style.backgroundImage = 'url(/images/load.gif)';  
  imgPD = document.getElementById('imgPDiv'); 
  imgPD.innerHTML = '';    
  img = new Image();
  img.src = '/images/jpg/img_'+im+'.jpg?ih='+getRandomStr();
  img.onload = function () {
    if (bgLr.style.display == 'block') { 
	  cw = getClientWidth();  
	  ch = getClientHeight(); 	  
	  imgID = document.getElementById('imgIDiv');   
	  imgID.src = img.src;	  
	  imgLrW = img.width+20;
	  imgLrH = img.height+36;	
	  imgLr.style.width = imgLrW+'px';
	  imgLr.style.height = imgLrH+'px';
	  imgLrHOfs = imgLrH < ch ? (getBodyScrollTop()+parseInt(ch/2)-parseInt(imgLrH/2)) : (getBodyScrollTop()+parseInt(ch/2)-parseInt(imgLrH/2)+parseInt((imgLrH-ch)/2));
	  imgLr.style.left = imgLrW < cw ? (parseInt(cw/2)-parseInt(imgLrW/2))+'px' : 0+'px';
	  imgLr.style.top = imgLrHOfs+imgLrH < getDocumentHeight() ? imgLrHOfs+'px' : 0+'px';
	  imgLr.style.backgroundImage = 'none'; 
      imgLr.style.background = 'white'; 	  
      imgPD = document.getElementById('imgPDiv'); 
      imgPD.innerHTML = comment;    	
	  imgPD.style.visibility = 'visible';   
      imgID.style.display = 'block'; 
    }  
  }
  imgLr.style.display = 'block';   
  bgLr.style.display = 'block'; 
}
function imgDivHide() {
  bgLr = document.getElementById('bgDiv');
  imgLr = document.getElementById('imgDiv');  
  imgID = document.getElementById('imgIDiv');  
  imgPD = document.getElementById('imgPDiv'); 
  if (ieHack = document.getElementById('selIeHack')) ieHack.style.visibility = 'visible'; 
  imgLr.style.width = 100+'px'; 
  imgLr.style.height = 100+'px'; 
  imgLr.style.backgroundImage = 'url(/images/load.gif)';  
  imgPD.style.visibility = 'hidden'; 
  imgPD.innerHTML = '';  
  imgID.style.display = 'none';  
  imgLr.style.display = 'none';  
  bgLr.style.display = 'none'; 
}
function preveiwShow(im, evnt) {  
  bgLr = document.getElementById('bgDiv');   
  prvLr = document.getElementById('prvDiv');
  if (!evnt) evnt = window.event;
  if (evnt.clientY > 100) {
    prvLr.style.left = evnt.clientX+document.body.scrollLeft+5+'px';
    prvLr.style.top = evnt.clientY+getBodyScrollTop()-105+'px';
  }
   else {
     prvLr.style.left = evnt.clientX+document.body.scrollLeft+5+'px';
     prvLr.style.top = evnt.clientY+getBodyScrollTop()+5+'px';
   } 
  prvLr.style.backgroundImage = 'url(/images/load.gif)'; 
  img = new Image();
  img.src = '/images/jpg/img.php?im='+im+'&ih='+getRandomStr(); 
  img.onload = function () {
    prvImg = document.getElementById('imgPrv');  
    prvImg .src = img.src;	 
	prvLr.style.backgroundImage = 'none';
    prvImg .style.display = 'block'; 	
  }  
  prvLr.style.display = 'block';
  if (!is_ie) document.body.style.cursor = 'pointer'; 
} 
function preveiwHide() {   
  prvImg = document.getElementById('imgPrv');  
  prvImg.src = '/images/load.gif'; 
  prvLr = document.getElementById('prvDiv');
  prvLr.style.display = 'none';
  prvLr.style.backgroundImage = 'url(/images/load.gif)'; 
  if (!document.all) document.body.style.cursor = 'default';
}
function winDivShow(width, height, caption) {
  cw = getClientWidth();  
  ch = getClientHeight();   
  prvLr = document.getElementById('prvDiv');
  prvLr.style.display = 'none';      
  bgLr = document.getElementById('bgDiv');    
  if (document.all) {
    bgLr.style.height = getDocumentHeight();	
    if (ieHack = document.getElementById('selIeHack')) ieHack.style.visibility = 'hidden';
  }
  winLr = document.getElementById('winDiv');    
  winLr.style.width = width+'px'; 
  winLr.style.height = height+'px';   
  winLrHOfs = height < ch ? (getBodyScrollTop()+parseInt(ch/2)-parseInt(height/2)) : (getBodyScrollTop()+parseInt(ch/2)-parseInt(height/2)+parseInt((height-ch)/2));
  winLr.style.left = width < cw ? (parseInt(cw/2)-parseInt(width/2))+'px' : 0+'px';
  winLr.style.top = winLrHOfs+height < getDocumentHeight() ? winLrHOfs+'px' : 0+'px';  
  winLr.style.display = 'block';   
  bgLr.style.display = 'block'; 
  capLr = document.getElementById('capWinDiv');   
  capLr.innerHTML = caption; 
  bgLr.style.display = 'block';   
  winLr.style.display = 'block';  
}
function winDivHide() {
  winLr = document.getElementById('winDiv');
  bgLr = document.getElementById('bgDiv');
  if (ieHack = document.getElementById('selIeHack')) ieHack.style.visibility = 'visible';    
  winLr.style.display = 'none';    
  bgLr.style.display = 'none';    
}
function checkStr(str, crlf) {
  for (i = 0; i < str.length; i++) {
    ucode = str.charCodeAt([i]);
	if (((ucode<0x20) && (((crlf == true)) || ((crlf == false) && (ucode!=0x0A) && (ucode!=0x0D)))) || ((ucode>0x7D) && (ucode!=0x96) && (ucode!=0xAB) && (ucode!=0xB8) && (ucode!=0xB9) && (ucode!=0xBB) && (ucode!=0x401) && (ucode!=0x451) && (ucode!=0x2013) && (ucode!=0x2116) && ((ucode<0x410) || (ucode>0x44F)))) return (ucode < 0x20 ? (ucode == 0x9 ? 'табуляция' : (ucode == 0xD ? 'возврат каретки' : (ucode == 0xA ? 'перевод строки' : '0x'+Number(ucode).toString(16)))): String.fromCharCode(ucode));
  }  
  re = /\S{50,}/;
  if (re.test(str)) return 0; else return -1;
}
function ltrim(str) {
  str = str.replace(/^\s+/, '');
  str = str.replace(/^\x00-\x1F/, '');
  return str;
}
