originalConfirmFunction = window.confirm;
window.confirm = function (str){
  var res = originalConfirmFunction(str);
  if (navigator.appVersion.indexOf("MSIE") != -1)
   if (window.event)
    window.event.returnValue = res; // IE
  return res;
}
var loaded = 0;
function init(){
  if (!loaded){
    prepareLoader('content');
    var reg = new RegExp("^content", "i");
    if (reg.test(ajaxfixer.history.getCurrent())){
      clearPromos();
    }
    LoadContainer();
    loaded = 1;
  }
}

addEvent(window, "load", init);

function get_iframes(className){
    var tags = document.getElementsByTagName('iframe');
    var i;
    var iframes = new Array();
    for(i=0;i<tags.length;i++) {
        var name = String(tags[i].getAttribute('class'));
        if('null' == name)
            name = String(tags[i].getAttribute('className'));                
        if(name==className)
            iframes[iframes.length] = tags[i];
    }
    return iframes;
}
function rotate_iframes(iframes){
    var i;
    for(i=0; i<iframes.length; i++){    
        src = String(iframes[i].src);
        if (src.match(/rnd=[\d\.]+/)){
          src = src.replace(/rnd=[\d\.]+/, 'rnd='+Math.random());
        } else {
          src = src + '&rnd='+Math.random();
        }
        iframes[i].src = src;        
    }
}
function reloadBanners(){
  var iframes = get_iframes('openx-iframe');
  rotate_iframes(iframes);
  //new Ajax.Updater( 'topBanner', '/getOpenX.php?zone=6&rnd='+Math.random(), { method: 'post', evalScripts: true } );
}

function retFalse(skipFocus){
  if (!skipFocus){
    $('focusFixer').focus();
  }
  if (navigator.appVersion.indexOf("MSIE") != -1)
   if (window.event)
    window.event.returnValue = false; // IE
	return false;
}
function switchTab(contentSource, element, checkOpen, skipFocus){

  var setContent = 1;
  var list = $('searchArea').childNodes;
  if (checkOpen){
    setContent = 0;
    for (i = 0; i < list.length; i++){
      if (list[i] && list[i].style && list[i].style.display == 'block'){
        setContent = 1;
      }
    }
  }
  if (setContent){
    for (i = 0; i < list.length; i++){
      if (list[i].style){
        list[i].style.display = 'none';
      }
    }
    $(contentSource).style.display = 'block';
  }

  var list = $('searchTabs').childNodes;
  for (i = 0; i < list.length; i++){
    list[i].className = '';
  }

  if (element){
    element.parentNode.className='selected';
  }
  window.focus();
  return retFalse(skipFocus);
}
function setTab(tab, skipFocus){
  var element = $('l' + tab);
  var contentSource = 'h' + tab;
  switchTab(contentSource, element, 1, skipFocus);
}

function getRelativeURL(href){
  var reg = new RegExp("https?://" + window.location.hostname, "i") ;
  return href.replace(reg, '');
}
function upd( container, href, skipFocus){
  if ("https:" == document.location.protocol) return true;
  new AUpdate( container, getRelativeURL(href), {}, container + 'Loader' );
  if (!skipFocus){
    window.scroll(0, 165);
  }
  closePlayer();
  reloadBanners();
  //highlightUserMenu(0);
  return retFalse(skipFocus);
}

function updNH( container, href){
  if ("https:" == document.location.protocol) return true;
  if ($(container + 'Loader')){
    $(container + 'Loader').style.visibility = 'visible';
  }
  new Ajax.Updater( container, getRelativeURL(href), { method: 'post', evalScripts: true, onSuccess: hideContentLoader } );
  closePlayer();
  window.scroll(0, 165);
  return retFalse();
}


function clearPromos(keep){
  if (keep != 'promos'){
    if ($("promos")){
      //$("promos").innerHTML = '';
      $("promos").style.display = 'none';
    }
  }
  if (keep != 'cart'){
    HideCart();
  }
  if (keep != 'mostWanted'){
    if ($("mostWantedMain"))
      $("mostWantedMain").style.display = 'none';
  }
  if (keep != 'recommendedReleases'){
    if ($("recommendedReleasesFrameCont"))
      $("recommendedReleasesFrameCont").style.display = 'none';
  }

}
function prepareLoader(container){
  var wnd = document.getElementById( container + 'Loader' );
  if (wnd){
    wnd.style.width = $(container).offsetWidth + 'px';
    wnd.style.height = $(container).offsetHeight + 'px';
  }
}

