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

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/133/tuncorn-pty-ltd_96642b729b.ico');
	
	menu.contactDetails({
		
		phone: '0740312788', //optional, can have multiple values[array] 
		mobile: null, //optional, can have multiple values[array]
		email: 'admin@mchuoptom.com.au', //optional, can have multiple values[array] 
		address: '1st Floor Suite 6/361 Sheridan Street, North Cairns, QLD 4870', //optional, single value
		hours: [['Mon-Fri','8:30am-5:30pm']] //optional
		
	});
    
     // View section_1
    $('#view_section_1').insertBefore('.footer');

    // View error div
    $('#error').insertBefore('.footer');    
    
    //nav justify
    $('.navbar .nav').addClass('nav-justified');
    $('.navbar .nav a').addClass('ease');
    
    // Javascript to enable link to tab
    var url = document.location.toString();
    if (url.match('#')) {
        $('#page-content .nav a[href=#'+url.split('#')[1]+']').tab('show') ;
    }

    // Change hash for page-reload
    $('#page-content .nav a').on('shown.bs.tab', function (e) {
        window.location.hash = e.target.hash;
    })    
    
    if(window.location.hash) {
        $('html, body').animate({scrollTop: $('.tab-content').offset().top }, 'slow');
    }    
    
    $('#slider').flexslider({
        animation: "slide",
        controlNav: false,
        prevText: "",
        nextText: ""
    });
    
    $('.match').matchHeight();
    
    $('.faq-list').goFaq ();
    
    $('.module, .service, .brand').hover(function() {
        $('.module, .service, .brand').addClass('opac');
        $(this).removeClass('opac');
    }, function() {
        $('.module, .service, .brand').removeClass('opac');
    });    
    
    // fancybox
    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("*") ) {
    
        //map
        function map() {
          var myLatlng = new google.maps.LatLng(-16.90416, 145.75769);
          var mapOptions = {
            scrollwheel: false,
            zoom: 13,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
              styles: [
              {
                    "featureType": "landscape",
                    "stylers": [
                      { "saturation": -100 }
                    ]
                  },{
                    "featureType": "poi",
                    "stylers": [
                      { "saturation": -100 }
                    ]
                  },{
                    "featureType": "road",
                    "stylers": [
                      { "saturation": -100 }
                    ]
                  },{
                    "featureType": "transit",
                    "stylers": [
                      { "saturation": -100 }
                    ]
                  },{
                    "featureType": "administrative",
                    "stylers": [
                      { "saturation": -100 }
                    ]
                  },{
                    "featureType": "water",
                    "stylers": [
                      { "hue": "#28b3aa" }
                    ]
                  }
                ]
              
          }

          if ($('#map').length > 0) {
              var map = new google.maps.Map(document.getElementById('map'), mapOptions);

              var marker = new google.maps.Marker({
                  position: myLatlng,
                  map: map 
              });

              google.maps.event.addDomListener(window, 'resize', function() {
                    map.setCenter(myLatlng);
              });         
              google.maps.event.addDomListener(window, 'orientationchange', function() {
                    map.setCenter(myLatlng);
              });   
            }
        }
        $(window).load(function(){
            map();
        });
        
        // Contact Form
        $('#contact_form').smartCaptcha({
            validateText: ["name","message"],
            validateEmail: ["email"],
            redirectLink: null,
            validateStyle: "default"
        });   
        
        $('#map').insertAfter('#header');
        $('#slider').remove();
        
    }
    
    
    
    
     
}); 
