').attr('type', 'audio/mp3').appendTo('body');
var $audiofile;
var width = 0;
function spacing(){
width = $(window).width();
$('#photogridcontainer img').css({'height': 'auto'}).outerWidth(width/3);
}
$(window).on('load resize', spacing);
$('#photogridcontainer img').on('mouseover', function(){
$(this).stop().animate({'opacity': .35}, {duration:200, queue:false});
});
$('#photogridcontainer img').on('mouseout', function(){
$(this).stop().animate({'opacity': 1}, {duration:200, queue:false});
});
$('#photogridcontainer img').on('click', function(){
if($(this).data('audiofile')){
if(!$(this).hasClass('playing')){
//$audiofile.attr('src', $(this).data('audiofile'));
//$audiofile[0].play();
if(typeof $audiofile !== 'undefined'){
$audiofile.destruct();
}
$audiofile = soundManager.createSound({url: $(this).data('audiofile'), autoPlay: true});
$('#photogridcontainer img').css({'border':'none'}).outerWidth(width/3).removeClass('playing');
$(this).css({'border':'3px solid white'}).outerWidth(width/3).addClass('playing');
} else {
if($audiofile.paused){
$audiofile.play();
} else {
$audiofile.pause();
}
}
}
});
});