function updL( container, l){
	hideLoginMenu();
  if ("https:" == document.location.protocol) return true;
  clearPromos('cart');
  CloseWindow();
  prepareLoader(container);
  upd( container, l );
  return retFalse();
}
function updC( container, l){
	hideLoginMenu();
  if ("https:" == document.location.protocol) return true;
  clearPromos();
  CloseWindow();
  prepareLoader(container);
  upd( container, l );
  return retFalse();
}
function updP( container, l ){
	hideLoginMenu();
  if ("https:" == document.location.protocol) return true;
  clearPromos('mostWanted');
  prepareLoader(container);
  upd( container, l );
  return retFalse();
}
function updPR( container, l ){
	hideLoginMenu();
  if ("https:" == document.location.protocol) return true;
  clearPromos('promos');
  prepareLoader(container);
  upd( container, l );
  return retFalse();
}
/*
function updPRFlash( container, href ){
  clearPromos('promos')
	new AUpdate( container, getRelativeURL(href), {}, container + 'Loader' );
	window.scroll(0, 165);
}
*/

function setSearchLinks(cont, id){
  if (id){
    var list = $$('#' + cont + ' a');
    for (i = 0; i < list.length; i++){
      if (list[i].tagName == 'A'){
        if (list[i].id == id){
          list[i].className = 'active';
        } else {
          list[i].className = '';
        }
      }
    }
  }
}

function setSearchLinksClick(cont, id){
  if (id){
    var list = $(cont).childNodes;
    var item;
    for (i = 0; i < list.length; i++){
      item = false;
      if (list[i].tagName == 'A'){
        item = list[i];
      } else{
        if (list[i].childNodes.length){
          for (j = 0; j < list[i].childNodes.length; j++){
            if (list[i].childNodes[j].tagName == 'A'){
              item = list[i].childNodes[j];
            }
          }
        }
      }
      if (item){
        if (item.id == id){
          item.className = 'active';
        } else {
          item.className = '';
        }
      }
    }
  }
}

function updActive( container, l, skipFocus){
  if ("https:" == document.location.protocol) return true;
  if (l.parentNode.className == 'alphaTab'){
    setSearchLinksClick(l.parentNode, l.id);
  } else {
    setSearchLinksClick(l.parentNode.parentNode, l.id);
  }
  upd( container, l.href, skipFocus);
  if (!skipFocus){
    window.scroll(0, 165);
  }
  return retFalse(skipFocus);
}

function updF(container, href){
  if ("https:" == document.location.protocol) return true;
  new AUpdate(container, getRelativeURL(href), {}, container + 'Loader' );
  return retFalse(1);
}

function submitSearch(frm){
  if ("https:" == document.location.protocol) return true;
  setTab('Search');
  //$("hSearch").innerHTML = $('searchArea').innerHTML;
  var section = Form.Element.Serializers.selectOne(frm.section);
  var search = frm.search.value;
	new AUpdate( 'browse', '/search/' + section + '/' + search, {}, 'browseLoader' );
	window.scroll(0, 165);
  return retFalse();
}

/** LOGIN FUNCTIONS **/
/** LOGIN FUNCTIONS **/
function Login()
{
  new Ajax.Updater( 'loginContainer', '/login', { method: 'post', evalScripts: true, parameters: { username: $F('username'), password: $F('password') } } );
  document.getElementById( 'loginForm' ).innerHTML = '<div style="text-align: center; width:190px; margin-top: 30px; color: #666; font-weight: normal"><img src="/images/loader-black.gif" alt="" align="absmiddle" /><br /> Logging in ... </div>';
  return retFalse();
}
function Logout()
{
  new Ajax.Updater( 'loginContainer', '/logout', { method: 'get', evalScripts: true } );
  document.getElementById( 'loginBtns' ).innerHTML = '<div style="text-align: center; width:190px; padding-top: 5px; float: left;"><img src="/images/loader-gray.gif" alt="" align="absmiddle" /> Logging out ... </div>';
  hideLoginMenu();
  return retFalse();
}
function ResetLogin()
{
  new Ajax.Updater( 'loginContainer', '/login', { method: 'get', evalScripts: true } );
//  document.getElementById( 'loginForm' ).innerHTML = '<div style="loader"><img src="/images/loader_login_error.gif" alt="" align="absmiddle" /> Loading form ... </div>';
  return retFalse();
}

