$(document).ready(function() {

$("#tags a").bind("click",function(){
$("#livesearch").css("display","block");
$(this).find(".replay").css("display","inline");
document.getElementById('twitterq').value=$(this).attr("href");
$('body').animate({
scrollTop:100}, 1000);
twitterq = $('#twitterq').attr('value');
		
			
		$.ajax({
			type: "POST",
			url: "search.php",
			cache: false,
			data: "twitterq="+ twitterq,
			success: function(html){
				$("#twitter-results").html(html);
				displayTweet();
			}
		});
return false;


});

$("li").bind("mouseover",function(){
$(this).find(".replay").css("display","inline");
$(this).find(".rt").css("display","inline");
$(this).find(".follow").css("display","inline");
$(this).find(".dm").css("display","inline");
$(this).find(".follow").html("Followed").css("color","#B2E45D");
});
$("li").bind("mouseout",function(){
$(this).find(".replay").css("display","none");
$(this).find(".dm").css("display","none");
$(this).find(".follow").css("display","none");
$(this).find(".rt").css("display","none");

});
  $('a.jt').cluetip({
  cluetipClass: 'jtip', 
  arrows: true, 
  dropShadow: false,
  hoverIntent: false,
  sticky: true,
  mouseOutClose: true,
  splitTitle:',',
  closePosition: 'title',
  closeText: '<img src="http://www.twittoma.com/images/cross.png" alt="close" />'
});
 var twitterq = '';
   
  function displayTweet(){
	var i= 0;
	var limit = $("#twitter-results > li").size();
	var myInterval = window.setInterval(function () {
	var element =  $("#twitter-results li:last-child");
	$("#twitter-results").prepend(element);
	element.fadeIn("slow");
	i++;
	
		
	},2000);
  }
 	
	
	$("form#twittersearch").submit(function() {
		twitterq = $('#twitterq').attr('value');
		
			
		$.ajax({
			type: "POST",
			url: "search.php",
			cache: false,
			data: "twitterq="+ twitterq,
			success: function(html){
				$("#twitter-results").html(html);
				displayTweet();
			}
		});
		return false;
		});

  });

function compteur()
{
document.getElementById("spn").style.fontWeight="normal";
document.getElementById("spn").style.color="black";
document.getElementById("spn").innerHTML=140-(document.getElementById("status").value.length);
if(140-(document.getElementById("status").value.length)<=0)
{
document.getElementById("spn").style.color="#FF0000";
document.getElementById("spn").innerHTML=140-(document.getElementById("status").value.length);
}
if((140-(document.getElementById("status").value.length)<=20)&&(140-(document.getElementById("status").value.length)>=0))
{
document.getElementById("spn").style.fontWeight="bold";
document.getElementById("spn").innerHTML=140-(document.getElementById("status").value.length);
}
}
function fading(){

$("#flash").fadeIn();
$("#form1").fadeOut();
timer=setTimeout("fade()",6000);
clearTimeout(timer);
$("#flash").fadeOut();
$("#form1").fadeIn();

}


function get(){
if(document.getElementById('status').value.length>0){
var i=document.getElementById('status').value;

var lien="http://www.twittoma.com/index/afficher/st/"+i;

getData(lien, 'contenuAjax');
document.getElementById('status').value="";
//fading();

//test("http://www.twittoma.com/index/updfriendtwe","contenuAjax");
document.getElementById('spn').innerHTML="140";
}
else{
	return false;
}



}

function logout(){



var lien="http://www.twittoma.com/index/logout";
getData(lien, 'targetDiv');

}


function follow(user){
//var text=String(document.location);
//var temp=text.substring(text.lastIndexOf("/")+1);
//var user=temp.replace("#","");

var lien="http://www.twittoma.com/index/index/folow/"+user;
getData(lien, 'folowC');
}


/*$(function(){

$("#rt a").click(function(){
//$("h3.services").not(this).removeClass("selected");
//$(this).toggleClass("selected");
alert($(this).attr("href"));
return;
//$(this).parent().children("div").removeClass('active');
//$(this).next(".ctn").slideToggle("slow");
//$(this).next(".ctn").addClass('active');	
	//$(".ctn:not(.active)").hide("slow");
		
	});
	});*/




function rt(status,user){
$('body').animate({
scrollTop:100}, 1000);
document.getElementById('status').value=" RT @"+user+" : "+status;

}
function updateBack(backCo,backIm){
document.getElementById('style').innerHTML="body{background:#"+backCo+" url("+backIm+" )no-repeat fixed;}"
getSession("http://www.twittoma.com/index/background");

}

function replay(user){
$('body').animate({
scrollTop:100}, 1000);
document.getElementById('status').value="@"+user;
return;
}




function hide(){
$(this).hide();
}
function show(){
$('.cc').hide();
$(this).next().show();

}
function getUser(user){
$('#userdiv').fadeOut(2000);
getUs("http://www.twittoma.com/"+user, 'userdiv');
$('#userdiv').fadeIn(2000);
return;
}
function fade(){
$('#userdiv').fadeOut(2000);
}

      
function dm(user){
$('body').animate({
scrollTop:100}, 1000);
document.getElementById('status').value="D "+user;
} 
