function addEvent(elm, evType, fn, useCapture) 
{ if(elm.addEventListener) 
  { elm.addEventListener(evType, fn, useCapture);
    return true;
  }
  else if(elm.attachEvent) 
  { var r = elm.attachEvent('on' + evType, fn);
    return r;
  }
  else 
  elm['on' + evType] = fn;
}
function getCookie(name) 
{ var start = document.cookie.indexOf( name + '=' );
  var len = start + name.length + 1;
  if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
  return null;
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ';', len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}	
function setCookie(name,value,expires,path,domain,secure)
{ var today = new Date();
  today.setTime( today.getTime() );
  if ( expires ) 
  expires = expires * 1000 * 60 * 60 * 24;	
  var expires_date = new Date( today.getTime() + (expires) );
  document.cookie = name+'='+escape( value ) +
  ( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) +
  ( ( path ) ? ';path=' + path : ';path=/' ) +
  ( ( domain ) ? ';domain=' + domain : '' ) +
  ( ( secure ) ? ';secure' : '' );
}
function deleteCookie(name,path,domain)
{ if ( getCookie( name ) ) document.cookie = name + '=' +
  ( ( path ) ? ';path=' + path : '') +
  ( ( domain ) ? ';domain=' + domain : '' ) +
  ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
function open_window(url,w,h,id,center,scroll)
{ scroll=scroll?'yes':'no';
  if(center)
  var win = 'width='+w+',height='+h+',Left='+Math.ceil(document.body.clientWidth/2-w/2)+',Top='+Math.ceil(document.body.clientHeight/2-h/2)+',menubar=no,location=no,resizable=yes,scrollbars='+scroll;
  else
  var win = 'width='+w+',height='+h+',menubar=no,location=no,resizable=yes,scrollbars='+scroll;
  var newWin = window.open(url,id,win);
  newWin.focus();
}
function open_imgwindow(src,title,w,h)
{ var newWin = window.open('','popupimage','width='+(w+20)+',height='+(h+25)+',Left='+Math.ceil(document.body.clientWidth/2-w/2)+',Top='+Math.ceil(document.body.clientHeight/2-h/2)+',menubar=no,location=no,resizable=yes,scrollbars=no');
  newWin.document.open();
  newWin.document.write('\
  <html>\
  <head>\
  <title>'+title+'</title>\
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">\
  <style type="text/css">\
  a:link {font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#0099FF;text-decoration:underline;}\
  a:visited {font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#0099FF;text-decoration:underline;}\
  a:hover {font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#FF6699;text-decoration:underline;}\
  a:active {font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#CCCCCC;text-decoration:none;}\
  </style></head><body>\
  <table width="100%" border="0" cellspacing="0" cellpadding="0">\
  <tr><td align="center"><img src="'+src+'" border="0"></td></tr>\
  <tr><td align="center"><a href="javascript:window.close()">Закрыть</a></td></tr>\
  </table>\
  </body>\
  </html>');
  newWin.document.close();
  newWin.focus();
}
function open_cwindow(idcontent,w,h,id,center,scroll)
{ var obj=$(idcontent);
  if(obj)
  { scroll=scroll?'yes':'no';
    if(center)
    var win = 'width='+w+',height='+h+',Left='+Math.ceil(document.body.clientWidth/2-w/2)+',Top='+Math.ceil(document.body.clientHeight/2-h/2)+',menubar=no,location=no,resizable=yes,scrollbars='+scroll;
	else
	var win = 'width='+w+',height='+h+',menubar=no,location=no,resizable=yes,scrollbars='+scroll;
    var newWin = window.open('',id,win);
    newWin.document.open();
    newWin.document.write(obj.value);
    newWin.document.close();
    newWin.focus();
  }	
}