/** CART FUNCTIONS **/
function HideCart()
{
  var cart = document.getElementById( 'cart-data' );
  if( !cart )
    return retFalse();
  cart.style.display = "none";
  cart.style.position = "absolute";
  var b = document.getElementById( 'cartButton' );
  if( b )
    b.src = "/images/cartButton.gif";
}
function ShowCart()
{
  var cart = document.getElementById( 'cart-data' );
  if( !cart )
    return retFalse();
  cart.style.display = "block";
  cart.style.position = "relative";
  var b = document.getElementById( 'cartButton' );
  if( b )
    b.src = "/images/cartButton_on.gif";
}
function ShowHideCart()
{
  window.scroll(0, 165);
  var cart = document.getElementById( 'cart-data' );
  if( !cart )
    return retFalse();
  if( cart.style.display == 'block' )
    HideCart();
  else
    ShowCart();
  return retFalse(true);
}
function CartCheckout()
{
  var url = '/checkout/choose-method';
  if( document.user_logged )
    return OpenWindow( url, 530, 200 );
  else
    alert( 'Please login/register' );
//  document.forms['loginform'].username.focus();
  return retFalse();
}
function hideCartLoader(){
  $('cartContainerLoader').style.visibility = 'hidden';
}
function AddToCart( track, format, type )
{
  window.scroll(0, 165);
  if (format == 0) {
    alert('Please choose the subscription period!');
    return retFalse(true);
  }
  if (format == 'null') format = '';
  var el = document.getElementById( 'shoppingCrate' );
  var cart = document.getElementById( 'cart-data' );
  var cart_opened = false;
  if( cart )
    cart_opened = cart.style.display != "none";

  $('cartContainerLoader').style.visibility = 'visible';
  new Ajax.Updater( 'shoppingCrate', '/cart/add/'+type+'/' + track + '-' + format + '-' + (cart_opened ? '1' : '0'), { method: 'get', evalScripts: true, onSuccess: hideCartLoader } );
  
  return retFalse(true);
}
function AddCredit( price )
{
  var el = document.getElementById( 'shoppingCrate' );
  var cart = document.getElementById( 'cart-data' );
  var cart_opened = false;
  if( cart )
    cart_opened = cart.style.display != "none";

  $('cartContainerLoader').style.visibility = 'visible';
  new Ajax.Updater( 'shoppingCrate', '/cart/add/credit', { method: 'post', parameters: 'price='+price+'&expand='+(cart_opened?'1':'0') ,evalScripts: true, onSuccess: hideCartLoader } );
  window.scroll(0, 165);
  return retFalse();
}
function RefreshCart()
{
  var el = document.getElementById( 'shoppingCrate' );
  $('cartContainerLoader').style.visibility = 'visible';
  new Ajax.Updater( 'shoppingCrate', '/cart/show', { method: 'get', evalScripts: true, onSuccess: hideCartLoader } );
  return retFalse();
}
function DeleteFromCart( track_id, track_name )
{
  /*if ( !confirm( 'Delete ' + track_name ) )
    return false; */
  var el = document.getElementById( 'shoppingCrate' );
  var cart = document.getElementById( 'cart-data' );
  var cart_opened = false;
  if( cart )
    cart_opened = cart.style.display != "none";
  $('cartContainerLoader').style.visibility = 'visible';
  new Ajax.Updater( 'shoppingCrate', '/cart/delete/' + track_id + '-'+(cart_opened?'1':'0'), { method: 'get', evalScripts: true, onSuccess: hideCartLoader } );
  return retFalse();
}
function ClearCart()
{
  if ( !confirm( 'Are you sure you want to clear the shopping cart?' ) )
    return retFalse();
  var el = document.getElementById( 'shoppingCrate' );
  $('cartContainerLoader').style.visibility = 'visible';
  new Ajax.Updater( 'shoppingCrate', '/cart/clear', { method: 'get', evalScripts: true, onSuccess: hideCartLoader } );
  return retFalse();
}
function SetQuantity(id, quantity){
  var el = document.getElementById( 'shoppingCrate' );
  var cart = document.getElementById( 'cart-data' );
  var cart_opened = false;
  if( cart )
    cart_opened = cart.style.display != "none";
  $('cartContainerLoader').style.visibility = 'visible';
  new Ajax.Updater( 'shoppingCrate', '/cart/setQuantity/' + id + '-' + quantity + '-' + (cart_opened?'1':'0'), { method: 'get', evalScripts: true, onSuccess: hideCartLoader } );
  return retFalse();
}
function hideContentLoader(){
  $('contentLoader').style.visibility = 'hidden';
}
/** REGISTRATION FORM **/
function RegisterUser( frm )
{
  if ("https:" == document.location.protocol) return true;
  $('contentLoader').style.visibility = 'visible';
  new Ajax.Updater( 'content', '/register', { method: 'post', evalScripts: true, parameters: Form.serialize( frm, true ), onSuccess: hideContentLoader } );
  window.scroll(0, 165);
  return retFalse();
}
function ClearRegisterForm()
{
  var frm = document.forms['register-form'];
  frm.reset();
  if( document.js_checkboxs )
  {
    for( i=0; i < document.js_checkboxs.length; i++ )
    {
      el = document.getElementById( document.js_checkboxs[i] );
      el.innerHTML = '';
    }
  }
  return retFalse();
}
function UpdateProfile( frm )
{
  if ("https:" == document.location.protocol) return true;
  $('contentLoader').style.visibility = 'visible';
  new Ajax.Updater( 'content', '/profile', { method: 'post', evalScripts: true, parameters: Form.serialize( frm, true ), onSuccess: hideContentLoader } );
  window.scroll(0, 165);
  return retFalse();
}
/** WINDOW IN WINDOW (WIW) **/
function getWinHeight() {
	var winHt = 0;
	if (window.innerHeight) winHt = window.innerHeight-18;
	else if (document.documentElement && document.documentElement.clientHeight)
		winHt = document.documentElement.clientHeight;
	else if (document.body && document.body.clientHeight)
		winHt = document.body.clientHeight;
	return winHt;
}
function getWinWidth() {
	var winWt = 0;
	if (window.innerWidth) winWt = window.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth)
		winWt = document.documentElement.clientWidth;
	else if (document.body && document.body.clientWidth)
		winWt = document.body.clientWidth;
	return winWt;
}
function getScrollY() {
	var sy = 0;
	if (document.documentElement && document.documentElement.scrollTop)
		sy = document.documentElement.scrollTop;
	else if (document.body && document.body.scrollTop)
		sy = document.body.scrollTop;
	else if (window.pageYOffset)
		sy = window.pageYOffset;
	else if (window.scrollY)
		sy = window.scrollY;
	return sy;
}
function hideSelects(action) {
  //documentation for this script at http://www.shawnolson.net/a/1198/
  //possible values for action are 'hidden' and 'visible'
  if (action!='visible'){action='hidden';}
  if (navigator.appName.indexOf("MSIE")) {
    for (var S = 0; S < document.forms.length; S++){
      for (var R = 0; R < document.forms[S].length; R++) {
        if (document.forms[S].elements[R].options) {
          document.forms[S].elements[R].style.visibility = action;
        }
      }
    }
  }
  $('topBanner').style.visibility=action;
}

