	function setHeader (){
		var docBody = $("body").width();
		if (docBody<963){
			$("#topwrapper").css("width",963);
		}else{
			var padding = (docBody - 963) / 2;
			var vscape = $("#docBody").width();
			$("#topwrapper").css("margin-left",padding);
			$("#topwrapper").css("padding-right",padding);
		}
	}
	
	function templatecats (){
		var catHeight = $("div#catsArea").height();
		var tmpHeight = $("div#tempArea").height();
		if (catHeight>tmpHeight){
			$("div#tempArea").height(catHeight);
		}else{
			$("div#catsArea").height(tmpHeight);
		}
	}
	
	
	function loadImage(gid){
		jQuery.ajax({
			type: "POST",
			url: "/loadGallery.php",
			data: "galleryID=" + gid,
			success: function(msg){
				$("div#galleryPost").html(msg);
			},
			error: function (XMLHttpRequest, textStatus, errorThrown){
				//alert("Loading Error: " + gid);
				alert(XMLHttpRequest + "," + textStatus + "," + errorThrown);
				
			}
		});
	}
	
	$(function () {
		setHeader();
		templatecats();
		
		
		$("ul#pstList li").click(function(){
			$('ul#pstList li').removeClass('selected');
			$(this).addClass('selected');
			my_images = new Array();
			$("#galleryPost").stopTime('controlled');
			jQuery.ajax({
				type: "POST",
				url: "/loadGallery.php",
				data: "galleryID=" + $(this).attr("id"),
				success: function(msg){
					$("div#galleryPost").html(msg);
				},
				error: function (XMLHttpRequest, textStatus, errorThrown){
					//alert("Loading Error: " + gid);
					//alert(XMLHttpRequest + "," + textStatus + "," + errorThrown);
					
				}
			});
			$("#ImageBrowser").attr("src",TEMPLATEPATH + "/images/loading-image.gif");
		})
		
		var tabContainers = $('div.ajaxBox > div.ajaxBoxInside > div');
		tabContainers.hide().filter(':first').show();

		$('div.ajaxBox > div.ajaxBoxLinks > a').click(function () {
			tabContainers.hide();
			tabContainers.filter(this.hash).show();
			$('div.ajaxBox > div.ajaxBoxLinks > a').removeClass('selected');
			$(this).addClass('selected');
			return false;
		}).filter(':first').click();

		
		$(window).resize(function(){
			setHeader();
		});
		
		
	});

	/*$("div#galleryPost a", demos).everyTime(1000,function() {
		alert("Ver");
		//alert($(this).attr("href"));
	});*/

	
