$(document).ready(function(){
	$('a.lightbox').lightBox();
	
	$('ul.vehicles-list li').mouseover(function(){
		var id = $(this).attr('id');
		$('#roll_img li').hide();
		$('#roll_img li#'+id+'_img').show();
	});
	
	$('#questions a').click(function(){
		var id = $(this).attr('id');
		$('.linkTop').hide();
		$('#rep_'+id+' .linkTop').show();
	});
	
	/*mapix = document.getElementById('background-img');
	ratio = resizeHautSeul(mapix.height, mapix.width);
	var newHeight =  Math.ceil(mapix.height*ratio);
	var newWidth =  Math.ceil(mapix.width*ratio);
	mapix.height = newHeight;
	mapix.width = newWidth;
	window.onresize = resizePics;
	resizePics();*/
});

// function pour communiquer avec les galerie 
function thisMovie(movieName) {
     if (navigator.appName.indexOf("Microsoft") != -1) {
          return window[movieName]
     }
     else {
          return document[movieName]
     }
}

// function appele par le flash pour lancer la gallerie lightbox
function showGallery(currentPic, part, page)
{
	
	$.ajax({
		type: 		"GET",
		url: 		"gallery.php?currentPic="+currentPic+"&part="+part+"&page="+page,
		success: 	function(msg)
		{
			var pics = msg.split(';');
			$('#gallery').remove();
			$('#main').append('<div id="gallery"></div>');
			var i = 0;
			for (p in pics)
			{
				var n = pics[p].length
				var court = pics[p].substr(0, n-4);
				$('#gallery').html(
					$('#gallery').html() + 
					'<a class="lightbox" rel="colorbox" id="'+court+'" href="media/photos/' + pics[p] + '">'+
					//'<img title="img_'+i+'" src="/media/photos/' + pics[p] + '" />'+
					'img_'+i+
					'</a>'
					
				);
				
				$('a.lightbox').lightBox();
				/*
				$("a[rel='colorbox']").colorbox({
					open:true,
					onComplete: function() {
						var elt = $('#cboxPhoto');
						var src = elt.attr('src');
						//alert(src);
					},
					onOpen: function() {
						$('embed, object, select').css({ 'margin-right' : '-5000px' });
					},
					onClosed: function() {
						$('embed, object, select').css({ 'margin-right' : '0' });
					}
				});*/
				i++;
			}

			var n = pics[currentPic].length
			var court = pics[currentPic].substr(0, n-4);
			$('#'+court).click();
		}
	});
}


