//*********
//LISTA DOS NOMES DAS PESSOAS

var pessoas = [
			{nome:'andreabid',img:'img/_bid_pequeno.jpg',cargo:'Diretora', fraseum:'Im at <span class=desthash >#cherryplus</span>).', frasedois:''},
			
			{nome:'cherryplus',img:'img/_cherry_pequeno.jpg',cargo:'institucional', fraseum:'Por do Sol lindo aqui na <span class=desthash >#cherryplus</span> =D', frasedois:'Quem não ama Cupcake de Cherry?'},
			
			{nome:'fellyph',img:'img/_ph_pequeno.jpg',cargo:'Desenvolvedor Flash', fraseum:'#FF #cherryplus 1: @cherryplus @filtro @frufru @icomatias @andreabid @leonardomaciel  @juliadlakmin', frasedois:'hora da goiabinha na <span class=desthash >#cherryplus</span>'},
			
			{nome:'nuneswagner',img:'img/_nunes_pequeno.jpg',cargo:'Front-End', fraseum:'Nova cria da <span class=desthash >#cherryplus</span> no ar. http://lelis.com.br/', frasedois:'RT: @fellyph: Almoço com a equipe <span class=desthash >#cherryplus</span> http://twitpic.com/3huv8f'},
			
			{nome:'filtro',img:'img/_fil_pequeno.jpg',cargo:'Diretor de Arte', fraseum:'o @icomatias arrasou no site novo da cherry! em breve no ar ;-) <span class=desthash >#cherryplus</span>', frasedois:'Últimos ajustes no novo site da <span class=desthash >#cherryplus</span>'},
			
			{nome:'mabsss',img:'img/_mari_pequeno.jpg',cargo:'Assistente de Arte', fraseum:' Só alegria aqui na <span class=desthash >#cherryplus</span> #adoro', frasedois:''},
						
			{nome:'caiorizzato',img:'img/_caio_pequeno.jpg',cargo:'Analista de Redes Sociais', fraseum:'o @icomatias arrasou no site novo da cherry! em breve no ar ;-) <span class=desthash >#cherryplus</span>', frasedois:'Últimos ajustes no novo site da <span class=desthash >#cherryplus</span>'},
						
			{nome:'luapontes',img:'img/_lua_pequeno.jpg',cargo:'Diretora', fraseum:'', frasedois:'semana intensa e produtiva, a gente adora! <span class=desthash >#cherryplus</span>'},
			
			{nome:'_cbrandao',img:'img/_chris_pequeno.jpg',cargo:'Conte&uacute;do/Planejamento', fraseum:'RT @Luapontes: orgulho da @cherryplus (http://twitter.com/cherryplus), é nóis no thecssawards, parabéns povo, especial pro @icomatias e @leonardomaciel http://bit.ly/bbwFzy <span class=desthash >#cherryplus</span> ', frasedois:''},
			
			{nome:'liviasalomoni',img:'img/_livia_pequeno.jpg',cargo:'Conte&uacute;do/Planejamento', fraseum:'RT @Luapontes orgulho da @cherryplus, no thecssawards, parabéns! http://bit.ly/bbwFzy <span class=desthash >#cherryplus</span>', frasedois:''},
			{nome:'tatianafauza',img:'img/_tati_pequeno.jpg',cargo:'Planejamento', fraseum:'RT @Luapontes orgulho da @cherryplus, no thecssawards, parabéns! http://bit.ly/bbwFzy <span class=desthash >#cherryplus</span>', frasedois:''}
];

function randOrd(){
	return (Math.round(Math.random())-0.5);
}

function replaceURLWithHTMLLinks(text) {
	var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
	return text.replace(exp,"<a href='$1' target='_blank' class='linktwiter' >$1</a>");
}

function replaceHash(text) {
	var exp = /(^|\s)#(\w+)/ig;
	return text.replace(exp," <span class='desthash' >#$2</span>");
}



var boxTemplate = '<li id="twits%id%" class="bxtwits" ><div class="boxInfoTwit" onmouseover="jQuery(this).slideToggle(\'fast\');" ></div><div class="character"><div id="av%id%" class="charFoto"><a href="http://twitter.com/%id%" target="_blank">%id%</a></div><div class="charContent" id="bx%id%" ><h1>%id%</h1><h4>%cargo%</h4></div></div></li>'
boxTemplate += "<script type=\"text/javascript\">jQuery(\'#av%id% a\').mouseover( function(){ jQuery(\'#twits%id% .boxInfoTwit\').fadeIn(\'fast\') } );jQuery(\'#av%id% a\').mouseout( function(){ jQuery(\'#twits%id% .boxInfoTwit\').fadeOut(\'fast\') } ); </script>";

function twtscherrys(idDiv,hashtag,URLPath){
	
	
	pessoas.sort( randOrd );

	jQuery(idDiv).html('');
	jQuery(pessoas).each(function(i){
	
	//MONTA OS LIs
	var htmlTwitt = boxTemplate.replace('%img%',URLPath + pessoas[i].img);
	htmlTwitt = htmlTwitt.replace(/(%id%)/gi,pessoas[i].nome);
	htmlTwitt = htmlTwitt.replace(/(%cargo%)/gi,pessoas[i].cargo);
	
	
	
	//jQuery(idDiv).append(htmlTwitt);


		//%23ie

		jQuery.getJSON('http://search.twitter.com/search.json?q=%23cherryplus+from:' + pessoas[i].nome + '&callback=?', function(data) {

			var arAux = data.results;
			var totalIt = (arAux.length > 2)? 2 : arAux.length;

			if(arAux.length == 0){
			
				jQuery('#bx' + pessoas[i].nome ).append('<p>' + pessoas[i].fraseum + '</p>' + '<p>' + pessoas[i].frasedois + '</p>');
				
				
			}else{
			
				for(i=0;i < totalIt ;i++){
					
					var nomebx = arAux[i].from_user;
					
					jQuery('#bx' + nomebx.toLowerCase() ).append('<p>' + replaceHash( replaceURLWithHTMLLinks(arAux[i].text) ) + '</p>');
					
				}
			}

		});
		
		jQuery(idDiv).append(htmlTwitt);


	});


	ligaCarrossel( "#lstTwits",".proximoTwitter",".anteriorTwitter","",0,1 );

}
