/*Object.prototype.hasClass = function(className) {
   var pattern = new RegExp('(^|\\s)' + className + '(\\s|$)'); //use this regexp
   return pattern.test(this.className); //to check for the class
}

Object.prototype.addClass = function(className) {
   if (!this.hasClass(className)) { //if the class isn't there already
      this.className += (' ' + className); //append it to the end of the class list
   }
}

Object.prototype.removeClass = function(className) {
   var pattern = new RegExp('(^|\\s)' + className + '(\\s|$)'); //use this regexp
   this.className = this.className.replace(pattern, ' '); //to make a search and replace by a blank space
}

Function.bundle = function(context, f, args) {
  if(typeof f == "string" && context)
    f = context[f];
  if(arguments.length < 3)
    args = [];
  else if(!(args instanceof Array))
    args = Array.prototype.slice.call(arguments, 2);
  return function() {
    return f.apply(context, args);
  };
};

function openSubMenu(o) {
  if(!o.hasClass('open')) {
    o.addClass('open');
    ol = o.down('ol');
    Effect.BlindDown(ol, {duration: '0.25', queue:'end', afterFinish:function(){
    }});
  }
}

function closeSubMenu(o) {
  if(o.hasClass('open')) {
    o.removeClass('open');
    ol = o.down('ol');
    Effect.BlindUp(ol, {duration: '0.25', queue:'end', afterFinish:function(){
      }});
  }
}

function hideSubMenus() {
  $$('#root .hasChilds').each(function(o) {
    o.down('ol').hide();
  });
}

document.observe("dom:loaded", function() {
  $$('#root .hasChilds').invoke('observe', 'mouseover', function(event) {
    e = event.toElement || event.relatedTarget;
    / *if (e.parentElement == this || e.up('li') == this) {
       return;
    }* /
    //setTimeout(Function.bundle(this, "openSubMenu", -1), 500);
    openSubMenu(this);
  });
  $$('#root .hasChilds').invoke('observe', 'mouseout', function(event) {
    e = event.toElement || event.relatedTarget;
    oTemp = e;
    for(i=0;i<5;i++) {
      if(oTemp == this) {
        return;
      }
      if(oTemp.up('li') != undefined) {
        oTemp = oTemp.up('li');
      }
    }
    / *if (e.up('li') == this || e == this) {
      return;
    }* /
    closeSubMenu(this);
  });
});
*/

function openNewsBlock(iContentId, sOpener, sClose) {
  var newsBlock = $('hContent_'+iContentId);
  var descBlock = $('sDescription_'+iContentId);
  var currentStatus = newsBlock.getStyle('display');

  if (currentStatus == 'none') {
  	$('openerBtn_'+iContentId).innerHTML = '&raquo;'+sClose;
  	newsBlock.setStyle({display: "block"});
  	descBlock.setStyle({display: "none"});
  } else {
    $('openerBtn_'+iContentId).innerHTML = '&raquo;'+sOpener;
    newsBlock.setStyle({display: "none"});
  	descBlock.setStyle({display: "block"});
  }
}

function openDesc(id) {
  oDesc = $('memberContainer_'+id).down('.desc');
  if(oDesc.getStyle('display') == 'none') {
    oDesc.show();
    /*$('opener_'+id).hide();
    $('closer_'+id).show();*/
  } else {
    oDesc.hide();
    /*$('opener_'+id).show();
    $('closer_'+id).hide();*/
  }
}


/*function openResCategory(iCatId) {
  var ProductsBlock = $('catContainer_'+iCatId);
  var currentStatus = ProductsBlock.getStyle('display');
  var ProdContainer = $$('div.productContainer');
  var iProdCount    = ProdContainer.length;
  var i             = 0;
  for (i;i<iProdCount;i++) {
    ProdContainer[i].hide();
  }
  if (currentStatus == 'none') {
    ProductsBlock.setStyle({display: "block"});
  } else {
    ProductsBlock.setStyle({display: "none"});
  }
}

function openNewsBlock(iContentId, sOpener, sClose) {
  var newsBlock = $('hContent_'+iContentId);
  var descBlock = $('sDescription_'+iContentId);
  var currentStatus = newsBlock.getStyle('display');

  if (currentStatus == 'none') {
    $('openerBtn_'+iContentId).innerHTML = '&raquo;'+sClose;
    newsBlock.setStyle({display: "block"});
    descBlock.setStyle({display: "none"});
  } else {
    $('openerBtn_'+iContentId).innerHTML = '&raquo;'+sOpener;
    newsBlock.setStyle({display: "none"});
    descBlock.setStyle({display: "block"});
  }
}

function hideProdContainer() {
  $('resourceDetailFrame').hide();
}

function movingFooter() {
    var contentHeight   = $('contentFrame').getHeight();
    var leftHeight      = $('leftFrame').getHeight();
    var topHeight       = $('topFrame').getHeight();
    var totalHeight     = contentHeight+topHeight;
    var totalLeftHeight = leftHeight+topHeight;
    var footerTop       = $('footerRow').getStyle('top');

    var windowSize      = document.viewport.getHeight();
    var frameHeight     = $('frameContainer').getHeight();

    if(totalHeight > windowSize) {
      $('footerRow').setStyle({ position: 'static'}).addClassName('clearingItem');
    } else {
      var content = windowSize - topHeight - 40;
      $('contentFrame').setStyle({height: content+"px"});
    }

    //alert(totalHeight+" "+frameHeight+" "+contentHeight);
    /* if (footerTop != null) {
      var footerTopValue = footerTop.split('px');
    }
    else {
      var footerTopValue = 0;
    }

    if ((totalHeight > footerTopValue[0]) || (totalLeftHeight > footerTopValue[0])) {
       //var marginBottom = totalHeight-footerTopValue[0];

       $('footerRow').setStyle({ position: 'static'}).addClassName('clearingItem');
    }* /
    //Event.observe(window, 'resize', movingFooter);
}
function init() {
var aMenus     = $$('#leftFrame > ul ul');
var iMenuCount = aMenus.length;
var oUpperLi   = null;

//	alert(iMenuCount);

  for (i = 0; i < iMenuCount; i++) {
  var oActiveMenu = aMenus[i];
  if (((oUpperLi = oActiveMenu.up('li')).hasClassName('active')) || (oActiveMenu.down('.active'))) {
    oActiveMenu.show();

    if (oUpperLi) {
      oUpperLi.addClassName('active');
    }
  } else {
    oActiveMenu.hide();
  }

  oUpperLi = null;
  }
}
function invisibleMenu () {
 var menuField = $('')
}*/
