// Indigo Milano
// www.indigo.it
// Nessun diritto alla distribuzione

function urlencode(txt) {
	txt = txt.replace(/ /g,'+');
	txt = txt.replace(/&/g,'%26');
	txt = txt.replace(/=/g,'%3D');
//	txt = txt.replace(/\//g,'%2F');
  return txt;
}

function facebook(text,url) {

  if (url) {
	  u= encodeURIComponent(url);
	} else {
	  u= encodeURIComponent(location.href);
	}

	t= encodeURIComponent(text);

	window.open('http://www.facebook.com/sharer.php?u='+u+'&t='+t,'fbsharer','toolbar=0,status=0,width=626,height=436')

}

function twitter(txt) {

  var status = '';

  if (document.all) {
    status = txt.split(" ").join("+");
	} else {
	  status = txt.replace(/ /g,"+");  
	}
	
	window.open("http://www.twitter.com/?status="+status, "TwitterPop", "width=740, height=600, location, status, scrollbars, resizable");

}

if (typeof(texttoshare) == "undefined") {
	texttoshare = "Vieni a visitare il sito Sunnyway";
}

var jn = texttoshare.split('|');

if (jn.length > 1) {
  texttoshare = jn[0];
	linktoshare = jn[1];
} else {
  linktoshare = location.href;
}

function shareTwitter() {
  var txt = texttoshare+' '+linktoshare;
	twitter(txt);
  return false;
}
function shareFacebook() {
	facebook(texttoshare,linktoshare);
  return false;
}

