function ffade(elName){
   if (Prototype.Browser.IE) {
     $(elName).setStyle({opacity: 0}); 
   }else{
     $(elName).fade({ to: 0.01, duration: 0.2 });
   }
}
function aappear(elName){
   if (Prototype.Browser.IE) {
     $(elName).setStyle({opacity: 1}); 
   }else{
     $(elName).appear({ duration: 0.2 });
   }
}
function ge(id){
   return document.getElementById(id);
}

function show_content() {
    // выходим, если функция уже выполнялась
    if (arguments.callee.done) return;

    // устанавливаем флаг, чтобы функция не исполнялась дважды
    arguments.callee.done = true;
//    for(i=1; i<=5; i++){
  //     setBg(i);
    //}
    ge('loading').style.display='none'; 
    ge('content').style.visibility = "visible";
    if(Prototype.Browser.IE)
        ge('content').style.display='block'; 
    else
        ge('content').style.display='table'; 
    //window.scrollTo(60,0);
    calc_heights();
    if(ge('col1')&&ge('col2')&&ge('col3')&&ge('col3_div')&&ge('col1_div')){
      if($(document.body).getWidth() > 1024){
         ge('col2').style.width = "450px";
         ge('col1').style.width = "300px";
         ge('col3').style.width = "300px";
      
      }
    }

}
function setBg(num){
    if(ge("bc"+num) != null){
        ge("bc"+num).style.background="url('img/circle_"+num+"_in.png') center center no-repeat";
//        alert("bc"+num);
    }
    /*
background: url('img/circle_1_in.png'); background-position: center center; background-repeat: no-repeat;
background: url('img/circle_2_in.png'); background-position: center center; background-repeat: no-repeat;
background: url('img/circle_3_in.png'); background-position: center center; background-repeat: no-repeat;
background: url('img/circle_4_in.png'); background-position: center center; background-repeat: no-repeat;
background: url('img/circle_5_in.png'); background-position: center center; background-repeat: no-repeat;
    */
}
function all_texts_display(style){
   var divs = document.getElementsByTagName('div');
   var tables = document.getElementsByTagName('table');
   for (i=0; i<divs.length; i++){
       if(divs[i].className == 'text_with_title'){
          ge("fixed_table").style.height = "1000px";
          $(divs[i]).style.display = style;
       }
   }  /*
   for (i=0; i<tables.length; i++){
       if(tables[i].className == 'table_with_text'){
          $(tables[i]).style.display = style;
       }
   }*/
  // alert( $("center_td").getHeight()  );
   ge("left_td").style.height = ($("center_td").getHeight() - 130) + "px";
}
function show_text(id){
   $(ge(id)).style.display = "block";
   ge("left_td").style.height = ($("center_td").getHeight() - 130) + "px";
}

function setOffs(offs, id){
//   if(Prototype.Browser.IE) offs += 0; 
   ge(id).style.height = document.viewport.getHeight() - offs + 'px';
}
function animate(offs, id){
/*
    ge('xx').innerHTML = "";
    ge('flashcontent').className = "padding_0";
    ge('headimg').className = "head_mini";
    ge('xx').style.height = "273px";
    setOffs(274, 'flashcontent'); 
    ge('headimg').onclick = navigate_photo; 
    Effect.SlideUp('x'); */

<!--<div id="grow_demo" style="display:none; width:80px; height:80px; background:#ccc;"></div>-->

}

function navigate_index(){
      document.location.href='./';
}
function navigate_photo(){
      document.location.href='./photo.php';
//      window.history.back();
}
function calc_heights(){
      if(!(ge('right_table')&&ge('left_table')&&ge('nizok')&&ge('fixed_table'))) return;
      ge('right_table').style.height = "11px";
      ge('left_table').style.height = "11px";
      ge('nizok').style.height = "11px";
      ge('fixed_table').style.height = "11px";

      r = $(ge('right_table')).getHeight();
      l = $(ge('left_table')).getHeight();
      n = $(ge('nizok')).getHeight();
      f = $(ge('fixed_table')).getHeight();

      magicconst = 0;

      if(l < r+n){
         if(Prototype.Browser.IE) magicconst = 71;
         ge('left_table').style.height = r+n -magicconst +"px";
      
      }else{
         if(Prototype.Browser.IE) magicconst = 5;
         ge('nizok').style.height = l-r -magicconst +"px";
      
      }
      
      //ge('nizok').innerHTML += " "+a+":"+f;


      //f_t_h = $(ge('fixed_table')).getHeight();
//      ge('right_table').style.height = a + "px";


      //ge('last_right_td').innerHTML += ":"+f_t_h;
}

