function el(t){return document.getElementById(t);}

function easycook (name, value)
{
 SetCookieForNWeeks (name, value, 54, "/", document.domain.replace('www.', ''), "");
}

function SetCookieForNWeeks(name, value, weeks, path, domain, secure)
{
 var today = new Date();
 expires = new Date(today.getTime() + weeks*7*24*60*60*1000);
 document.cookie = name + "=" + escape(value) +
 "; expires=" + expires.toGMTString() +
 ((path) ? "; path=" + path : "") +
 ((domain) ? "; domain=" + domain : "") +
 ((secure) ? "; secure" : "");
}

function getCookie(name)
{
 var dc=document.cookie;
 var prefix=name+"=";
 var begin=dc.indexOf("; "+prefix);
 if (begin==-1)
 {
  begin=dc.indexOf(prefix);
  if (begin!=0)
   return null;
 }
 else
  begin+=2;
 var end=document.cookie.indexOf(";", begin);
 if (end==-1)
 end=dc.length;
 return unescape(dc.substring(begin+prefix.length,end));
}

var todo;
function resize_font(todo)
{
 var fontmin=-2,fontmax=5,fsx=2,a,t,t2;
 var fontcook_name='fontsize';
 var fs=getCookie(fontcook_name);

 if(fs==null) fs=0;
 if(todo=='+'&&fs<fontmax) fs++;
 if(todo=='-'&&fs>fontmin) fs--;

 if(typeof(mod_font_flag)!="undefined")
 {
  el('fontmin').innerHTML=fs>fontmin ? '<a class="menu" href="javascript:void(0)" onclick="resize_font('+"'-'"+')">-</a>' : '-';
  el('fontmax').innerHTML=fs<fontmax ? '<a class="menu" href="javascript:void(0)" onclick="resize_font('+"'+'"+')">+</a>' : '+';
  el('indefont').innerHTML=fs;
 }

 if (fs!=0||todo!='')
 {
  var tg=new Array('TABLE','TD','A','DIV','LEGEND','SPAN','P','INPUT','TEXTAREA','BODY','SELECT','H1','H2','UL','LI');
  for(i2=0;i2<tg.length;i2++)
  {
   a=document.getElementsByTagName(tg[i2]);
   for(i=0;i<a.length;i++)
   {
    t=a[i].className;t2=0;
    if(t=='win0'||t=='win1') a[i].style.width=235+fs*25+"px";
    if(a[i].id=='abi0'||a[i].id=='abi1') a[i].style.width=500+fs*35+"px";
    if(t=='size11') t2=11;
    if(t=='size12'||t=='scribe'||t=='s12') t2=12;
    if(t=='size13') t2=13;
    if(t=='standart') t2=15;
    if(t.substr(0,6)=='border') t2=25;
    if(t=='size20') t2=20;
    if(t2==0) t2=14;
    if(tg[i2]!='A')
     a[i].style.fontSize=t2+fs*fsx+"px";
   }
  }
  easycook(fontcook_name,fs);
 }
}

function seek_demo(sac)
{
 var o0s=document.getElementById("mod_seek_demo_id");
 var o1s=document.getElementById("mod_seek_query_id");
 var o2s=document.getElementById("mod_seek_loc_whe");
 var o3s=document.getElementById("mod_seek_f");
 if (sac==1) {
  if (fseek==0) {
   fseek=1;oseek=o1s.value;o1s.value="";o1seek=o2s.selectedIndex;pseek=0;o0s.className="menu2";}
  else {
   clearTimeout(tseekID);fseek=0;o1s.value=oseek;o2s.options[o1seek].selected=true;o0s.className="menu";return;}}
 if (o1s.value!=seek_qs) {
  o1s.focus();
  o1s.value+=seek_qs.substr(pseek,1);
  if(browser=="ie"){
  t=o1s.createTextRange();
  t.collapse(false);
  t.select();}
  pseek++;
  tseekID=setTimeout("seek_demo(0)",100);}
 else if (o2s.selectedIndex!=seek_indx0) {
  o2s.options[seek_indx0].selected=true;
  tseekID=setTimeout("seek_demo(0)",500);}
 else
  o3s.submit();
}
function seek_check()
{
 var o0s=document.getElementById("mod_seek_demo_id");
 var o1s=document.getElementById("mod_seek_query_id");
 var o2s=o0s.innerHTML;
 if(!o1s.value)
 {
  if(o2s.indexOf("...")>0)
   o0s.innerHTML=o2s.replace("...","?..");
  else if(o2s.indexOf("?..")>0)
   o0s.innerHTML=o2s.replace("?..","?!.");
  else
  {
   o0s.innerHTML=o2s.replace("?!.","!!!");
   seek_demo(1);
  }
  return false;
 }
}
function seek_local(t)
{
 if (t.substr(0,8)=="software")
  document.getElementById("mod_seek_loc_whe").options[0].selected=true;
 document.getElementById("mod_seek_loc_whe").name="";
 var o=document.getElementById("mod_seek_subst");
 o.name="query";
 o.value=t;
 document.getElementById("mod_seek_f").submit();
}

