//confirm box
var confirm_box_callback_function;

function confirmBox(confirm_text,command)
{
    confirm_box_callback_command = command;
    $('confirm_box_content').innerHTML = confirm_text;
    $('confirm_box').style.display = "";
    setElementCenterScreen('confirm_box');
}

function confirmBoxClicked(confirm_value)
{
    if (confirm_box_callback_command)
    {
        if (confirm_value)
        {
            eval(confirm_box_callback_command);
            confirm_box_callback_command = undefined;
        }
        $('confirm_box').style.display = "none";
    }
}

function popupRatingBox(mb_id)
{
	var left = $('member_rate_section_' + mb_id).style.left;
	var top = $('member_rate_section_' + mb_id).style.top;
    $('member_rate_section_'+mb_id).style.display = "none";
	$('rating_box_'+mb_id).style.display = "";
	$('rating_box_'+mb_id).style.left = left;
	$('rating_box_'+mb_id).style.top = top;
	$('rating_box_'+mb_id).style.position = 'static';
}
function closeRatingBox(mb_id)
{
    $('member_rate_section_'+mb_id).style.display = "";
	$('rating_box_'+mb_id).style.display = "none";
}

function choosingRate(mb_id,value)
{
    for (i=1;i<=value;i++)
    {
        $('rating_star'+i+"_"+mb_id).className = 'danhgiasao active';
    }
}

function resetRate(mb_id)
{
    for (i=1;i<=5;i++)
    {
        $('rating_star'+i+"_"+mb_id).className = 'danhgiasao';
    }
}

function rateMember(mb_id,rate_value)
{
    closeRatingBox(mb_id);
    callAJAX("xoad_rating_handler","rateMember",$H({mb_id:mb_id,rate_value:rate_value}),rateMember_callback);
}

function rateMember_callback(result)
{
    msgBox(result);
}

var mouseX = 0;
var mouseY = 0;

function getMousePos()
{
   mouseX = event.x;
   mouseY = event.y;
}
function getMousePosMOZ(e)
{
   mouseX = e.pageX;
   mouseY = e.pageY;
//   msgBox(mouseX + " " + mouseY);
}
if (!document.all)
{
    window.captureEvents(Event.CLICK);
    window.onclick=getMousePosMOZ;
}
else
{
    document.onclick=getMousePos;
}

function sendMessage(receiver)
{
    showLoading();
    callAJAX("xoad_rating_handler","sendMessage",$H({receiver:receiver}),sendMessage_callback);
}

function sendMessage_callback(result)
{    
    endLoading();
    if (result=="OK")
    {
        
        $('message_box').style.display = "";
        setElementCenterScreen('message_box');
    }
    else
    {
        msgBox(result);
    }
}

function sendMessageTo(receiver)
{
	$('message_box').style.display = "none";
	showLoading();
	callAJAX("xoad_rating_handler","sendMessageTo",$H({receiver:receiver,subject:$('subject').value, message:$('message_content').value}),sendMessageTo_callback);
}

function sendMessageTo_callback(result)
{
    endLoading();
	msgBox(result);
}

function cancelSendMessageTo()
{
    $('message_box').style.display = "none";
}

function cancelSendMessage()
{
    $('message_box').style.display = "none";
}

function replyMessage(receiver,message_id, sent_date)
{
	callAJAX("xoad_rating_handler","replyMessage",$H({receiver:receiver, message_id:message_id, sent_date:sent_date}),sendMessage_callback);
}


function showHighestRateMember()
{
    $('rate_member_text').style.display = '';
    $('rate_member_link').style.display = 'none';
    $('newest_member_link').style.display = '';
    $('newest_member_text').style.display = 'none';
	$('random_member_link').style.display = '';
    $('random_member_text').style.display = 'none';
    $('active_member_link').style.display = '';
    $('active_member_text').style.display = 'none';
    $('thanh_vien_tieu_bieu_section').style.display ='';
    $('thanh_vien_moi_nhat_section').style.display ='none';
	$('thanh_vien_ngau_nhien_section').style.display ='none';
    $('thanh_vien_nang_dong_section').style.display ='none';
}

