
//JQUERY ACCORDIAN
function initMenus() {
	$('ul.menu ul').hide();
	$.each($('ul.menu'), function(){
		$('#' + this.id + '.expandfirst ul:first').show();
	});
	$('ul.menu li a').click(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			if($('#' + parent).hasClass('noaccordion')) {
				$(this).next().slideToggle('normal');
				return false;
			}
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
}

//TURN AUTOCOMPLETE OFF FOR FORM
function autoSubmitOff() {
	if (!document.getElementById) return false;
	var f = document.getElementById('contact_form');
	var u = f.elements[1];
	f.setAttribute("autocomplete", "off");
	//u.focus();
}

//INLINE LABELS
$(function(){ 
	$("#contact_form label").inFieldLabels(); 
	$("input").attr("autocomplete","off");
});


$(document).ready(function() {
	
	//INTERNAL PAGE SIDEBAR THUMB ACCORDIAN
	//initMenus();

	//TURN AUTOCOMPLETE OFF FOR FORM
	autoSubmitOff();


	// HOMEPAGE LATEST WORK
	$('#slides').slides({
		preload: true,
		preloadImage: 'site-includes/images/slider/loading.gif',
		play: 5000,
		pause: 2500,
		hoverPause: true,
		animationStart: function(current){
			$('.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){
			$('.caption').animate({
				bottom:0
			},200);
			if (window.console && console.log) {
				// example return of current slide number
				console.log('animationComplete on slide: ', current);
			};
		},
		slidesLoaded: function() {
			$('.caption').animate({
				bottom:0
			},200);
		}
	});

});


// GOOGLE MAPS
function initialize() {    

	// INITIALIZE THE MAP
	var myOptions = {
    	zoom: 15,
    	center: new google.maps.LatLng(53.78268, -0.41396),
    	mapTypeId: google.maps.MapTypeId.ROADMAP
    };
	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);    

	// ADD INITIAL MARKER
	//var image = 'beachflag.png';
	var myLatLng = new google.maps.LatLng(53.78268, -0.41396);
	var beachMarker = new google.maps.Marker({
		position: myLatLng,
		animation: google.maps.Animation.DROP,
		map: map
		//icon: image
	});	
}
