function regError(msg)
{
  alert(msg);
}

function loadPage(page) {
  var oRPC = new jsRPC();
  oRPC.href = page + ((page.indexOf('?') != -1)?'&':'?') + 'html_load=1';
  oRPC.execute();
}

$.fn.pause = function(duration) {
  $(this).animate({ dummy: 1 }, duration);
  return this;
};
     
$(window).load(function () {
});
      
$(document).ready(function() {

});

var rotateCounter = 0;

function rotateHPImages(c)
{
  if (typeof(c) == 'undefined') c = (++rotateCounter);
  if (c != rotateCounter) return;
  rotateCounter++;

  var img = $('#hp-slider img:first');
  if (img.length > 0)
  {
    if (img.is(':visible'))
    {
      $('#hp-slider img:first').next().fadeIn(1000);
      $('#hp-slider img:first').fadeOut(1000, function() { 
        $(this).insertAfter($('#hp-slider img:last'));
      });
    }
    else
      img.fadeIn(1000);
    var s = '' + (c + 1);
    $('#hp-slider-timer').stop(true, true)
                         .animate({ width: '0' }, 200)
                         .animate({ width: '750px' }, 5000, function () {
      setTimeout('rotateHPImages(' + s + ')', 0);
    }); 
  }
} 

var rotateGalleryPointers = null; 
var rotateGalleryPointer = 0;
var rotateGalleryTimeout = 0;

function rotateGalleryImages(init)
{
  if (init)
  {
    rotateGalleryPointers = $('#gallery-links a');
    rotateGalleryPointer = 0;
    rotateGalleryTimeout = Math.random();
  }
  else
    rotateGalleryPointer = (rotateGalleryPointer + 1) % rotateGalleryPointers.length;
  
  $(rotateGalleryPointers[rotateGalleryPointer]).click();

  var s = '' + rotateGalleryTimeout;
  $('#hp-slider-timer').stop(true, true)
                       .animate({ width: '0' }, 200)
                       .animate({ width: '550px' }, 5000, function () {
    if (s == '' + rotateGalleryTimeout)
      setTimeout('rotateGalleryImages()', 0);
  }); 
}
