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

//Javascripts
$(document).ready(function(){
    $.favicon('http://cdn.myld.com.au/2/1439/web_darwin-iga-xpress_b688dd6ad5.png');

    menu.contactDetails({

        phone: '0889819206', //optional, can have multiple values[array]
        email: 'admin@igadarwin.com.au', //optional, can have multiple values[array]
        address: '132 Smith Street Darwin NT 0800', //optional, single value
        hours: [['Mon - Wed','6:30am-8:30pm'],['Thu - Fri','6:30am-9:00pm'],['Sat','7:00am-9:00pm'],['Sun','8:00am-7:00pm'],['Holidays','8:00am 7:00pm']] //optional

    }); 
    
    $('h1, h2, h3, h4, h5 , h6').attr('itemprop','name');
    $('p').attr('itemprop','description');
    $('.container').attr('itemtype','http://schema.org/LocalBusiness');
    $('.container-fluid').attr('itemtype','http://schema.org/LocalBusiness');
    $('img').attr('itemprop','image');

    //Contact Page
    if ( $("body#contact").is("*") ) {
      
    }
    
    //VIEW SECTION 1
    $('#view_section_1').insertAfter('#header');
    //$('#view_section_1').append('#content-container');

    //VIEW ERROR DIV
    $('#error').insertAfter('#view_section_1');
    //$('#error').append('#content-container');

    // Make sure this.hash has a value before overriding default behavior
    if (window.location.hash.slice(1) !== "") {
      // Prevent default anchor click behavior
      event.preventDefault();
  
      // Store hash
      var hash = '#'+window.location.hash.slice(1);
      
      $('.products-title li a[href*='+hash+']').trigger("click");

      $('html, body').animate({ scrollTop: $('a[href*='+hash+']').offset().top}, 800, function(){window.location.hash = hash;});
    }  // End if

    $(".icon-google img").hover(function(){
        $(this).attr('src','http://cdn.myld.com.au/2/1439/web_darwin-iga-xpress_dfb633912b.png');
        }, function(){
        $(this).attr('src','http://cdn.myld.com.au/2/1439/darwin-iga-xpress_71a02a9608.png');
    });

    $(".icon-fb img").hover(function(){
        $(this).attr('src','http://cdn.myld.com.au/2/1439/web_darwin-iga-xpress_bff5e55a72.png');
        }, function(){
        $(this).attr('src','http://cdn.myld.com.au/2/1439/web_darwin-iga-xpress_b915baf1d2.png');
    });

    $(".icon-lshead img").hover(function(){
        $(this).attr('src','http://cdn.myld.com.au/2/1439/web_darwin-iga-xpress_17289f7599.png');
        }, function(){
        $(this).attr('src','http://cdn.myld.com.au/2/1439/web_darwin-iga-xpress_e15050406e.png');
    });

    // Contact Form
    $('#contact_form').smartCaptcha({ 
        validateText: ["name"],
        validateEmail: ["email"],
        validateChar: [{ id: "message", max: null }],
        validateRange: [{ id: "phone", limit: [3,13] }],
        validateStyle: "default",
        validateSpam: true
    });


    //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='group']").fancybox({
            'transitionIn'    :    'elastic',
            'transitionOut'    :    'elastic',
            'speedIn'        :    600, 
            'speedOut'        :    200 
        });
    }
});


$(window).load(function() {
  $("body").addClass("loaded");
});


$(window).load(function(){
  googlemap();
});


function googlemap() {
  var myLatlng = new google.maps.LatLng(-12.45649, 130.83567);
  var image = 'http://cdn.myld.com.au/2/1882/darwin-iga-xpress_07e21361f5.png';
  var mapOptions = {
    zoom: 17,
    center: myLatlng,
    scrollwheel: false,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  
  if ($('#google-map').length > 0) {
      var map = new google.maps.Map(document.getElementById('google-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);
	  });   
	}
}