//draw_back() was written by !mharvester from promoforum.ru and slightly modified by me
function draw_back()
{
 var blo=document.getElementsByTagName('SPAN');
 for(var i=0; i<blo.length; i++)
 {
  if(blo[i].className=='border')
  {
   var pn=blo[i].parentNode;
   for(var j=0; j<5; j++)
   {
    var nd=blo[i].cloneNode(true);
    nd.className='border_0';
    nd.style.color=rgb(db_color2);
    nd.style.position='absolute';
    switch(j)
    {
     case 0:nd.style.marginTop='-1px';break;
     case 1:nd.style.marginLeft='-1px';break;
     case 2:nd.style.marginLeft='1px';break;
     case 3:nd.style.marginTop='1px';break;
     case 4:nd.style.color=rgb(db_color);blo[i].style.display='none';nd.className='border_1';break;
    }
    pn.appendChild(nd);
   }
  }
 }
 return false;
}
function draw_back_hi(t)
{
 if (typeof(db_ti)!="undefined") clearTimeout(db_ti);
 if((t>0&&db_count<db_iter)||(t<0&&db_count>0))
 {
  var i,t2,beg,res,step;
  for(i=0;i<3;i++)
  {
   res=t?db_adj_to[i]:db_color2[i];
   beg=t?db_color2[i]:db_adj_to[i];
   step=Math.floor((res-beg)/db_iter);
   db_adj_go[i]=beg+step*db_count;
  }
  var blo=document.getElementsByTagName('SPAN');
  for(i=0;i<blo.length;i++)
  {
   if(blo[i].className=='border_0')
    blo[i].style.color=rgb(db_adj_go);
  }
  db_count+=t;
  db_ti=setTimeout("draw_back_hi("+t+")",100);
 }
}
function rgb(t)
{
 return "rgb("+t[0]+","+t[1]+","+t[2]+")";
}
function draw_back_act()
{
 var url="http://"+document.domain;
 if(window.sidebar)
  window.sidebar.addPanel(title,url,"");
 else if(window.opera&&window.print)
 {
  var mbm=document.createElement('a');
  mbm.setAttribute('rel','sidebar');
  mbm.setAttribute('href',url);
  mbm.setAttribute('title',title);
  mbm.click();
 }
 else if(document.all)
  window.external.AddFavorite(url,title);
}

function rehide(t)
{
 var t=document.getElementById(t);
 t.style.display=t.style.display==""?"none":"";
}

nchars=new Array();
function numchars(nc_o)
{
 var nc_e=nc_o.substr(nc_o.length-1);
 var nc_c=document.getElementById('numchars'+nc_e);
 if(!nchars[nc_e])
  nchars[nc_e]=nc_c.innerHTML;
 var nc_l=nchars[nc_e]-document.getElementById(nc_o).value.length;
 if (nc_l<0)
  nc_c.className="r14";
 else
  nc_c.className="";
 nc_c.innerHTML=nc_l;
}

//InsertText() was written by !PHP-DIRECTOR <black@wmtime.ru> from forum.vingrad.ru and slightly modified by me
cursor=0;
function position(t)
{
 str=document.getElementById(t);
 str.focus();
 if (!document.selection) cursor=str.selectionStart;
 else cursorIE=document.selection.createRange().duplicate();
}
function InsertText(text)
{
 if (typeof(str)=="undefined")
  try{position("message2")}
 catch(e){}
 if (typeof(str)!="undefined")
 {
  if(navigator.userAgent.indexOf('Opera')>0)
  {
   if(document.selection)
   {
    document.selection.createRange().text += text;
    if(str.tagName.toUpperCase()=="TEXTAREA") str.focus();
   }
   else
    str.value+=text;
   return true;
  }

  if (document.selection)
  {
   var input1=str.createTextRange();
   if(typeof(cursorIE)!="undefined")
    var sel=cursorIE;
   sel.text+=text;
   sel.select();
  }

  else if(str.setSelectionRange)
  {
   var strFirst=str.value.substr(0, cursor);
   var strEnd=str.value.substr(cursor, str.value.length);
   str.value=strFirst+text+strEnd;
   if (text.indexOf("\n\n")!=-1)
    cursor=strFirst.length+text.substr(0,text.indexOf("\n\n")).length+1;
   else
    cursor=strFirst.length+text.length;
   str.selectionStart=str.selectionEnd=cursor;
   str.focus();
  }
  else
   str.value+= text+' ';
 }
}

