﻿function OpenWindowPriceList(url)
{
    var w = (window.screen.width/2) - 300;
    var onFocusObj = window.open(url, "_blank", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no, width=610,height=470,left='+w+', top=100,screenX='+w+'px,screenY=100px');
    onFocusObj.focus();
}
function OpenWindow(url)
{
    window.open(url, "_blank", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=700,height=600');
    return false;
}
function Messages(msg, url)
{
    alert(msg);
    document.location.href = url;
}
function Msg(msg)
{
    alert(msg);
    return false;
}
function ActivePrinter(PrinterTopBar, PrinterBottomBar)
{
    document.getElementById(PrinterTopBar).style.visibility='hidden';
    document.getElementById(PrinterBottomBar).style.visibility='hidden';
    window.print();
    ClosePopup();
    return false;
}
function getNextSibling(startBrother){
  endBrother=startBrother.nextSibling;
  while(endBrother && endBrother.nodeType!=1){
    endBrother = endBrother.nextSibling;
  }
  return endBrother;
}

function getFirstChild(startParent){
  endNode=startParent.firstChild;
  while(endNode && endNode.nodeType!=1){
    endNode = endNode.firstChild;
  }
  return endNode;
}
function ShowPopup(e, Width, Height, LinkPath, Title, Caption, Author){
    var desc = '';
    try {
        var el = getNextSibling(e.parentNode.parentNode);
        el = el.offsetParent;
        if (el.rows.length > 1) {
            el = el.rows[1].cells[0];
            desc = el.innerHTML;
        }
    } catch (err) {
        desc = '';
    }
    myLightWindow.activateWindow({
        loadingAnimation: false,
        href: LinkPath,
        caption: Caption,
        title: Title,
        width: Width,
        height: Height,
        Author: Author
    });
}
function ClosePopup(){
    window.parent.myLightWindow.deactivate();
}
function AlertClose(msg)
{
    alert(msg);
    ClosePopup()
}
function CssObj(obj,CssClass){
    obj.className = CssClass;
}
function LinksObj(url)
{
    document.location.href = url;
}
function CheckAll(checked,CheckInList)
{
    for (var i=0;i<document.forms[0].elements.length;i++)
    {
        var e = document.forms[0].elements[i];
        if (e.name == CheckInList) e.checked = checked;
    }
}
function IsSelectedRowList(CheckInList)
{
    var Value = false;
    var SelectedCounter = 0;
    for (var i=0;i<document.forms[0].elements.length;i++)
    {
        var e = document.forms[0].elements[i];
        if ((e.name == CheckInList) && (e.checked))
            SelectedCounter +=1;
    }
    if(SelectedCounter > 0) Value = true;
    return Value;
}
function ConfirmDelete()
{
    return confirm('Bạn có chắc chắn muốn xoá?');
}
function ConfirmListDelete(CheckInList)
{
    if(!IsSelectedRowList(CheckInList))
    {
        alert('Bạn chưa chọn mẫu tin nào trong danh sách hoặc danh sách rỗng!');
        return false;
    }
    else
    {
        return confirm('Bạn có chắc chắn muốn xoá mẩu tin đã chọn từ danh sách?');
    }
}
function ListChecked(CheckInList)
{
    if(!IsSelectedRowList(CheckInList))
    {
        alert('Bạn chưa chọn mẫu tin nào trong danh sách hoặc danh sách rỗng!');
        return false;
    }
    return true;
}