var templaworld_ajax = {
	site: "http://www.templaworld.net/wp-content/themes/v19.2/",
	image: "images/refresh.gif",
	visited: new Array(),
	
	page: function (page) {
		var query = "paged=" + page;
		var image = "<img src='" + this.site + this.image + "' alt='refresh' />";
		jQuery("#c-switcher").prepend(image);
		this.ajax(query);
			
		return false;
	},
	
	category: function (cat, page) {
		var query = "paged=" + page + "&category_name=" + cat;
		var image = "<img src='" + this.site + this.image + "' alt='refresh' />";
		jQuery("#c-switcher .switch_" + cat).before(image);
		this.ajax(query);
			
		return false;
	},
	
	ajax: function (query) {
		if (typeof(this.visited[query]) == "undefined") {
			jQuery.ajax({
				type: "GET",
				url: this.site + "posts.php?" + query,
				success: function(html) {
					jQuery("#c-posts").html(html);
					templaworld_ajax.visited[query] = html;
				}
			});
		}
		else
			jQuery("#c-posts").html(this.visited[query]);
	}
};
jQuery(document).ready(function () {templaworld_ajax.visited["paged=1"] = jQuery("#c-posts").html();});