var ab_go,ab_x,ab_y;
ab_x=150;ab_y=50;
function alert_box(t)
{
 tune_y=-10;
 ab_o=el("alert_box_id");
 if(t==1)
 {
  ab_go=1;
  ab_o.style.display="";
 }
 if(t==0)
 {
  ab_go="";
  ab_o.style.display="none";
  window.onscroll="";
  window.onresize="";
 }
 if(ab_go)
 {
  try
  {
   ab_o.style.top=(innerHeight/2-ab_y+tune_y)+"px";
   ab_o.style.left=(innerWidth/2-ab_x)+"px";
  }
  catch(e)
  {
   ab_o.style.top=document.body.scrollTop+(document.body.clientHeight/2-ab_y+tune_y)+"px";
   ab_o.style.left=document.body.scrollLeft+(document.body.clientWidth/2-ab_x)+"px";
   window.onscroll=alert_box;
   window.onresize=alert_box;
  }
 }
}

var ghostL=4;
//var scrx=screen.width||1024;
//scrx-=200;
var scrx=document.body.clientWidth||window.innerHeight||1024;
ghost_arX=new Array(10,160,310,410,610);
ghost_arY=new Array(3,23,43,13,33);
ghost_arS=new Array();
for(i=0;i<=ghostL;i++)
 ghost_arS[i]=Math.round(Math.random()*5)+1;

function ghost_farm()
{
 for(i=0;i<=ghostL;i++)
 {
  if(el('ghost'+i).className)
  {
   var obj=el('ghost'+i);
   if(ghost_arX[i]<scrx)
    ghost_arX[i]+=ghost_arS[i];
   else
    ghost_arX[i]=-34;
   obj.style.left=ghost_arX[i]+"px";
   obj.style.top=ghost_arY[i]+"px";
   obj.className="ghost";
   if(Math.round(Math.random()*15)==3)
    obj.className="ghost2";
  }
 }
 ghostID=setTimeout("ghost_farm()",100);
}

document.write('<div id="help" class="help"></div>');
document.write('<div id="help2" class="help2"></div>');
var tg=new Array('TD','IMG','A','SPAN','LEGEND','DIV','INPUT');
//var tg=new Array('INPUT');
var i,i2,a,h,xadd,yadd;
var tooltip_x,tooltip_timer,tooltip_timer2,g_xadd,g_yadd,g_cr,g_cr2;

function tooltipmouse(t)
{
 addEvent(t,'mouseover',tooltipover);
 addEvent(t,'mouseout',tooltipout);
}

var tmp_id=0;
function tooltiptitle(node)
{
 if(node==null)
  return;
 else if(!node.title)
  node.title=node.alt;

 if(node.childNodes)
 {
  for(var i=0;i<node.childNodes.length;i++)
   if(node.childNodes[i].nodeValue==null)
   {
    if(!node.id)
    {
     tmp_id++;
     node.id="tmpid_"+tmp_id;
    }
    node.childNodes[i].title="childof_"+node.id;
   }
 }
}

function addEvent(a,e,o)
{
 if(document.addEventListener)
 {
  a.removeEventListener(e,o,false);
  a.addEventListener(e,o,false);
 }
 else
 {
  a.detachEvent('on'+e,o);
  a.attachEvent('on'+e,o);
 }
}

function deEvent(a,e,o)
{
 if(document.removeEventListener)
  a.removeEventListener(e,o,false);
 else
  a.detachEvent('on'+e,o);
}

function tooltip()
{
 a=document.getElementsByTagName('A');
 for(i=0;i<a.length;i++)
 {
  if(a[i].id.substr(0,4)=="mha_")
  {
   addEvent(a[i],'mouseover',mh);
   addEvent(a[i],'mouseout',mh);
  }
 }
 for(i2=0;i2<tg.length;i2++)
 {
  a=document.getElementsByTagName(tg[i2]);
  for(i=0;i<a.length;i++)
  {
   if(a[i].title||a[i].alt)
   {
    tooltiptitle(a[i]);
    tooltipmouse(a[i]);
    t=a[i].title;
    t=t.replace(/</g,"&lt;");
    t=t.replace(/>/g,"&gt;");
    var smiles_ar1=new Array (':D',':)))',':))',':)',':-)',';)','=)','=(',':o','=o','8)))','8))','8(',':(');
    var smiles_ar2=new Array ('biggrin','biggrin','biggrin','smile','smile','wink','bigeyes','ogo_sad','ogo','astoned','haha_rol','haha_rol','rol_sad','sad');
    for(var i3=0;i3<smiles_ar1.length;i3++)
     for(var i4=0;i4<4;i4++)
      t=t.replace(smiles_ar1[i3],('<img src="/graphics/smile_'+smiles_ar2[i3]+'.gif" alt="" />'));
    a[i].title=t;
   }
  }
 }
}

