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

//Javascripts
$(document).ready(function() {
  $.favicon('http://cdn.myld.com.au/2/1026/port-macquarie-metal-recyclers_2a6dd7d570.png');

  menu.contactDetails({

    phone: '0402 231 968', //optional, can have multiple values[array]
    mobile: null, //optional, can have multiple values[array]
    email: 'jimwardrope@bigpond.com', //optional, can have multiple values[array]
    address: '11 Merrigal Road Port Macquarie, NSW 2444', //optional, single value
    hours: [['Mon to Fri', '8am to 4pm'], ['Weekends', 'By Appointment']] //optional

  });

  //VIEW SECTION 1
  $('#view_section_1').insertBefore('.footer');

  //VIEW ERROR DIV
  $('#error').insertBefore('.footer');

  //PAGE TITLE
  $('#page-title').insertAfter('#slider');

  // Home
  if ($('body#home').is('*')) {
    $('#module1').mouseenter(function() {
      $('.grey-wrap a').removeClass('active');
      $('#tab1').addClass('active');
    });

    $('#module2').mouseenter(function() {
      $('.grey-wrap a').removeClass('active');
      $('#tab2').addClass('active');
    });

    $('#module3').mouseenter(function() {
      $('.grey-wrap a').removeClass('active');
      $('#tab3').addClass('active');
    });

    $('.module').mouseleave(function() {
      $('.grey-wrap a').removeClass('active');
    });
  }// End Home

  // Buy & Sell Scrap Metal
  if ($('body#buy-sell-scrap-metal').is('*')) {
    var hash = window.location.hash;
    console.log(hash);
    switch (hash) {
      case '#storage':
        console.log('case successful');
        $('#tabber a[href="#storage"]').tab('show');
        break;
      default:
        break;
    }
  }// End Buy & Sell Scrap Metal

  // Contact Us
  if ($('body#contact-us').is('*')) {

    // Contact Form
    $('#contact_form').smartCaptcha({
      validateText: ['name', 'message'],
      validateEmail: ['email'],
      redirectLink: null,
      validateStyle: 'default'
    });

    // Remove Slider
    $('#slider').remove();

    // Insert Map
    $('#map').insertBefore('#page-title');

    // Remove FOoter
    $('#footer-top').remove();

    // Map
    function contactmap() {
          var myLatlng = new google.maps.LatLng(-31.45306, 152.88194);
          var image = 'http://cdn.myld.com.au/2/1026/port-macquarie-metal-recyclers_251f3e8c1d.png';
          var mapOptions = {
            scrollwheel: false,
            zoom: 13,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
          }

          if ($('#contact-map').length > 0) {
            var map = new google.maps.Map(document.getElementById('contact-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() {
      contactmap();
    });

  } // End Contact Us

});
