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

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/1626/anderson-waste-services-pty-ltd_2e2518b20b.png');
  
	menu.contactDetails({
		
		phone: '0248694260', //optional, can have multiple values[array] 
		mobile: null, //optional, can have multiple values[array]
		email: 'mick@andersonwasteservices.com.au', //optional, can have multiple values[array] 
		address: '12-14 Old Dairy Close Moss Vale NSW 2577', //optional, single value
		hours: [['Mon to Fri','7:00am-3:30pm']] //optional
		
	});
    
    
    // View section_1
    $('#view_section_1').insertBefore('.footer');

    // View error div
    $('#error').insertBefore('.footer');
    
    // SLIDER
    $("#slider").backstretch([
      "http://cdn.myld.com.au/2/1626/anderson-waste-services-pty-ltd_4bed9c3524.jpg",
      "http://cdn.myld.com.au/2/1626/anderson-waste-services-pty-ltd_f2b5258714.jpg"    
    ], {duration: 3000, fade: 750, random: true});    
    
    
    $(window).bind("load resize",function(){
        var s_width = $('.service').width();
            
        $('.service').css({ "height": s_width }); 
        //$('.spacer').css({ "height": s_height }) 
    });    
    
  //Gallery
var elem = document.querySelector('.grid');
var iso = new Isotope( elem, {
  // options
  itemSelector: '.grid-item',
  layoutMode: 'fitRows'
});

// element argument can be a selector string
//   for an individual element
var iso = new Isotope( '.grid', {
  // options
});
    
    // 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
        });

    }  
    


    
    
    // CONTACT
    if ( $("body#contact").is("*") ) {

        // Contact Form
        $('#contact_form').smartCaptcha({
            validateText: ["name","phone","message"],
            validateEmail: ["email"],
            redirectLink: null,
            validateStyle: "default"
        });

        // Remove Slider
        $('#slider').remove();

        // Insert Map
        function map() {
          var myLatlng = new google.maps.LatLng(-34.53820, 150.35491);
          var image = 'http://cdn.myld.com.au/2/1626/anderson-waste-services-pty-ltd_096ab7ba45.png';
          var mapOptions = {
            scrollwheel: false,
            zoom: 13,
            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();
        });        
        
        
        
    } else {
        // Contact Form
        $('#contact_form').smartCaptcha({
            validateText: ["name","phone","message"],
            validateEmail: ["email"],
            redirectLink: null,
            validateStyle: "default"
        });
        
    }
    
    
     
}); 
