﻿function popupNewWindows(url,iheight,iwidth){
	if(iheight<0){
		iheight = screen.height;
	}
	if(iwidth<0){
		iwidth = screen.width;
	}	
	var feature = "height=" + iheight + ",width=" + iwidth + ",status=0,toolbar=0,location=0,menubar=0,directories=0,";
	feature += "resizable=1,scrollbars=1,top=" + (screen.height-iheight)/2 + ",left=" + (screen.width-iwidth)/2;
	window.open(url,'_blank',feature);
}//popupWindows

function toggleLayer(whichLayer, value)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = value;
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = value;
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = value;
	}
}

function confirmDelete(){
	if(confirm("Bạn có chắc chắn muốn xóa không?")){
		return true;
	}else{
		return false;
	}
}

function checkAll(itemName,values){
	var str = ":" + itemName;
	var reg = new RegExp(str);
	var max = document.forms[0].elements.length;
	for(var i=0; i<max; i++){
		var obj = document.forms[0].elements[i];
		if(obj.type == "checkbox"){
			if(reg.test(obj.name)){
				obj.checked = values;
			}
		}
	}
}//checkAll

function checkItem(itemName,chkAllItem){
	var str = ":" + itemName;
	var reg = new RegExp(str);
	var max = document.forms[0].elements.length;
	var ischecked = true;
	var i = 0;
	var index = 0;
	
	while(i<max & ischecked){
		var obj = document.forms[0].elements[i];
		if(obj.type == "checkbox"){
			if(reg.test(obj.name)){
				ischecked = obj.checked;
			}
		}
		i++;
	}
	document.forms[0].elements[chkAllItem].checked = ischecked;
}//checkItem

var my_window;
function openPopup(url)
{    
    my_window = window.open(url, "mywindow", "status=0,width=500,height=515,scrollbars=yes");
}

function closePopup()
{
    try{
	    if(false == my_window.closed)
	    {
	        my_window.close();
	    }
	}catch(err){
	
	}
}
