var ie = document.all?1:0;
var ns4 = document.layers?1:0;

var stathost = 'http://music.allofmp3.com';
var cathost  = 'http://music.allofmp3.com';
var myhost   = 'http://music.allofmp3.com';
var helphost    = 'http://music.allofmp3.com';
var previewhost = 'http://music.allofmp3.com';

var linkhost = 'http://account.allofmp3.com';
var serhost  = 'http://account.allofmp3.com';
var reghost  = 'http://account.allofmp3.com';
var smshost  = 'http://music.allofmp3.com';

// var linkhost    = 'http://links.allofmp3.com';
// var serhost  = 'http://secure.allofmp3.com';
// var reghost  = 'http://reg.allofmp3.com';

function golink(action,h_value){ document.form1.action=action; document.form1.queryrepost.value=h_value; document.form1.submit();}

function rnd() 
{ 
var ddd = "rnd="+Math.round(Math.random() * 1000000);
return ddd; 
}

function popup_OE(link,param)                { go_popup(link+'?unicid='+param,'350','200','mp3','no') }
function popup_GB(link,param)                { go_popup(link+'?MID='+param,'350','500','mp3','no') }
function popup2(param1)                      { go_popup(stathost+'/order.shtml?id='+param1,'480','535','mp3_order','no') }
function popup_v(param1)                     { go_popup(cathost +'/videofilez.shtml?code='+param1+'&'+rnd(),'500','510','movie_file','no');}
function popup_3()                               { go_popup(helphost+'/help.shtml?','480','550','mp3_help','no');}
function popup_text(param1,param2,param3)    { go_popup(stathost+'/text.shtml?group='+param1+'&album='+param2+'&song='+param3,'494','550','mp3_text','yes');}
function popup_preview(param1,param2,param3) { go_popup(previewhost+'/preview.shtml?group='+param1+'&album='+param2+'&song='+param3+'&'+rnd(),'760','410','mp3_prev','yes');}
function popup_smsorder(param1,param2,param3) { go_popup(previewhost+'/sms/order.shtml?group='+param1+'&album='+param2+'&song='+param3+'&'+rnd(),'760','720','mp3_sms','yes');}
function popup_getit_v(param1)               { go_popup(myhost  +'/getit.shtml?code='+param1+'&'+rnd(),'250','150','mp3_getit_v','no');}
function popup_links()                       { go_popup(reghost +'/mylinks.shtml?'+rnd(),'640','400','mp3_mylinks','yes');}
function gobasket(link)                      { window.opener.location=link; window.close(); }
function closew()                            { window.close(); }
function popup_getit(param1,param2,param3)   { go_popup(myhost  +'/getit.shtml?group='+param1+'&album='+param2+'&s0='+param3+'&'+rnd(),'640','400','mp3_addsongs','no');}
function popup_MSgetit(param1,param2,param3) { go_popup(myhost  +'/onlineenc/simple2.shtml?group='+param1+'&album='+param2+'&s1='+param3+'&'+rnd(),'440','500','mp3_addsongs','yes');}
function popup_getit_v(param1)               { go_popup(myhost  +'/getit.shtml?code='+param1+'&'+rnd(),'640','400','mp3_addvideo','no');}
function popup_legend(param1)                { go_popup(helphost+'/legend_nv.shtml?v='+param1,'760','410','mp3_legend','no');}
function popup_pass(param1)                  { go_popup(reghost +'/reg/pass.shtml?'+param1+'=on','400','270','mp3_pass','no');}
function popup_help(prm)                     { go_popup(helphost+'/help/help.shtml?prm='+prm+'&'+rnd(),1000,600,'mp3_help','yes');}
function popup_help2(gs, gd)                     { go_popup(helphost+'/help/help.shtml?gs='+gs+'&gd='+gd+'&'+rnd()+'&popup=yes',1000,600,'mp3_help','yes'); return false;}
function popup_sitelink(param1,param2)       { go_popup('/addlink.shtml?'+param1+'=on&group='+param2,'500','400','mp3_link','yes');}
function popup_MSSPDESC(param1)              { go_popup(reghost +'/doc.shtml?doc='+param1,'400','400','PDESC','yes');}
function popup_payment(param1,param2)        { go_popup(reghost +'/payment/kvit.shtml?code='+param1+'&months='+param2,'850','700','Kvitok','yes');}
function popup_tour(width,height)            { go_popup(helphost+'/tour/index.shtml',width,height,'tour','yes');}
function popup_album(action,group,album,ex)  { go_popup(linkhost+'/basket_album.shtml?action='+action+'&group='+group+'&album='+album+'&ex='+ex+'&'+rnd(),600,600,'balbum','yes');}
function popup_SMSorder(param1,param2)       { go_popup(smshost +'/sms/smsorder.shtml?group='+param1+'&album='+param2+'&'+rnd()+'&action=first','730','460','mp3_smsorder','yes');}
function popup_Giftorder(param1,param2)      { go_popup(smshost +'/gift/postcard.shtml?group='+param1+'&album='+param2+'&'+rnd()+'&action=first','880','600','mp3_giftorder','yes');}

function popup_adds()                       
{
 var s= myhost+'/getit.shtml?';
 s = s+'group='+document.ADD['group'].value;
 s = s+'&album='+document.ADD['album'].value;
 s = s+'&albref='+document.ADD['albref'].value;
 for(i = 0; i < 200; i++)
 {
  if(document.ADD[i].name == 'submit' || document.ADD[i].name == 'all') break;
  if(document.ADD[i].type == 'checkbox' && document.ADD[i].checked) s = s+'&S'+i+'='+document.ADD[i].value;
 }
 go_popup(s,'640','400','mp3_addsongs','yes');
}

