﻿/// <reference path="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.1.min.js"/>
/// <reference path="/Script/JSON-2/json2.js"/>
/// <reference path="/Script/jquery.comments/jquery.comments.js"/>

var Homepage = {
	photos: null,
	init: function () {
		$(window).load(function () {
			Homepage.getPhotos();
			Homepage.setCycle();
		});
	},
	getPhotos: function () {
		Homepage.photos = JSON.parse($("#PhotobookCell").comments(0));
		var hrefPrefix = $("#PhotobookCell h3 a").attr("href");
		$.each(Homepage.photos, function (i, val) {
			$("#PhotobookCell .images div").append("<a href=\"" + hrefPrefix + "\"><img src=\"/Upload/PhotobookPhotos/Large/" + val.f + "\" /></a>");
		});
	},
	setCycle: function () {
		$("#PhotobookCell .images div a:first-child").animate({
			marginTop: (($("#PhotobookCell .images div a:first-child img").height() - 126) / 2 * -1)
		}, 1000, function () {
			$("#PhotobookCell .images div").cycle({
				before: function () {
					$(this).animate({
						marginTop: (($(this).height() - 126) / 2 * -1)
					}, 0);
				}
			});
		});
	}
};
$(document).ready(function () {
	Homepage.init();
});
