﻿//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function Get_Element_By_Id_4(doc,wi_ch2,First_Frame)
{
    var ret= doc.getElementById(wi_ch2);
    if (ret!=null) return ret;
    wi_ch2="UC_"+First_Frame+"_"+wi_ch2;
    return Get_Element_By_Id_2(doc,wi_ch2);
}
function Get_Element_By_Id_3(doc, wi_ch2) {
    var Pre_Def = "";
    var d = doc.getElementById(Pre_Def + wi_ch2);
    if (d == null) {
        Pre_Def = 'ctl00_';
        d = doc.getElementById(Pre_Def + wi_ch2);
    }
    return d;
}
//******************************************************************************
function Get_Element_By_Id_2(doc, wi_ch2) {
    //var id=M_GetFormID2();
    var d=null;
    d=Get_Element_By_Id_Sub(doc,wi_ch2)
        if (d == null) {
            d = Get_Element_By_Id_Sub2(doc, wi_ch2)
        }
    return d;
}

function Get_Element_By_Id_Sub(doc, wi_ch2) {
    var Pre_Def = "";
    try { } catch (exp) { }
    var d = doc.getElementById(Pre_Def + wi_ch2);
    if (d == null) {
        Pre_Def = 'ctl00_ctl00_ContentPlaceHolder1_';
        d = doc.getElementById(Pre_Def + wi_ch2);
        if (d == null) {
            Pre_Def = 'ctl00_ContentPlaceHolder1_';
            d = doc.getElementById(Pre_Def + wi_ch2);
        }
        if (d == null) {
            Pre_Def = 'ctl00_';
            d = doc.getElementById(Pre_Def + wi_ch2);
        }
        
    }
    return d;
}
//**********************************************************************************
function Get_Element_By_Id_Sub2(doc,wi_ch2)
{
    var d = doc.getElementsByTagName('*');
    for (var i1 = 0; i1 < d.length; i1++) {
        if (d[i1].id.indexOf(wi_ch2) >= 0) {
            return d[i1];
        }
    }
    return null;
}

//*********************************************************************************/
function Get_Element_By_Id(doc, wi_ch2) {
    var D1=Get_Element_By_Id_Sub(doc,wi_ch2);
    if (D1!=null) return D1;
    var d = doc.getElementsByTagName('*');
    for (var i1 = 0; i1 < d.length; i1++) {
        if (d[i1].id.indexOf(wi_ch2) >= 0) {
            return d[i1];
        }
    }
    return null;
}
/*********************************************************************************/
/*********************************************************************************/
function mouseOverItem(tab_table) {
    if (!tab_table.getAttribute('active'))
        tab_table.className = "S_Menu_Item_Over";
}
/*********************************************************************************/
/*********************************************************************************/
function mouseLeaveItem(tab_table) {
    if (tab_table.getAttribute('active'))
        tab_table.className = "S_Menu_Item_Over";
    else
        tab_table.className = "S_Menu_Item";
}
var flag = 1;
function Get_Cookie(c1, check_name) {
    var a_all_cookies = c1.document.cookie.split(';');
    var a_temp_cookie = '';
    var cookie_name = '';
    var cookie_value = '';
    var b_cookie_found = false;
    for (i = 0; i < a_all_cookies.length; i++) {
        a_temp_cookie = a_all_cookies[i].split('=');
        cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
        if (cookie_name == check_name) {
            b_cookie_found = true;
            if (a_temp_cookie.length > 1) {
                cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
            }
            return cookie_value;
            break;
        }
        a_temp_cookie = null;
        cookie_name = '';
    }
    if (!b_cookie_found) {
        return null;
    }
}
function Delete_Cookie(c1, name) {
    if (Get_Cookie(c1, name)) document.cookie = name + "=" + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function Set_Cookie(c1, name, value) {
    var expires = 365 * 1000 * 60 * 60 * 24;
    var today = new Date();
    today.setTime(today.getTime());
    var expires_date = new Date(today.getTime() + (expires));
    c1.document.cookie = name + "=" + escape(value) + ";expires=" + expires_date.toGMTString();
}
function Check_Switch_Enable_Request() {
    flag++;
    if (flag > 9) flag = 0;
    Set_Cookie_To_Eleman3('Active_Switch_Request' + flag);
    setTimeout('Check_Switch_Enable_Response()', 800);
}
var last_pic = false;
function Check_Switch_Enable_Response() {
    var str = Get_Cookie_From_Eleman3();
    if (str.length > 0) str = str.substr(0, str.length - 1);
    if (str == 'Active_Switch_Response') {
        if (last_pic != true) {
            var lbl = document.getElementById('Image1');
            lbl.className = 'h_auto_update2_bmp';
            last_pic = true;
        }
    }
    else {
        if (last_pic != false) {
            var lbl = document.getElementById('Image1');
            lbl.className = 'h_auto_update1_bmp';
            last_pic = false;
        }
    }
    setTimeout('Check_Switch_Enable_Request()', 800);
}
//-----------------------------------------------------------------------------
function Init() {
    Check_Switch_Enable_Request();
}
//-----------------------------------------------------------------------------
function Set_Cookie_To_Eleman2(varx) {
    Set_Cookie(this, 'var1', 'FSNytA' + varx);
}
function Clear_Cookie() {
    Delete_Cookie(this, 'var1');
    Delete_Cookie(this, 'var2');
}
//-----------------------------------------------------------------------------
function Set_Cookie_To_Eleman3(varx) {
    Set_Cookie(this, 'var2', 'FSNytA' + varx);
}
function Get_Cookie_From_Eleman2() {
    var varx = Get_Cookie(this, 'var1');
    if (varx.length >= 6) {
        return varx.substring(6, varx.length);
    }
    else return '';
}
function Get_Cookie_From_Eleman3() {
    try {
        var varx = Get_Cookie(this, 'var2');
        if (varx.length >= 6) {
            return varx.substring(6, varx.length);
        }
        else return '';
    }
    catch (ex) {
        return '';
    }
}
