function  utf8Encode(string) {
	
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
		}
 
		return utftext;
}

function utf8Decode(utftext) {
	
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
		}
 
		return string;
}


// FACEBOOK
function compartilharNoFacebook(titulo, link) {
	
	fbShareUrl = 'http://www.facebook.com/sharer.php?u=' + link + '&t=' + titulo;
	
	window.open(fbShareUrl,'Facebook','height=450,width=650');
}

// TWITTER
function compartilharNoTwitter(titulo, link) {
	
	twShareUrl = 'http://twitter.com/share?url=' + link + '&text=' + titulo + '&source=riofestacom';
	
	window.open(twShareUrl,'Twitter','height=350,width=500');
}

//LINKEDIN
function compartilharNoLinkedIn(titulo, descricao, link) {
	
	lkdShareUrl = 'http://www.linkedin.com/shareArticle?mini=true&url=' + link + '&title=' + titulo + '&summary=' + descricao + '&source=RioFesta';
	
	window.open(lkdShareUrl,'LinkedIn','height=450,width=550');
}

// MYSPACE
function compartilharNoMySpace (titulo, descricao, link) {

	mspShareUrl = 'http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=' + link + '&t=' + titulo + '&c=' + descricao;
	
	window.open(mspShareUrl,'MySpace','height=450,width=550');
}

//WINDOWS LIVE
function compartilharNoWindowsLive(titulo, descricao, link) {

	winlShareUrl = 'http://profile.live.com/badge?url=' + link + '&title=' + titulo + '&description=' + descricao + '&wa=wsignin1.0';
	
	window.open(winlShareUrl,'WindowsLive','height=600,width=550');
}

// ORKUT
function compartilharNoOrkut(titulo, descricao, link, imgUrl){
	
	link = link.replace("?","%3F");
	link = link.replace("&","%26");
	link = link.replace(".br","");

	orkutShareUrl = 'http://promote.orkut.com/preview?nt=orkut.com&tt=' + titulo + '&du=' + link + '&cn=' + descricao;

	window.open(orkutShareUrl,'Orkut','height=400,width=650');
	
	/*
    var params = {};
   	    params[google.orkut.share.Field.TITLE] 			 = utf8Encode(titulo);
        params[google.orkut.share.Field.DESTINATION_URL] = link;
    	params[google.orkut.share.Field.CONTENT] 		 = utf8Encode(descricao);
    	params[google.orkut.share.Field.THUMBNAIL] 		 = imgUrl;
    	
		var connection = new google.orkut.share.Connection(params);
    	
		connection.send('orkut.com', {}); 
	*/
}
			
