
// Called from ActionScript
function showMenu(id)
{
	onMouseOverHandler(null, id)
}



// Menu as Array
var navArray = [
				{'p' : 'visit', 'c' : 'visitsubnav'}, 
				{'p': 'play', 'c' : 'playsubnav'}, 
				{'p' : 'learn', 'c' : 'learnsubnav'},
				{'p' : 'grow', 'c' : 'growsubnav'}
				]
	


	
	
function onMouseOverHandler(evt, id)
{
	var id = id || $(evt.currentTarget).attr('id');
	
	//var id = $(evt.currentTarget).attr('id');
	var i;
	for (i = 0; i < navArray.length; i++)
	{
		$('#' + navArray[i].c).css('z-index', 4000).hide();
	}
	
	// show the current
	$('#' + id + 'subnav').css('z-index', 4100).show();
	
};
	
	
	
function onMouseOutHandler(evt)
{
	// Hide all
	var i;
	for (i = 0; i < navArray.length; i++)
	{
		$('#' + navArray[i].c).hide().css('z-index', 4000);	
	}
	
}




$(document).ready(function($) { 
	
	
 	
    // open a link in a new window, this is valid target="_blank" is not.
    $('a.blank').click(function(){ 
        window.open(this.href);
        return false;
    });
    
	
	
	$('a[rel*=facebox]').facebox({
        loadingImage : '/images/facebox/loading.gif',
        closeImage   : '/images/facebox/closelabel.gif'
      });
	
	
	
	
	$('#visit, #play, #learn, #grow').bind('mouseenter', onMouseOverHandler, false, 0, true);
	$('#flashsubnav').bind('mouseleave', onMouseOutHandler);
	/*
	$.facebox(function () 
	{
		$('#usermessage').show();
		$.facebox({div: '#usermessage' });
	}); 
	*/
	
	// jquery flash plugin
	/*
    $('#navigation').flash({    
        swf: '/swfs/navigation.swf', 
		height: 176,
		width: 578,
        wmode: 'transparent',   
        flashvars: {   name1: 'jQuery'   }   
    });
	*/
	// Swfobject
	
	
	// Footer Swf
	var flashvar = { };
	var params = { wmode : 'transparent'};
	var attributes = {};
	swfobject.embedSWF('/swfs/flash-footer.swf', 'flashfooter', '787', '196', '9.0.0', '/expressInstall.swf', flashvar, params, attributes );
	
	// Newsletter
	var flashvarnewsletter = { };
	var paramsnewsletter = { wmode : 'transparent'};
	var attributesnewsletter = {};
	swfobject.embedSWF('/swfs/newsletter.swf', 'newsletter', '250', '267', '9.0.0', '/expressInstall.swf', flashvarnewsletter, paramsnewsletter, attributesnewsletter );
	
	// Purple Flower
	var flashvarpurple = { };
	var paramspurple = { wmode : 'transparent'};
	var attributespurple = {};
	swfobject.embedSWF('/swfs/flower.swf', 'flowers', '142', '180', '9.0.0', '/expressInstall.swf', flashvarpurple, paramspurple, attributespurple );
	
	// Garlic Ride
	var flashvargarlic = {};
	var paramsgarlic = { wmode : 'transparent'};
	var attributesgarlic = {};
	swfobject.embedSWF('/swfs/garlic-ride.swf', 'spaceship', '200', '185', '9.0.0', '/expressInstall.swf', flashvargarlic, paramsgarlic, attributesgarlic );
	
	
	
	
	/* Event Calendar */
	 $('.evtDay').live({ 
         mouseenter:
             function(evt){
        	 $($(evt.currentTarget).contents('div')[2]).css('display', 'block');
        	 //alert('enter');
             },
         mouseleave:
             function(evt){
        	 $($(evt.currentTarget).contents('div')[2]).css('display', 'none');
        	 //alert('leave');
             }
     });
	
	
	/* -- FAQs -- */
	$('.answer').hide();
	$('.question').bind('click', function (evt) {
		evt.preventDefault();
		$(this).next().toggle(300);
	});
	
	/*
	// this is for the flowplayer overlay
	$("body").append("<div class='overlay' id='overlay'><div class='contentWrap'></div></div>");
	var exposeConfig = {color: '#000',loadSpeed: 200,	opacity: 0.8 };
	
	$("a[rel*=#overlay]").overlay({ 
	   expose: exposeConfig, 	
        onBeforeLoad: function() { 
            var wrap = this.getContent().find(".contentWrap"); 
            wrap.load(this.getTrigger().attr("href")); 
        } 
    }); 
	*/
	
	
	function formatText(index, panel) {
			return "";
	};
	
	 $('.anythingSlider').anythingSlider({
		easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
		autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
		delay: 6000,                    // How long between slide transitions in AutoPlay mode
		startStopped: false,            // If autoPlay is on, this can force it to start stopped
		animationTime: 900,             // How long the slide transition takes
		hashTags: true,                 // Should links change the hashtag in the URL?
		buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
		startText: "Go",                // Start text
		stopText: "Stop",               // Stop text
		navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
	});
	
	
	var labels = $("label.replace");
    labels.inFieldLabels({fadeOpacity: 0.2, fadeDuration: 200});
    labels.bind('select, click',function(){ $(this).next('input').focus(); });
	
	
	// newsletter dropdown
	//$('#newsletter-dd').hide();

	$('.newsletter').click(function() {
		$('#newsletter-dd').slideToggle('fast', function() {
	  });
	});
	
	/*
    //nav - on hover over
    function megaHoverOver() {
        $(this).find(".sub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
        (function ($) {
            //Function to calculate total width of all ul's
            jQuery.fn.calcSubWidth = function () {
                rowWidth = 0;
                //Calculate row
                $(this).find("ul").each(function () { //for each ul...
                    rowWidth += $(this).width(); //Add each ul's width together
                });
            };
        })(jQuery);

        if ($(this).find(".row").length > 0) { //If row exists...

            var biggestRow = 0;

            $(this).find(".row").each(function () {	//for each row...
                $(this).calcSubWidth(); //Call function to calculate width of all ul's
                //Find biggest row
                if (rowWidth > biggestRow) {
                    biggestRow = rowWidth;
                }
            });

            $(this).find(".sub").css({ 'width': biggestRow }); //Set width
            $(this).find(".row:last").css({ 'margin': '0' });  //Kill last row's margin

        } else { //If row does not exist...

            $(this).calcSubWidth();  //Call function to calculate width of all ul's
            $(this).find(".sub").css({ 'width': rowWidth }); //Set Width

        }
    }
    //nav - on hover out
    function megaHoverOut() {
        $(this).find(".sub").stop().fadeTo('fast', 0, function () { //Fade to 0 opactiy
            $(this).hide();  //after fading, hide it
        });
    }


    // for dropdowns - set custom configurations
    var config = {
        sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
        interval: 100, // number = milliseconds for onMouseOver polling interval
        over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
        timeout: 500, // number = milliseconds delay before onMouseOut
        out: megaHoverOut // function = onMouseOut callback (REQUIRED)
    };

    $("ul#mainNav li .sub").css({ 'opacity': '0' }); //Fade sub nav to 0 opacity on default
    $("ul#mainNav li").hoverIntent(config); //Trigger Hover intent with custom configurations
	
	// for ligthbox with grouping support
    //$('a[rel*=lightbox]').lightbox(); // Select all links that contains lightbox in the attribute rel
	*/
}); 
//END (DOCUMENT).READY

//find all form with class transform and apply the plugin
//$(function() {
  //  $("form.transform").jqTransform();
//});












