﻿// Select All Checkbox
function SelectAllCheckboxes(spanChk)
 {
   // Added as ASPX uses SPAN for checkbox
   var oItem = spanChk.children;
   var theBox= (spanChk.type=="checkbox") ? spanChk : spanChk.children.item[0];
   xState=theBox.checked;
   elm=theBox.form.elements;

   for(i=0;i<elm.length;i++)
     if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
     {
       if(elm[i].checked!=xState)
         elm[i].click();
     }
 }


function ImageOver(ImgName, ImgSrc)
{
    document.getElementById(ImgName).src = ImgSrc;
}

function ImageOut(ImgName, ImgSrc)
{
    document.getElementById(ImgName).src = ImgSrc;
}



// FixPNG
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function FixPNG(myImage) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
     var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
                  
	   myImage.outerHTML = strNewHTML	  
    }
}


function OpenWindow(target) 
{ 
    window.open(target, "test", "toolbar=no,scrollbars=yes,resizable=yes,width=300,height=300");
}



// Chỉ cho nhập số
function numeralsOnly(evt) 
{
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));

    //alert(charCode);

    if (charCode == 46 || charCode == 35 || charCode == 36) // 46 = phím Delete, 35 = End , 36 = Home
        return true;

    if (charCode >= 37 && charCode <= 40) // 4 phím mũi tên
        return true;

    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        alert("Enter numerals only in this field.");
        return false;
    }

    return true;
}


