$(function(){
	if ($('#map').length > 0) {
		initialize();
	}
	/*if ($('body').hasClass('home')) {
		$('<div id="tiptip_holder"><div id="tiptip_arrow"></div><div id="tiptip_content">asdas</div></div>').appendTo('body');
	}
	
	$("body.home #content ul li a").tooltip({
		effect   : 'fade',
		position : 'bottom center',
		tip      : '#tiptip_content'
	});*/
	$('body.home #content ul.products li a').tipTip({
		delay: 100,
		edgeOffset: -12,
		maxWidth: 300
	});
	
	$('#contact-form input[type=text], #contact-form textarea').each(function(){
		if ($(this).val() == ''){
			$(this).val($(this).siblings('label').text());
		}
	});
	$('#contact-form input[type=text], #contact-form textarea').focus(function(){
		if ($(this).val() == $(this).siblings('label').text()) {
			$(this).val('');
		}
	});
	$('#contact-form input[type=text], #contact-form textarea').blur(function(){
		if ($(this).val() == ''){
			$(this).val($(this).siblings('label').text());
		}
	});
	
	if ($('table.listing').size() > 0) {
		$('table.listing tr th:last-child, table.listing tr td:last-child').addClass('last');
		$('table.listing').dataTable({
			bInfo : false,
			bLengthChange : false,
			bPaginate : true,
			iDisplayLength : 10,
			sPaginationType : 'full_numbers',
			sAjaxSource : 'vendors.php',
			oLanguage: {
				oPaginate: {
					sFirst: 'Première',
					sLast: 'Dernière',
					sNext: 'Suivant',
					sPrevious: 'Précédent'
				},
				sSearch: 'Recherchez'
			}
		});
	}
	
});


function initialize() {
	var latlng = new google.maps.LatLng(45.449971, -73.420215);
	var myOptions = {
		zoom: 14,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	
	var map = new google.maps.Map(document.getElementById("map"), myOptions);
	var image = $('#map-icon').attr('src');
	var icon = new google.maps.Marker({
	      position: latlng,
	      map: map,
	      icon: image,
	      title: 'Marie Morin'
	});
	/*
	var infowindow = new google.maps.InfoWindow({
	    content: 'content'
	});
	google.maps.event.addListener(icon, 'click', function() {
		infowindow.open(map, icon);
	});
	*/
}
