/* Udzzis 2011 */
var originalTitle;
function setCookie(aCookie, aValue){$.cookie(aCookie, aValue,{expires:365});}
function setBlock(){if($.tools.tooltip.blocked){$(".block").text("ENABLE TOOLTIPS");}else{$(".block").text("DISABLE TOOLTIPS");}$(".block").css({ "display": "inline-block"});}
function loadContent(hash){
	var url, params = {};
	hash = hash.replace(/!/g, "");
	url = "sitecontent.html?" + hash;
	var keys = hash.replace(/([^=&]+)=([^&]*)/g, function(m,key,value){params[key] = value;});
	var title = 'Support Ron Paul for President 2012';
	if (params['tag']) title = title + ' - ' +  params['tag'].replace(/\+/g, ' ');
	if (params['page']) title = title + ' - page ' +  params['page'];
	originalTitle = title;
	document.title = title;
	if ($("#ajax-content").height() > 0){
		$("#fuzz").css("height", $("#ajax-content").height());
		$("#fuzz").css("top", $("#ajax-content").position().top);
	}else{
		$("#fuzz").css("height", $(document).height());
		$("#fuzz").css("top",0);
	}
	$("#loading").vCenter();
	$("#fuzz").fadeIn(200);
	$.ajax({
		type: "GET", url: url,
		success: function(html){
			$("#fuzz").fadeOut(200, function(){
				$("#ajax-content").showHtml(html, 400, function(){
					if ($.cookie('tooltips') == "false") {$.tools.tooltip.block();}	setBlock();
					$('a.dsframe').tooltip({onBeforeShow: function(){this.getTrigger().fixZIndex({exclude: "nozfix", recursive: false, msieOnly: true, zIndex: 9});},onHide: function(){this.getTrigger().restoreZIndex({msieOnly: true});}, predelay: 100, delay: 0, effect: 'slide', slideInSpeed: 200, slideOutSpeed: 100, slideOffset: 50, bounce: true, relative: true, position: 'center right', offset: [50, 20]}).dynamic(); 
					$('.block').click(function(){$.tools.tooltip.block(); setCookie("tooltips",!$.tools.tooltip.blocked); setBlock();});
					$('.taglist').change(function(){window.location.href = $(this).attr('value');});
					$('.taglist').linkselect({change: function(li, value, text){window.location.href = value;}});
					$('a[href^="http"]').mousedown(function(e){if(e.which === 1){var src, dst; src = escape(document.URL); dst = escape($(this).attr('href')); new Image().src= "track/track.php?src=" + src + "&dst=" + dst;}});
					$('.preload').preloadImages({showSpeed: 500});
				});
			});
		}
	});
}
$(document).ready(function(){
	$.history.init(loadContent);
});
if ($.browser.msie){
	document.attachEvent('onpropertychange', function (evt){
		if(evt.propertyName === 'title' && document.title !== originalTitle) document.title=originalTitle;
	});
}
$(window).bind("resize", function(){
	if ($("#ajax-content").height() > 0) {
		$("#fuzz").css("height", $("#ajax-content").height());
	}else{
		$("#fuzz").css("height", $(document).height());
	}
});
$(window).scroll(function(){
	if($(window).scrollTop() === 0){
		$('a.upButton').fadeOut("slow");
	}else{
		if($('a.upButton').length === 0){
			$('#wrapper').append('<a href="#" class="upButton"></a>');
		}
		$('a.upButton').fadeIn("slow");
	}
});
$('a.upButton').live('click', function(event){
	event.preventDefault();
	$('html,body').animate({scrollTop: 0}, 'slow');
});
var _gaq=[['_setAccount','UA-24895083-2'],['_trackPageview'],['_trackPageLoadTime']];
	(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
	g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
	s.parentNode.insertBefore(g,s);}(document,'script'));
(function(){
	var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
	po.src = 'https://apis.google.com/js/plusone.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
(function(d, s, id) {
	var js, fjs = d.getElementsByTagName(s)[0];
	if (d.getElementById(id)) {return;}
	js = d.createElement(s); js.id = id;
	js.src = "//connect.facebook.net/en_US/all.js#appId=222060227851665&xfbml=1";
	fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
(function() {
	var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
	s.type = 'text/javascript';
	s.async = true;
	s.src = 'http://widgets.digg.com/buttons.js';
	s1.parentNode.insertBefore(s, s1);
})();
