$(function(){
	// checkboxes
	$('#filter').click(function(event){
		$target = $(event.target);
		$input = $target.children('input');
		if($input.attr('checked')) {
			$input.removeAttr('checked');
			$target.removeClass('checked');
		} else {
			$input.attr('checked', 'checked');
			$target.addClass('checked');
		}
	});
	
	// wall
	$('#wallpapers li').hover(
		function() {
			$this = $(this);
			$this.children('.info').animate({
				opacity: 1
			},400);
			$this.find('.source a').fadeIn().css('display','block');
		},
		function() {
			$this = $(this);
			$this.children('.info').animate({
				opacity: 0.3
			},400);
			$this.find('.source a').fadeOut();
		}
	);
	
	// add
	$('#add .title').change(function(){
		val = $(this).val();
		val = val	.replace(/[^a-zA-Z0-9 -]/g, '')
					.replace(/\s+/g, '-')
					.toLowerCase();
		$(this).next().next().val(val);
	});
	
	// Facebook
	window.fbAsyncInit = function() {
        FB.init({appId: '136739376358282', status: true, cookie: true,
                 xfbml: true});
      };
      (function() {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
      }());
	
});

//Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17380674-1']);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})(); 
