﻿
/* Get Querystring Values */
function getParameterByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return null;
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

/* Carousel Functions */
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
 
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
 
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


function goToByScroll(id) {
    $('html,body').animate({ scrollTop: $(id).offset().top }, 'slow');
}


// Required for our slidey panels
var demoEnterState = function(state) {
    //$(this).append("Entered " + state + "<br />");

    if (state == 'Maximized')
        $(this).addClass("selected");
};

var demoLeaveState = function(state) {
    // $(this).append("Leaving " + state + "<br />");

    if (state == 'Maximized')
        $(this).removeClass("selected");
};

var demoClearPanels = function() {
    //  $("#demo2 li").empty();
    $(this).removeClass("selected");
};


// Fading images
// when the DOM is ready:
$(document).ready(function() {
    // find the div.fade elements and hook the hover event
    $('ul.slidingPanels li').hover(function() {
        // on hovering over, find the element we want to fade *up*
        var fade = $('> div', $(this).find('div.fade'));

        // if the element is currently being animated (to a fadeOut)...
        if (fade.is(':animated')) {
            // ...take it's current opacity back up to 1
            fade.stop().fadeTo(250, 1);
        } else {
            // fade in quickly
            fade.fadeIn(250);
        }
    }, function() {
        // on hovering out, fade the element out
    var fade = $('> div', $(this).find('div.fade'));
        if (fade.is(':animated')) {
            fade.stop().fadeTo(3000, 0);
        } else {
            // fade away slowly
            fade.fadeOut(3000);
        }
    });
});
