/***********************
*** Script SlideShow ***
************************/
function slideSwitch() {
    var $active = $('#RandomPics IMG.active');

    if ( $active.length == 0 ) $active = $('#RandomPics IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#RandomPics IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});

/*****************
*** GOOGLE MAP ***
*****************/
function initialize() {
	if (GBrowserIsCompatible()) {
		//***********************
		//*** Map pour Morges ***
		//***********************
		var map = new GMap2(document.getElementById("map_canvas_morges"));
		map.setCenter(new GLatLng(46.508421, 6.497855), 13);
		map.setUIToDefault();
		
		// Create our "tiny" marker icon
		var blueIcon = new GIcon(G_DEFAULT_ICON);
		blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png";

                
		// Set up our GMarkerOptions object
		markerOptions = { icon:blueIcon };
		
		var point = new GLatLng(46.508421, 6.497855);
		map.addOverlay(new GMarker(point));
		//Fin de la map Morges
	}
	
	if (GBrowserIsCompatible()) {		
		//***************************
		//*** Map pour Montricher ***
		//***************************
		var map = new GMap2(document.getElementById("map_canvas_montricher"));
		map.setCenter(new GLatLng(46.6003, 6.375966), 13);
		map.setUIToDefault();
		
		// Create our "tiny" marker icon
		var redIcon = new GIcon(G_DEFAULT_ICON);
		redIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png";
                
		// Set up our GMarkerOptions object
		markerOptions = { icon:redIcon };
	
		//Add 1 marker at the center location
		var point = new GLatLng(46.6003, 6.375966);
		map.addOverlay(new GMarker(point, markerOptions));
		//Fin de la map Montricher
	}
	
	if (GBrowserIsCompatible()) {
		//***********************
		//*** Map pour Assens ***
		//***********************
		var map = new GMap2(document.getElementById("map_canvas_assens"));
		map.setCenter(new GLatLng(46.613955, 6.62246), 13);
		map.setUIToDefault();
		
		// Create our "tiny" marker icon
		var blueIcon = new GIcon(G_DEFAULT_ICON);
		blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png";
                
		// Set up our GMarkerOptions object
		markerOptions = { icon:blueIcon };

		//Add 1 marker at the center location
		var point = new GLatLng(46.613955, 6.62246);
		map.addOverlay(new GMarker(point, markerOptions));
		//Fin de la map Assens
	}
}