function popup_OEadds()                       
{
 var s= myhost+'/onlineenc/simple2.shtml?';
 s = s+rnd()+'&group='+document.ADD['group'].value+'&album='+document.ADD['album'].value+'&albref='+document.ADD['albref'].value;
 for(i = 0; i < 102; i++)
 {
  if(document.ADD[i].name == 'submit' || document.ADD[i].name == 'all') break;
  if(document.ADD[i].type == 'checkbox' && document.ADD[i].checked) s = s+'&S'+i+'='+document.ADD[i].value;
 }
 go_popup(s,'440','500','mp3_addoesongs','yes');
}

function popup_WLadds(remove)
{
  var s= myhost + '/getwait_1.shtml?';
  s = s+rnd()+'&group='+document.ADD['group'].value+'&album='+document.ADD['album'].value+'&albref='+document.ADD['albref'].value;
  if (remove) {
     s += '&remove=yes';
  }
  document.getElementById('toLoad').src = s;
}

function popup_OEWLadds(group,album,albref,url)                       
{
 var s= myhost+'/onlineenc/simple2.shtml?';
 s = s+rnd()+'&group='+group+'&album='+album+'&albref='+albref+url;
 go_popup(s,'440','500','mp3_addoesongs','yes');
}


function checkbuttons_OLD(CB)
{
 var s = true;
 for(i = 0; i < 200; i++)
 {
  if(document.ADD[i].name == 'submit' || document.ADD[i].name == 'all') break;
  if(document.ADD[i].type == 'checkbox' && document.ADD[i].checked && document.ADD[i].name != 'all')  { s = false; break; }
 }
 document.ADD['submit'].disabled = s;
}




function checkbuttons(CB){
    var iname;
    var s = true;
    var st = 'big disabled';
    for (var i=0; i < document.getElementsByTagName("input").length; i++) {
        iname = document.getElementsByTagName("input")[i].name;
        if( iname ){ if( ! iname.indexOf("add_") && document.getElementsByTagName("input")[i].checked ){ s = false; st = 'big enabled'; break; } }
    }
    document.ADD['submit'].disabled = s;
    document.ADD['submit'].className = st;
}


function changeGetItState()
{
 var s = document.ADD['all'].checked; 
 for(i = 0; i < 200; i++)
 {
  if(document.ADD[i].name == 'submit' || document.ADD[i].name == 'all') break;
//  if(document.ADD[i].type == 'checkbox')  { document.ADD[i].checked = s; CCB(document.ADD[i],'TR_sel'); }
  if(document.ADD[i].type == 'checkbox')  { document.ADD[i].checked = s; CCB(document.ADD[i],'selected'); }
 }
 checkbuttons();
}


function set_bookmark()                       
{
 var s= myhost+'/setbookmark_1.shtml?set=on';
// var s= myhost+'/setbookmark.shtml?set=on';
 if(BookPresent != 'on' && IsAuth != 'off')
 { 
  s = s+'&group='+document.BMark['group'].value+'&add=on'; 
  document.BMark['submit'].value = (CLang=='ENG'?'Delete from CheckList':'Удалить из Закладок'); 
  BookPresent = 'on';
 }
  else 
 { 
  s = s+'&group='+document.BMark['group'].value+'&del=on'; 
  document.BMark['submit'].value = (CLang=='ENG'?'add to Checklist':'добавить в Закладки'); 
  BookPresent = 'off';
 }
  document.getElementById('toLoad').src = s;
  //frames["toLoad"].location.href = s;
  //go_popup(s,'640','200','mp3_bookmarks','yes');
}

function CCB(CB,trclass) {if (CB.checked) hL(CB,trclass); else dL(CB);}

function hL(E,trclass) { if (ie) { while (E.tagName!="TR") {E=E.parentElement;} } else { while (E.tagName!="TR"){E=E.parentNode;} }
  E.className = trclass;
}

function dL(E){ if (ie) { while (E.tagName!="TR"){E=E.parentElement;}  }  else  {    while (E.tagName!="TR") {E=E.parentNode;}  }
  E.className = "";
}

function go_popup(path,w,h,wname,scroll){
    p='width='+w+',height='+h+',resizable=yes,toolbar=no,location=no,directories=no,status=yes,scrollbars='+scroll+',menubar=no';
    xxx=window.open(path,wname,p);
    window.xxx.focus();
}

function SetLinkClass(param,ex) 
{
 for(i = 0; i < document.links.length; i++)  
   if(document.links[i].name == param)   
   { 
     document.links[i].className = ex; 
     break; 
  }
}

function openw( url, name, width, height ) {
  if ( height < 100 ) height = 100; if ( width < 100 ) height = 100;
  var top = screen.availHeight / 2 - height / 2;
  var left = screen.availWidth / 2 - width / 2;
  var w = window.open( url, name, 'resizable=no,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,top='+top+',left='+left+',height='+height+',width='+width );
  w.focus();
  return true;
}

function OpenNetRadio(group,album,song) 
{
 w = window.open( "http://netradio.tochka.ru", 'second' );
 openw('http://tech.tochka.ru/fcgi/extnrrate.cgi?'+group+','+album+','+song, 'first', 300, 100 );
}

function vh_sceneLoaded()
{
	setStatus(1,0);
}

function caseOver(obj) {
    for(i=0; i<obj.childNodes.length; i++) {
        if((obj.childNodes[i].tagName == "DIV") && (obj.childNodes[i].className == "transparent")) {
            obj.childNodes[i].style.display = "none";
            break;
        }
    }
}
function caseOut(obj) {
    for(i=0; i<obj.childNodes.length; i++) {
        if((obj.childNodes[i].tagName == "DIV") && (obj.childNodes[i].className == "transparent")) {
            obj = obj.childNodes[i].style.display = "block";
            break;
        }
    }
}