function getNextSibling(startBrother)
{
endBrother=startBrother.nextSibling;
while(endBrother.nodeType!=1)
{
endBrother = endBrother.nextSibling;
}
return endBrother;
}
function getFirstChild(elm)
{
if ( !elm.childNodes.length )
{
return;
}
var children = elm.childNodes.length;
for ( var i = 0; i <= children; ++i )
{
if ( elm.childNodes[i].nodeType == 1 )
{
return elm.childNodes[i];
}
}
return;
}
function lights_up(obj){
     els = document.getElementsByTagName('TD');
     for (i=0; i<els.length; i++){
        if(els[i].className.indexOf("music_row_images") != -1){
           els[i].className = "music_row_images";
           if(getFirstChild(els[i]).src.match(".*_in\.jpg$"))
              getFirstChild(els[i]).src = getFirstChild(els[i]).src.match("(.*)_in\.jpg$")[1] + ".jpg";
        }
        if(els[i].className.indexOf("music_row_description") != -1){
           els[i].className = "music_row_description";
        }
     }
     // first td (with image)
//     getFirstChild(obj.parentNode.parentNode).className += ' trans_box1';

     // second td (width text description)
     getNextSibling(getFirstChild(obj.parentNode.parentNode)).className += ' trans_box2';

     var _img = getFirstChild(getFirstChild(obj.parentNode.parentNode));
     if(_img.src.match(".*_in\.jpg$") == null && _img.src.match("\/music\/") != null)
        _img.src = _img.src.match("(.*)\.jpg$")[1] + "_in.jpg";
//     alert(obj.parentNode.parentNode.firstChild.nextSibling.className);
}


//window.onload = show_content;





// thanks!:) original from http://dean.edwards.name/weblog/2005/10/add-event/
// with input from Tino Zijdel, Matthias Miller, Diego Perini, Tanny O'Haley, Hedger Wang
// Author: Dr. Dirk Fischer, Koln, Germany : Tested with www.browsershots.org : thanks!

