
/**
 * On Page Load
 */
 
$(document).ready(function()
{
	// jQZoom
	$('.jqzoom').jqzoom(
	{
		showEffect: "fadein",
		hideEffect: "fadeout",
		title: false,
	    zoomWidth: 225,
	    zoomHeight: 280,
        xOffset: 10,
        yOffset: 0,
        position: "right"
    });

    // Handle Menu Hover
	$("#nav li.show-nav").each(function(i, element)
	{
	    $(element).bind('mouseenter', function(e) { $(e.currentTarget).addClass('active'); });
	    $(element).bind('mouseleave', function(e) { $(e.currentTarget).removeClass('active'); });
	});
	
	// Handle Video Lightbox
    $(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'light_square',slideshow:2000, autoplay_slideshow: true});
    $(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast',slideshow:10000});
			
    $("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({
        custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
        changepicturecallback: function(){ initialize(); }
    });

    $("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({
        custom_markup: '<div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
        changepicturecallback: function(){ _bsap.exec(); }
    });
	
	// Slideshow :: Home Banner
    $("#home-banner .slideshow").cycle(
    { 
        prev: '#home-banner .previous', 
        next: '#home-banner .next', 
        timeout: 10000
    });
	
	// Slideshow :: New
    $("#whats-new .slideshow").cycle(
    { 
        prev: '#whats-new .previous', 
        next: '#whats-new .next', 
        timeout: 0 
    });
	
	// Slideshow :: Featured
    $("#featured .slideshow").cycle(
    { 
        prev: '#featured .previous', 
        next: '#featured .next', 
        timeout: 0 
    });
	
	// Slideshow :: Twitter
    $("#twitter .slideshow").cycle(
    { 
        prev: '#twitter .previous', 
        next: '#twitter .next', 
        timeout: 10000
    });
	
	// Carousel :: Default
    $("#carousel .carousel").jCarouselLite(
	{
        btnNext: "#carousel .next",
        btnPrev: "#carousel .previous",
		speed: 600,
		auto: 10000,
		easing: "easeinout"

    });
});

/**
 * Utility Functions
 */

function MM_openBrWindow(theURL,winName,features)
{ //v2.0
   var myTop  = (screen.availHeight - 300) / 2;
   var myLeft = (screen.availWidth - 300) / 2;
   
   window.open(theURL,winName,features + ',top=' + myTop + ',left=' + myLeft);
}

jQuery.preloadImages = function()
{
  for(var i = 0; i < arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

function moveOnMax(field,nextFieldID){
  if(field.value.length >= field.maxLength){
    document.getElementById(nextFieldID).focus();
  }
}

