
rotate_counter = 0;
rotate_max = $('#rotator_nav a').size();
rotate_pause = false;

jQuery.jQueryRandom = 0;
jQuery.extend(jQuery.expr[":"], {
    random: function(a, i, m, r) {
      if (i == 0) {
        jQuery.jQueryRandom = Math.floor(Math.random() * r.length);
      };
      return i == jQuery.jQueryRandom;
    }
});

$(document).ready(function() {
    loadMenu();

    if (rotate_max > 0)
        setInterval('rotateOne()', 18000);

    if($('#slideshow').length > 0) {
        $('#slideshow').after('<div id="nav">').cycle({
            fx : 'scrollLeft',
            timeout : 5000,
            speed : 850,
            speed : 'slow',
            pager : '#nav',
            width : 620, 
            height : 350,
            fit : true,
            pagerAnchorBuilder : function(idx, slide) {
                    return '<a href="#"></a>'
                }
            });
    }

    if($('#slideshow-main').length > 0) {
        $('#slideshow-main').after('<div id="navmain">').cycle({
            fx : 'uncover',
            timeout : 4000,
            speed : 750,
            pager : '#navmain',
            pagerAnchorBuilder : function(idx, slide) {
                    return '<a href="#"></a>'
                }
            });
    }
});

function loadMenu() {
    $("#menu li a").wrapInner( '<span class="out"></span>' ).append( '<span class="bg"></span>' );

    $("#menu li a").each(function() {
        $( '<span class="over">' +  $(this).attr('title') + '</span>' ).appendTo( this );
    });
     
    $("#menu li a").hover(function() {
        $(".out",   this).stop().animate({'top':    '45px'},    250); // move down - hide
        $(".over",  this).stop().animate({'top':    '0px'},     250); // move down - show
        $(".bg",    this).stop().animate({'top':    '0px'},     130); // move down - show
     
    }, function() {
        $(".out",   this).stop().animate({'top':    '0px'},     250); // move up - show
        $(".over",  this).stop().animate({'top':    '-110px'},   250); // move up - hide
        $(".bg",    this).stop().animate({'top':    '-110px'},   130); // move up - hide
    });
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

