function getNameBrouser() {
  var ua = navigator.userAgent.toLowerCase();
  // Определим Internet Explorer
  if (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1) {
    return "msie"
  }
  // Opera
  if (ua.indexOf("opera") != -1) {
    return "opera"
  }
  // Gecko = Mozilla + Firefox + Netscape
  if (ua.indexOf("gecko") != -1 && ua.indexOf("safari") == -1) {
    return "gecko";
  }
  // Safari, используется в MAC OS
  if (ua.indexOf("safari") != -1) {
    return "safari";
  }
  // Konqueror, используется в UNIX-системах
  if (ua.indexOf("konqueror") != -1) {
    return "konqueror";
  }
  return "unknown";
}

var cur1="slideshow";
        
function setselect(id){

        if(cur1!='project_music'){
                document.getElementById(cur1).style.display = "none";
        }else{
            document.getElementById(cur1).style.height = "1px";
            document.getElementById(cur1).style.width = "1px";      
            document.getElementById(cur1).style.visibility = "hidden";
            document.getElementById(cur1).style.overflow = "hidden";
        }
        document.getElementById(cur1+"_a").className = "topmenu";
        document.getElementById(cur1+"_a").onmouseover = function(){this.className='topmenu_select'}
        document.getElementById(cur1+"_a").onmouseout = function(){this.className='topmenu'}
        if(id!='project_music'){
                document.getElementById(id).style.display = "block";
        }else{
                document.getElementById(id).style.height = "auto";
                document.getElementById(id).style.width = "auto";
        document.getElementById(id).style.display = "block";
            document.getElementById(cur1).style.visibility = "visible";

        }

        document.getElementById(id+"_a").className = "topmenu_select";
        document.getElementById(id+"_a").onmouseover = function(){return false;}
        document.getElementById(id+"_a").onmouseout = function(){return false;}
        cur1 = id;

}

var pup = null;

function img_on(imgName,imgTarg) {
    document[imgTarg].src = imgName;
}

function make_obj(name){
   if(document.layers) return eval("document.layers['" + name + "']");
   else return document.getElementById(name);
}

function m_sel(name, mode){
   if(mode==1) make_obj(name).className='tops';
   else make_obj(name).className='top';
}

function openwin(url,w,h,scr,title){
    var x=(screen.width/2)-(w/2); var y=(screen.height/2)-(h/2);
    if(x==null || y==null) x=y=10;
    if(pup != null && !pup.closed) pup.close();
    if(scr == null) scr="no";

   options="height="+h+", width="+w+", left="+x+", top="+y+", scrollbars="+scr+", resizable=yes'";

    pup=window.open(url,title,options);
    pup.focus();
}

function openDocWindow(docName, section, baseUrl) {
    var url = baseUrl + "onlinedoc-view?name=" + docName + "&section=" + section;
    openwin(url, 720, 480, 'yes', 'onlinedoc');
}

function getCookie(Name) {   
  var search = Name + "="; 
  if (document.cookie.length > 0) { 
    offset = document.cookie.indexOf(search); 
    if (offset != -1) { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(offset, end));
   }    
  }
  return null;
}

function PreloadImages() { 
  var d=document; 

    if(d.images){ 
        if(!d.p) 
            d.p=new Array();
            var i,j=d.p.length,a=PreloadImages.arguments; 
            for(i=0; i<a.length; i++)
               if (a[i].indexOf("#")!=0){ 
                  d.p[j]=new Image; 
                  d.p[j++].src=a[i];
               }
    }
}


function setCookie(Name,value) {   
  var data=escape(value);
  var search = Name + "="   
  document.cookie=search+data+';'+'path=/';
}

function add_points(path){
  var points=getCookie('sel_points');
  if(points==null) {
     alert('мХВЕЦН МЕ БШАПЮМН');
     return;
  }
  window.location.href=path+'&points='+points;
  return;
}

function toggle_point(id) {   
  var res="";
  var find=false;
  if(getCookie("sel_points")){
   var points=getCookie("sel_points").split("-");
   for(i=0;i < points.length; i++){
    if(points[i]!=id) {
       if(res!="") res+="-";  
       res+=points[i];
       continue;
    }
    find=true;
   }
  }
  if(!find){
    if(res!="") res+="-";  
    res+=""+id;
  }
  setCookie("sel_points",res);  
}


function show_selections() {   

  if(getCookie("sel_points")){
   var points=getCookie("sel_points").split("-");
   for(i=0;i < points.length; i++){
    name="sel_"+points[i];
    el=document.getElementById(name);
    if(el){
        el.checked=true;
    }
   }
  }
}

function drop_selections() {   
  setCookie("sel_points","");
}

function set_selections(id) {   
  if(getCookie("sel_points")) res=getCookie("sel_points")+"-"+id;
  else res=""+id;
  setCookie("sel_points",res);
}

function refresh_changes() {
  window.location.reload(0);
}

function getRadioValue (radioButtonOrGroup) {
  var buttonsLength = radioButtonOrGroup.length;
  if (buttonsLength) { // group
    for (var b = 0; b < buttonsLength; b++)
      if (radioButtonOrGroup[b].checked)
        return radioButtonOrGroup[b].value;
  }
  else if (radioButtonOrGroup.checked)
    return radioButtonOrGroup.value;
  return null;
}