function showNewestMember()
{
    $('rate_member_text').style.display = 'none';
    $('rate_member_link').style.display = '';
    $('newest_member_link').style.display = 'none';
    $('newest_member_text').style.display = '';
	$('random_member_link').style.display = '';
    $('random_member_text').style.display = 'none';
    $('active_member_link').style.display = '';
    $('active_member_text').style.display = 'none';
    $('thanh_vien_tieu_bieu_section').style.display ='none';
    $('thanh_vien_moi_nhat_section').style.display ='';
	$('thanh_vien_ngau_nhien_section').style.display ='none';
    $('thanh_vien_nang_dong_section').style.display ='none';
}

function showRandomMember()
{
    $('rate_member_text').style.display = 'none';
    $('rate_member_link').style.display = '';
    $('newest_member_link').style.display = '';
    $('newest_member_text').style.display = 'none';
	$('random_member_link').style.display = 'none';
    $('random_member_text').style.display = '';
    $('active_member_link').style.display = '';
    $('active_member_text').style.display = 'none';
    $('thanh_vien_tieu_bieu_section').style.display ='none';
    $('thanh_vien_moi_nhat_section').style.display ='none';
	$('thanh_vien_ngau_nhien_section').style.display ='';
    $('thanh_vien_nang_dong_section').style.display ='none';
}

function showActiveMember()
{
    $('rate_member_text').style.display = 'none';    
    $('newest_member_text').style.display = 'none';	
    $('random_member_text').style.display = 'none';  
    $('active_member_text').style.display = '';
    $('rate_member_link').style.display = '';
    $('newest_member_link').style.display = '';
    $('random_member_link').style.display = '';
    $('active_member_link').style.display = 'none';
    $('thanh_vien_tieu_bieu_section').style.display ='none';
    $('thanh_vien_moi_nhat_section').style.display ='none';
	$('thanh_vien_ngau_nhien_section').style.display ='none';
    $('thanh_vien_nang_dong_section').style.display ='';
}

function showMostViewedPhoto()
{
    $('most_view_photo_text').style.display = '';
    $('most_view_photo_link').style.display = 'none';
    $('newest_photo_link').style.display = '';
    $('newest_photo_text').style.display = 'none';
    $('viewed_photo_section').style.display ='';
    $('new_photo_section').style.display ='none';
	$('random_photo_link').style.display = '';
    $('random_photo_text').style.display = 'none';
	$('random_photo_section').style.display ='none';
}

function showNewestPhoto()
{
    $('most_view_photo_text').style.display = 'none';
    $('most_view_photo_link').style.display = '';
    $('newest_photo_link').style.display = 'none';
    $('newest_photo_text').style.display = '';
    $('viewed_photo_section').style.display ='none';
    $('new_photo_section').style.display ='';
	$('random_photo_link').style.display = '';
    $('random_photo_text').style.display = 'none';
	$('random_photo_section').style.display ='none';
}

function showRandomPhoto()
{
    $('most_view_photo_text').style.display = 'none';
    $('most_view_photo_link').style.display = '';
    $('newest_photo_link').style.display = '';
    $('newest_photo_text').style.display = 'none';
    $('viewed_photo_section').style.display ='none';
    $('new_photo_section').style.display ='none';
	$('random_photo_link').style.display = 'none';
    $('random_photo_text').style.display = '';
	$('random_photo_section').style.display ='';
}

function shareFacebookLHXDD()
{
	window.open("http://www.facebook.com/share.php?u=" + application_url + 'the-le-le-hoi-xdd.html', "_blank");
}

function shareFacebook() {
    window.open("http://www.facebook.com/share.php?u=" + window.location.protocol + "//" + window.location.host + window.location.pathname, "_blank");    
}

function shareTwitter(title) {
    window.open("http://twitter.com/home?status=" + title + " " + window.location.protocol + "//" + window.location.host + window.location.pathname, '_blank');
}

function setZeroAlert_old()
{
	$('cnt_alert').innerHTML = 0;
	callAJAX("xoad_handler_reload","inactiveReadNotification",$H({}));
	
	if ( document.getElementById('box_header_alert_comment').className == 'ctn_photo' )
	{
		document.getElementById('box_header_alert_comment').className = 'ctn_photo click';
		document.getElementById('id_notice_list').className = 'cnt_t click';
	}
	else
	{
		document.getElementById('box_header_alert_comment').className = 'ctn_photo';
		document.getElementById('id_notice_list').className = 'cnt_t';
	}
}

function inactiveANotification(noti_id)
{
	callAJAX("xoad_handler_reload","inactiveANotification",$H({noti_id:noti_id}));
}
