/**
*
*  UTF-8 data encode / decode
*  http://www.webtoolkit.info/
*
**/

var Utf8 = {

    // public method for url encoding
    encode : function (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;
    },

    // public method for url decoding
    decode : function (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;
    }

}
/*********************************************************************************************************/

function repasse(obj) {
 var el = document.getElementById(obj);
 if ( el.style.height != '125px' ) {
 el.style.height = '125px';
 }
 else {
 el.style.height = 'auto';
 }
 }


function socialBookmark(svc,t,u){
	var title;
	var url;
	
	if(!t) title = encodeURI(document.title);
	else title = t;
	if(!u) url = document.location.href;
	else url = u;
	
	switch (svc){
		case 'orkut':			
			if (typeof(tn_orkut)== "undefined"){
				tn_orkut = 'http://info.abril.com.br/img/logo_info_100x100.png';
			}			
			window.open('http://promote.orkut.com/preview?nt=orkut.com&tt='+title+'&du='+url+'&tn='+tn_orkut);			
			break;
		case 'delicious':
			window.open('http://del.icio.us/post?url=' + url + '&title=' + title,'wSocialBM');
			break;
		case 'blinklist':
			window.open('http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url=' + url + '&Title=' + title,'wSocialBM');
			break;
		case 'feedmelinks':
			window.open('http://feedmelinks.com/categorize?from=toolbar&op=submit&name=' + title + '&url=' + url,'wSocialBM');
			break;
		case 'google':
			window.open('http://www.google.com/bookmarks/mark?op=edit&bkmk=' + url + '&title=' + title,'wSocialBM');
			break;
		case 'newsvine':
			window.open('http://www.newsvine.com/_wine/save?popoff=0&u=' + url + '&h=' + title,'wSocialBM');
			break;
		case 'reddit':
			window.open('http://reddit.com/submit?url=' + url + '&title=' + title,'wSocialBM');
			break;
		case 'yahoo':
			window.open('http://myweb2.search.yahoo.com/myresults/bookmarklet?t=' + title + '&u=' + url,'wSocialBM');
			break;
		case 'facebook':
			window.open('http://www.facebook.com/sharer.php?u=' + url + '&t=' + title,'wSocialBM');
			break;
		case 'technorati':
			window.open('http://technorati.com/faves?add=' + url + '&title=' + title,'wSocialBM');
			break;
		case 'digg':
			window.open('http://digg.com/submit?phase=2&url=' + url + '&title=' + title,'wSocialBM');
			break;
		case 'rec6':
			window.open('http://rec6.via6.com/link.php?url=' + url + '&title=' + title,'wSocialBM');
			break;
		case 'twitter':
			window.open('http://twitter.com/home?status=' + Utf8.encode(title) + ':%20' + url,'wSocialBM');
			break;
		case 'windowslive':
			window.open('https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url=' + url + '&title=' + title,'_self');
			break;
		case 'netvibes':
			window.open('http://www.netvibes.com/subscribe.php?type=rss&url=http://www.netvibes.com/subscribe.php?url=http://info.abril.com.br/aberto/infonews/rssnews.xml','wSocialBM');
			break;
		case 'linkk':
			window.open('http://www.linkk.com.br/submit.php?&noui&jump=close&url='+url+'&title='+title , 'wSocialBM');
		      break;
		case 'blogblogs':
			window.open('http://blogblogs.com.br/my/bookmarks/add?bookmark_url[url]=' + url + '&title=' + title,'wSocialBM');
			break;
		case 'gostei':
			window.open('http://gostei.abril.com.br/post/new?t='+title+'&u='+url, 'wSocialBM');
		case 'dihitt':
			window.open('http://dihitt.com.br?botao=enviar&url=' + url + '&title=' + title,'wSocialBM');
		break;
	}
}
