var w, h;
var arTags;

(function($){

var Core = {
	ondomready: function(){
	// page functions go here
		w = $(window).width();
		h = $(window).height();
	
		Core.centerMain();
		Core.animateLinks();
		//Core.loadPhotos();
		//Core.loadTags();
	},
	
	placeTags: function() {
		Core.animateLinks();	
		maxShow = 5;
		
	},
	
	loadTags: function() {
		$("html").append("<div class='dataContainer' id='tags'></div>");
		$("#tags").load("js/ajax/tags.php", function() {
			Core.placeTags();
		});	
	},
	
	centerMain: function() {
		$("#main").hAlign().vAlign();
	},
	
	animateLinks: function() {
		$("a").hover(function() {
			$(this).animate({color: "#333366"}, {queue: false, duration: 500});
		}, function() {
			$(this).animate({color: "#999999"}, {queue: false, duration: 500});
		});
	},
	
	
	placePhoto: function() {
		$("#photos").delay(2000).vAlign().fadeIn(2000, "easeOutCirc", function() {
			setTimeout("Core.clearPhotos();", 3000);
			
		});
	}, 
	
	clearPhotos: function() {
		$("#photos").fadeOut(2000, "easeOutCirc", function() {
			Core.loadPhotos();
		});
	},
	
	loadPhotos: function() {
		var size = parseInt(w / 4);
		$("html").append("<div class='dataContainer' id='photos'></div>");
		$("#photos").css({left: (w/10)+"px"});
		$("#photos").load("js/ajax/photos.php?size="+size, function() {
			Core.placePhoto();
		});	
	}
	
	
}

window.Core = Core;

$(document).ready(function(){Core.ondomready()});

})(jQuery);

(function ($) {
$.fn.vAlign = function() {
	return this.each(function(i){
	var h = $(this).height();
	var oh = $(this).outerHeight();
	var mt = (h + (oh - h)) / 2;	
	$(this).css("margin-top", "-" + mt + "px");	
	$(this).css("top", "50%");
	$(this).css("position", "absolute");	
	});	
};
})(jQuery);
 
(function ($) {
$.fn.hAlign = function() {
	return this.each(function(i){
	var w = $(this).width();
	var ow = $(this).outerWidth();	
	var ml = (w + (ow - w)) / 2;	
	$(this).css("margin-left", "-" + ml + "px");
	$(this).css("left", "50%");
	$(this).css("position", "absolute");
	});
};
})(jQuery);

