var r1=r2=r3=r4=r5=ba=tm=tm1=tm3=tm2=popup=0;
var domn   = window.location.host.split(".");
var domain_real = domn[domn.length-2]+"."+domn[domn.length-1];
var domain_url = "http://"+domain_real;
var RefrashVar = 0;
var mBlayout = "mBlayout";

var _ua = navigator.userAgent.toLowerCase();
var browser = {
  version: (_ua.match( /.+(?:me|ox|on|rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
  opera: /opera/i.test(_ua),
  msie: (!this.opera && /msie/i.test(_ua)),
  msie6: (!this.opera && /msie 6/i.test(_ua)),
  msie7: (!this.opera && /msie 7/i.test(_ua)),
  msie8: (!this.opera && /msie 8/i.test(_ua)),
  mozilla: /firefox/i.test(_ua),
  chrome: /chrome/i.test(_ua),
  safari: (!(/chrome/i.test(_ua)) && /webkit|safari|khtml/i.test(_ua)),
  iphone: /iphone/i.test(_ua),
  ipod: /ipod/i.test(_ua),
  iphone4: /iphone.*OS 4/i.test(_ua),
  ipod4: /ipod.*OS 4/i.test(_ua),
  ipad: /ipad/i.test(_ua),
  safari_mobile: /iphone|ipod|ipad/i.test(_ua),
  mobile: /iphone|ipod|ipad|opera mini|opera mobi/i.test(_ua)
}

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;
        }
}

      if(navigator.appName == 'Netscape'){
      document.captureEvents(Event.MOUSEMOVE);
      document.onmousemove = getCoord;
      }	

      function getCoord(event) {
        pageX = event.pageX;
        pageY = event.pageY;
      return {"x":pageX, "y":pageY};
      }

      document.onkeydown=ctrlenter;
 if (!document.all) document.captureEvents(Event.KEYDOWN)


window.onload = function() {

  if(window.name=="uploadframe"){
	self.parent.document.body.innerHTML = document.body.innerHTML;
  }

  if(document.getElementById('dot') && typeof titleMenu == 'function'){
    var nu = document.getElementById('dot').getElementsByTagName('DIV');
      for(i=0;i<nu.length;i++){
        if(nu[i].title){
          nu[i].onmouseover=function(){this.setAttribute('title1',this.getAttribute('title'));this.setAttribute('title','');titleMenu(this,1);};
          nu[i].onmouseout =function(){titleMenu(this,2);};
        }
      }
 }
	setTimeout(emul_href,1000);
	 if(document.getElementById('h_head1')){
		ImgPross('h_cont');
		inScript('/inc/bhjs.php','h_head1'); //domain_url+
	 }
}


function messback(o,n){
if(n==1){
o.rows=5;
o.style.height='';
if(r4==0){o.innerHTML='';r4=1;}
o.form.all.style.display='block';
}else{
r4=0;
o.form.text.rows=1;
o.form.text.style.height='26';
o.form.all.style.display='none';
}
}


function setMenuABC(did,nav){
if(document.getElementById(did)){
var n=0;var m=0;
home    = document.getElementById(did);
if(home.getElementsByTagName('A').length){
linkArr = home.getElementsByTagName('A');
for(i=0;i<linkArr.length;i++){
  alink=linkArr[i];
  if(alink.getElementsByTagName('IMG').length||alink.getElementsByTagName('I').length)continue;
  n=0;
  if(!nav){
	 alink.onmouseover = function(){change_href(this);timeoutABC(this);};
         n=1;
  }  else    {
	 if(alink.nextSibling && alink.nextSibling.tagName=='DIV'){
         n=m=1;
	 alink.onclick = function(){timeoutABC(this,m);return false;};
	}
  }

  if(n) alink.onmouseout =function(){if(tm2){clearTimeout(tm2);viewMenuABC(this,2);}};

}}}
}

function timeoutABC(n,m){
tm2=setTimeout(function(){viewMenuABC(n,1,m)}, 50);
}

function viewMenuABC(o,n,m){

if(n==2){ba=0;tm=setTimeout("delRemm()",1000);return;}else{clearTimeout(tm);ba=1;}
var f = document.getElementById('remm');
    f.onmouseover = function(){ba=1;};
    f.onmouseout  = function(){ba=0;setTimeout("delRemm()",1000);};

if(!m)
f.innerHTML = "<div><b style='position:absolute;z-index:100'>"+o.innerHTML+"</b><div align=right style='position:absolute;z-index:110;width:120px'><b>"+(lang!='eng'?'укажите где искать':'where search')+":</b><div style='padding:10px 0px;'><a href='"+o.href+"&find=executor' class='clip clip1'>"+(lang!='eng'?'Исполнитель':'Artist')+"</b></a><br><a href='"+o.href+"&find=namemus&s=namemus' class='clip clip1'>"+(lang!='eng'?'Название песни':'Name Song')+"</b></a></div></div></div>";
else
f.innerHTML = "<div><b style='font-weight:normal;'>"+o.nextSibling.innerHTML+"</b></div>";

var pos = getElementPositions(o);

f.style.top  = String(pos.top+pos.height+1+(m?-3:0))+"px";
f.style.left = String(pos.left-35+(m?15:0))+"px";

var y = f.getElementsByTagName('b')[0];
y.style.fontSize=(m?11:60)+"px";
y.style.color='#F9B7BC';
y.style.top  = "12px";
y.style.left = "10px";

var y1 = f.getElementsByTagName('div')[0];
y1.style.width = (m?"155px":"135px");
y1.style.height = (m?"auto":"75px");
y1.style.border = "1px solid red";
y1.style.background  = '#FFFFE1';
y1.style.borderColor  = '#A80F1A';
y1.style.padding  = (m?'5px 5px 20px':'0px 5px');

if(m) y1.style.borderWidth = "0px 1px 2px 3px";

f.style.height = (m?"auto":"70px");
f.style.width  = (m?"150px":"130px");
f.style.background  = 'transparent';
f.style.border  = 0;
f.style.display = 'block';

}


function delRemm(){
if(ba==1)return;
var f = document.getElementById('remm');
f.style.display = 'none';
f.style.background  = '#FFFFE1';
f.style.border  = '#A80F1A 1px solid';
ba==0;
}


function setMenuRight(){

if(document.getElementById('m_right')){

home    = document.getElementById('m_right');
linkArr = home.getElementsByTagName('TD');

for(i=0;i<linkArr.length;i++){

if(linkArr[i].className=='news2'){

linkArr[i].style.padding="2 2 2 5";
  if(linkArr[i].getElementsByTagName('A').length){
  alink=linkArr[i].getElementsByTagName('A')[0];
  alink.className ='noline';
  alink.onmouseover=function(){menu_1(this,1);};
  alink.onmouseout =function(){menu_1(this,2);};
  }

  if(linkArr[i].getElementsByTagName('IMG').length){
  ilink=linkArr[i].getElementsByTagName('IMG')[0];
  ilink.setAttribute('align','top');
  }

  if(linkArr[i].getElementsByTagName('DIV').length){
  dlink=linkArr[i].getElementsByTagName('DIV')[0];
  dlink.style.color='white';
  dlink.style.padding='0 5 0 0';
  dlink.setAttribute('align','right');
  }
}}}

}


function setVote(t){

linkArr = document.getElementsByTagName('B');
for(i=0;i<linkArr.length;i++){

if(linkArr[i].getAttribute('id')=='vote'){
desc = linkArr[i].innerHTML;
linkArr[i].style.display='block';
linkArr[i].innerHTML = lang=='rus'?"<i onclick='window.open(\"/asms.php?name="+desc+"&t="+t+"\",\"New1\",\"width=250,height=600,location=no,toolbar=no,menubar=no,status=no\");New1.focus()' target=New1 title='Проголосовать за Исполнителя: "+desc+" и принять участие в конкурсе с Ценными призами!' class='isi si_img_vote voit'></i>":"<i class='isi si_img_vote voit' onclick='window.open(\"/asms.php?lang=eng&name="+desc+"&t="+t+"\",\"New1\",\"width=250,height=600,location=no,toolbar=no,menubar=no,status=no\");New1.focus()' target=New1 title='Vote for Artist: "+desc+" adn to obtain prize!'></i>";

}}}

var bal = 0;

	// среднее меню
function li_1(este,fl){

if(fl==1){
este.className='foc';
bal=1;
setTimeout(function(){prevopen(este);},300);
}else if (fl==2){
este.className='real';
bal=0;
setTimeout("prevclose()",1000);
}}

function prevopen(v){
Preview(v.id,'aj');
}

	// среднее меню
function menu_1(este,fl){
var bb = este.id=='bb'?1:0;
if(fl==1){
 if(bb){ este.parentNode.className = "blist6b";
  }else{  este.parentNode.className = "blist6";
 }
}else if (fl==2){ este.parentNode.className = "news1";}
}

function prevclose(){
if(bal)return;
var n = document.getElementById('aj');
n.style.display='none';
}
	// выпадающие меню
function Preview(obj,sid){

if(document.getElementById('a'+obj) && bal){
var o = document.getElementById(obj);
var n = document.getElementById(sid);
var d = document.getElementById('a'+obj);

n.innerHTML   = d.innerHTML;
n.onmouseout  = function(){this.style.display='none';bal=0;};
n.onmouseover = function(){this.style.display='block';bal=1;};

var w = o.offsetWidth;
var h = o.offsetHeight;
var pos = getElementPositions(obj);
n.style.top =pos.top+20;
n.style.left=pos.left+5;
n.setAttribute("style","left:"+String(pos.left+5)+"px;"+"top:"+String(pos.top+20)+"px;");  
n.style.display = 'block';
}else{vv=bal;bal=0;prevclose();bal=vv;}
}



	// открытие меню поиска
function open_select(){
var home   = document.getElementById('OpenSelect');
var asearh = document.getElementById('asearh');
home.style.display = (home.style.display=='none')?('block'):('none');
asearh.innerText   = (home.style.display=='none')?(lang=='rus'?'Открыть условия поиска':'Open search parametrs'):(lang=='rus'?'Скрыть условия поиска':'Close search parametrs');
return true;
}

	// открытие меню поиска
function split_select(){
var home   = document.getElementById('Split');
var asearh = document.getElementById('asplit');

home.style.display = (home.style.display=='none')?('block'):('none');
asearh.innerText   = (home.style.display=='none')?(lang=='rus'?'Частный нарез +':'Arbitrary split +'):(lang=='rus'?'Частный нарез -':'Arbitrary split -');

return true;
}


	// выбор куда переход
function change_href(este){
if(!document.forms.Searh.find)return;
var vc = este.href;
var alink = document.forms.Searh.find.value;
  if(alink=='namemus'){
    vc+="&find=namemus";
  }else{
    vc+="&find=executor";
  }
eval("este.onclick =function(){this.href='"+vc+"';}");
}



	// выбор куда переход
function arh_href(este,param,nminus,ntrack,nvideo){

var nourl=1;

var alink = este.href;

  if(document.getElementById('Rm').checked && nminus){
    alink="/catalog.php?";
//  }
//  else if(document.getElementById('Rp').checked && ntrack){
//    alink="/mp3_catalog.php?find=namemus&";
//  }
//  else if(document.getElementById('Rv').checked && nvideo){
//    alink="/mp3_catalog.php?type=1&find=namemus&";
  }else{
    nourl = 0;
  }

if(nourl) este.href=alink+param;


}



	// выбор куда переход
function arh_action(este){

var nourl=1;

var alink = document.getElementById(este).action;

  if(document.getElementById('Rm').checked){
    alink="/catalog.php?";
//  }
//  else if(document.getElementById('Rp').checked){
//    alink="/mp3_catalog.php?find=namemus&";
//  }
//  else if(document.getElementById('Rv').checked){
//    alink="/mp3_catalog.php?type=1&find=namemus&";
  }else{
    nourl = 0;
  }

if(nourl) document.getElementById(este).action=alink;


document.getElementById(este).action = alink;
document.getElementById(este).submit();
return;

}


function add_link(este,y1,m1,lang){
	var table = document.getElementById(este);
for(var row=0; row<table.rows.length; row++) {
    for(var col=0; col<table.rows[row].cells.length; col++) {
        eml = table.rows[row].cells[col];
        if(eml.innerText>0 && eml.children.tags('A').length==0){
	// получить данные из селект
	var y = document.forms.Mont.y1.options[document.forms.Mont.y1.selectedIndex].value;
	var m = document.forms.Mont.m1.options[document.forms.Mont.m1.selectedIndex].value;
            m = m<10?"0"+m:m;
        var d = eml.innerText;
            d = d<10?"0"+d:d;

	var url = (lang!='eng'?"/ru":"/en")+"/blog/sid/"+y+m+d+".html";
        eml.innerHTML = "<a href='"+url+"' title='"+(lang=='rus'?"Дневник событий за":"History events ")+" "+y+"."+m+"."+d+"' class=author style='font-weight:normal'>"+eml.innerText+"</a>";
//      onclick='arh_href(this,\"tk=1&dat1="+y+"-"+m+"-"+d+"\",1,1,1)'
	} 
    }
}
}


	// эмуляция 
function emul_href(){

if(popup){DivOff_popupsu_blocks();popup=0;}



linkArr = document.getElementById('b_eng').getElementsByTagName('A');
point   = Math.round(Math.random()*linkArr.length-1);
for(i=0;i<linkArr.length;i++){
if(linkArr[i])linkArr[i].className = "cat2";
}
if(linkArr[point])linkArr[point].className="cit2";

linkArr = document.getElementById('b_rus').getElementsByTagName('A');
point   = Math.round(Math.random()*linkArr.length-1);
for(i=0;i<linkArr.length;i++){
if(linkArr[i])linkArr[i].className = "cat1";
}

if(point>0 && linkArr[point]) {linkArr[point].className = "cit1";}

setTimeout(emul_href,15000);

}

function getCookie(name) {
 var prefix = name + "="
 var cookieStartIndex = document.cookie.indexOf(prefix)
 if (cookieStartIndex == -1)
  return null
 var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
 if (cookieEndIndex == -1)
  cookieEndIndex = document.cookie.length
 return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}


function getClientCenterX(){return parseInt(getClientWidth()/2)+getBodyScrollLeft();}
function getClientCenterY(){return parseInt(getClientHeight()/2)+getBodyScrollTop();}
function getClientWidth(){return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;}
function getClientHeight(){return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;}
function getBodyScrollTop(){return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);}
function getBodyScrollLeft(){return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);}

