/***************************************************************************
function to set gallery cookie and change page
***************************************************************************/
function changePhotoGallery(path,title){
// Measure Gallery Click
measureApp("Newsroom","Photos",title);
setGallery(path);
document.location.href = '/en_US/news/photos/gallery.html';
}
/***************************************************************************
function to populate page
***************************************************************************/
function initPhotosPage(jsonDoc){
var count = 1;
var photosRowHTML = "";
$('#photosContent').html('');
$.each(jsonDoc.day, function(index,value){
var galleryDate = this.date;
$.each($(this.item).get().reverse(), function(index,value){
//$( $(this.item).get().reverse()).each(function(index,value){
if(count == 1){
photosRowHTML+='<div class="photosRow">';
}
if(count < 3){
photosRowHTML+='<div class="item" onclick="changePhotoGallery(\''+ this.link +'\',\''+ this.title.replace(/'/,"\\\'") +'\');"><img src="'+ this.image +'" width="236" height="133" border="0" alt="'+ this.title +'"/><h3>'+ this.title +'</h3><span class="date">'+ galleryDate +'</span><div class="divider">|</div><div class="count">' +this.count+ ' photos</div></div>';
}
if(count == 3){
photosRowHTML+='<div class="item end" onclick="changePhotoGallery(\''+ this.link +'\',\''+ this.title.replace(/'/,"\\\'") +'\');"><img src="'+ this.image +'" width="236" height="133" border="0" alt="'+ this.title +'"/><h3>'+ this.title +'</h3><span class="date">'+ galleryDate +'</span><div class="divider">|</div><div class="count">' +this.count+ ' photos</div></div>';
}
count++;
if(count > 3 ) {
photosRowHTML+='</div>';
$('#photosContent').append(photosRowHTML);
photosRowHTML = ""
count = 1;
}
});
});
//add closing div if final count is not a multiple of 3
if(count <= 3) {
photosRowHTML+='</div>';
$('#photosContent').append(photosRowHTML);
}
$('.photosRow .item').unbind('hover');
$('.photosRow .item').hover(
function(){ $(this).children('h3').css('text-decoration','underline'); },
function(){ $(this).children('h3').css('text-decoration','none'); }
);
}
/***************************************************************************
load json
***************************************************************************/
$(document).ready(function(){
$.ajax({
url: '/en_US/xml/gen/galleries/galleries.json',
dataType: 'json',
error: function(){
//alert('Error loading document - /en_US/xml/gen/galleries/galleries.json');
},
success: function(jsonResp){
jsonDoc = jsonResp;
initPhotosPage(jsonDoc);
}
});
});
