$(document).ready(function () {
	//grab the page url. If you are setting this from php, that would be better. E.G.:

	//var site_url = 	window.location.host;
	
	//wraps content in an anchor so that we can make links jump up to top
	//$("#content").wrap("<a name='content'></a>");
	//look for all anchors. Run ajaxify function on each one that is a site link.
	//Should work even with the new links that get loaded by ajax.
	//modify this if you would rather look for your own links of a certain class.
	//attach a click check to every link
	$("a").live("click", function(){
		//if if matches a site link, ajaxify it
		
		if( url_filter($(this)) === true){
		//if( $(this).attr("href") && $(this).attr("href").search(site_url) != -1 ){
			$(this).ajaxify();
			//kill the link from firing
			return false;
		}
		
	});
	
});

// Exceptions to ajax rewriter
function url_filter(link){
	var url = $(link).attr("href");

	if(url == undefined) return false;
	if(url.search(site_url) == -1) return false;
	if(url.search(".jpg") != -1) return false;
	if(url.search(".png") != -1) return false;
	if(url.search(".mp3") != -1) return false;
	if(url.search(".zip") != -1) return false;
	if( $(link).hasClass("go_to_checkout") == true) return false;
	if( $(link).hasClass("continue_shopping") == true) return false;
	if( $(link).hasClass("thickbox") == true) return false;
	if( $(link).hasClass("preview_link") == true) return false;
	
	return true;
}