function OpenWindow( content_url, width, height )
{
  var wnd = document.getElementById( 'wiw' );
  var cwnd = document.getElementById( 'wiw-content' );
  if( !wnd || !cwnd )
    return retFalse();

  hideSelects();

  wnd.style.width = document.body.clientWidth + 'px';
  wnd.style.height = document.body.clientHeight + 'px';
  wnd.style.display = 'block';

  tempY = getScrollY();
  ah = getWinHeight();
  aw = getWinWidth();

  xpos = ( (aw / 2) - ( width / 2 ) );
  ypos = tempY + ( (ah / 2) - ( height / 2 ) );

  cwnd.style.top = ypos + 'px';
  cwnd.style.left = xpos  + 'px';
  cwnd.style.width = width + 'px';
  cwnd.style.height = height + 'px';
  cwnd.style.display = 'block';

  cwnd.innerHTML = '<div style="position: absolute;"><img src="/images/ajax-loader.gif" alt="" align="absmiddle" /> Loading ... </div>';

  new Ajax.Request( content_url, { method: 'get', evalScripts: true, onSuccess: WindowUpdate } );
  return retFalse();
}
function WindowUpdate( param )
{
  var cwnd = document.getElementById( 'wiw-content' );
  if( !cwnd )
    return false;
  setTimeout(function() {param.responseText.evalScripts()}, 10);
  cwnd.innerHTML = param.responseText;
  cwnd.innerHTML = '<div style="position:absolute; top:5px; right: 5px;"><a href="#" onclick="return CloseWindow();"><img src="/images/close.gif" width="21" height="19" alt="Close" /></a></div>' + cwnd.innerHTML;
//  cwnd.innerHTML += '<div class="clear ch10"></div><center><a href="#" onclick="return CloseWindow();"> close </a></center><div class="clear ch10"></div>';
}
function CloseWindow()
{
  var wnd = document.getElementById( 'wiw' );
  var cwnd = document.getElementById( 'wiw-content' );
  if( !wnd || !cwnd )
    return retFalse();

  cwnd.style.display = 'none';
  wnd.style.display = 'none';
  hideSelects('visible');
  return retFalse();
}
function MoveWindow()
{
  var wnd = document.getElementById( 'wiw' );
  var cwnd = document.getElementById( 'wiw-content' );
  if( !cwnd || !wnd )
    return false;
  if( cwnd.style.display != 'block' )
    return false;

  wnd.style.width = document.body.clientWidth + 'px';
  wnd.style.height = document.body.clientHeight + 'px';

  tempY = getScrollY();
  ah = getWinHeight();
  aw = getWinWidth();

  width = parseInt( cwnd.style.width );
  height = parseInt( cwnd.style.height );

  xpos = ( (aw / 2) - ( width / 2 ) );
  ypos = tempY + ( (ah / 2) - ( height / 2 ) );

  cwnd.style.top = ypos + 'px';
  cwnd.style.left = xpos + 'px';

  return false;
}
if (window.addEventListener)
{
  window.addEventListener("scroll", MoveWindow, "false");
  window.addEventListener("resize", MoveWindow, "false");
}
else if (window.attachEvent)
{
  window.attachEvent("onscroll", MoveWindow );
  window.attachEvent("onresize", MoveWindow );
}