function mousePageXY(e){  
 var x = 0, y = 0;  
  if (!e){ 
  if(navigator.appName == 'Netscape'){
        return {"x":pageX,"y":pageY};
	}else{e = window.event;}
  }
 
  if (e.pageX || e.pageY) {
   x = e.pageX;y = e.pageY;
  }else if(e.clientX || e.clientY){
   x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft; 
   y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;  
  } 
   return {"x":x, "y":y};
}

function getElementPositions(el)
{


    var elem = ge(el);
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
    var l = 0;
    var t = 0;
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }
    return {"left":l, "top":t, "width": w, "height":h};
}


function clipMenu(o,sid){
var p = document.getElementById(sid);
if(p.style.display=='none'){
o.innerHTML = '<i class=\"isi si_lk_close voit\"></i>';
p.style.display = 'block';
addCookie("lmenu",'0');
}else{
o.innerHTML = '<i class=\"isi si_lk_open voit\"></i>';
p.style.display = 'none';
addCookie("lmenu",'1');
}}

function addCookie(name,visits){
var now = new Date();
fixDate(now);
now.setTime(now.getTime() + 24 * 60 * 60 * 30);
setCookie(name,visits,now,"/",domain_real);
}

function setCookie(name, value, expires, path, domain, secure) {
 var curCookie = name + "=" + escape(value) +
  ((expires) ? "; expires=" + expires.toGMTString() : "") +
  ((path) ? "; path=/" : "") +
  ((domain) ? "; domain=" + domain : "") +
  ((secure) ? "; secure" : "")
   document.cookie = curCookie;
}

