function toggle_sidebars(){
	if (jQuery.cookie('sidebars_hidden')=='true'){
		show_sidebar();
	} else {
		hide_sidebar();
	}
}

function show_sidebar(){
	jQuery.cookie('sidebars_hidden','false', { path: '/'});
    jQuery('#container').css({'marginLeft': 250})
    jQuery('#leftside').show();

}

function hide_sidebar(){
	jQuery.cookie('sidebars_hidden','true', { path: '/'});
    jQuery('#leftside').hide();
    jQuery('#container').css({'marginLeft': 0})

}

jQuery(document).ready( function() {

	if (jQuery.cookie('sidebars_hidden')=='true'){
		hide_sidebar(false);
	}
    /*
	jQuery('a[rel^="lightbox"]').prettyPhoto({
		opacity: 0
		, overlay_gallery: false
	});
	*/
	
	jQuery('.tooltip_top').each( function(i){
		jQuery(this).tipsy({gravity: 's'});
	});
	jQuery('.tooltip_left').each( function(i){
		jQuery(this).tipsy({gravity: 'e'});
	});
	jQuery('.tooltip_bottom').each( function(i){
		jQuery(this).tipsy({gravity: 'n'});
	});
	jQuery('.tooltip_right').each( function(i){
		jQuery(this).tipsy({gravity: 'w'});
	});
	
	jQuery('.social_bookmarks').mouseover(function() {
		jQuery(this).css({
			marginTop: '-8px'
		})
	});	
	jQuery('.social_bookmarks').mouseout(function() {
		jQuery(this).css({
			marginTop: '0'
		})
	});	
	
    jQuery('.hilite').css({ opacity: 0.5 });
    jQuery('.hilite').hover(
      function () {
        jQuery(this).fadeTo(400, 1.0);
      }, 
      function () {
        jQuery(this).fadeTo(400, 0.5);
      }
    );
});

function skss_share(service) {
    // Get href and title
    // PDS URL correction, remove when going live
    var url = location.href;
    url = url.replace(/^http:\/\/[a-z]+\.u\./i,'http://www.');
    encodedurl = encodeURIComponent(url);
    var encodedtitle = encodeURIComponent(document.title);

    var serviceUrl = null;
    if (service == 'delicious') {
        serviceURL = 'http://del.icio.us/post?v=4&noui&jump=close'
            + '&url='      + encodedurl
            + '&title='    + encodedtitle;
    } else if (service == 'digg') {
        serviceURL = 'http://digg.com/submit?phase=2'
            + '&url='      + encodedurl
            + '&title='    + encodedtitle;
    } else if (service == 'facebook') {
        serviceURL = 'http://www.facebook.com/sharer.php'
            + '?u=' + encodedurl
            + '&t=' + encodedtitle;
    } else if (service == 'fark') {
        serviceURL = 'http://www.fark.com/cgi/fark/submit.pl'
            + '?new_url='     + encodedurl
            + '&new_comment=' + encodedtitle;
    } else if (service == 'google') {
        serviceURL = 'http://www.google.com/bookmarks/mark?op=add'
            + '&bkmk='       + encodedurl
            + '&title='      + encodedtitle
            + '&labels='     + ''
            + '&annotation=' + '';
    } else if (service == 'newsvine') {
        serviceURL = 'http://www.newsvine.com/_tools/seed&save'
            + '?u='      + encodedurl;
    } else if (service == 'reddit') {
        serviceURL = 'http://reddit.com/submit'
            + '?url='      + encodedurl
            + '&title='    + encodedtitle;
    } else if (service == 'slashdot') {
        serviceURL = 'http://slashdot.org/bookmark.pl'
            + '?url='   + encodedurl
            + '&title=' + encodedtitle;
    } else if (service == 'technorati') {
        serviceURL = 'http://technorati.com/faves?sub=favthis'
            + '&add=' + encodedurl;
    } else if (service == 'twitter') {
        serviceURL = 'http://twitter.com/home?status='+encodedtitle+': '+encodedurl;
    } else if (service == 'stumbleupon') {
        serviceURL = 'http://www.stumbleupon.com/submit?url='+encodedurl+'&title='+encodedtitle;
    } else if (service == 'svejonet') {
        serviceURL = 'http://svejo.net/story/submit_by_url?url='+encodedurl;
    } else if (service == 'identica') {
		serviceURL = 'http://identi.ca/?action=newnotice&status_textarea='+encodedtitle+' '+encodedurl
    } else if (service == 'netvibes') {
		serviceURL = 'http://www.netvibes.com/share?title='+encodedtitle+'&url='+encodedurl
    }
    
    if ( serviceURL != null ) {
        var theNewWin = window.open(serviceURL,'sfgateshare','width=900,height=640,resizable=yes,toolbar=no,location=no,scrollbars=yes');
        if ( typeof theNewWin != "undefined" &&
             theNewWin != null ) {
            theNewWin.focus();
        }
    }
}

