	function C(){
		this.imageArray = new Array();
		this.initImage = null;
		this.c = 0;
	};
	var M = new C();


	C.prototype.loadImage = function(obj, id, type, size){
		var url = "http://picasaweb.google.com/data/entry/api/user/m77portfolio/photoid/"+id+"?alt=json&kind=thumb&thumbsize="+size+"&imgmax=800&callback=?";
		$.getJSON(url,function(data){ 
			var picture = data.entry;
			//console.log(picture);
			switch(type) {
				case "thumb":
					var marginTop = (picture.media$group.media$thumbnail[0].height - 140)/4;
					var marginLeft = (picture.media$group.media$thumbnail[0].width - 292)/4;
					var path = picture.media$group.media$thumbnail[0].url;
					break;
				case "large":
					var path = picture.content.src;
					break;
			
			}
			var img = obj;
			if($(img).parent().attr("id") == "img"){
				$(img).parent().attr("href", picture.content.src);
			}
			//console.log("mt: " + marginTop + " ml: " + marginLeft)
			$(img).hide();
			$(img).load(function () {
			    $(this).fadeIn();
			})
			.error(function () {})
			.attr({
			    src: path,
			 // src: picture.content.src,
			    style: "margin-top:-" + marginTop + "px" 
			})
		});
	}

	function linkLoad(hash){
		$.historyLoad(hash);
	}
	function pageload(hash) {
		if(hash) {
			SC.loadImage(hash);
		}else{
			SC.loadImage();
		}
		
	}

	$(document).ready(function(){
		var hash = document.location.hash;
		//
		if(!hash){
			$('#logo img').hide();
		}
		$("a#img").fancybox({
			overlayOpacity: .6
		});


		$('a.email').each(function(){
			e = this.rel.replace('/','@');
			this.href = 'mailto:' + e;
			//$(this).text();
		});
		$('.medium').each(function(){
		//	e = this.rel.replace('/','@');
		//	this.href = 'mailto:' + e;
			//console.log(this.id);
			M.loadImage(this, this.id, "thumb", 288);
			//
			
			//
		});
		$('#image-thumb > a > img').each(function(){
		//	e = this.rel.replace('/','@');
		//	this.href = 'mailto:' + e;
			//console.log(this.id);
			M.loadImage(this, this.id, "thumb", 288);
			//
			
			//
		});
		$('#image-large > a > img').each(function(){
		//	e = this.rel.replace('/','@');
			
			M.loadImage(this, this.id, "large", 576);
			//
			
			//
		});
		
		$('#image-header > img').each(function(){
		//	e = this.rel.replace('/','@');
		//	this.href = 'mailto:' + e;
			//console.log(this.id);
			M.loadImage(this, this.id, "header", 1280);
			//
			
			//
		});
		//$('.container').masonry({ columnWidth: 390 });

	});
	