function fixDate(date) {
 var base = new Date(0);
 var skew = base.getTime();
 if (skew > 0) date.setTime(date.getTime() - skew);
}



function setClip(o,sid){
var p = document.getElementById(sid);
var s = p.getElementsByTagName('SPAN')[1];
if(p.style.overflow=='hidden'){
p.setAttribute('className','clp1');
p.setAttribute('class','clp1');
p.style.overflow = 'visible';
o.innerHTML = 'свернуть';
s.style.display = 'block';
}else{
o.innerHTML = 'развернуть';
p.setAttribute('className','clp');
p.setAttribute('class','clp');
p.style.overflow = 'hidden';
s.style.display = 'none';
}}


function vClose(m,n,f){
var o = document.getElementById(n);
o.style.overflow=o.style.overflow=='visible'?'hidden':'visible';
m.innerHTML = o.style.overflow=='visible'?'свернуть '+f+' -':'развернуть '+f+' +';
o.style.height = o.style.overflow=='visible'?'auto':45;

}


function golos(o,sid){
New1=window.open('/asms.php?sid='+sid,'New1','width=250,height=600,location=no,toolbar=no,menubar=no,status=no');
New1.focus();
}

function dialog(o,sid){
Wind=window.open('/message.php?sid='+sid,'win'+sid,'width=500,height=650,location=no,toolbar=no,menubar=no,status=no');
Wind.focus();
}

function ProsessBar(sid){
var f = document.getElementById("fA"+sid);
var o = document.getElementById('remm');
o.innerHTML    = "<div style='margin:20px;font-size:12px;color:red;position:absolute;z-index:51' id='sels'><img src='/img/prosses.gif' align=left>Внимание идет загрузка файлов!<br>Подождите пожалуйста, процесс можете занять несколько минут.</div>";
o.style.top    = getClientCenterY()-50;
o.style.left   = getClientCenterX()-250;
o.style.height = 100;
o.style.width  = 500;
o.style.background  = '#E8E8E8';
o.style.display = 'block';
return true;
}

