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

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/1497/coffs-carports_cc336622a4.png');
	
	menu.contactDetails({
		
		phone: '0266534116', //optional, can have multiple values[array] 
		mobile: '0417239837', //optional, can have multiple values[array]
		email: 'admin@coffscarports.com.au', //optional, can have multiple values[array] 
		address: null, //optional, single value
		hours: [['Mon to Fri','7:00am-5:00pm'],['Saturday','8:00am-12:00pm']] //optional
		
	});
  
     // View section_1
    $('#view_section_1').insertBefore('.footer');

    // View error div
    $('#error').insertBefore('.footer');  
    
    // home      
    if ( $("body#home").is("*") ) {
        $(window).bind("load resize",function(){
            var width = $(window).width();
            if (width < 992) {
                $('#header .brand-wrap .overlay').insertBefore('#intro-wrap');
            } else {
                $('#page-content .overlay').insertAfter('#slider');
            }
        });    
      
    }
    
    // Or, to start a slideshow, just pass in an array of images
    /*$("#slider").backstretch([
      "http://cdn.myld.com.au/2/1497/coffs-carports_061be2ccda.jpg",
      "http://cdn.myld.com.au/2/1497/coffs-carports_d76145c827.jpg",
      "http://cdn.myld.com.au/2/1497/coffs-carports_92dd8f4298.jpg",
      "http://cdn.myld.com.au/2/1497/coffs-carports_0e4bd6e0e8.jpg"    
    ], {duration: 3000, fade: 750, random: true});   */
    $("#slider").backstretch([
      "http://cdn.myld.com.au/2/1536/web_coffs-carports_236145e5b0.JPG",
      "http://cdn.myld.com.au/2/1536/web_coffs-carports_d7a936e88c.jpg",
      "http://cdn.myld.com.au/2/1536/web_coffs-carports_d873ae55b9.JPG",
      "http://cdn.myld.com.au/2/1536/web_coffs-carports_0942dd0a9d.jpg",
      "http://cdn.myld.com.au/2/1536/web_coffs-carports_16956e0cb3.jpg"    
    ], {duration: 3000, fade: 750, random: true});   
    
    
    // gallery
    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
        });

    } 
    
    
    
    // map
    if ( $("body#contact").is("*") ) {

        // Contact Form
        $('#contact_form').smartCaptcha({
            validateText: ["name","phone","message"],
            validateEmail: ["email"],
            redirectLink: null,
            validateStyle: "default"
        });

        // Remove Slider
        $('#slider').remove();
        
        
        $(window).bind("load resize",function(){
            var width = $(window).width();
            if (width > 991) {
                $('#fimg').insertAfter('#header .brand');
            } else {
                $('#fimg').insertBefore('#intro-wrap');
            }
        });
        
        function map() {
          var myLatlng = new google.maps.LatLng(-29.53085, 153.33176);
          var image = 'http://cdn.myld.com.au/2/1497/coffs-carports_42ef08a60e.png';
          var mapOptions = {
            scrollwheel: false,
            zoom: 11,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
          }

          if ($('#map').length > 0) {
              var map = new google.maps.Map(document.getElementById('map'), mapOptions);

              var marker = new google.maps.Marker({
                  position: myLatlng,
                  map: map,
                  icon: image
              });

              google.maps.event.addDomListener(window, 'resize', function() {
                    map.setCenter(myLatlng);
              });         
              google.maps.event.addDomListener(window, 'orientationchange', function() {
                    map.setCenter(myLatlng);
              });   
            }
        }

        $(window).load(function(){
            map();
        });        
    }    

    
    
}); 
