jQuery.ajaxSetup({  
    'beforeSend': function (xhr) {xhr.setRequestHeader("Accept", "text/javascript")}  
});

function fb_share() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function delicious_share() {
	u=location.href;
	t=document.title;
	window.open('http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url='+encodeURIComponent(u)+'&amp;title='+encodeURIComponent(t), 'delicious','toolbar=no,width=550,height=550'); 
	return false;
}

function digg_share() {
	u=location.href;
	t=document.title;
	window.open('http://digg.com/submit?url='+encodeURIComponent(u)+'&amp;title='+encodeURIComponent(t), 'digg', 'toolbar=no,width=550,height=550'); 
	return false;
}

function stumble_share() {
	u=location.href;
	t=document.title;
	window.open('http://www.stumbleupon.com/submit?url='+encodeURIComponent(u)+'&amp;title='+encodeURIComponent(t), 'stumbleupon','toolbar=no,width=550,height=550'); 
	return false;
}

function rotate_elements(element) {
  var a = [-8, -7, -6, -5, -4,-3,-2,-1,0,1,2,3,4,5,6,7,8];
  $(element).each(
    function(){
      var picker = Math.round(Math.random()*17);
      var random = a[picker];
      $(this).css('-webkit-transform', 'rotate(' + random + 'deg)');
      $(this).css('-moz-transform', 'rotate(' + random + 'deg)');
      $(this).css('transform', 'rotate(' + random + 'deg)');
    }
  );
}


$(document).ready(function() {	
  $('a#search_location_name').click(function() {
    $('div#search_activity_menu').hide();
    $('div#search_location_menu').toggle();
    return false;
  });
  

  $('a#search_activity_name').click(function() {
    $('div#search_location_menu').hide();
    $('div#search_activity_menu').toggle();
    return false;
  });

  $('#home').click(function() {
    $('div#search_location_menu').hide();
    $('div#search_activity_menu').hide();
  })
	
	
	$('a.fb_share').click(function() {
		fb_share();
		return false;
	});
	
	$('a.delicious_share').click(function() {
		delicious_share();
		return false;
	});
	
	$('a.digg_share').click(function() {
		digg_share();
		return false;
	});
	
	$('a.stumble_share').click(function() {
		stumble_share();
		return false;
	});
});