function inScript(script,pid){

    if(getCookie('SESSID')){
        script = script+(script.match(/\?/)?"&":"?")+"session="+getCookie('SESSID')+"&"+lang;
    }
    var p = document.getElementById(pid); 
	p.innerHTML='';
    var targetNode = document.createElement('div');
	targetNode.id = 'dsc';
    p.appendChild(targetNode);
    try {
        var el = document.createElement('script');
		 targetNode.appendChild(el);
	setTimeout(function()
		   { 
		    el.language="javascript";
		    if (el.setAttribute)el.setAttribute("src",script);else el.src=script;
		   },10);
    } catch (e) {
        var el = document.createElement('span');
        targetNode.appendChild(el);
        el.innerHTML = "<br /><scr"+"ipt type='text/javascript' src='"+script+"' defer='defer'></script" + ">";
    }
}

function cont_ext(o,form1){
var doc = eval("document.forms."+form1+".find");
if(doc.value==0){
doc.style.color = '#ffffff';
doc.style.fontWeight = 'bold';
doc.style.fontSize   = '11px';

eval("setTimeout('cont_color(\""+form1+"\")',1000)");
return;
}

clearTimeout(tm3);
var fid = o;
   if(document.getElementById('fnd8'))
   { var lk = document.getElementById('fnd8');
     lk.setAttribute("id",lk.alt);
    }
    fid.setAttribute("alt",fid.id);
    fid.setAttribute("id","fnd8");
eval("tm3 = setTimeout(\"inScript('/search/context.php?qs="+o.value+"&t="+eval("document.forms."+form1+".find.value")+"&a="+o.accept+"&lang="+lang+"','scde')\",400)");
}

function cont_color(form1){
var doc = eval("document.forms."+form1+".find");
doc.style.color = (!r5?'#fcb100':'#ffffff');
r5=r5?0:1;
if(doc.value==0){
doc.onchange = function(){this.form.str.focus();this.form.str.click();};
eval("setTimeout('cont_color(\""+form1+"\")',1000)");}else{
doc.style.fontWeight = 'normal';
doc.style.color = '#ffffff';
}
}



function ctrlenter(k){
	if (k){ctrl=k.ctrlKey;
        k=k.which;}else{
        k=event.keyCode;
        ctrl=event.ctrlKey;
        }

var id   = "fonDialog";
if(document.getElementById(id) && k==27) removeDialog(id);

if(document.getElementById('remm')&&document.getElementById('remm').style.display!='none'){
var home = document.getElementById('remm');
if(home.getElementsByTagName('A') && home.getElementsByTagName('A').length){
var m = 'lim';
var l = home.getElementsByTagName('A');
var n = l.length;
var u = -1;
if(k==13){for(i=0;i<l.length;i++){if(l[i].alt==m){u=i;break;}}if(u!=-1&&l[u].href)
{l[u].focus();
location.href = l[u].href;
}} // alert(l[u].href);
if(k==40||k==38){

 setTimeout(function(){clearTimeout(tm3)},399);

u = k==40?-1:n-1;
for(i=0;i<l.length;i++){if(l[i].alt==m){u=i;break;}}
if(u>=0){
l[u].alt ='';l[u].style.background='transparent';
}
if(k==40){u++;if(u>n-1)u=0;}else{u--;if(u<0)u=n-1;}
l[u].alt =m;
l[u].style.background='#FFD9B3';
}}}
}

function ImgPross(elem){
if(document.getElementById(elem)){
document.getElementById(elem).innerHTML='<img src="/img/prosses.gif" align=left>';
}}

function createNRemm(obj){
if(document.getElementById('remm')) delRemm();
var f = document.getElementById('nremm');
if(!document.getElementById('ss_remove')){
f.innerHTML = "<div style='float:left;width:250px;' id='ss_content'></div><div style='float:right;width:20px;cursor:pointer;' align=right id='ss_remove' onclick='ba=0;delNRemm();'><i class='isi si_close'></i><p><div style='margin-top:50px;' id=prss align=left></div></div>";
}
var pos = getElementPositions(obj);

f.style.top  =  String(pos.top+pos.height+1)+"px";	
f.style.left =  String(pos.left-35)+"px"; 		
f.style.width  = "280px";
f.style.border  = 0;
f.style.background = '#D6EAFE';
f.style.display = 'block';
f.style.border = "solid 1px #399BFD";
}

function delNRemm(){
if(typeof clip != 'undefined')clip.destroy();
if(ba==1)return;
var f = document.getElementById('nremm');
f.style.display = 'none';
f.innerHTML     = '';
f.style.border  = '#0351a2 1px solid';
ba=0;
}

function createRAll(id,n,obj,wh,uid,refrash_div,space_left){
if(document.getElementById('remm'))delRemm();

if(document.getElementById(id)){
var o = document.getElementById(id);
    o.parentNode.removeChild(o);
}
    obj.onmouseout   = function(){eval("v_"+id+"=setTimeout(\"delRAll('"+id+"')\",500);");};
    if(obj.onmouseover){
    obj.onmouseover  = function(){clearTimeout(eval("v_"+id));dMore(uid,n,obj,refrash_div);};
    }

    var targetNode = document.createElement('div');
	targetNode.id = id;
	targetNode.style.display = 'none';
        window.document.body.appendChild(targetNode);
    var f = document.getElementById(id);
    f.onmouseover  = function(){clearTimeout(eval("v_"+id));};
    f.onmouseout   = function(){eval("v_"+id+"=setTimeout(\"delRAll('"+id+"')\",500);");};

if(!document.getElementById(id+'_body')){
f.innerHTML = "<a href='javascript:void(0)' onclick=delRAll('"+id+"')><img src=/img/close.gif align=right></a><div style='width:100%' id='"+id+"_body'></div>";
}

var pos = getElementPositions(obj.id);
f.style.position  = "absolute";	
f.style.padding  = "5px";	
f.style.top  =  pos.top+pos.height+1;	
f.style.left =  pos.left+space_left; 		
f.setAttribute("style","padding:5px;position:absolute;left:"+String(pos.left+space_left)+"px;"+"top:"+String(pos.top+pos.height+1)+"px;");  
f.style.width  = wh+"px";
f.style.border  = 0;
f.style.background = '#D6EAFE';
f.style.display = 'block';
f.style.border = "solid 1px #399BFD";
f.style.color  = "#0351a2";
f.style.fontSize   = "11px";

}