function getMovieName(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
   }
   else {
       return document[movieName]
   }
}

function closePlayer(){
    if ($('previewPlayer').style.height != '0px'){
        getMovieName('Player').closePlayer();
    }
}

function playSong(albumId, song){
  var timeout = 1;
  /*
  if ($('previewPlayer').style.display != 'block'){
    $('previewPlayer').style.display = 'block';
    timeout = 1000;
  }
  */
  if ($('previewPlayer').style.height == '0px'){
    $('previewPlayer').style.height = 'auto';
    //$('previewPlayer').style.margin = '0 0 0 0';
    var timeout = 1000;
  }
  
  if(document.getElementById('promos').style.display != 'none') {
    document.getElementById('promos').style.display = 'none';
  } 

//  getMovieName("Player").pl(song.href, song.title); 
  window.setTimeout("getMovieName('Player').pl("+albumId+", '"+song.href.replace(/\'/g,'\\\'')+"', '"+song.title.replace(/\'/g,'\\\'')+"')", timeout);

  //window.setTimeout("flashProxy.call('pl', '"+song.href.replace(/\'/g,'\\\'')+"', '"+song.title.replace(/\'/g,'\\\'')+"');", timeout);
  return retFalse(true);
}

function SubmitForm( frm, dontscroll )
{
  if ("https:" == document.location.protocol) return true;
  CloseWindow();
  prepareLoader('content');
  $('contentLoader').style.visibility = 'visible';
  new Ajax.Updater( 'content', getRelativeURL(frm.action), { method: 'post', evalScripts: true, parameters: Form.serialize( frm, true ), onSuccess: hideContentLoader } );
  if (!dontscroll)
    window.scroll(0, 165);
  return retFalse();
}

