﻿/// <reference path="jquery.js" />
$(document).ready(function() {
	$(".tblBulletin .trDataRow").css({ verticalAlign: "top" });
	$(".tblBulletin .trDataRow:even td").css("background-color", "#fff7cd");
	$(".tblBulletin td:nth-child(2)").css("textAlign", "center");
	$(".tblBulletin td:nth-child(3)").css("whiteSpace", "nowrap");
	$(".tblBulletin th:lt(3)").css("borderRight", "solid 1px white");

	var dialogHeight;
	if (jQuery.support.boxModel) {
		dialogHeight: 200;
	} else {
		dialogHeight: 204;
	}
	
	$('#alumniPhoto').dialog({
		title: "Alumni",
		resizable: false,
		draggable: false,
		bgiframe: true,
		autoOpen: false,
		width: 125,
		height: dialogHeight,
		modal: false,
		buttons: {
			close: function() {
				$(this).dialog('close');
			}
		}
	});
});

DdmSys.Bulletin = {
	ShowAlumniPhoto: function(sender, alumniID, imageYear, firstName) {
		var top = $('html').scrollTop();
		var left = $('html').scrollLeft();
		var linkOffsetTop = $(sender).offset().top;
		var linkOffset = linkOffsetTop;
		if (navigator.productSub > '20020801') { linkOffset = linkOffsetTop - top; } // this is for firefox

		if (parseInt(linkOffset) > 220) {
			top = (linkOffset + top) - 200;
		} else {
			top += 10;
		}

		$("#imagePlaceholder").find("span").remove();

		var img = $("#imagePlaceholder").find("img");
		if (img.length > 0) {
			$("#imagePlaceholder").find("img").remove();
		} else {
			img = new Image();
		}
		$(img).hide();

		$(img).load(function() {
			$('#imagePlaceholder')
				.append(this)
				.removeClass('loading')
				.animate({ height: this.height + 'px', "easing": "easein" }, 400, function() { $(img).fadeIn(500); });
		}).error(function() {
			$(img).remove();
			$(img).load(function() {
				$('#imagePlaceholder')
					.append(this)
					.removeClass('loading')
					.animate({ height: this.height + 'px', "easing": "easein" }, 500, function() { $(img).fadeIn(600); });
			}).attr({
				src: 'Images/Alumni/YearBook/' + alumniID.toString() + '.jpg',
				id: "photoImage"
			});
		}).attr({
			src: 'Images/Alumni/YearBook/' + alumniID.toString() + '.gif',
			id: "photoImage"
		});

		$('#imageYear').text(imageYear.toString());
		$("#alumniPhoto").dialog('option', 'position', [left + 120, top]);
		$('#alumniPhoto').dialog('option', 'title', firstName);
		$('#alumniPhoto').dialog('open');
		return false;
	}
}