function tooltipover(ev)
{
 ev=ev||window.event;
 g_cr=ev.target||ev.srcElement;
 if(browser=="ie")
 {
  g_xadd=(document.compatMode!="CSS1Compat"?document.body.scrollLeft:document.documentElement.scrollLeft)+ev.clientX-25;
  g_yadd=(document.compatMode!="CSS1Compat"?document.body.scrollTop:document.documentElement.scrollTop)+ev.clientY+20;
 }
 else
 {
  g_xadd=window.pageXOffset+ev.clientX-25;
  g_yadd=window.pageYOffset+ev.clientY+20;
 }

 tooltipover2();
}

var childof="",childof_title="";
function tooltipover2()
{
 clearTimeout(tooltip_timer2);
 cr=g_cr;
 xadd=g_xadd;
 yadd=g_yadd;
 if(h=document.getElementById("help"))
 {
  h2=document.getElementById("help2");

  if(typeof(tooltip_x)!="undefined")
  {
   t=h.innerHTML;
   t=t.replace(/<br>/g,"\n");

   if(childof)
   {
    document.getElementById(childof).title=childof_title;
    tooltip_x.title="childof_"+childof;
   }
   else
    tooltip_x.title=t;
//   if(tooltip_x.className=="bar_hi") barout(tooltip_x);
//   if(tooltip_x.className=="smile_hi") smileout(tooltip_x);
//   if(tooltip_x.className=="photo_hi") photoout(tooltip_x);
   tooltip_x="";
  }
  tooltip_x=cr;

  t=cr.title;
  t=t.replace(/\n/g,"<br>");
  if(t.substr(0,8)=="childof_")
  {
   childof=t.substr(8);
   t=document.getElementById(childof).title;
   childof_title=t;
   document.getElementById(childof).title="";
  }
  else
   childof="";
  h.innerHTML=t;
  h2.innerHTML=t;
  cr.title="";
//  alert(cr.title);
  h.style.top=yadd+"px";
  h2.style.top=yadd+"px";
//  if(t.length>30)
//  {
//   h.style.left=(xadd-100)+"px";
//   h2.style.left=(xadd-100)+"px";
//   h.style.width="200px";
//   h2.style.width="200px";
//  }
//  else
//  {
  h.style.left=xadd+"px";
  h2.style.left=xadd+"px";
  h.style.width="";
  h2.style.width="";
//  }
  h.style.visibility="visible";
  h2.style.visibility="visible";
 }
// if(cr.className=="bar"||cr.className=="bar_sel") barover(cr);
// if(cr.className=="smile") smileover(cr);
// if(cr.className=="photo") photoover(cr);
}
function tooltipout(ev)
{
 ev=ev||window.event;
 g_cr2=ev.target||ev.srcElement;
 tooltip_timer2=setTimeout("tooltipout2()",500);
}

function tooltipout2()
{
 if(tooltip_x==g_cr&&g_cr==g_cr2)
 {
  cr=g_cr;

  if(h=document.getElementById("help"))
  {
   h2=document.getElementById("help2");
   t=h.innerHTML;
   for(i=0;i<10;i++)
    t=t.replace("<br>","\n");
   if(childof)
   {
    document.getElementById(childof).title=childof_title;
    cr.title="childof_"+childof;
   }
   else
    cr.title=t;
   h.innerHTML="";
   h2.innerHTML="";
   h.style.visibility="hidden";
   h2.style.visibility="hidden";
  }

//  if(cr.className=="bar_hi") barout(cr);
//  if(cr.className=="smile_hi") smileout(cr);
//  if(cr.className=="photo_hi") photoout(cr);

  tooltip_x="";
 }
}

function mh(ev)
{
 ev=ev||window.event;
 var obj=ev.target||ev.srcElement;
 var id="mhs_"+obj.id.substr(4);
 obj=document.getElementById(id);
 if(obj.className=="mh_0")
  obj.className="mh_1";
 else
  obj.className="mh_0";
}