///// common functions
function OpenNewSized(url, width, height) {  
  NWin = open (url, 'additional', 'menubar=0,location=0,status=0,toolbar=0,scrollbars=1,resizable=1,height='+height+',width='+width);
}


function addBookmark(url, title)
{
if (!url) url = location.href;
if (!title) title = document.title;

//Gecko
if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
//IE4+
else if (typeof window.external == "object") window.external.AddFavorite(url, title);
//Opera7+
else if (window.opera && document.createElement)
{
var a = document.createElement('A');
if (!a) return false; //IF Opera 6
a.setAttribute('rel','sidebar');
a.setAttribute('href',url);
a.setAttribute('title',title);
a.click();
}
else return false;

return true;
}

///// menu
function switchDIV(id) {
  if ( (!document.getElementById(id).style.display) || (document.getElementById(id).style.display=="none") ) {
      document.getElementById(id).style.display="block";
  } else {
      document.getElementById(id).style.display="none";
  }
}

function show(ID) {
      document.getElementById(ID).style.visibility="visible";
      document.getElementById(ID).style.display="block";
      // alert ('show '+ID);
}

function hide(ID) {
      document.getElementById(ID).style.visibility="hidden";
      document.getElementById(ID).style.display="none";
      // alert ('hide '+ID);
}

function switchSubmenu(id) {
        if (!document.getElementById(id))  {return;}
        var obj = document.getElementById(id);
        // alert(id+'.display='+obj.display);
        if (obj.style.display!='block') {
                document.getElementById(id).style.display='block';
        } else {
                document.getElementById(id).style.display='none';
        }
}


//// music

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 setCookie(name, value, expires, path, domain, secure) {
        var curCookie = name + "=" + escape(value) +
                ((expires) ? "; expires=" + expires.toGMTString() : "") +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "")
        if ((name + "=" + escape(value)).length <= 4000)
                document.cookie = curCookie
        else
                if (confirm("Cookie превышает 4KB и будет вырезан !"))
                        document.cookie = curCookie
}
var music_status='play';
function switchMusic() {
   // http://dotupdate.wordpress.com/2007/08/15/using-wmp-and-quicktime-with-silverlight/
   if (music_status=='play') {
        if ( (document.getElementById('WMPlayer')) && (document.getElementById('WMPlayer').controls)) {document.getElementById('WMPlayer').controls.pause();}
        document.getElementById('musPicture').src="/img/mus-off.gif";
        music_status='pause';
        setCookie('music_play',0,'','/');
   } else {
        if ((document.getElementById('WMPlayer')) && (document.getElementById('WMPlayer').controls)) {document.getElementById('WMPlayer').controls.play();}
        document.getElementById('musPicture').src="/img/mus-on.gif";
        music_status='play';
        setCookie('music_play',1,'','/');
   }
}
