var link = 'http://www.duloren.com.br/';
//var siteBase = 'http://www.duloren.com.br/';
var siteBase = "http://simplesagencia.dyndns.info/duloren/";
var siteOnlineTemp = "http://www.duloren.com.br/";

var social = 
{
	link 	: 	siteBase,
	urlImg  : {
		capa		: siteBase + 'perfil_rede_globo.jpg',
		resultado 	: siteBase + 'data/flyers'
	},
	textos 	:
	{
		titulo 		:	"A gente se liga em você",
		facebook 	:	"A @rede_globo chegou a um milhão de seguidores e fez um mosaico em homenagem a todos que curtem seu perfil. Já viu quem está por lá?",
		twitter		: 	"A @rede_globo homenageia seu primeiro milhão de seguidores com um mosaico. Confira!"
	},		
	getTexto	: function (rede, hash) {
		//resultado = ( rede == 'twitter' ) ? this.textos.resultado + ' %23Cartõesdefimdeanodaglobo' : this.textos.resultado;
		resultado = this.textos.resultado;
		return ( hash == null ) ? this.textos.capa : resultado;
	},
	getLink : function(hash) {
		return this.link;
	},
	getUrlImg : function(hash) {
		if ( hash == null ) return this.urlImg.capa;
		
		var h1 = hash.substr(0,2);
		var h2 = hash.substr(2,2);	
		return this.urlImg.resultado + '/' + h1 + '/' + h2 + '/' + hash + '.jpg';
	},
	// Twitter API
	twitter:function(hash)
	{
		var url = 'http://twitter.com/intent/tweet?text=' + this.textos.twitter + '&hashtags=duloren&url=' + this.getLink(hash);
		window.open(url, 'intent', 'scrollbars=yes,resizable=no,toolbar=no,location=yes,width=550,height=420');
		
		return true;
	},
	// Facebook API
	facebook:function(hash)
	{

		var url = 'http://www.facebook.com/sharer.php?s=100';
		url += '&p[title]=' 	+ this.textos.titulo;
		url += '&p[url]=' 		+ this.getLink(hash);
		url += '&p[summary]=' 	+ this.textos.facebook;
		url += '&p[images][0]=' + this.getUrlImg(hash);
		
//		window.open(url,'facebook');
		window.open(url, 'intent', 'scrollbars=yes,resizable=no,toolbar=no,location=yes,width=1050,height=550');		
		return true;
	},
	// Orkut API
	orkut:function(hash)
	{
		var url = 'http://promote.orkut.com/preview?nt=orkut.com';
		url += '&du=' 	+ this.getLink(hash);
		url += '&tt=' 	+ this.textos.titulo;
		url += '&cn=' 	+ this.textos.facebook;
		url += '&uc=' 	+ this.textos.facebook;
		url += '&tn=' 	+ this.getUrlImg(hash);		
		
		window.open(url,'orkut');
		return true;
	}
};
function getSocialObj(){
	return social;
}
function fireFacebook(obj){
	social.link = siteBase + encodeURIComponent(obj.urlPath);
	social.textos.titulo = encodeURIComponent(obj.titulo);
	social.textos.facebook = encodeURIComponent(obj.texto);
	social.urlImg.capa = obj.thumb.replace("http://simplesagencia.dyndns.info/duloren/","http://www.duloren.com.br/"); // TEMP para testar no DYNDNS
	social.facebook();
}
function fireTwitter(obj){
	social.link = siteBase + encodeURIComponent(obj.urlPath);
	social.textos.twitter = encodeURIComponent(obj.texto);
	social.twitter();
}
function fireOrkut(obj){
	social.link = siteBase + encodeURIComponent(obj.urlPath);
	social.textos.titulo = encodeURIComponent(obj.titulo);
	social.textos.facebook = encodeURIComponent(obj.texto);
	social.urlImg.capa = obj.thumb.replace("http://simplesagencia.dyndns.info/duloren/","http://www.duloren.com.br/"); // TEMP para testar no DYNDNS
	social.orkut();
}
