/**
*
*
*
*/
var map, api;


$(document).ready(function(){
	$('.hidden').hide();
    
	// Init the scrollable on fr and en news page
	if($('#archive-accordion').length > 0){
		$("#archive-accordion").accordion({collapsible: true, active: 0, animated: ''});
		//$("#archive-accordion").accordion('activate', false);
		$("#archive-accordion h3:first-child").click(); //accordion('activate',0);
	}	
    
	
    // Init the scrollable on fr and en home page
	if($('#featured').length > 0){
		$("#featured").scrollable({circular: true}).autoscroll({interval: 5000});
		api = $("#featured").data("scrollable");
		var i = 0;
		//api.seekTo(0);
		//$("#dot_0").click();
		$(".dot-link").each(function(){
			$(this).data('id', i++);
			$(this).bind('mousedown', function(){
				api.seekTo($(this).data('id'));
				handle_navigator(parseInt($(this).data('id') + 1));
			});
		});	
		
		// Auto change slide
		api.onSeek(function(){
			handle_navigator(parseInt(api.getIndex() + 1));
		});
	}
	
	// Init the map feature
	if($('#map').length > 0){
		var myLatlng = new google.maps.LatLng(48.397, 1.644);
		var myOptions = {
		  zoom: 6,
		  center: myLatlng,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		};

		map = new google.maps.Map(document.getElementById("map"), myOptions);
		
		var france = new google.maps.LatLng(40.698470, -73.951442);
		central = new google.maps.LatLng(france);
		//map.setCenter(central);
		
		// Adds makers
		for(i = 0; i < pin_position.length; i++){
			var position = pin_position[i];
			var latLng = new google.maps.LatLng(position['lat'], position['lon']);
		    var marker = new google.maps.Marker({
		        position: latLng,
		        map: map
		    });
			
		}
	}
	
	// Tabs init
//	if($('#tabs').length > 0){
//		$(".tabs").tabs(".panes > div");
//	}	
	
});

function changeImage(src) {
	$("#product-image").attr('src', src);
}


function handle_navigator(slide_id) {
	// clear dot hightlight
	$(".dot-link").removeClass('dot-btn-on');
	$(".dot-link").addClass('dot-btn-off');
	// set current dot hightlight
	id = '#dot_' + slide_id;
	$(id).removeClass('dot-btn-off');
	$(id).addClass('dot-btn-on');
}


function initialize() {
	var myLatlng = new google.maps.LatLng(-34.397, 150.644);
	var myOptions = {
	  zoom: 8,
	  center: myLatlng,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	};

	map = new google.maps.Map(document.getElementById("map"), myOptions);
}
