/*  Copyright 2009  Carlos Pena  (email : carlos@creamscoop.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

var Socialite = {
  twitter : function (tweet, url) {
    window.open("http://twitter.com/home?status="+tweet, "_blank");
    GA_Track('socialite', 'twitter/'+ url);
    return false;
  },
  favorite : function (title, url) {
    if (window.sidebar) { // Mozilla Firefox Bookmark
  		window.sidebar.addPanel(title, url,"");
  	} else if( window.external ) { // IE Favorite
  		window.external.AddFavorite( url, title);
  	} else if(window.opera && window.print) { // Opera Hotlist
  		return false;
  	}
    GA_Track('socialite', 'favorite/'+ url);
  	return false;
  },
  delicious : function(title, url) {
    window.open("http://delicious.com/save?url="+url+"&title="+title, "_blank");
    GA_Track('socialite', 'delicious/'+ url);
    return false;
  },
  stumbleupon : function (title, url) {
    window.open("http://www.stumbleupon.com/submit?url="+url+"&title="+title, "_blank");
    GA_Track('socialite', 'stumbleupon/'+ url);
    return false;
  },
  meneame  : function(url) {
    window.open("http://meneame.net/submit.php?url="+url, "_blank");
    GA_Track('socialite', 'meneame/'+ url);
    return false;
  },
  enchilame : function(url) {
    window.open("http://enchilame.com/submit.php?url="+url, "_blank");
    GA_Track('socialite', 'enchilame/'+ url);
    return false;
  }
}

// Use Google Analytics to track JavaScript //
function GA_Track(what, category) {
  
  pageTracker._trackPageview("/"+ what +"/"+ category);
  
}


$(document).ready(function(){
  
  $('.rnd_tuts li a').mouseover(function() {
    
    var id = $(this).attr('id');
    $('.rnd_tuts li a div.'+id).css({
      opacity: 0.7
    }).show();
    
  });
  
  $('.rnd_tuts li a').mouseout(function() {
    
    var id = $(this).attr('id');
    $('.rnd_tuts li a div.'+id).hide();
    
  });
  
  // Track downloads
  $('a.track-download').click(function() {
    
    var url = $(this).attr("href");
    GA_Track('download', url);
    
  });
  
  // Track external links
  $('a.track-external').click(function() {
    
    var url = $(this).attr("href");
    GA_Track('outgoing', url);
    
  });
  
});


