jQuery(document).ready(function(){
	
	// ========== init map ========== //
	if(map == true)
	{
		initMap(currentDir);
	}
	// ========== END init map ========== //
	
	function mycarousel_initCallback(carousel) {
	    jQuery('#mycarousel-next').bind('click', function() {
	        carousel.next();
			
			if(carousel.last == $("#mycarousel li").size())
			{
				$("#mycarousel-next").css("opacity","0.5");
				$("#mycarousel-next").css("cursor","default");
			}
			
			$("#mycarousel-prev").css("opacity","1");
			$("#mycarousel-prev").css("cursor","pointer");
	        return false;
	    });
	 
	    jQuery('#mycarousel-prev').bind('click', function() {
	        carousel.prev();
			
			if(carousel.first == 1)
			{
				$("#mycarousel-prev").css("opacity","0.5");
				$("#mycarousel-prev").css("cursor","default");
			}
			
			$("#mycarousel-next").css("opacity","1");
			$("#mycarousel-next").css("cursor","pointer");

	        return false;
	    });
	};
	
	$('div#toggleButtonFooter').click(function(){
		$("div#togglePart").slideToggle("slow","easeInSine");
	});
	
	// Diaporama page
	$("#diaporamali").easySlider({
		prevId: 		'prevBtn',
		prevText: 		'',
		nextId: 		'nextBtn',	
		nextText: 		'',
		controlsShow:		true,
		controlsBefore:	'',
		controlsAfter:		'',	
		controlsFade:		true,
		firstId: 		'firstBtn',
		firstText: 		'First',
		firstShow:		false,
		lastId: 		'lastBtn',	
		lastText: 		'Last',
		lastShow:		false,				
		vertical:		false,
		speed: 			800,
		auto:			true,
		pause:			3000,
		continuous:		false, 
		numeric: 		false,
		numericId: 		'controls'
	});
	
	var numberOfImages = $("section#diaporamali ul li").size();
	if(numberOfImages <= 1)
	{
		$("#prevBtn a").css("visibility","hidden");
		$("#nextBtn a").css("visibility","hidden");
	}
	
	// Carousel Home
	if(isHome == true)
	{
		jQuery('#mycarousel').jcarousel({
			easing: 'swing',
			animation: 'slow',
			buttonNextHTML: null,
	        buttonPrevHTML: null,
	        initCallback: mycarousel_initCallback
		});
	}
		
	// ================== Fix Placeholder ================== //
	$(document).ready(function() {
		if(!Modernizr.input.placeholder){
			$("input").each(
				function(){
					if($(this).val()=="" && $(this).attr("placeholder")!=""){
						$(this).val($(this).attr("placeholder"));
						$(this).focus(function(){
					if($(this).val()==$(this).attr("placeholder")) $(this).val("");
			});
			$(this).blur(function(){
				if($(this).val()=="") $(this).val($(this).attr("placeholder"));
			});
			}
		});
		}
	});
	// ================== END Fix Placeholder ================== //
	
	// ================== Google Map ================== //	
	function initMap(currentDir) {
	 	var myLatlng = new google.maps.LatLng(48.880869,2.236882);
	 	var mapCenter = new google.maps.LatLng(48.882977,2.237177);
		var myOptions = {
		  zoom: 15,
		  center: mapCenter,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		
		var map = new google.maps.Map(document.getElementById("map_canvas"),
	    myOptions);
	    
	    var marker = new google.maps.Marker({
	    	map: map,
      		position: myLatlng,
      		draggable:false,
    		animation: google.maps.Animation.DROP,
    		icon: currentDir+'/images/pinMap-Neoma.png'
  		});
		
		var contentString = '<div class="mapInfoWindow"><ul><li><a target="blank" href="http://maps.google.fr/maps/place?cid=3007973266336367194&q=neoma&hl=fr&cd=1&cad=src:ppiwlink&ei=-Kc_Tua_IMa_8APP2KToBg">Neoma Interactive?</a></li><li>29 Rue Eugène Eichenberger</li><li>92800 Puteaux</li><li>01 45 06 51 70</li><li><a target="blank" href="http://maps.google.fr/local_url?q=http://www.neoma-interactive.com/&dq=neoma&f=q&source=s_q&hl=fr&geocode=&sll=46.75984,1.738281&sspn=10.509468,17.600098&ie=UTF8&hq=neoma&hnear=&t=h&cid=16010976254761648958&ll=48.883457,2.238894&spn=0.012699,0.02871&z=15&output=embed&oi=miw&sa=X&ct=miw_link&cd=1&cad=homepage,cid:3007973266336367194&ei=-Kc_Tua_IMa_8APP2KToBg&s=ANYYN7nDKSrxenvxwJsDzp_KbsdpqrVAUQ">www.neoma-interactive.com</a></li></ul></div>';
		
		var infowindow = new google.maps.InfoWindow({content: contentString, maxWidth: 500});
		infowindow.open(map,marker);
	}
	// ================== Google Map ================== //
});
