/* 
=========================================================================================================
Copyright 	: Copyright (c) 2009 JPL & The Hershey Company, Inc. All Rights Reserved.
Author(s) 	: J Jackson - jjackson@jplcreative.com
Date      	: 08/26/2009
Notes     	: js for share functionality
=========================================================================================================
			REQUIRES JQUERY */

$(document).ready(function(){

	// share it functionality
	$('a#btn').click( function () {
		if ($.browser.msie && $.browser.version=="6.0") { $('ul#list').css('display','block'); }
		else { $('ul#list').fadeIn('slow'); }
	});
	$("ul#list").hover(
		function () { },
		function () {
			if ($.browser.msie && $.browser.version=="6.0") { $(this).css('display','none'); }
			else { $('ul#list').fadeOut('slow'); }
		}
    );
	$('li.mix a, li.dig a, li.fac a, li.del a, li.red a, li.stu a, li.mys a').click( function () {
		var service = $(this).attr('href');
		assignURLstrings(service)
	});
	
	// url string variables
	var P_URL = jQuery(document.location).attr('href');
	var P_TITLE = 'default';
	
	// send to correct url
	function assignURLstrings(service) {
		
		P_TITLE = $('title').text();
		P_TITLE = escape(P_TITLE);
		P_URL = escape(P_URL);
			
		if (service == '#delicious') { window.location = 'http://del.icio.us/post?url=' + P_URL + '&amp;title=' + P_TITLE; }
		else if (service == '#digg') { window.location = 'http://digg.com/submit?phase=2&amp;url=' + P_URL + '&amp;title=' + P_TITLE; }
		else if (service == '#facebook') { window.location = 'http://www.facebook.com/share.php?u=' + P_URL + '&amp;t=' + P_TITLE; }
		else if (service == '#mixx') { window.location = 'http://www.mixx.com/submit?page_url=' + P_URL + '&amp;title=' + P_TITLE; }
		else if (service == '#myspace') { window.location = 'http://www.myspace.com/Modules/PostTo/Pages/?u=' + P_URL + '&amp;t=' + P_TITLE; }
		else if (service == '#reddit') { window.location = 'http://reddit.com/submit?url=' + P_URL + '&amp;title=' + P_TITLE; }
		else if (service == '#stumbleupon') { window.location = 'http://www.stumbleupon.com/submit?url=' + P_URL + '&amp;title=' + P_TITLE; }	
	}
	
});