function addEvent(element, type, handler) {
var special = window.execScript ? "i"                          // IE (first, because correct order is important)
   : /safari/i.test(navigator.userAgent) ? "s"                 // or Safari (found no easier test :[)
   : document.clientWidth                                      // or KDE,
     || window.opera&&!window.getSelection ? "k"               // and Opera<9 (Opera >=9 is OK, hm)
   : document.addEventListener ? false                         // all is supported
   : "o",                                                      // or other?
   t="DOMContentLoaded";

   if (type.toLowerCase()=="load")                             // could be wrong element or be overwritten
      element=initonLoadEvent(element, special);
   if (!element)                                               // just in case...
      return false;
   if (element.addEventListener&&!(special&&type == t))
      element.addEventListener(type, handler, false);
   else {
      // assign each event handler a unique ID
      if (!handler.$$guid) handler.$$guid = addEvent.guid++;
      // create a hash table of event types for the element
      if (!element.events) element.events = {};
      // create a hash table of event handlers for each element/event pair
      var handlers = element.events[type];
      if (!handlers) {
         handlers = element.events[type] = {};
         // store the existing event handler (if there is one)
         if (element["on" + type]) {
            handlers[0] = element["on" + type];
         }
      }
      // store the event handler in the hash table
      handlers[handler.$$guid] = handler;
      // assign a global event handler to do all the work
      element["on" + type] = handleEvent;
      if (type == t)
         initDOMLoadEvent(element, handler, special);
   }

   // The body-element and may be other scripts will overwrite previous attached events on the window object
   // for the onload event. This will work even on older Browsers.
   function initonLoadEvent(element, special){
      if (element&&(element==window||element==document||element==document.body)){
         if (special=="k")                                     // Konqueror and Opera only support DOCUMENT
            element=document;                                  // DOM 3 calls load-event on document...
         else
            element=window;                                    // ... but the Rest takes window
         if (!addEvent.waitLoad                                // wait still active?
            &&special&&special!="k"&&special!="s"){            // Safari, Konqueror and Opera are working correct
            if (document.ids)                                  // is needed for Ne4.x
               document.tags.body.position="absolute";
            addEvent.waitLoad=true;                            // wait till onload has happend...
            addEvent(element,'load',function(){addEvent.waitLoad=false;});
            (function(){
               if (addEvent.waitLoad){
               var o=document.body;                            // some use BODY or DOCUMENT or WINDOW => test all

                  if(!onloadTest(o)&&!onloadTest((o=document))&!onloadTest((o=window)))
                     setTimeout(arguments.callee,10);          // wait a bit
                  else{
                     addEvent(element,'load',o.onload);
                     o.onload=handleEvent;
                  }
               }
            })();
         }
      }
      return element;                                          // could be changed
   }
   
   function onloadTest(o){                                     // is there a unknown new event?
      return !o||typeof o.onload!="function"||o.onload==handleEvent?false:true; 
   }

   function initDOMLoadEvent(element,handler,special){         // works only, if element==window
      addEvent.waitDOMLoaded=true;                             // stop if more than one timeout in a row
      if (special=="s"||special=="k")                          // Safari, KDE, Opera<9
         (function(){
            if (addEvent.waitDOMLoaded){                       // not done?
               if(/loaded|complete/i.test(document.readyState))
                  doDOMLoad();
               else
                  setTimeout(arguments.callee,10);             // wait a bit
            }
         })();
      else if (special=="i")                                   // IE
         (function(){
            if (addEvent.waitDOMLoaded){                       // not done?
               /*@cc_on @*/                                    // else older Browsers killed by try...chatch statement
               /*@if (@_win32 || @_win64)
               var e=document.createElement('doc:rdy');
               try{
                  e.doScroll('left');
                  e=null;
                  doDOMLoad();
               }catch(err){
                  setTimeout(arguments.callee,10);             // wait a bit
               }
               @end @*/
            }
         })();
      else
         addEvent(element,"load",handler);                     // older Browsers may act onload
   }

   function doDOMLoad(){
   var t="DOMContentLoaded";

      addEvent.waitDOMLoaded=false;                            // flag that it is done
      (window["on"+t])({"type":t});                            // call the eventHandler with "handmade" event
   }
};
// a counter used to create unique IDs
addEvent.guid = 1;

function removeEvent(element, type, handler) {
   if (element.removeEventListener) {
      element.removeEventListener(type, handler, false);
   } else {
      // delete the event handler from the hash table
      if (element.events && element.events[type]) {
         delete element.events[type][handler.$$guid];
      }
   }
};

function handleEvent(event) {
   var returnValue = true,j=0;
   // grab the event object (IE uses a global event object)
   event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
   // get a reference to the hash table of event handlers
   var handlers = this.events[event.type];
   // execute each event handler
   for (var i in handlers) {
      this.$$handleEvent = handlers[i];
      if (this.$$handleEvent(event) === false) {
         returnValue = false;
      }
   }
   return returnValue;
};

function fixEvent(event) {
   // add W3C standard event methods
   event.preventDefault = fixEvent.preventDefault;
   event.stopPropagation = fixEvent.stopPropagation;
   return event;
};
fixEvent.preventDefault = function() {
   this.returnValue = false;
};
fixEvent.stopPropagation = function() {
   this.cancelBubble = true;
};




   /*

addEvent(window, 'DOMContentLoaded', myFunction);
addEvent(window, 'DOMContentLoaded', function() {
   showEvents("addEvent | DOMContentLoaded | anonymous function: Hello");
});
addEvent(window, 'load', function() {
   showEvents("addEvent | load | anonymous function: The whole page is loaded.");
   showEvents(
      window.execScript ? "Browser is IE own DOMContentLoaded support"
      : /Safari/.test(navigator.userAgent) ? "Browser is Safari with own DOMContentLoaded support"
      : document.clientWidth|| window.opera&&!window.getSelection ? "Browser is KDE or Opera<9 own DOMContentLoaded support"
      : document.addEventListener ? "DOMContentLoaded is full supported"
      : "other Browser, DOMContentLoaded is full supported"
   );
});
 */







addEvent(window, 'DOMContentLoaded', calc_heights);
//addEvent(window, 'load', show_content);