function delRAll(id){
var f = document.getElementById(id);
f.style.display = 'none';
}



function HUP(obj,rid,w){
if(!document.getElementById("nremm"))return;
  var f = document.getElementById("nremm");
  f.innerHTML  = "";
  setTimeout(function(){
  createNRemm(obj);
  f.style.height = "auto";
  if(w){ f.style.width = w+"px";document.getElementById("ss_content").style.width = w+"px";
  }
  ImgPross('ss_content');},10);
  inScript('/inc/b_more.php?rid='+rid+'&m='+ Math.floor(Math.random() * 99999),'h_head2'); 
}

function eDit(obj,script,task,nid,par,val){
if(!document.getElementById("nremm") && obj!='0') return;
  val = (val && val.match(/content_/))?val:'ss_content';
  if(obj!='0'){
  var f = document.getElementById("nremm");
  f.innerHTML  = "";
  setTimeout(function(){
  createNRemm(obj);
  ImgPross('ss_content');
},10);} else ImgPross(val);
  inScript('/members/ejs/'+script+'.php?nid='+nid+'&task='+task+'&par='+par+'&var='+val+'&m='+ Math.floor(Math.random() * 99999),'h_head2'); 
}

function MHUP(n,obj,rid){
if(!document.getElementById("nremm"))return;
  if(n==1){
  var f = document.getElementById("nremm");
  f.innerHTML  = "";
  setTimeout(function(){
  createNRemm(obj);
  f.style.height = "auto";
  f.style.background = '#FFFFE1';
  f.style.border = "solid 1px #F38189";
  ImgPross('ss_content');},10);
  inScript('/inc/b_mast.php?rid='+rid+'&m='+ Math.floor(Math.random() * 99999),'h_head2'); 
  }else if(n==2){
  var o = document.forms.MForm;
// удалять знаки лишние и обрывать
  var p='email='+o.elements["email"].value+'&phone='+o.elements["phone"].value+'&name='+o.elements["name"].value+'&keyw='+o.elements["keyw"].value+'&text='+o.elements["text"].value;
  ImgPross('ss_content');
  inScript('/inc/b_mast.php?rid='+rid+'&m='+ Math.floor(Math.random() * 99999)+'&s=save&'+p,'h_head2'); 
  }
}




//  f.style.background = '#FFFFE1';
//  f.style.border = "solid 1px #F38189";


function dMore(id,n,obj,refrash_div,space_left){

// n about

space_left = (space_left?space_left:135);

var f;
var wh = 400;
var pid = 0;
var rn1 = setTimeout(function(){
    pid = !refrash_div?"self_id_"+n+"_"+id:"self_id_"+n;
if(!refrash_div && document.getElementById(pid)){
    var pos = getElementPositions(obj.id);
    f = document.getElementById(pid); 
    f.style.position  = "absolute";	
    f.style.display='block';
    f.style.top  =  String(pos.top+pos.height+1)+"px";	
    f.style.left =  String(pos.left+space_left)+"px"; 		
    f.style.padding  = "5px";	
    f.style.background = '#D6EAFE';
    f.style.border = "solid 1px #399BFD";
    f.style.color  = "#0351a2";
    f.style.fontSize   = "11px";
    f.style.width  = wh+"px";

    obj.onmouseout = function(){eval("v_"+pid+"=setTimeout(\"delRAll('"+pid+"')\",500);");};
    if(obj.onmouseover){
    obj.onmouseover  = function(){clearTimeout(eval("v_"+pid));dMore(id,n,obj,refrash_div,space_left);};
    }

    return 10;
}
  var rn2 = setTimeout(function(){
  var s = createRAll(pid,n,obj,wh,id,refrash_div,space_left);
  ImgPross(pid+'_body');
  f = document.getElementById(pid);

},10);

inScript('/inc/b_more.php?id='+id+'&pid='+pid+'&n='+n+'&m='+ Math.floor(Math.random() * 99999),'h_head2'); 
},250);


//    if(!pid){
    obj.onmouseout  = function(){clearTimeout(rn1);delRAll('"+pid+"');};
//    }


}



function H_Menu(n,id){
if(document.getElementById('h_cont')){
if(n==1) document.getElementById('h_cont').innerHTML='<div class=h_scr><form name=HForm onsubmit="return false"><input type=text maxlength=25 name=h_title value="название" title="Введите название закладки" onclick="if(!r2){this.value=\'\';r2=1;}"><br><textarea title="Можно ввести описание закладки" onclick="if(!r3){this.innerHTML=\'\';r3=1;}" name=h_desc rows=2 style="height:30px">описание</textarea><br><select name=h_time title="Указать время когда удалить"><option value=0>не удалять авто<option value=1>удалить через час<option value=24>через 24 часа<option value=168>через неделю</select><input type=button value=OK class=h_click onclick=H_Menu(3,0)></form></div>';
else if(n==2) {
          ImgPross('h_cont');
	  inScript('/inc/bhjs.php?m='+ Math.floor(Math.random() * 99999),'h_head1'); 
}else if(n==3){
	  var o = document.forms.HForm;
	  var p='t='+o.elements["h_title"].value+'&d='+o.elements["h_desc"].value+'&tm='+o.elements["h_time"].value;
          ImgPross('h_cont');
	  inScript('/inc/bhjs.php?m='+ Math.floor(Math.random() * 99999)+'&s=save&'+p,'h_head1'); 
}else if(n==4){
          ImgPross('h_cont');
	  inScript('/inc/bhjs.php?m='+ Math.floor(Math.random() * 99999)+'&s=del&sid='+id,'h_head1'); 
}
}}


