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

//Javascripts
$('#view_section_1').insertAfter('#mobileCTA');

 
$('.navbar-nav li:nth-child(3)').addClass('dropdown');
$('.navbar-nav li:nth-child(4)').addClass('dropdown');
$('.navbar-nav li:nth-child(5)').addClass('dropdown');
$('.navbar-nav li:nth-child(6)').addClass('dropdown');
$('.navbar-nav li:nth-child(8)').addClass('dropdown');
 $('.navbar-nav li:nth-child(3)').append('<ul class="dropdown-menu"><li><a class="sub-a" href="jewellery#kalis-pearls-tab">Kalis Pearls</a></li><li><a class="sub-a" href="jewellery#mariana-tab">Mariana</a></li><li><a id="wr" class="sub-a" href="jewellery#dora-tab">Wedding Rings</a></li><li><a class="sub-a" href="jewellery#south-sea-pearls-tab">South Sea Pearls</a></li><li><a class="sub-a" href="jewellery#gold-tab">Gold</a></li><li><a class="sub-a" href="jewellery#silver-tab">Silver</a></li><li><a class="sub-a" href="jewellery#diamonds-tab">Diamonds</a></li><li><a class="sub-a" href="jewellery#precious-stones-gems-tab">Precious Stones/Gems</a></li></ul>'); 
 $('.navbar-nav li:nth-child(4)').append('<ul class="dropdown-menu"><li><a class="sub-a" href="manufacturing#handmade-jewellery-tab">Handmade</a></li><li><a class="sub-a" href="manufacturing#computer-graphic-jewellery-design-tab">Computer Graphic</a></li><li><a class="sub-a" href="manufacturing#gem-sourcing-tab">Gem Sourcing</a></li></ul>'); 
 $('.navbar-nav li:nth-child(5)').append('<ul class="dropdown-menu"><li><a class="sub-a" href="jewellery-repairs-restoration#jewellery-repairs-tab">Repairs</a></li><li><a class="sub-a" href="jewellery-repairs-restoration#jewellery-restoration-tab">Restoration</a></li><li><a class="sub-a" href="jewellery-repairs-restoration#ring-resizing-tab">Resizing</a></li><li><a class="sub-a" href="jewellery-repairs-restoration#jewellery-clean-polishing-tab">Clean & Polish</a></li></ul>');
 $('.navbar-nav li:nth-child(6)').append('<ul  class="dropdown-menu"><li><a class="sub-a" href="jewellery-information#diamonds-tab">Diamonds</a></li><li><a class="sub-a" href="jewellery-information#pearls-tab">Pearls</a></li><li><a class="sub-a" href="jewellery-information#gold-tab">Gold</a></li><li><a class="sub-a" href="jewellery-information#silver-tab">Silver</a></li><li><a class="sub-a" href="jewellery-information#precious-stones-gems-tab">Precious Stones/Gems</a></li></ul>'); 
 $('.navbar-nav li:nth-child(8)').append('<ul class="dropdown-menu"><li><a class="sub-a" href="gallery#previous-work-tab">Previous Work</a></li><li><a class="sub-a" href="gallery#larger-projects-tab">Larger Projects</a></li><li><a class="sub-a" href="gallery#events-tab">Events</a></li><li><a class="sub-a" href="gallery#store-tab">Store</a></li></ul>');
 
 
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/1215/creative-jewellers_b387c86b09.png'); 
  
 menu.contactDetails({
    phone: "0889411233", //optional, can have multiple values[array]
    mobile: null, //optional, can have multiple values[array]
    email: "sales@creativejewellers.com", //optional, can have multiple values[array]
		address: "Shop 1/32 Star Village, Smith Street Mall, Darwin, NT 0800", //optional, single value
		hours: [ 
            [ 'Mon-Fri', '9:30am - 5:00pm'],
            [ 'Sat-Sun', '9:30am - 2:30pm']
          ] 
});

menu.reset();

$('.flexslider').flexslider({
    animation: "fade",
    controlNav: false,
    directionNav: false,
    animationLoop: true
});
 

$('#myTabs a').click(function (e) {
  e.preventDefault()
  $(this).tab('show')
});

$(window).bind("load resize scroll",function(){
	//isotope
	var $container = $('.isotopeMain').isotope({
		"itemSelector": ".item",
		masonry: {
			columnWidth: ".item"
		}
	});
	
	var $container = $('.isotope').isotope({
		"itemSelector": ".item",
		masonry: {
			columnWidth: ".item"
		}
	});
	
	var $container = $('.isotope2').isotope({
		"itemSelector": ".item",
		masonry: {
			columnWidth: ".item"
		}
	});
	
	var $container = $('.isotope3').isotope({
		"itemSelector": ".item",
		masonry: {
			columnWidth: ".item"
		}
	});
	
		$('.filters').on( 'click', 'a', function() {
			$('.filters li').removeClass('active');
			$(this).parent('li').addClass('active');
			var filterValue = $(this).attr('data-filter');
			$('.isotope').isotope({ filter: filterValue });
		});
	
		$('.filters2').on( 'click', 'a', function() {
			$('.filters2 li').removeClass('active');
			$(this).parent('li').addClass('active');
			var filterValue = $(this).attr('data-filter');
			$('.isotope2').isotope({ filter: filterValue });
		});
	
		$('.filters3').on( 'click', 'a', function() {
			$('.filters3 li').removeClass('active');
			$(this).parent('li').addClass('active');
			var filterValue = $(this).attr('data-filter');
			$('.isotope3').isotope({ filter: filterValue });
		});
});

$(document).ready(function () {
	$('.tree-toggler').click(function () {
		$('.tree').toggle(300);
		return false;
	});

	$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
		$('.isotopeMain').resize();
		/*$('.isotope').resize();
		$('.isotope2').resize();
		$('.isotope3').resize();*/
		$('.isotope').isotope({ filter: '.classic-collection' });
		$('.filters li').removeClass('active');
		$('.filters li:eq(0)').addClass('active');
		$('.isotope2').isotope({ filter: '.blends-two-tone' });
		$('.filters2 li').removeClass('active');
		$('.filters2 li:eq(0)').addClass('active');
		$('.isotope3').isotope({ filter: '.classic' });
		$('.filters3 li').removeClass('active');
		$('.filters3 li:eq(0)').addClass('active');
	});
	
	$('a#wr').click(function () {
		$('.tree').toggle(300);
	});
});


var target = window.location.hash;
if(target)
        {  
          newid=target+"-btn";
          $(newid)[0].click();
          
          $('html, body').animate({
           scrollTop: $('#tab-content').offset().top
           }, 2000);
        }  
     


});
function map() {
  var myLatlng = new google.maps.LatLng(-12.46426, 130.84284);
  var image = 'http://cdn.myld.com.au/2/1219/creative-jewellers_244806772c.png';
  var mapOptions = {
    zoom: 17,
    scaleControl: false,
    scrollwheel: false,
    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();
});


$('#custom_form').smartCaptcha({ 
    validateText: ["name","phone","message"],
    validateEmail: ["email"],
    redirectLink: null,
    validateStyle: "default"
}); 


 
$('.sub-a').click(function(e) {
       
       var insidetarget = this.hash;
       
       var newid=insidetarget+'-btn';
         $(newid)[0].click();
         $('html, body').animate({
           scrollTop: $('#tab-content').offset().top
           }, 2000);
          
});   

 
// Fancy Box

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 
    });

/* Apply with thumbnails visible */
    $("a.fancybox").fancybox({
		helpers : {
			thumbs : {
				width: 200,
				height: 200
			}
		}
    });
}