$(function(){

// carousel slide for brand logos
			$('#slides_two').slides({
				preload: true,
				play: 4000,
				pause: 2500,
				hoverPause: true,
				generatePagination: false,
				hoverPause: true
			});			
			
// carousel slide for gallery images
			$('#slides_three').slides({
				preload: true,
				preloadImage: 'images/loading.gif',
				effect: 'fade',
				fadeEasing: "easeOutBounce",
				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);
				}
			});

			
// carousel slide for main home images
			$('#slides').slides({
				preload: true,
				play: 3000,
				pause: 6000,
				effect: 'fade',
				crossfade: true,
				fadeSpeed: 3250,
				fadeEasing: "easeOutQuad",
				hoverPause: true
			});

//==================== BRANDS DESCRIPTION - TIPSY TOOLTIP ===========================//

$(".brandDescrip").tipTip({
				maxWidth: "200px", 
				fadeIn:800,
				fadeOut: 1000,
				edgeOffset: 10
			});

//==================== BRANDS DESCRIPTION - TIPSY TOOLTIP ===========================//

$(".installGal").tipTip({
				maxWidth: "200px", 
				fadeIn:800,
				fadeOut: 1000,
				edgeOffset: 10
			});


//==================== TOGGLE CONTAINER - INSTALLATIONS  ===========================//
$(".toggle_container").hide(); 

			//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
			$("div.trigger").click(function(){
				$(this).toggleClass("active").next().slideToggle("slow");
				return false; //Prevent the browser jump to the link anchor
			});


//========================= CONTACT FORM SUBMIT  =================================//

	$('#submitcontact').click(function () {		
		
		//Get the data from all the fields
		var name = $('input[name=name]');
		var email = $('input[name=email]');
		var phone = $('input[name=phone]');
		var comment = $('textarea[name=comment]');

		//Simple validation to make sure user entered something
		//If error found, add hightlight class to the text field
		if (name.val()=='') {
			name.addClass('hightlight');
			return false;
		} else name.removeClass('hightlight');
		
		if (email.val()=='') {
			email.addClass('hightlight');
			return false;
		} else email.removeClass('hightlight');
		
		if (comment.val()=='') {
			comment.addClass('hightlight');
			return false;
		} else comment.removeClass('hightlight');
		
		//organize the data properly
		var data = 'name=' + name.val() + '&email=' + email.val() + '&phone=' + 
		phone.val() + '&comment='  + encodeURIComponent(comment.val());
		
		//disabled all the text fields
		$('.text').attr('disabled','true');
		
		//show the loading sign
		$('.loading').show();
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "includes/process.php",	
			
			//GET method is used
			type: "GET",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {				
				//if process.php returned 1/true (send mail success)
				if (html==1) {					
					//hide the form
					$('.contactform').fadeOut('slow');					
					
					//show the success message
					$('.done').fadeIn('slow');
					
				//if process.php returned 0/false (send mail failed)
				} else alert('Sorry, unexpected error. Please try again later.');				
			}		
		});
		
		//cancel the submit button default behaviours
		return false;
	});	


//=================================================================================//
});


//============================== GOOGLE MAPS =====================================//


function initialiseLENC() {
    var latlng = new google.maps.LatLng(-28.808136, 153.277433);
    var myOptions = {
        zoom: 15,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map"), myOptions);
    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        title: "Living Entertainment North Coast"
    });
}




