
/*$( function() {
	$(".port img").click( function()
	{
		PhotoMessage.Hide();
		$(".port span").fadeIn("medium", function() { $(this).show() } )
		$(".port div").css("opacity",0.7).fadeIn("medium", function() { $(this).show() } );
	})
	
	$( ".port div, .port span").click( function () {
		$(".port div, .port span").fadeOut("medium", function() { $(this).hide() })
	})

	$(".port div, .port span").hide();
	
	if ($(".port img")[0]) {
		PhotoMessage.Init();
		var exOnLoad = $(".port img")[0].onload || function () { };
		$(".port img")[0].onload = function () {
			exOnLoad();
			PhotoMessage.Show(this);
		}
		PhotoMessage.Show();
	}
} )*/

var exwindowload = window.onload || function () { };
window.onload = function () {
	exwindowload();
	
	if ($(".port img")[0]) {
		$(".port img").click( function()
		{
			PhotoMessage.Hide();
			$(".port span").fadeIn("medium", function() { $(this).show() } )
			$(".port div").css("opacity",0.7).fadeIn("medium", function() { $(this).show() } );
		})
		
		$( ".port div, .port span").click( function () {
			$(".port div, .port span").fadeOut("medium", function() { $(this).hide() })
		})
	
		$(".port div, .port span").hide();
	
		PhotoMessage.Init();
		var exphotoload = $(".port img")[0].onload || function () { };
		$(".port img")[0].onload = function () {
			exphotoload();
			PhotoMessage.Show(this);
		}
		PhotoMessage.Show();
	}
}

var PhotoMessage = {
	HTMLObj: null,
	CookieStatus: null,
	
	Init: function () {
		this.HTMLObj = document.createElement('div');
		this.HTMLObj.setAttribute('id', 'photo-message');
		this.HTMLObj.style.position = 'absolute';
		this.HTMLObj.style.top = '65px';
		this.HTMLObj.style.left = '60px';
		this.HTMLObj.innerHTML = 'tap the image for more information';
		document.body.appendChild(this.HTMLObj);
		
		//this.HTMLObj.style.display = 'none';
		$(this.HTMLObj).hide();
		
		this.CookieStatus = this.ReadCookie('photomessage');
	},
	Show: function (obj) {
		if (this.CookieStatus) return;
		
		if (obj) {
			var coords = this.FindCoord(obj);
			this.HTMLObj.style.top = coords[1] + 'px';
			this.HTMLObj.style.left = coords[0] + 'px';
		}
		
		//this.HTMLObj.style.display = 'block';
		$(this.HTMLObj).fadeIn("medium");
		
		this.CreateCookie('photomessage', 'yes', 60);
	},
	Hide: function () {
		$(this.HTMLObj).fadeOut("medium", function() { $(this).hide() });
	},
	FindCoord: function (obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		return [curleft,curtop];
	},
	CreateCookie: function (name, value, minutes) {
		if (minutes) {
			var date = new Date();
			date.setTime(date.getTime()+(minutes*60*1000));
			var expires = "; expires="+date.toGMTString();
		} else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	},
	ReadCookie: function (name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
};
