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

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/1487/c-l-joinery_9583e45f18.png');
	
	menu.contactDetails({
		
		phone: '0249587244', //optional, can have multiple values[array] 
		mobile: null, //optional, can have multiple values[array]
		email: 'info@candljoinery.com.au', //optional, can have multiple values[array] 
		address: '1 Pitt Street, Teralba, NSW 2284', //optional, single value
		hours: [['Mon - Fri','8:00am-4:30pm'],['Sat & Sun','Closed']] //optional
		
	});
  
     // View section_1
    $('#view_section_1').insertBefore('.footer');

    // View error div
    $('#error').insertBefore('.footer');  
    
    //nav justify
    $('.navbar .nav').addClass('nav-justified');
    
    $('.match').matchHeight();
    
    $('#scroll-top').click(function(){
        $("html, body").animate({ scrollTop: 0 }, 1000);
    });
    
    // 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","enquiry"],
            validateEmail: ["email"],
            redirectLink: null,
            validateStyle: "default"
        });

        // Remove Slider
        $('#slider').remove();

        // Insert Map
        function map() {
          var myLatlng = new google.maps.LatLng(-32.96624, 151.60253);
          var image = 'http://cdn.myld.com.au/2/1487/c-l-joinery_19013e8bb0.png';
          var mapOptions = {
            scrollwheel: false,
            zoom: 16,
            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();
        });        
        
    }    
    
     
}); 
