﻿function AsyncWait(btnId, btnStyle, imgId, imgStyle, imgSrc, imgTot) {
    var btn = document.getElementById(btnId);
    if (btn) {
        btn.style.display = btnStyle;
    }
    SeeMe(imgId, imgStyle);
    LoadAnim(imgId, imgSrc, imgTot);
}

var yPos;
var yPosInterval;

function ScrollPosInt() {
    yPosInterval = setInterval("getScrollPos()", 1);
}

function getScrollPos() {
    yPos = CurrentScrollPos();
}

function setScrollPos() {
    clearInterval(yPosInterval);
        window.scrollTo(0, yPos);
}

function CurrentScrollPos() {
    return f_filterResults(
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function AsyncPageLoaded(sender, args) {
    CustomColor('div', 'UserUpdateLnk', 'member_link', '5', 'ColorDiv', 'background-color:#', true);
    CustomColor('div', 'UpdateDiv', 'update_div', '5', 'ColorDiv', 'border-color:#', false);
    CustomColor('div', 'UpdateDiv', 'update_div', '5', 'ColorDiv', 'background-color:#', false);

    CustomColor('table', 'HistoryTbl', 'message_history', '5', 'ColorDiv', 'border-color:#', false);
    CustomColor('a', 'HistoryUser', 'message_hist_lnk', '5', 'ColorDiv', 'background-color:#', false);
    CustomColor('span', 'HistoryTitle', 'read_title', '5', 'ColorDiv', 'color:#', false);

    CustomColor('div', 'Album', 'album_lnk', '5', 'ColorDiv', 'border-color:#', false);
    CustomColor('div', 'Album', 'album_lnk', '5', 'ColorDiv', 'color:#', false);

    AsyncWait('ctl00_Main_Content_Btn_Talk', 'inline', 'loadImg', 'none', 'load', 10);
    AsyncWait('MailContent', 'inline', 'Img_NextLoad', 'none', 'circle', 8);
    AsyncWait('MailContent', 'inline', 'Img_PrevLoad', 'none', 'circle', 8);
    AsyncWait('HistoryContent', 'inline', 'Img_HistoryLoad', 'none', 'circle', 8);
    AsyncWait('RecentUpdateDiv', 'block', 'Img_Load', 'none', 'circle', 8);
    clearInterval(LoadInt);
}

function AsyncBeginRequest(sender, args) {
    ScrollPosInt();
}

function AsyncPageLoading(sender, args) {
    
}

function AsyncEndRequest(sender, args) {
    setScrollPos();
} 
