$(function(){
		var rndnum = Math.random();//Trick the Cache
		$("#content-main").text("Loading...");
		/*$.get('../../processors/getmerchsearch.php',function(data){
			$("#content-main").html(data);
		});*/
		
		$(".searchpager a, a#prevsearch").livequery('click', function(){
			if($(this).attr('href') != '#'){
				$.get($(this).attr('href'), function(data){
					$("#content-main").html(data);
					$.get("../../processors/getsearchsessurl.php", function(data){
						$("a.orderby, a#searchfrndonly, a#prevsearch").attr("href", data);
						$("a#prevsearch").hide();
					});
				});
			}
			else{
				if(confirm("Go to Boutique Homepage?")){
					window.location = 'http://www.shejustgotmarried.com/modules/boutique';
				}
			}
			return false;
		});
		$("#frmMerchSearch").livequery("submit", function(){
			$("#content-main").text("Loading...");
			var search_criteria = $("#txtSearchCriteria").val();
			$.get("../../processors/getmerchsearch.php", {search_criteria : search_criteria},function(data){
				$("#content-main").html(data);
				$.get("../../processors/getsearchsessurl.php", function(data){
					$("a.orderby, a#searchfrndonly, a#prevsearch").attr("href", data);
				});
			});
			return false;
		});
		$("#tagcloud").tagcloud({type:"list",sizemin:10,colormin:"6E674D",colormax:"6E674D"}).find("li").tsort();
		$("#tagcloud li a").click(function(){
			$("#content-main").text("Loading");
			var searchurl = $(this).attr("href");
			$.get(searchurl,function(data){
				$("#content-main").html(data);
				$.get("../../processors/getsearchsessurl.php", function(data){
					$("a.orderby, a#searchfrndonly, a#prevsearch").attr("href", data);
				});
			});
			return false;
		});
		/*$("a.specificitemlnk").livequery('click', function(){
			var merchID = $(this).attr("name");
			$("#content-main").text("Loading...");
			$.post("specificitem.php", {merchID:merchID}, function(data){
				$("#content-main").html(data);
				$("a#prevsearch").show();
			});
			$.post("../../processors/setrecitm.php", {recitm:merchID});
			$("#recentitms").text('Loading...')
			$("#recentitms").load('../../processors/getrecitms.php');
			return false;
		});*/
		$("a.specificitemlnk").livequery(function(){
			$(this).attr('href', 'http://www.shejustgotmarried.com/modules/boutique/?itemID=' + $(this).attr('name')); 	
		});
		$("a.orderby").livequery("click", function(){
			if($(this).attr('href') != "#"){
				var item_sort = $(this).attr("name");
				$("#content-main").text("Loading...");
				$.post("../../processors/setsearchorderby.php", {item_sort:item_sort});
				$("#content-main").load($(this).attr("href"));
			}
			else{
				if(confirm("Go to Boutique Homepage?")){
					window.location = 'http://www.shejustgotmarried.com/modules/boutique';
				}
			}
			return false;
		});
		$("a#searchfrndonly").click(function(){
			if($(this).attr('href') != '#'){
				$("#content-main").text("Loading...");
				$.post("../../processors/setsearchfrndonly.php", function(data){
					$("#searchfrndonly").text(data);
				});
				$("#content-main").load($(this).attr("href"));
			}
			else{
				if(confirm("Go to Boutique Homepage?")){
					window.location = 'http://www.shejustgotmarried.com/modules/boutique';
				}
			}
			return false;
		});
		$("a#prevsearch").hide();
		$("#recentitms").load('../../processors/getrecitms.php');
});