function uncheckRadioGroup (radioButtonOrGroup) {
  if (radioButtonOrGroup.length) { // we have a group
    for (var b = 0; b < radioButtonOrGroup.length; b++)
      if (radioButtonOrGroup[b].checked) {
        radioButtonOrGroup[b].checked = false;
        break;
      }
  }
  else 
    radioButtonOrGroup.checked = false;
}



function select_bush(select_mode,formname,fieldname,bush_id,page_id){
    var par=window.opener.parent;

    if(par){

// alert("select "+page_id);

        if(select_mode=="bush") par.document.forms[formname].elements[fieldname].value=bush_id;
        else  par.document.forms[formname].elements[fieldname].value=page_id;

        var dom = document.getElementById("b"+bush_id);      

// alert(bush_id+":"+dom.attributes["title"].value);

        par.document.forms[formname].elements[fieldname+"_title"].value=dom.attributes["title"].value;

    }
    window.close();

}

function select_doc_prm(formname,fieldname,title){
    var par=window.opener.parent;
    if(par) par.document.forms[formname].elements[fieldname].value=title;
    window.close();

}

function select_ban_prm(formname,obj,type, title){
    var par=window.opener.parent;
    if(par){
         par.document.forms[formname].elements["obj_id"].value=obj;
         par.document.forms[formname].elements["obj_type"].value=type;
         par.document.forms[formname].elements["obj_title"].value=title;
    }
    window.close();

}

var tmpImg = new Image();
tmpImg.src = '/images/sel-arrow-s.gif';
function switchDiv(divID,thisAnc) {
 if (document.getElementById(divID)) {
  if (!(document.getElementById(divID).style.display) || document.getElementById(divID).style.display == 'block') {
   document.getElementById(divID).style.display = 'none'
   thisAnc.className = 'divSelect';
   if (document.getElementById(divID + '-i')) document.getElementById(divID + '-i').src = '/images/sel-arrow.gif';
   } else {
     document.getElementById(divID).style.display = 'block';
     thisAnc.className = 'divSelectS';
     if (document.getElementById(divID + '-i')) document.getElementById(divID + '-i').src = '/images/sel-arrow-s.gif';
   }
 }
}

function openimg(url,w,h,season,scr,title){
    var x=(screen.width/2)-(w/2); var y=(screen.height/2)-(h/2);
    if(x==null || y==null) x=y=10;
    if(pup != null && !pup.closed) pup.close();
    if(scr == null) scr="no";
    
    options="height="+h+", width="+w+", left="+x+", top="+y+", scrollbars="+scr+", resizable=yes, align=center '";

    pup=window.open('','',options); 
    pup.document.open();
    pup.document.write("<html><head><title></title></head><body bgcolor='#e5e5e5'>");
    

    
        pup.document.write("<img onclick=\"window.close()\" src=\""+url+"\"/>");
        pup.document.write("</body></html>");
    pup.document.close();

    pup.focus();
}

show = false;
/*financial system*/
function show_close(id,idimg,oldsrc,newsrc) {
var h=150;
        if(show) {        


        if(getNameBrouser()=='opera'){
        document.getElementById("ch1").style.height = "0%";
        document.getElementById("ch2").style.height = "0%";
        document.getElementById("ch3").style.height = "0%";
        document.getElementById("ch4").style.height = "0%";
        }
        document.getElementById(id).style.display = "none";     

        if(getNameBrouser()=='opera'){
        document.getElementById("ch1").style.height = "100%";
        document.getElementById("ch2").style.height = "100%";
        document.getElementById("ch3").style.height = "100%";
        document.getElementById("ch4").style.height = "100%";
        }

        if(getNameBrouser()=='gecko'){
        document.getElementById("tr2").style.height = "50px"
        document.getElementById("tbl_1").setAttribute("height","699");
        document.getElementById("ch3").setAttribute("height",document.getElementById("tbl_1").offsetHeight+document.getElementById("menu").offsetHeight);
        document.getElementById("ch4").setAttribute("height",document.getElementById("tbl_1").offsetHeight+document.getElementById("menu").offsetHeight);
        
        } 

        show=false;
        document.getElementById(idimg).src=newsrc;



        }else{                                 
  

        document.getElementById(id).style.display = "block"; 
        if(getNameBrouser()=='opera'){document.getElementById("full_news").style.height=document.getElementById("full_news").offsetHeight+"px"}
        if(getNameBrouser()=='gecko'){
        document.getElementById("tr2").style.height = "100%"
        document.getElementById("tbl_1").setAttribute("height","100%");
        document.getElementById("ch3").setAttribute("height",document.getElementById("tbl_1").offsetHeight+document.getElementById("menu").offsetHeight);
        document.getElementById("ch4").setAttribute("height",document.getElementById("tbl_1").offsetHeight+document.getElementById("menu").offsetHeight);
        }
        document.getElementById(idimg).src=oldsrc;
        show=true;
        }

}

window.onload = function() {
    if(getNameBrouser()=='opera') document.getElementById("tbl_1").style.height="699px";
}

