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

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/1573/boambee-home-improvements_d1ca802fba.png');
	
	menu.contactDetails({
		
		phone: null, //optional, can have multiple values[array] 
		mobile: '0412519787', //optional, can have multiple values[array]
		email: 'admin@boambeehomeimprovements.com.au', //optional, can have multiple values[array] 
		address: '12 O\'Keefe Drive Coffs Harbour, NSW 2450', //optional, single value
		hours: '7:00am-4:00pm' //optional
		
	});
    
    
    // View section_1
    $('#view_section_1').insertBefore('.footer');

    // View error div
    $('#error').insertBefore('.footer');
    
    $('.navbar .nav > li').clone().appendTo('#footer-nav');
    
    // MAP
    function map() {
      var myLatlng = new google.maps.LatLng(-30.31681, 153.09942);
      var image = 'http://cdn.myld.com.au/2/1573/boambee-home-improvements_0873f5686b.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();
    });    
    
    $(window).bind("load resize",function(){
        var elem = $('#modules-wrap .left'),
            ctaWidth = $(window).width() - (elem.offset().left + elem.width()),
            vwidth = $(window).width();
        
        if (vwidth > 767) {
            $('#tabber .tab-pane').css({ "width": ctaWidth });
        }
    });            
    
    // 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
            });

        }    
    
    }
    
    // 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
        $('#map').insertBefore('#page-content');
        
    } else {
        
    }
    
    
     
}); 
