/**
 * @author c809907
 */
/**
 * @author C809907
 */
////excludes and includes for the social toolbar
$(document).ready(function (){
	$('#BNSF_social-toolbar').show()
	var l = this.location.href
	if (
	l.indexOf('financial-information') >= 0 ||
	l.indexOf('financial-information') >= 0 ||
	l.indexOf('communities/contact-us') >= 0 ||
	l.indexOf('our-people') >= 0 ||
	l.indexOf('our-officers') >= 0 ||
	l.indexOf('communities/contact-us/') >= 0 ||
	l.indexOf('about-bnsf/contact-us/') >= 0 ||
	l.indexOf('employees/contact-us/') >= 0 ||
	l.indexOf('media/contact-us/') >= 0 ||
	l.indexOf('exempt-retirees/contact-us/') >= 0 ||
	l.indexOf('scheduled-retirees/contact-us/') >= 0 ||
	l.indexOf('/customers/') >= 0  ||
	l.indexOf('/careers/') >= 0  ||
	l.indexOf('/suppliers/') >= 0  ||
	l.indexOf('domestic-containers-and-trailers/prohibited-commodities.html') >= 0
		){
		$('#BNSF_social-toolbar-IE6 li.optional').addClass('hidden')
		$('#BNSF_social-toolbar li.optional').addClass('hidden')
		}	
})
var u;

function setValue(){

    bnsf_title = window.document.title;
    split_title = bnsf_title.split(" - ");
    s = "I found this on bnsf.com!";
    u = $('form[name=emailer] textarea[name=ReferringURL]').text();//location.href;
    t1 = split_title.slice(0, 1);
    t2 = split_title.slice(-1);
	d = $.trim($('#contentarea p:first').text())
	
   
    if (split_title.length > 1) {
        t = t1 + "-" + t2;
    }
    else {
        t = t1
    }
};
/*removed Sep 12, og meta not needed right now. JHowes
/*function setMeta(){
	setValue();
 	var og_i = '<meta property="og:image" content="http://www.bnsf.com/images/thumb.jpg"/>';
	var og_t='<meta property="og:title" content="'+bnsf_title+'"/>';
	var og_u ='<meta property="og:url" content='+u+'/>';
	var og_d = '<meta property="og:description" content="'+d+'"/>';
	var og_type = '<meta property="og:type" content="website"/>';
	var description = '<meta name="description" content="'+d+'"/>';
	$('head').append(og_i).append(og_u).append(og_t).append(og_type).append(og_d).append(description);
};*/
/*$(document).ready(function(){	
setMeta();
});*/
function bnsf_twitter(){
	setValue()	
	BitlyCB.shortenResponseCB = function(data){
		var result;
		var short_u;
		for (var r in data.results) {
			result = data.results[r];
			result['longUrl'] = r;
			break;
		};
			short_u = result['shortUrl'];
			var string_short=unescape(short_u);
		if (string_short.indexOf('undefined') >= 0) {
			var tweetString = "http://twitter.com/home?status=" + t + " - " + u;
			}
			else{
			var tweetString = "http://twitter.com/home?status=" + t + " - " + short_u;
		}  
		$('.twitter-bw').attr('href', tweetString) 
			
	}
	BitlyClient.shorten(u, 'BitlyCB.shortenResponseCB');
};

function bnsf_stumble(){
    setValue();
	
		var stumbleString = "http://www.stumbleupon.com/submit?url=" + u;
			$('.stumble-bw').attr('href', stumbleString) 
	
};
function bnsf_facebook(){
    setValue();
 	
	BitlyCB.shortenResponseFB = function(data){
		var result;
		var short_u;
		for (var r in data.results) {
			result = data.results[r];
			result['longUrl'] = r;
			break;
			};
		short_u = result['shortUrl'];
		var string_short=unescape(short_u);
		if (string_short.indexOf('undefined') >= 0) {
			var facebookString = "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(u) + '&t=' + t;
		}
		else {
			var facebookString = "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(short_u) + '&t=' + t;
		}
		$('.facebook-bw').attr('href', facebookString)	
	};
	BitlyClient.shorten(u, 'BitlyCB.shortenResponseFB');	
};

function bnsf_delicious(){
    setValue();
   
    BitlyCB.delicious_shortenResponse = function(data){
        var result;
		var short_u;
        for (var r in data.results) {
            result = data.results[r];
            result['longUrl'] = r;
            break;
        };
        short_u = result['shortUrl'];
		var string_short=unescape(short_u);
		if (string_short.indexOf('undefined') >= 0) {
			var deliciousString = "http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url=" + encodeURIComponent(u) + "&amp;title=" + t;
		}
		else {
			var deliciousString = "http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url=" + encodeURIComponent(short_u) + "&amp;title=" + t;
		}
		$('.delicious-bw').attr('href', deliciousString)
    };
	 BitlyClient.shorten(u, 'BitlyCB.delicious_shortenResponse');
};

function bnsf_digg(){ 
 setValue();
 
    BitlyCB.digg_shortenResponse = function(data){
		var result;
		var short_u;
		for (var r in data.results) {
			result = data.results[r];
			result['longUrl'] = r;
			break;
		};
		short_u = result['shortUrl'];
		var string_short=unescape(short_u);
		if (string_short.indexOf('undefined') >= 0) {
			var diggString = "http://www.digg.com/submit?url=" + u + '&title=' + t;
		}
		else {
			var diggString = "http://www.digg.com/submit?url=" + short_u + '&title=' + t;
		}
			$('.digg-bw').attr('href', diggString)
	};  
   BitlyClient.shorten(u, 'BitlyCB.digg_shortenResponse');
};


function bnsf_linkedin(){
    setValue();
  
    BitlyCB.linked_shortenResponse = function(data){
        var result;
		var short_u;
        for (var r in data.results) {
            result = data.results[r];
            result['longUrl'] = r;
            break;
        };
        short_u = result['shortUrl'];
		var string_short=unescape(short_u);
		if (string_short.indexOf('undefined') >= 0) {
			var linkedString = "http://www.linkedin.com/shareArticle?mini=true&url=" + u + "&title=" + t + "&summary=" + s + "&source=" + u;
		}
		else {
			var linkedString = "http://www.linkedin.com/shareArticle?mini=true&url=" + short_u + "&title=" + t + "&summary=" + s + "&source=" + u;
		}
		$('.linkedin-bw').attr('href', linkedString)
    
    };
	  BitlyClient.shorten(u, 'BitlyCB.linked_shortenResponse');
};

function bnsf_reddit(){
setValue();
 
  BitlyCB.reddit_shortenResponse = function(data){
	var result;
	var short_u;
	for (var r in data.results) {
		result = data.results[r];
		result['longUrl'] = encodeURIComponent(r);
		break;
		};
		short_u = result['shortUrl'];
		var string_short=unescape(short_u);
		if (string_short.indexOf('undefined') >= 0) {
			var redditString="http://reddit.com/submit?url=" + encodeURIComponent(u) + "&title=" + encodeURIComponent(t);
		}
		else {
		var redditString = "http://reddit.com/submit?url=" + encodeURIComponent(short_u) + "&title=" + encodeURIComponent(t);
		}
		$('.reddit-bw').attr('href', redditString)
	};  
BitlyClient.shorten(u, 'BitlyCB.reddit_shortenResponse');

};

