// Accordion
jQuery(function(){
        jQuery("#accordion").accordion({
            header: "h3",
            event: "mouseover",
            active: '.selected',
            selectedClass: 'active'
        });
        //hover states on the static widgets
        jQuery('#dialog_link, ul#icons li').hover(
                function() { jQuery(this).addClass('ui-state-hover'); },
                function() { jQuery(this).removeClass('ui-state-hover'); }
        );
});

//Slides
jQuery(function(){
        jQuery('#slides').slides({
                generatePagination: false,
                preload: true,
                preloadImage: '../img/loading.gif',
                play: 5000,
                pause: 2500,
                hoverPause: true,
                pagination: false,
                animationStart: function(current){
                        jQuery('.caption').animate({
                                bottom:-35
                        },100);
                        if (window.console && console.log) {
                                // example return of current slide number
                                console.log('animationStart on slide: ', current);
                        };
                },
                animationComplete: function(current){
                        jQuery('.caption').animate({
                                bottom:0
                        },200);
                        if (window.console && console.log) {
                                // example return of current slide number
                                console.log('animationComplete on slide: ', current);
                        };
                },
                slidesLoaded: function() {
                        jQuery('.caption').animate({
                                bottom:0
                        },200);
                }
        });
});
// Contact Form
jQuery(document).ready(function(){

	$('#contactform').submit(function(){

		var action = $(this).attr('action');

		$("#message").slideUp(750,function() {
		$('#message').hide();

 		$('#submit')
			.after('<img src="../img/ajax-loader.gif" class="loader" />')
			.attr('disabled','disabled');

		$.post(action, {
			name: $('#name').val(),
			email: $('#email').val(),
			phone: $('#phone').val(),
			subject: $('#subject').val(),
			comments: $('#comments').val(),
			verify: $('#verify').val()
		},
			function(data){
				document.getElementById('message').innerHTML = data;
				$('#message').slideDown('slow');
				$('#contactform img.loader').fadeOut('slow',function(){$(this).remove()});
				$('#contactform #submit').attr('disabled','');
				if(data.match('success') != null) $('#contactform').slideUp('slow');

			}
		);

		});

		return false;

	});

});


