var default_content="";

var lasturl="";

function checkURL(hash)
{
	if(!hash) hash=window.location.hash;
	
	if(hash != lasturl)
	{
		lasturl=hash;
		
		// FIX - if we've used the history buttons to return to the homepage,
		// fill the pageContent with the default_content
		
		if(hash=="")
		$('#load_content').html(default_content);
		
		else
		loadPage(hash);
	}
}


function loadPage(url)
{
	url=url.replace('#','');
	
	$('#loading_page').css('display','block');
	
	$.ajax({
		type: "POST",
		url: "load_page.php",
		data: 'view='+url,
		dataType: "html",
		success: function(msg){
			
			if(parseInt(msg)!=0)
			{
				$('#load_content').html(msg);
				$('#loading_page').css('display','none');
			}
		}
		
	});

}

function checkCart(){
	//$('#loading').css('display','block');
	
	$.ajax({
		type: "POST",
		url: "cart_summary.php",
		dataType: "html",
		success: function(msg){
			
			if(parseInt(msg)!=0)
			{
				$('#mem_msg').html(msg);
				//$('#loading').css('display','none');
			}
		}
		
	});
}

function refCart(add_pdId, qty){
	$('#loading_cart').css('display','block');
	url= "&add="+add_pdId+"&qty="+qty;
	
	$.ajax({
		type: "POST",
		url: "load_page.php",
		data: "view=cart"+url,
		dataType: "html",
		success: function(msg){
			
			if(parseInt(msg)!=0)
			{
				$('#load_content').html(msg);
				$('#loading_cart').css('display','none');
			}
		}
		
	});
}

function load_prods(id){
	$('#loading_page').css('display','block');
	url= "&cat_select="+id;
	
	$.ajax({
		type: "POST",
		url: "load_page.php",
		data: "view=display_prods"+url,
		dataType: "html",
		success: function(msg){
			
			if(parseInt(msg)!=0)
			{
				$('#load_content').html(msg);
				$('#loading_page').css('display','none');
			}
		}
		
	});
}