function viewBlock(id,obj,act){
var par = id.split("_");
if(par[3] && par[3]=='all'){ // ищем все и закрываем
if(!document.getElementById("_"+par[1]+"_"))return;
var oparent = document.getElementById("_"+par[1]+"_");
for(i=0;(ah=oparent.getElementsByTagName("div").item(i));i++){
var re=new RegExp("_"+par[1]+"_","i");;
if(ah.id.match(re)){
viewBlock(ah.id,0,par[2])
}}
return;
}

if(!document.getElementById(id))return;
var node = document.getElementById(id);
if(obj){
  if(act){ obj.src = (act=='close'?'/img/c_minus.gif':'/img/c_plus.gif');
  }else{   obj.src = (node.style.display && node.style.display=='none'?'/img/c_minus.gif':'/img/c_plus.gif'); }
}
if(act){node.style.display = (act=='open'?'block':'none');}
else   {node.style.display = (node.style.display && node.style.display=='none'?'block':'none');}

}

function childLinksFocus(n,obj){
var divs = Array("_mylk_","_site_");
var pars=0;
var par=0;

for(ii=0;ii<divs.length;ii++){
if(!document.getElementById(divs[ii]))continue;
var oparent = document.getElementById(divs[ii]);
for(i=0;(ah=oparent.getElementsByTagName("a").item(i));i++){
pars=0;
if(ah.href==obj.href){
oparent.style.display = 'block'; // раскрыть раздел
ah.parentNode.style.display = 'block'; // группу
par = ah.id.split("ooo");
if(par[1])viewBlock('_site_serv_'+par[1],0,'open');

ah.style.backgroundColor = n==1?"#FFFF00":"transparent";

if(n==1){
ah.parentNode.style.backgroundImage = "url(/img/c_marker.gif)";
ah.parentNode.style.backgroundPosition = "80% 50%" ;
ah.parentNode.style.backgroundRepeat = "no-repeat";
}else{
ah.parentNode.style.backgroundImage = "";
}
}}}}


var ctime = new Date();
var ymd   = ctime.getYear()+"-"+ctime.getMonth()+"-"+ctime.getDate();
var ym    = ctime.getYear()+""+ctime.getMonth();


function printf( ) { 
 var ret = this.sprintf.apply(this, arguments);  
 document.write(ret);  
 return ret.length;  
} 


function InStart(lang){
var k = document.cookie;
var r = document.referrer;
var h = getCookie('HIT');
var nowu = 0;
if(h){
var n = h.split("+");
var dats = n[0].split("-");
var tims = n[1].split(":");
    nowu = (dats[2]==ctime.getDate() && tims[1]==ctime.getMinutes())?1:0;
}
if(!k){
document.write("<tr><td colspan='7' align=left id=mainmenu1><span style='color:blue'>"+(lang=='rus'?"Для корректной работы Вам необходимо включить COOKIE!":"Enable Cookie!")+" &nbsp;</span></td></tr>");
}else if(lang!='eng' && r.indexOf(location.hostname)==-1 && nowu){
document.write("<tr><td colspan='7' align=left id=mainmenu1><span style='color:blue;font-size:12px;'>Если Вы первый раз на MinusOK.com, ознакомление можете начать с <a href='/my_now.php' style='color:blue;border-bottom: dashed 1px blue'>Навигатора Цели</a></span></td></tr>");
}}


document.write("<div id='aj1'>"+
"<a href='http://my.minusok.com/' title='Сообщество Творческих Талантов'><b>А</b>вторский раздел</a><br>"+
"<a href='/my_users.php'><b>Т</b>ОП участников</a><br>"+
"<a href='/my_proj.php'><b>Т</b>ОП проектов</a><br>"+
"<a href='/members/?category=6'><b>Р</b>егистрация</a><br>"+
"<a href='/members/?task=memb&cat=6&serv=3'><b>А</b>вторизация</a><br>"+
"<a href='/img/doc/author_help.doc'><b>И</b>нструкция по разделу</a><br>"+
"</div>"+

"<div id='aj10'>"+
"<a href='/rsound.php'><b>С</b>траница студии</a><br>"+
"<a href='/rsound.php?task=order&var=sound1'><b>З</b>аказать фонограмму</a><br>"+
"<a href='/rsound.php?task=order&var=clip1'><b>З</b>аказать клип (ролик)</a><br>"+
"<a href='/rsound.php'><b>З</b>аказать рекламу</a><br>"+
"<a href='/rsound.php#sales' title='Приглашаем к сотрудничеству компании и частных лиц, представляющие платные услуги ВИДЕО (клипы, ролики, реал, мульт) и ЗВУКОЗАПИСИ'><b>C</b>отрудничество</a><br>"+
"</div>"+

"<div id='aj3'>"+
"<a href='/partner.php'><b>В</b>еб мастеру</a><br>"+
"<a href='/rsound.php#sales' title='Приглашаем к сотрудничеству компании и частных лиц, представляющие платные услуги ВИДЕО (клипы, ролики, реал, мульт) и ЗВУКОЗАПИСИ'><b>В</b>идео и Звукозапись</a><br>"+
"<a href='/members/'><b>Р</b>егистрация</a><br>"+
"</div>"+

"<div id='aj6'>"+
"<a href='/members/?task=memb' title='зайти в личный кабинет'><b>Л</b>ичный кабинет</a><br>"+
"<a href='/members/?task=forgot'><b>Н</b>апомнить пароль</a><br>"+
"<a href='/members/'><b>Р</b>егистрация</a><br>"+
"<a href='/members/?task=support'><b>Т</b>ех поддержка</a><br>"+
"<a href='/img/doc/mhelp.doc' title='Описание личного кабинета'><b>О</b>писание</a><br>"+
"</div>"+

"<div id='aj7'>"+
"<a href='/map.php' title='Подбор разделов по указаной Цели'><b>К</b>арта сайта + Навигатор</a><br>"+
"<a href='/faq.php'><b>Ч</b>астые вопросы</a><br>"+
"<a href='/partner.php'><b>П</b>омощь партнерам</a><br>"+
"<a href='/help_pay.php'><b>М</b>етоды оплаты</a><br>"+
"<a href='/members/?task=support'><b>К</b>онтакты</a><br>"+
"</div>"+

"<div id='aj8'>"+
"<a href='/privat.php' title='Анкеты зарегистрированных пользователей. Поиск.'><b>В</b>се анкеты</a><br>"+
"<a href='/privat.php?task=online' title='кто online'><b>К</b>то сейчас на сайте</a><br>"+
"<a href='/my_users.php'><b>Т</b>олько авторы</a><br>"+
"<a href='/members/' title='Страница общей регистрации'><b>Р</b>егистрация</a><br>"+
"</div>"+

"<div id='aj12'>"+
"<a href='/master.php' title='Страница предложений репетиторства'><b>В</b>се предложения</a><br>"+
"<a href='/members/?task=memb&cat=4&serv=7' title='Добавить предложение (после авторизации)'><b>Д</b>обавить предложение</a><br>"+
"</div>"+

"<div id='aj9'>"+
"<a href='/script/newsite/rus/index.php?page=news&r=1'><b>Н</b>овости сайта</a><br>"+
"<a href='/blog.php?sid="+ym+"' title='события сайта'><b>Д</b>невник событий</a><br>"+
"<a href='/news/index.php?channel=rssrus' title='новости музыки и пользователей'><b>Н</b>овости музыки</a><br>"+
"<a href='/news/blog.xml'><b>R</b>SS канал сайта</a><br>"+
"<a href='http://do.minusok.com/'><b>Д</b>оска объявлений</a><br>"+
"<a href='http://do.minusok.com/do.php'><b>П</b>оиск объявлений</a><br>"+
"<a href='http://do.minusok.com/add.php'><b>Д</b>обавить объявление</a><br>"+
"<a href='http://do.minusok.com/list.php'><b>П</b>одписка</a><br>"+
"</div>");

	// перенесено -----

