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

// Custom JavaScript Document

$(window).load(function(){
        // Initialize portfolio isotope 
        var $container          = $('.filter-feed');
        var $filter             = $('.filter-nav a');
        var selector = '*';
        isotopeFilter(selector, $container);
        
        $filter.click(function() { 
            selector = $(this).attr('data-filter'); 
            $filter.removeClass('active');
            $(this).addClass('active');
            isotopeFilter(selector, $container);
            return false;
        }); 
        
        $(window).resize(function(){  
            isotopeFilter(selector, $container);
        });
        
        function isotopeFilter(selector, $container) {
            $container.isotope({
                filter              : selector, 
                animationOptions    : {
                    duration            : 450,
                    easing              : 'linear',
                    queue              : false
                }
            });			
        }
});

$(document).ready(function(){  
  $('head').append('<link rel="shortcut icon" type="image/x-icon" href="http://cdn.myld.com.au/2/467/michael-duncan-constructions-pty-ltd_f0c67b40f7.ico">');
  $('#logo').html('<a href="/"><img src="http://cdn.myld.com.au/2/466/michael-duncan-constructions-pty-ltd_0c2850c936.png" /></a>').appendTo('.logo-here');
  $('.navbar').appendTo('.nav-here');
  $('#header').prependTo('body').after($('#feature'));
  $('body').children('div, header, footer').wrapAll('<div id="wrapper" class="container-fluid">');
  
  //********Windows IE8 and below popup*********//   		     		
	$("body").browserDetect( {     	
		name: "Michael Duncan Constructions Pty Ltd",     
		logo: "http://cdn.myld.com.au/2/470/michael-duncan-constructions-pty-ltd_eaa2085bf9.png",      
		phone: "0402 980 897",     //optional
		fax: "07 5578 8793",      //optional
		email: "enquiries@mdcbuilding.com.au",      //optional
		address: "Based in Robina, we service the Gold Coast and surrounding regions.",  //optional	
		ldprofile: "http://www.localdirectories.com.au/Gold-Coast-South,QLD/Michael-Duncan-Constructions-Pty-Ltd/profile/stGc"  
	});  

	//********Mobile Telephone*********//  
	mobileTel(402980897); //edit phone number
  
  // Gallery
    if ($('body#featured-work').is('*')) {
        if(jQuery.browser.mobile)
            {
               var myPhotoSwipe = $(".fancybox").photoSwipe({ enableMouseWheel: false , enableKeyboard: false });
            }
            else
            {
                $("a.fancybox").fancybox();
                $("a.fancybox[rel='gallery_group']").fancybox({
                    'transitionIn'    :    'elastic',
                    'transitionOut'    :    'elastic',
                    'speedIn'        :    600, 
                    'speedOut'        :    200 
                });
            }
    }
	


//header
$("#header").backstretch([
  "http://cdn.myld.com.au/2/466/michael-duncan-constructions-pty-ltd_cb80d29684.jpg",
  ], 
  {duration: 3000, fade: 750});
  
//feature
$("#feature").backstretch([
  "http://cdn.myld.com.au/2/466/michael-duncan-constructions-pty-ltd_d16c3e0a80.jpg",
  "http://cdn.myld.com.au/2/466/michael-duncan-constructions-pty-ltd_080759d6cd.jpg",
  "http://cdn.myld.com.au/2/466/michael-duncan-constructions-pty-ltd_12664946ad.jpg",
  "http://cdn.myld.com.au/2/466/michael-duncan-constructions-pty-ltd_b08fb4f58a.jpg",
  "http://cdn.myld.com.au/2/466/michael-duncan-constructions-pty-ltd_72e5e29c92.jpg",
  ], 
  {duration: 3000, fade: 750});

//footer
$("#footer").backstretch([
  "http://cdn.myld.com.au/2/466/web_michael-duncan-constructions-pty-ltd_45b773f119.jpg",
  ], 
  {duration: 3000, fade: 750});
  
  if($('body#home').is('*')) {
	if(!(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) ) {
		  //Animate 'fade in'
		  $('.animate-fadein .overlay').animate({ opacity:0}, 0);
		  $('.animate-fadein').hover(function() {
			  $(this).find('.overlay').stop(true, false).animate({ opacity:1 }, 600);
		  }, function() {
			  $(this).find('.overlay').stop(true, false).animate({ opacity:0 });
		  });	
		}  
  }
  
  
  if($('body#contact-us').is('*')) {
    $('#feature .backstretch').remove();
    $('#map-canvas').appendTo('#featureInner');
  	//GOOGLE MAP WITH SIMPLE MARKER
            function contactMap() {
              var mapOptions = {
                zoom:  12,
                center: new google.maps.LatLng(-28.07962, 153.38813),
                mapTypeId: google.maps.MapTypeId.ROADMAP
              }
              var map = new google.maps.Map(document.getElementById('map-canvas'),
                                            mapOptions);
            
              var image = 'http://cdn.myld.com.au/2/466/michael-duncan-constructions-pty-ltd_b8efc5cd23.png';
              var myLatLng = new google.maps.LatLng(-28.07962, 153.38813);
              var marker = new google.maps.Marker({
                  position: myLatLng,
                  map: map,
                  icon: image
              });
            }
            
            google.maps.event.addDomListener(window, 'load', contactMap);
			
			 //form validation
			 $(document).ready(function(){ 
				$('#custom_form').formValidation({ 
					validateText: ["name", "message", "number"],
					validateEmail: ["email"],
					validateSpam: true
				});
			});  
  }
  });