﻿/* ------------------------------------------------------------------
*   BAO GOM CAC HAM THUC HIEN CAC CONG VIEC CHUNG NHAT CUA CAC TRANGn C
*   (C) 2009 - Luong Tien Chung - CSoft
*   1. Xu ly chon lua Checkbox
*   2. Xu ly View hoac Hidden 1 doi tuong
*   3. Xu ly hien thi cua so
*   4. Xy ly font chu 
-------------------------------------------------------------------*/

//----------------------------
// nhom ham chon lua checkbox
// using : javascript: checkAll('<%= Gridview1.ClientID %>','CheckBox1');
//----------------------------
function sdfja93rjf0wa() { var ajfsodj0823urf03090f93irfi; } function sdfja93rjf0wag() { var ajfsodj0823urf03090f93irfi; } function checkAll(strGridviewId, strCheckboxId) { var i = 0; var strRegExp = "^" + strGridviewId + "_\\w+_" + strCheckboxId + "$"; var re = new RegExp(strRegExp); var chkItems = document.getElementsByTagName("INPUT"); for (i = 0; i < chkItems.length; i++) { if ((chkItems[i].getAttribute("Type") == "checkbox")) { if (chkItems[i].getAttribute("id").match(re)) { chkItems[i].checked = true; } } } } function unCheckAll(strGridviewId, strCheckboxId) { var i = 0; var strRegExp = "^" + strGridviewId + "_\\w+_" + strCheckboxId + "$"; var re = new RegExp(strRegExp); var chkItems = document.getElementsByTagName("INPUT"); for (i = 0; i < chkItems.length; i++) { if ((chkItems[i].getAttribute("Type") == "checkbox")) { if (chkItems[i].getAttribute("id").match(re)) { chkItems[i].checked = false; } } } } function receiveCheck(strGridviewId, strCheckboxId) { var i = 0; var strRegExp = "^" + strGridviewId + "_\\w+_" + strCheckboxId + "$"; var re = new RegExp(strRegExp); var chkItems = document.getElementsByTagName("INPUT"); for (i = 0; i < chkItems.length; i++) { if (chkItems[i].getAttribute("Type") == "checkbox" && chkItems[i].getAttribute("id").match(re)) { if (chkItems[i].checked) { chkItems[i].checked = false; } else { chkItems[i].checked = true; } } } }

//----------------------------
// nhom ham view - hidden
//an va hien 1 doi tuong
//using : isView=viewHideObject(id, isView);
//----------------------------
function sdfja93rjf0waa() { var ajfsodj0823urf03090f93irfi; } function sdfja93rjf0wah() { var ajfsodj0823urf03090f93irfi; } function viewObject(id) { var elem = document.getElementById(id); elem.style.display = "block"; } function hideObject(id) { var elem = document.getElementById(id); elem.style.display = "none"; } function viewHideObject(id, isView) { if (isView) { viewObject(id); } else { hideObject(id); } return !isView; }

//----------------------------
// nhom ham check data
// using : 
//----------------------------
function checkItemDelete(strGridviewId, strCheckboxId) {
    var i = 0;
    var isCheck = false;
    var strRegExp = "^" + strGridviewId + "_\\w+_" + strCheckboxId + "$";
    var re = new RegExp(strRegExp);
    var chkItems = document.getElementsByTagName("INPUT");
    for (i = 0; i < chkItems.length; i++) {
        if ((chkItems[i].getAttribute("Type") == "checkbox")) {
            if (chkItems[i].getAttribute("id").match(re)) {
                isCheck = isCheck || chkItems[i].checked;
            }
        } //if
    } //for
    if (isCheck) {
        return confirm("Ban co chac chan muon xoa muc chon nay khong?");
    }
    else {
        alert("Ban hay chon mot muc chon truoc khi thuc hien xoa");
        return false;
    }
}

//--------------------------------------------------------
// nhom ham view hide panel
// using :
//--------------------------------------------------------
function view(id) {
    var elem = document.getElementById(id);
    if (elem) {
        elem.style.display = "block";
    }
}

function hide(id) {
    var elem = document.getElementById(id);
    if (elem) {
        elem.style.display = "none";
    }
}

function openWindow(url) {
    window.open(url,"newwindow");
}

//--------------------------------------------------------
// nhom ham thao tac voi popup dialog = div
// using :
//--------------------------------------------------------
//canh giua 1 doi tuong
function centerAlign(id, width, height) {
    if (document.getElementById(id)) {
        var scroll = 0;
        if (document.body.scrollTop)
            scroll = parseInt(document.body.scrollTop);
        else
            scroll = parseInt(document.documentElement.scrollTop);
        document.getElementById(id).style.left = parseInt(screen.availWidth - width) / 2 + "px";
        document.getElementById(id).style.top = parseInt(screen.availHeight - height) / 2 + scroll + "px";
        //alert("(screen.availHeight - height + scroll) / 2 = (" + screen.availHeight + " - " + height + " + " + scroll + ") / 2 = " + document.getElementById(id).style.top);
    }
}
// hien va canh giua man hinh
function displayAndCenterAlign(id, width, height) {
    centerAlign(id, width, height);
    view(id);
}
//
function ClearValue(textbox) {
    alert(document.getElementById(textbox).value);
    document.getElementById(textbox).value = "";
}

//--------------------------------------------------------
// nhom ham thao tac voi font chu
// using :
//--------------------------------------------------------
function increactionFontSize(size) {
    document.body.style.fontsize = size + "%";
}
//--------------------------------------------------------
// ham lightBox
// using : onclick="LTCLightBox('url','title');"
//--------------------------------------------------------
function LTCLightBox(url, title) {var height = (document.height)? document.height : (document.body.clientHeight + 10);var width = (document.width) ? document.width : (document.body.clientWidth + 10);
/* create background */var div = document.createElement("div"); div.setAttribute("id", "LTCLightBoxContainer"); div.setAttribute("style", "height:" + (height + 20) + "px;width:" + (width + 10) + "px;"); 
div.setAttribute("onclick", "document.body.removeChild(document.getElementById('LTCLightBox'));document.body.removeChild(document.getElementById('LTCLightBoxContainer'));"); document.body.appendChild(div);
    //create content
    var divContent = document.createElement("div");
    divContent.setAttribute("id", "LTCLightBox");
    divContent.setAttribute("style", "top:40px;left:" + (width/2 - 235) + "px;");
    document.body.appendChild(divContent);
    var divTop = document.createElement("div");
    divTop.innerHTML = title;
    divContent.appendChild(divTop);
    var img = document.createElement("img");
    img.setAttribute("src", url);
    divContent.appendChild(img);
    var divControl = document.createElement("div");
    divContent.appendChild(divControl);
    //if (navigator.appName == 'Microsoft Internet Explorer') {
        divTop.className = "LTCLightBox-Box-Top";
        img.className = "LTCLightBox-Box-Image";
        divControl.className = "LTCLightBox-Box-Control";
        divContent.className = "LTCLightBox-Box";
        div.className = "LTCLightBox-Background";
    //}
    //else {
        //divTop.setAttribute("class", "LTCLightBox-Box-Top");
        //img.setAttribute("class", "LTCLightBox-Box-Image");
        //divControl.setAttribute("class", "LTCLightBox-Box-Control");
        //divContent.setAttribute("class", "LTCLightBox-Box");
        //div.setAttribute("class", "LTCLightBox-Background");
    //}
        alert(div.currentStyle.width);
        if (div.currentStyle.width == "auto") {
            div.currentStyle.width = "1000px";
        }
        alert(div.currentStyle.width);
}
