// JavaScript Document

// Build an URL for the share service passed in the function argument
function share_this(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 == 'twitter') {
	        serviceURL = 'http://twitter.com/home/'
	            + '?status='      + 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'
		//serviceURL = 'http://www.newsvine.com/_tools/seed&save?u='		
            + '?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 == 'mixx') {
		serviceURL = 'http://www.mixx.com/submit/story'
            + '?page_url=' + encodedurl
            + '&title=' + encodedtitle;

	} else if (service == 'linkedin') {
		serviceURL = 'http://www.linkedin.com/shareArticle?mini=true'
		    + '&url=' + encodedurl
		    + '&add=' + encodedurl
		    + '&title=' + encodedtitle;

	} else if (service == 'yahoobuzz') {
		//serviceURL = 'http://technorati.com/faves?sub=favthis'
		//	+ '&add=' + encodedurl;

	} else if (service == 'stumbleupon') {
		serviceURL = 'http://www.stumbleupon.com/submit'
		    + '?url=' + encodedurl
		    + '&title=' + encodedtitle;
	}



    if ( serviceURL != null ) {
        var theNewWin = window.open(serviceURL,'sharethis','width=900,height=640,resizable=yes,toolbar=no,location=no,scrollbars=yes');
        if ( typeof theNewWin != "undefined" &&
             theNewWin != null ) {
            theNewWin.focus();
        }
    }
    // remove the layer.
    document.getElementById('popup').style.display='none';
}
// end


