//Side Accordian for index

    jQuery().ready(function(){
        // simple accordion
        jQuery('#PayPal').hide();
        jQuery('#Events').accordion({
            autoheight: true,
            fillSpace: true }
            );
    });
    
    jQuery().ready(function(){    
        var loader = jQuery('<div id="loader"><img src="images/loading.gif" alt="loading..." /></div>').css({position: "relative", top: "1em", left: "25em"}).appendTo("body").hide();
        jQuery().ajaxStart(function() {
            loader.show();
        }).ajaxStop(function() {
            loader.hide();
            jQuery('#PayPal').show();
            jQuery('#email_form').hide();
        }).ajaxError(function(a, b, e) {
            loader.hide();
            throw e;
        });
    
    /*username: {
                required: true,
                minlength: 2
            },
            password: {
                required: true,
                minlength: 5
            },
            confirm_password: {
                required: true,
                minlength: 5,
                equalTo: "#password"
            },
            */
            
            
            /*topic: {
                required: "#newsletter:checked",
                minlength: 2
            },
            agree: "required"*/
    // validate signup form on keyup and submit
    var v = jQuery("#signupForm").validate({
        
        rules: {
            firstname: "required",
            lastname: "required",
            
            email: {
                required: true,
                email: true 
            },
            emailVer: {
                required: true,
                email:true,
                equalTo: "#email"
            },
            address: {
                required: true
            },
            zip: {
                required: true
            },
            city: {
                required: true
            },
            dob: {
                required: true,
                date: true
            },
            
            homePhone: {
                required: "#workPhone:blank" || "#cellPhone:blank" 
                //phoneUS: true
            } 

               
        },
        messages: {
            firstname: "Please enter your firstname",
            lastname: "Please enter your lastname",
            /*username: {
                required: "Please enter a username",
                minlength: "Your username must consist of at least 2 characters"
            },
            password: {
                required: "Please provide a password",
                minlength: "Your password must be at least 5 characters long"
            },*/
            confirm_password: {
                required: "Please provide a password",
                minlength: "Your password must be at least 5 characters long",
                equalTo: "Please enter the same password as above"
            },
            email: "Please enter a valid email address",
            emailVer: {
                required: "Please provide a email again for verification",
                equalTo: "Email addresses must match"
            },
            homePhone: {
                required: "At least one phone number is required"
                //phoneUS: "Must be a valid phone number"
            },
            dob: {
                required: "please provide your date of bith",
                date: "must be a date"
            }
            
        },
        submitHandler: function(form) { jQuery(form).ajaxSubmit({ target: "#result" }); }
        
    });
});

jQuery().ready(function(){    
    var v = jQuery("#take_action").validate({
        rules: {
            action_email: {
                required: true,
                email: true 
            }     
        },
        messages: {
            action_email: "Please enter a valid email address"
        },
        submitHandler: function(form) { jQuery(form).ajaxSubmit({ target: "#action_result" }); }
        
    });
});

    
    
//Photo Gallery
    /*$(document).ready(function(){
        $('.gallery_demo_unstyled').addClass('gallery_demo'); // adds new class name to maintain degradability
        
        $('ul.gallery_demo').galleria({
            history   : true, // activates the history object for bookmarking, back-button etc.
            clickNext : true, // helper for making the image clickable
            insert    : '#main_image', // the containing selector for our main image
            onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
                
                // fade in the image & caption
                image.css('display','none').fadeIn(1000);
                caption.css('display','none').fadeIn(1000);
                
                // fetch the thumbnail container
                var _li = thumb.parents('li');
                
                // fade out inactive thumbnail
                _li.siblings().children('img.selected').fadeTo(500,0.3);
                
                // fade in active thumbnail
                thumb.fadeTo('fast',1).addClass('selected');
                
                // add a title for the clickable image
                image.attr('title','Next image >>');
            },
            onThumb : function(thumb) { // thumbnail effects goes here
                
                // fetch the thumbnail container
                var _li = thumb.parents('li');
                
                // if thumbnail is active, fade all the way.
                var _fadeTo = _li.is('.active') ? '1' : '0.3';
                
                // fade in the thumbnail when finnished loading
                thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
                
                // hover effects
                thumb.hover(
                    function() { thumb.fadeTo('fast',1); },
                    function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
                )
            }
        });
    });*/
    


//var Locs = new Array();    
//Locs[1] = 'South Coast Plaza, Costa Mesa, CA';              
function ShowLoc(Loc){
    window.location.hash = 'loc'; 
    document.documentElement.scrollTop; 
    initialize(Loc);
};
                               

/*    function initialize() {
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      //zoom: 8,
      //center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  }*/

  var map;
var directionsPanel;
var directions;

var StartAddress = "Santa Ana, CA";
var HoldEndAddress = "South Coast Plaza, Costa Mesa, Ca";

function initialize(EndAddress) {
  
  map = new GMap2(document.getElementById("map_canvas"));
  //map.setCenter(new GLatLng(42.351505,-71.094455), 15);
  directionsPanel = document.getElementById("route");
  directions = new GDirections(map, directionsPanel);
  if (EndAddress) { HoldEndAddress= EndAddress; }
  directions.load("from: " +  StartAddress + " to: " + HoldEndAddress);
  map.setUIToDefault();     
  

}

function ReUp() {
    StartAddress = document.getElementById("StartAddy").value;
    initialize();
}

$.validator.setDefaults({
    submitHandler: function() { alert("submitted!"); }
});

 jQuery().ready(function() {  
     $("span.description","p.action_item").hide();
     $("p.action_item").mouseover(function () {
        $("span.description",this).show();
    });
    $("p.action_item").mouseout(function () {
        $("span.description",this).hide();
    });
    
    $('#action_all').click(function() {
        $(".action_check").each( function(){
            this.checked = true;
        })
    })
    
    $('#action_none').click(function() {
        $(".action_check").each( function(){
            this.checked = false;
        })
    })
});