function hasChecked(name){
  var chk = document.getElementsByName(name);
  for (i = 0; i < chk.length; i++){
    if (chk[i].checked) return true;
  }
  alert('Please select tracks to download first.')
  return retFalse();
}

function checkAll(name, checked){
  var chk = document.getElementsByName(name);
  for (i = 0; i < chk.length; i++){
    chk[i].checked = checked;
    if (chk[i].onclick)
      chk[i].onclick();
  }
}

var DocumentTitle = '';
function setTitle(){
  document.title = DocumentTitle;
  window.setTimeout("setTitle()", 1000);
}
var rotateInterval = 0;
function bodyLoad(){
  // just in case the ajax header is not passed by the browser
  var observerContainers = new Array('mainContainer', 'browseContainer', 'cartContainer');
  var containers = null;
  for (i = 0; i < observerContainers.length; i++){
    containers = $$('div.'+observerContainers[i]);
    if (containers && containers.length > 1){
      containers[0].innerHTML = containers[1].innerHTML;
    }
  }
  DocumentTitle = document.title;
  window.setTimeout("setTitle()", 1000);
  if (!rotateInterval)
    rotateInterval = window.setInterval("rotateTopLinks()", 1000);
}
function setPlayerHeight(h){
  $('Player').setAttribute('height', h);
}
function playlistToWishlist(){
  updC('content', '/wishlist/addFromPlayer');
}
function addToWishlist(id){
  updC('content', '/wishlist/add/'+id);
}
function playlistToCart(id){
  var el = document.getElementById( 'shoppingCrate' );
  $('cartContainerLoader').style.visibility = 'visible';
  new Ajax.Updater( 'shoppingCrate', '/cart/add/release/' + id, { method: 'get', evalScripts: true, onSuccess: hideCartLoader } );
  return retFalse();
}

function chartToCart(chartId){
  var el = document.getElementById( 'shoppingCrate' );
  $('cartContainerLoader').style.visibility = 'visible';
  new Ajax.Updater( 'shoppingCrate', '/cart/addChart/' + chartId, { method: 'get', evalScripts: true, onSuccess: hideCartLoader } );
  return retFalse();
}
function cartFlash(on){
//  $('cart-items').style.backgroundColor = on ? '#0083D7' : 'transparent';
  $('cart-items').style.color = on ? '#FFFFFF' : '#2F2C18';
}
function hideLoginMenu(){
  if(document.getElementById('loginContainer').style.left != '-9999px') {
    document.getElementById('loginContainer').style.left = '-9999px';
  }
}
function loginMenu() {
  if(document.getElementById('loginContainer').style.left != '-9999px') {
    hideLoginMenu();
  } else {
    var loginBtn = document.getElementById('loginBtn');
//    var loginBtnLeft = findPosX(loginBtn);
    document.getElementById('loginContainer').style.left = '759px';
    document.getElementById('username').focus();
  }
}

