/**
 * @author jins
 */
$(document).ready(function() {
	loginPop();
	startListUI();
});

function showAlert(str)
{
	$("#alert_cont").slideDown("slow", function(){setTimeout("hideAlert()", 3000);})
		.click(function(){hideAlert();});
	$("#alert_txt").text(str);
}

function hideAlert()
{
	$("#alert_cont").slideUp("slow");
	//$("#alert_txt").text('');
}

function loginPop()
{
	$("a#btn_login_pop").click(function(){
		$("div#login").toggle();
		$("#login_userid").focus();
	});
	
	$("#a_forget_username").mouseover(function(){
	    $("img#forget_username").show();
	}).mouseout(function(){
	    $("img#forget_username").hide();
	});

}

function getTweetByUser(user)
{
	$.jTwitter(user, 3, function(data){
		$("div#twt_following span.num").text(addCommas(data[0].user.friends_count));
		$("div#twt_followers span.num").text(addCommas(data[0].user.followers_count));
		$("div#twt_updates span.num").text(addCommas(data[0].user.statuses_count));
        $.each(data, function(i, post){
            $('#twt_list').append(
                '<li>'
            		+ cleanTweet(post.text)
                +'</li>'
            );
        });
    });
}

function startListUI()
{
	$("div.list ul li").mouseover(function(){
		$(this).find("div.video img.play_lay").show();
	}).mouseout(function(){
		$(this).find("div.video img.play_lay").hide();
	});
	
	$("div.list_main ul li").mouseover(function(){
		$(this).find("div.video img.play_lay").show();
	}).mouseout(function(){
		$(this).find("div.video img.play_lay").hide();
	});
}

function getMyRecords(dir)
{
	var page = parseInt($("#my_records").attr("rel"));
	
	if(dir == "next")
		page += 1;
	else page -= 1;
	
	if(page < 1) page = 1;
	
	var sendData = "todo=myrecs&p="+page
	var baseUrl = "/";
	
    $.ajax({
        type: "POST",
        url: baseUrl,
        dataType: "html",
        data: sendData,
        success: function(result){
    		$("#my_rec_conts").html(result);
    		$("#my_records").attr("rel", page);
        }
    });
}