          var vInterval = 5000;
          var vIntervalHandle;
	  $(document).ready(function() {
	    initMainPhoto();
	  });

	  function initMainPhoto() {
	    $("#main-photo-div a").css({"opacity": "0.0"});
	    $("#main-photo-div a:first").css({"opacity": "1.0"});
	    var marginLeft = (547 - parseInt($("#main-photo-div a").find("img").css("width"),10)) / 2;
	    var marginTop = (318 - parseInt($("#main-photo-div a").find("img").css("height"),10)) / 2;
	    $("#main-photo-div a").find("img").css("margin-left",marginLeft);
	    $("#main-photo-div a").find("img").css("margin-top",marginTop);
	    $("#main-photo-div .caption").css("margin-left",marginLeft);
	    $("#main-photo-div .caption").css("margin-bottom",marginTop);
	    $("#main-photo-div .caption").css({opacity: 0.7});
	    $("#main-photo-div .caption").css({width: $("#main-photo-div a").find("img").css("width")});
	    $("#main-photo-div .content").html($("#main-photo-div a:first").find("img").attr("rel")).animate({opacity: 0.7}, 400);
	    if ($("#main-photo-div a:first").find("img").attr("rel") == "")
	      $("#main-photo-div .caption").css({display: "none"});
            if ($("#main-photo-div a").length > 1) {
	      vIntervalHandle = setInterval(function(){updateMainPhoto();},vInterval);
              var vPreviewDiv = document.createElement("div");
              vPreviewDiv.id = "vPreviewDiv";
              vPreviewDiv.style.position = "relative";
              vPreviewDiv.style.left = parseInt(273 - (15 * $("#main-photo-div a").length),10) + "px";
              vPreviewDiv.style.top = "-12px";
              vPreviewDiv.style.zIndex = "600";
              document.getElementById("main-photo").appendChild(vPreviewDiv);
              for (var i=0; i < $("#main-photo-div a").length; i++) {
                var vCurrentImage = $("#main-photo-div a")[i].getElementsByTagName("img")[0];
                var vPreview = document.createElement("div");
                vPreview.style.display = "inline-block";
                vPreview.style.marginRight   = "5px";
                vPreview.style.backgroundColor = (i == 0 ? "#FFFFFF" : "#606060");
                vPreview.style.border          = "1px solid #FFFFFF";
                vPreview.style.width           = "24px";
                vPreview.style.height          = "7px";
                vPreview.style.cursor          = "pointer";
                vPreview.id                    = "vPreviewImg" + i;
                vPreview.onmouseover           = function(){
                                                   var current = ($("#main-photo-div a.show") ? $("#main-photo-div a.show") : $("#main-photo-div a:first"));
                                                   if (current.index() != parseInt($(this).attr("id").replace(/vPreviewImg/,""),10)) {
                                                     $(this).css("background-color","#E38B40");
                                                     $(this).css("border","1px solid #E38B40");
                                                   }
                                                 };
                vPreview.onmouseout            = function(){
                                                   var current = ($("#main-photo-div a.show") ? $("#main-photo-div a.show") : $("#main-photo-div a:first"));
                                                   if (current.index() != parseInt($(this).attr("id").replace(/vPreviewImg/,""),10)) {
                                                     $(this).css("background-color","#606060");
                                                     $(this).css("border","1px solid #FFFFFF");
                                                   }
                                                 };
                vPreview.onclick               = function(){
                                                   var vImgNbrToDisplay = $(this).attr("id").replace(/vPreviewImg/,"");
	                                           var current = ($("#main-photo-div a.show") ? $("#main-photo-div a.show") : $("#main-photo-div a:first"));
                                                   if (current.index() == vImgNbrToDisplay) return;
                                                   for (var i=0; i < $("#main-photo-div a").length; i++) {
                                                     if (i != vImgNbrToDisplay)
                                                       $("#vPreviewImg" + i).css("background-color","#606060");
                                                   }
                                                   $(this).css("background-color","#FFFFFF");
                                                   $(this).css("border","1px solid #FFFFFF");
	                                           var next = $("#main-photo-div a:eq(" + vImgNbrToDisplay + ")");
	                                           var marginLeft = (547 - parseInt(next.find("img").css("width"),10)) / 2;
	                                           var marginTop = (318 - parseInt(next.find("img").css("height"),10)) / 2;
	                                           next.find("img").css("margin-left",marginLeft);
	                                           next.find("img").css("margin-top",marginTop);
	                                           var caption = next.find("img").attr("rel");
	                                           next.css({opacity: 0.0}).addClass("show").animate({opacity: 1.0}, 1000);
	                                           current.animate({opacity: 0.0}, 1000).removeClass("show");
	                                           $("#main-photo-div .caption").css("margin-left",marginLeft);
	                                           $("#main-photo-div .caption").css("margin-bottom",marginTop);
	                                           $("#main-photo-div .caption").css({width: next.find("img").css("width")});
	                                           $("#main-photo-div .caption").animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: "1px"}, { queue:true, duration:300 });	
                                                   if (caption != "")
	                                             $("#main-photo-div .caption").animate({opacity: 0.7},100).animate({height: "75px"},500);
	                                           $("#main-photo-div .content").html(caption);
                                                   clearInterval(vIntervalHandle);
                                                 };
                vPreview.innerHTML             = "&nbsp;";
                document.getElementById("vPreviewDiv").appendChild(vPreview);
              }
            }
	  }

	  function updateMainPhoto() {
	    var current = ($("#main-photo-div a.show")?  $("#main-photo-div a.show") : $("#main-photo-div a:first"));
	    var next = ((current.next().length) ? ((current.next().hasClass("caption"))? $("#main-photo-div a:first") :current.next()) : $("#main-photo-div a:first"));
            for (var i=0; i < $("#main-photo-div a").length; i++) {
              if (i != next.index())
                $("#vPreviewImg" + i).css("background-color","#606060");
            }
            $("#vPreviewImg" + next.index()).css("background-color","#FFFFFF");
	    var marginLeft = (547 - parseInt(next.find("img").css("width"),10)) / 2;
	    var marginTop = (318 - parseInt(next.find("img").css("height"),10)) / 2;
	    next.find("img").css("margin-left",marginLeft);
	    next.find("img").css("margin-top",marginTop);
	    var caption = next.find("img").attr("rel");
	    next.css({opacity: 0.0}).addClass("show").animate({opacity: 1.0}, 1000);
	    current.animate({opacity: 0.0}, 1000).removeClass("show");
	    $("#main-photo-div .caption").css("margin-left",marginLeft);
	    $("#main-photo-div .caption").css("margin-bottom",marginTop);
	    $("#main-photo-div .caption").css({width: next.find("img").css("width")});
	    $("#main-photo-div .caption").animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: "1px"}, { queue:true, duration:300 });	
            if (caption != "")
	      $("#main-photo-div .caption").animate({opacity: 0.7},100).animate({height: "75px"},500);
	    $("#main-photo-div .content").html(caption);
	  }
