// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$(document).ready(function () {
	jQuery.each($('img.fancybox'),function(){
    $(this).wrap('<a href="'+this.src+'" title="'+this.title+'"></a>').parent().fancybox();
});
	addCaption("imgLeft");
addCaption("imgRight");
   if ($('#flash').length>0) {
    $('#flash').effect("bounce", { times:3, direction: 'right',distance: 200 }, 300);
    window.setTimeout(function() {
        $('#flash').fade();
        }, 6000);
   }
   
});
Window.keepMultiModalWindow=true;


function addCaption(xClass) {
	var allImages = $("img."+xClass);
for ( var i=0; i < allImages.length; i++) {
var imageCaption = document.createTextNode(allImages[i].title);
var imageContainer = document.createElement("div");
var imagePara = document.createElement("p");
var imageWidth = allImages[i].getAttribute("width");
var spareSpan = document.createElement("span");
imagePara.appendChild(imageCaption);
allImages[i].parentNode.insertBefore(imageContainer, allImages[i]);
imageContainer.appendChild(allImages[i]);
if ( allImages[i].title != "" ) {
imageContainer.appendChild(imagePara);
}
imageContainer.appendChild(spareSpan);
imageContainer.className = xClass
spareSpan.className = "spareSpan"
allImages[i].className = "img"
imageContainer.style.width = imageWidth + "px";
}
}