function findPosX(obj) {
  var curleft = 0;
  if(obj.offsetParent)
      while(1) 
      {
        curleft += obj.offsetLeft;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.x)
      curleft += obj.x;
  return curleft;
}
function chartTabs(clickedTabContent, tabUrl) {
		if(clickedTabContent == 'newsBox') {
			var currentTabContent = 'featuredBox';
		} else {
			var currentTabContent = 'newsBox';
      if(tabUrl != null) {
        //updF('content', tabUrl);
      }
		}	
    
    var tab = clickedTabContent + 'Tab';
    var currentTab = currentTabContent + 'Tab';
    
    var tab = document.getElementById(tab);
		var currentTab = document.getElementById(currentTab);
    
		var tabContent = document.getElementById(clickedTabContent);
		var currentTabContent = document.getElementById(currentTabContent);
					
		tab.className = 'chartTab';
		currentTab.className = 'chartTab chartTabInactive';

		if(tabContent.style.display == 'none') {
			tabContent.style.display = "block";
			currentTabContent.style.display = "none";
		}
}
var RRInterval = null;
var numRRImages = 0;
function Scroll(direction, numImages) {
  clearInterval(RRInterval);
  ScrollEx(direction, numImages)
}
function ScrollEx(direction, numImages) {
     
      var currentLeft = document.getElementById('albumsFrame').style.left;
      var pattern = /px/;
      currentLeft = currentLeft.replace(pattern, "");
      currentLeft = Number(currentLeft);
      
      
      numColumns = Math.ceil(numImages / 2);
      numHiddenColumns = numColumns - 3;
      var dur = 0.5;
      var imgSize = 137;
      var imgMargin = 10;
      var imgOffset = imgSize + imgMargin;
      var maxRightPosition = numHiddenColumns * imgOffset;
      maxRightPosition = -maxRightPosition;
      notMoving = currentLeft % imgOffset;
                
      if(notMoving == 0) {
        if(direction == 1) {
          if (currentLeft > maxRightPosition){
            var newLeft = currentLeft - imgOffset;
            new Effect.Move(document.getElementById('albumsFrame'), { x: -imgOffset, y: 0, duration: dur });
          } else {
            if(numColumns-3 > 0) {
              new Effect.Move(document.getElementById('albumsFrame'), { x: imgOffset*(numColumns-3), y: 0, duration: dur });
            }
          }
        } else if(direction == 2) {   
          if (currentLeft != 0){
            var newLeft = imgOffset + currentLeft;
            new Effect.Move(document.getElementById('albumsFrame'), { x: imgOffset, y: 0, duration: dur });
            notActive = newLeft;
          } else {
            if(numColumns-3 > 0) {
              new Effect.Move(document.getElementById('albumsFrame'), { x: -imgOffset*(numColumns-3), y: 0, duration: dur });
            }
          }
        }
      }
}
function autoscrollRR(){
  ScrollEx(1, numRRImages);
}
function autoscrollRRStart(){
  clearInterval(RRInterval);
  RRInterval = setInterval("autoscrollRR()", 4000);
}

function slideTopNews(){
  if (PlayTopNews && NubmerTopNews > 1){
    var prevCurrentTopNews = CurrentTopNews;
    CurrentTopNews++;
    if (CurrentTopNews >= NubmerTopNews) CurrentTopNews = 0;
    document.getElementById('newsItemTopBox' + CurrentTopNews).style.left = '265px';
    for (i = 0; i < NubmerTopNews; i++){
      if (i != prevCurrentTopNews && i != CurrentTopNews)
        document.getElementById('newsItemTopBox' + i).style.zIndex = 0;
    }
    document.getElementById('newsItemTopBox' + prevCurrentTopNews).style.zIndex = 5;
    document.getElementById('newsItemTopBox' + CurrentTopNews).style.zIndex = 10;
    
    new Effect.Move(document.getElementById('newsItemTopBox' + CurrentTopNews), { x: -265, y: 0, duration: 0.5 });
    setTimeout ( "slideTopNews()", 3000 );

  }
}
function highlightUserMenu(n){
    return;
  document.getElementById("userMenu1").className = 'first';
  //document.getElementById("userMenu2").className = '';
  document.getElementById("userMenu3").className = '';
  document.getElementById("userMenu4").className = 'last';
  if (n){
      if (n == 1) document.getElementById("userMenu1").className = 'first active';
      else if (n == 4) document.getElementById("userMenu4").className = 'last active';
      else document.getElementById("userMenu"+n).className = 'active';
  }
}

function rotateTopLinks ()
{
    var arrLinks = $$('#mainMenu a');
	this.counter = this.counter < (arrLinks.length-1) ? this.counter + 1 : 0;

	for (i=0;i<arrLinks.length;i++){
		if (i == this.counter){
			$(arrLinks[i]).addClassName('active');
		} else {
			$(arrLinks[i]).removeClassName('active');
		}
	}
}

function getRadioValue(radioGrp){
    if (!radioGrp.length && radioGrp.value){
        return radioGrp.value;
    }
    for(i=0; i < radioGrp.length; i++){
        if (radioGrp[i].checked == true) {
            return radioGrp[i].value;
        }
    }
    return 0;
}
