﻿// JScript File
var DateTime = 
        {
            Days : ['<font color=red>Chủ Nhật</font>','Thứ Hai','Thứ Ba','Thứ Tư','Thứ Năm','Thứ Sáu','<font color=red>Thứ Bảy</font>'],
            Months : ['1','2','3','4','5','6','7','8','9','10','11','12'],
            FixNum : function(x)
            {
                if(x < 10) { x = "0" + x; }
                return x;
            } ,
            Show : function(objid)
            {
                var today = new Date();
                var day = DateTime.Days[today.getDay()];
                var date = today.getDate();
                var month = DateTime.Months[today.getMonth()];
                var year = today.getFullYear();
                
                var h = today.getHours();
                var m = today.getMinutes();
                var s = today.getSeconds();
                
                var at = ' am';
                if(h > 12) { h-= 12; at = ' pm';}
                if(h == 0) h = 12;
                
                date = DateTime.FixNum(date);
                m = DateTime.FixNum(m);
                s = DateTime.FixNum(s);
                
                var obj = document.getElementById(objid);
                obj.innerHTML = day + ", " + date + "/" + month + "/" + year + " " + h + ":" + m + ":" + s + at;
                setTimeout("DateTime.Show('" + objid + "')" , 500);
            } ,
            ShowDate : function(objid)
            {
                var today = new Date();
                var day = DateTime.Days[today.getDay()];
                var date = today.getDate();
                var month = DateTime.Months[today.getMonth()];
                var year = today.getFullYear();
                
                date = DateTime.FixNum(date);
                
                var obj = document.getElementById(objid);
                obj.innerHTML = day + " " + date + "/" + month + "/" + year;
            }
        }
        function selectAll(involker) 
        {
            // Since ASP.NET checkboxes are really HTML input elements
            //  let's get all the inputs 
            var inputElements = document.getElementsByTagName('input');
            for (var i = 0 ; i < inputElements.length ; i++) {
                var myElement = inputElements[i];
                // Filter through the input types looking for checkboxes
                if (myElement.type === "checkbox") {
                   // Use the involker (our calling element) as the reference 
                   //  for our checkbox status
                    myElement.checked = involker.checked;
                }
            }
        }  
        function openWin(url, width , height)
		    {
			    var def = 'status=no,resizable=no,scrollbars=yes,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(height).concat(',').concat('width=').concat(width).concat(',');
			    def = def.concat('top=').concat((screen.height - height)/2).concat(',');
			    def = def.concat('left=').concat((screen.width - width)/2);
			    open(url, '_blank', def);
		    }

function FocusOnClick(e , txt, objid)
        {
            var obj = document.getElementById(objid);	
            if(!e) var e = window.event;
            var keyCode = e.keyCode ? e.keyCode : e.which;
            if(keyCode == 13)
            {
                obj.click();
                
                if(!e.stopPropagation)
                {
                    e.returnValue = false;
                }
                else
                {
                    e.preventDefault(true);
                    e.stopPropagation(true);
                }
            }
        }       
var lastColor; 
    function DG_changeBackColor(row, highlight) 
    { 
        if (highlight) 
        { 
            row.style.cursor = "pointer"; 
            lastColor = row.style.backgroundColor; 
            row.style.backgroundColor = '#87cefa'; 
        } 
        else 
            row.style.backgroundColor = lastColor; 
    }        