function removeDialog(id){

        if(myFName=='effectOpen'){
          parent.upSettings();
	}

        hiddScrollBody();

	if(document.getElementById(id)){
          delNode(id);
	}
	if(document.getElementById(id+"_div")){
          delNode(id+"_div");
	}
	if(document.getElementById(id+"_01")){
          delNode(id+"_01");
	}
	if(parent.RefrashVar){
	   parent.location = parent.location;
	}
}

function hiddScrollBody(par){
if(document.getElementById(mBlayout)){
	return;
}else {
        if(par) { document.body.style.overflowY = par;absPositionDoc(par=="hidden"?"absolute":"static");return;}
        if(document.body.style.overflowY == "hidden"){
          document.body.style.overflowY = "auto";
          absPositionDoc("static"); 
	}
}
}


	// удаление строк

function delNode(id){
if(document.getElementById(id)){
var o = document.getElementById(id);
for(i=0;i<50;i++){
o = document.getElementById(id);
if(o){o.parentNode.removeChild(o);} else {break;}
}}
}


function onBodyResize(){

	// если есть горизонтальный скролл то ширину не 100% а больше для фон1
        // модифицировать при скроллинге

  var id   = "fonDialog";
  if(!document.getElementById(id)) return;

  var pos;
  var fon  = document.getElementById(id);
  var fon1 = document.getElementById(id+"_01");
  var div  = document.getElementById(id+"_div");

  var scrollY = getBodyScrollTop();
  var scrollX = getBodyScrollLeft();

	var w = div.offsetWidth;
	var h = div.offsetHeight;
  
	    var cW = getClientCenterX()-w/2; 
                cW=cW<5?5:cW;
                // cW=(cW-scrollX)<0?scrollW:cW;
	    var cH = getClientCenterY()-h/2; 
                cH=(cH-scrollY)<0?scrollY:cH;
	    var aW = (cW+w/2)*2;
		aW = aW>=document.body.scrollWidth?aW:document.body.scrollWidth;
	    var aH = (cH+h/2)*2;

 	    hiddScrollBody("hidden");

	    fon.style.width  = "100%";
	    fon.style.height = "100%";

//          pos = getElementPositions(id);
//	    fon.style.width  = String(aW)+'px'; // pos.width+'px';
//	    fon.style.height = String(pos.top+pos.height+50)+'px';

            pos = getElementPositions(id+"_01");
	    fon1.style.width  = scrollX?String(aW)+"px":"100%";
	    fon1.style.height = "100%";
	    fon1.style.overflowX = "hidden";
	    fon1.style.overflowY = "auto";

	    // fon1.style.left    = cW+'px';
	    fon1.style.top     = cH+'px';
	    div.style.left     = cW+'px';

}

