/***********************
*  Site Specific JS   *
************************/

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/1117/dubbo-city-smash-mechanical_a4cceece9b.png');
	
	menu.contactDetails({
		
		phone: '0268853530', //optional, can have multiple values[array] 
		mobile: null, //optional, can have multiple values[array]
		email: 'dubbocitysmash@bigpond.com', //optional, can have multiple values[array] 
		address: '38 Mountbatten Drive, Dubbo NSW 2830', //optional, single value
		hours: [['Mon-Thur','8:30am-5:00pm'],['Friday','8:30am-4:00pm']] //optional
		
	});
  
     // View section_1
    $('#view_section_1').insertBefore('.footer');

    // View error div
    $('#error').insertBefore('.footer');  
  
    
    // slider
    $("#slider").backstretch([
      "http://cdn.myld.com.au/2/1114/dubbo-city-smash-mechanical_11cd47a185.jpg",
      "http://cdn.myld.com.au/2/1114/dubbo-city-smash-mechanical_e941d37dda.jpg",
      "http://cdn.myld.com.au/2/1114/dubbo-city-smash-mechanical_60a75d7c2f.jpg",
      "http://cdn.myld.com.au/2/1114/dubbo-city-smash-mechanical_1be760bdaf.jpg"    
    ], {duration: 3000, fade: 750, random: true});
    
    // match
    $('.match').matchHeight();
    
    
    function jqUpdateSize(){
        // Get the dimensions of the viewport
        var width = $(window).width();
        
        if (width > 991) {
            $(window).scroll(function() {
                var height = $(window).scrollTop();

                if(height  > 200) {
                    $('#logo-wrap .brand').css('height','200px')
                }
                if(height  < 200) {
                    $('#logo-wrap .brand').css('height','310')
                }
            });
        } else {
            $('#service1 .overlay').insertAfter('#service1');
            $('#service2 .overlay').insertAfter('#service2');
            $('#service3 .overlay').insertAfter('#service3');
            $('#service4 .overlay').insertAfter('#service4');
        }

    };
    $(document).ready(jqUpdateSize);    // When the page first loads
    $(window).resize(jqUpdateSize);     // When the browser changes size    
    
    
    // map
            google.maps.event.addDomListener(window, 'load', init);
        
            function init() {
                // Basic options for a simple Google Map
                // For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions
                var image = 'http://cdn.myld.com.au/2/1117/dubbo-city-smash-mechanical_26c80c62b1.png';
                var mapOptions = {
                    // How zoomed in you want the map to start at (always required)
                    scrollwheel: false,
                    zoom: 13,
                    //center: myLatlng,
                    mapTypeId: google.maps.MapTypeId.ROADMAP,

                    // The latitude and longitude to center the map (always required)
                    center: new google.maps.LatLng(-32.24954, 148.63733), // New York

                    // How you would like to style the map. 
                    // This is where you would paste any style found on Snazzy Maps.
                    styles:[{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","stylers":[{"saturation":-100},{"lightness":51},{"visibility":"simplified"}]},{"featureType":"road.highway","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"saturation":-100},{"lightness":30},{"visibility":"on"}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":-25},{"saturation":-100}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]}]
                };

                // Get the HTML DOM element that will contain your map 
                // We are using a div with id="map" seen below in the <body>
                var mapElement = document.getElementById('map');

                // Create the Google Map using our element and options defined above
                var map = new google.maps.Map(mapElement, mapOptions);

                // Let's also add a marker while we're at it
                var marker = new google.maps.Marker({
                    position: new google.maps.LatLng(-32.24954, 148.63733),
                    map: map,
                    icon: image
                });
            } 
    
    
    //gallery
    if ( $("body#gallery").is("*") ) {
        if(Modernizr.touch && $(".fancybox").length > 0 )
        {
           var myPhotoSwipe = $(".fancybox").photoSwipe({ enableMouseWheel: false , enableKeyboard: false });
        }
        else
        {
        /* Apply to single image */
            $("a.fancybox").fancybox();

        /* Apply fancybox to multiple items */
            $("a.fancybox[rel='gallery_group']").fancybox({
                'transitionIn'    :    'elastic',
                'transitionOut'    :    'elastic',
                'speedIn'        :    600,
                'speedOut'        :    200
            });

        /* Apply with thumbnails visible */
            $("a.fancybox").fancybox({
                  helpers : {
                       thumbs : {
                            width: 200,
                            height: 200
                       }
                  }
            });
        }  
    } // end gallery
    
    
    // careers
    if ( $("body#careers").is("*") ) {
        $('#career_form').smartCaptcha({
            validateText: ["name","contact_number","cover_letter"],
            redirectLink: null,
            validateStyle: "default"
        });
    } // end careers    
    
    
    // contact us
    if ( $("body#contact-us").is("*") ) {

        // Contact Form
        $('#contact_form').smartCaptcha({
            validateText: ["name","message"],
            validateEmail: ["email"],
            redirectLink: null,
            validateStyle: "default"
        });

        // Insert Map
        $('#map').insertAfter('#slider');
    
        // Remove Slider
        $('#slider').remove();
        
    } // end contact us    
    

    // 404
    /*if ( $("body#page-not-found").is("*") ) {
        $('<div style="margin-bottom:130px"></div>')insertBefore('#error');
    } // 404
  */
    
     
}); 