var myFName;
function initDialog(name,sid,w,h,flag,nid){

        myFName = name;
        var pos,types;
	var id   = "fonDialog";
	var href = "/sing/dialog/"+name+".php?sid="+sid+(nid?"&nid="+nid:"")+(flag?"&task="+flag:"");
	// 0 если не нужно обновлять флеш плеер
	types = (name=='rules'||name=='effect')?0:1;

            w=w?w:400;
            h=h?h:400;
	    var scrollY = getBodyScrollTop();
	    var scrollX = getBodyScrollLeft();
	    var cW = getClientCenterX()-w/2; 
                cW=cW<5?5:cW;
	    var cH = getClientCenterY()-h/2; 
		cH=(cH-scrollY)<0?scrollY:cH;

// alert(getBodyScrollLeft() + " "+ cW+ " "+cH);

	    var aW = aW1 = (cW+w/2)*2;
		aW = aW>=document.body.scrollWidth?aW:document.body.scrollWidth;
	    var aH = (cH+h/2)*2;

	var W3CDOM = (document.createElement && document.getElementsByTagName);
	if (!W3CDOM) return;
	removeDialog(id);

        if(types) hiddScrollBody("hidden");
	
	var fon = document.createElement('div');
	    fon.id        = id;
	    fon.innerHTML = '&nbsp;';
	    document.body.appendChild(fon);
            pos = getElementPositions(id);

	    fon.style.position        = "absolute";
	    fon.style.backgroundColor = '#D2E9FF';
	    fon.style.top = 0;
	    fon.style.left = 0;
	    fon.style.zIndex  = '500';
	    fon.style.width  = String(aW)+'px'; // pos.width+'px';
	    fon.style.height = (aH>=document.body.scrollHeight?aH:document.body.scrollHeight)+"px"; //String(pos.top+pos.height+50)+'px';
            setElementOpacity(id,0.8);

	var fon1 = document.createElement('div');
	    fon1.id        = id+"_01";
	    fon1.innerHTML = '&nbsp;';
	    document.body.appendChild(fon1);
            pos = getElementPositions(id+"_01");
	    fon1.style.position  = "absolute";
	    fon1.style.left = 0;
	    fon1.style.top = cH+'px';
	    fon1.style.zIndex  = '501';

	// нужно расчитать ширину не 100% общая ширина окна -  left и scroll?

	    fon1.style.width  = scrollX?String(aW1)+"px":"100%";
	    fon1.style.height = "100%";
	    fon1.style.overflowX = "hidden";
	    fon1.style.overflowY = "auto";

	var div = document.createElement('div');
	    div.id        = id+"_div";
	    div.style.display = 'none';
	    div.innerHTML = '<table cellpadding=5 cellspacing=0 border=0 width='+w+' height='+h+' class="mDialog"><tr valign=top height=20><th width="'+String(w-20)+'"><div id='+id+'_title>Заголовок</div></th><th width=20 align=right><div align=right style="cursor:pointer;" onclick=removeDialog("'+id+'") title="Закрыть диалоговое окно"><i class="isi si_close"></i></div></th></tr><tr valign=top><td colspan=2><iframe id="'+id+'_body" src="" name=idialog marginwidth="0" marginheight="0" frameborder="0" scrolling="no" width="'+w+'" height="'+(h-20)+'"></iframe></td></tr></table>';
	    fon1.appendChild(div);

	setTimeout(function(){
            document.getElementById(id+"_body").src = href;
	    div.style.position        = "absolute";
	    div.style.backgroundColor = 'white';
	    div.style.left    = cW+'px';
	    div.style.top     = 5;
	    div.style.width   = w+'px';
	    div.style.height  = h+'px';
	    div.style.display = 'block';
	    setElementOpacity(div.id, 0);
	    animate(div.id,1,10);
	    div.style.zIndex  = '501';
	    if(document.frames)document.getElementById(id+"_title").innerHTML = document.frames.getElementById(id+"_body");
   
       },500);
}

function absPositionDoc(el){
            el = el?el:"absolute";
	var m = document.body.children;
	var otbl;
	    for (i=0; i<m.length; i++){
	       if(m.item(i).tagName=='TABLE'){
	          otbl  =m.item(i); 
		  otbl.style.position  = "static";
	         break;
	       } 
	    }
	    if(otbl){
	    otbl.style.left      = el=="static"?"auto":otbl.offsetLeft;
	    otbl.style.position  = el;
	    }
return;
}


function delAllId(id){
 if(document.getElementById(id)){
    var node = document.getElementById(id);
    removeChildren(node);
 }
}

function removeChildren(node) {
     var children = node.childNodes
     while(children.length) {
         node.removeChild(children[0])
     }
 }

function linkCopy(doc){
    doc.focus();
    doc.select();
    doc.document.execCommand('Copy', false, '');
}

function ge(el) {return (typeof el == 'string' || typeof el == 'number') ? document.getElementById(el) : el;}
function isFunction(obj) { return Object.prototype.toString.call(obj) === "[object Function]"; }
function isArray(obj) { return Object.prototype.toString.call(obj) === "[object Array]"; }


// -------------- ALPHA ------------------ // 

function animate(id, alpha, speed, callback) {
if(!document.getElementById(id)) return;
// hs.animate(document.getElementById(id), { opacity: alpha }, speed);

  var _cb = isFunction(callback) ? callback : function() {};
  var obj = document.getElementById(id); 
  var opacityProp = getOpacityProperty(id); 
  if(opacityProp===false) return;
      opacityProp = opacityProp*1;
  var step = 0.1;
  var end  = 0;
  if(alpha>opacityProp){ 	// увеличиваем
     opacityProp += step;
     if(opacityProp>alpha) end=1;
  }else if(alpha<opacityProp){  // уменьшаем
     opacityProp -= step;
     if(opacityProp<alpha) end=1;
  }else return;
  setElementOpacity(id,opacityProp);
  if(alpha==opacityProp || end){
	 setTimeout(_cb,0);
	 return;
  }
   setTimeout(function(){animate(id, alpha, speed, callback)},speed);
return;
}

function setElementOpacity(sElemId, nOpacity)
{
  if(!document.getElementById(sElemId))return;
  var opacityProp = getOpacityProperty();
  var elem = document.getElementById(sElemId);
  if (!elem || !opacityProp) return;
  if (opacityProp=="filter")  // Internet Exploder 5.5+
  {
    nOpacity *= 100;
    var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
    if (oAlpha) oAlpha.opacity = nOpacity;
    // Для того чтобы не затереть другие фильтры используем "+="
    else elem.style.filter    += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")"; 
  }
  else {
    elem.style[opacityProp] = nOpacity;
  }
}

function getOpacityProperty(id)
{
	if(id && document.getElementById(id)) var obj = document.getElementById(id);

           // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9, IE7)
  if (typeof document.body.style.opacity == 'string'){
    return obj?obj.style.opacity:'opacity';
	   // Mozilla 1.6 и младше, Firefox 0.8 
  } else if (typeof document.body.style.MozOpacity == 'string'){
    return obj?obj.style.MozOpacity:'MozOpacity';
	 // Konqueror 3.1, Safari 1.1
  } else if (typeof document.body.style.KhtmlOpacity == 'string'){
    return obj?obj.style.KhtmlOpacity:'KhtmlOpacity';
	// Internet Exploder 5.5+
  } else if (typeof document.body.filters != 'unknown' && document.body.filters && navigator.appVersion.match(/MSIE ([d.]+);/)[1]>=5.5) {
    return obj?false:'filter';
 }
  return false;
}



