﻿var IE = (document.all) ? 1 : 0;
var ie = (document.all) ? 1 : 0;
var NS = (document.layers) ? 1 : 0;
var preloadFlag = false;

if (document.all != null) 
    IE = 1
else if ((document.layers != null) || (document.getElementById))
    NS = 1

// WINDOW STATUS FUNCTIONS
window.defaultStatus = "";
function winStatus( msg ){
	window.status = msg;
	return true;
}

function goThere( node,loc ) {
	//Only perform folder opening, don't close anything
	if( parent.nav.indexOfEntries[node].isOpen == false )
		parent.nav.clickOnNode(node);
	window.location = loc;
}

function closeMe() {
	//self.close();
	parent.close();
}

// STRING FUNCTIONS
function trim( str ) {
	if ((str.charAt(0) != ' ') && (str.charAt(str.length-1) != ' ')){
		return str; 
	}
	
	// Trim leading spaces
	while (str.charAt(0)  == ' '){
		str = '' + str.substring(1,str.length);
	}
	// Trim trailing spaces
	while (str.charAt(str.length-1)  == ' '){
		str = '' + str.substring(0,str.length-1);
	}

	return str;
}

function strReplace( entry, bad, good ) {
	temp = "" + entry; // temporary holder
	while (temp.indexOf(bad) > -1){
		pos= temp.indexOf(bad);
		temp = "" + (temp.substring(0, pos) + good + temp.substring((pos + bad.length), temp.length));
	}
	return temp;
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

//var selectFields = "<%=selectFields%>";
//var fields = new Array(<%=fields%>);
var rowSelected = null;
var dataObjSelected = null;

function SelectFields(){
	try{
		var selectFields2 = window.showModalDialog("<%=SelectFieldsASP%>?Type=<%=currentType%>&Status=<%=status%>&Fields=" + selectFields,"","dialogWidth:200px;dialogHeight:350px;help:0;status:0;");
		if (selectFields2 != null){
			selectFields = selectFields2;
			var obj, i, j, length2, style;
			var length = fields.length;
			
			for (var i=0; i<length; i++){
				obj = eval(fields[i]);
				if (obj != null){
					length2 = obj.length;
					style = ((selectFields.indexOf(fields[i]) >= 0) ? "block" : "none");
					if (length2 != null){
						for (j=0; j<length2; j++)
							obj[j].style.display = style;
					}else{
						//alert(obj.style.display)
						obj.style.display = style;
					}
				}
			}
		}
	}catch(e){}
}

function SelectDivisionLevel(stt){
	try{
		if (stt == null) stt = 0;
		var index = document.MyForm.DivisionLevel.options.selectedIndex;
		if (index >= 0){
			var levelID = parseInt(document.MyForm.DivisionLevel.options[index].value);
			var currentLength = 1, stt = 0, value;
			document.MyForm.DivisionAdministrative.options.length = 1;
			var length = document.MyForm.DivisionAdministrative2.options.length;
			for (stt = 0; stt<length; stt++){
				value = parseInt(document.MyForm.DivisionAdministrative2.options[stt].LevelID);
				if ((value == levelID) || (levelID == 0)){
					document.MyForm.DivisionAdministrative.options.length = currentLength + 1;
					document.MyForm.DivisionAdministrative.options[currentLength].value = document.MyForm.DivisionAdministrative2.options[stt].value;
					document.MyForm.DivisionAdministrative.options[currentLength].text = document.MyForm.DivisionAdministrative2.options[stt].text;
					document.MyForm.DivisionAdministrative.options[currentLength].LevelID = document.MyForm.DivisionAdministrative2.options[stt].LevelID;
					currentLength++;
				}
			}
			if ((stt != null) && (stt != 0))
				SelectDivisionAdministrative2();
			else
				SelectDivisionAdministrative();
		}
	}catch(e){}
	return true;
}

function SelectDivisionAdministrative(){
	try{
		if (rowSelected != null) rowSelected.className = "";
		rowSelected = null;
		if (!Row) return true;
		var index = document.MyForm.DivisionLevel.options.selectedIndex;
		if (index >= 0){
			var levelID = parseInt(document.MyForm.DivisionLevel.options[index].value);
			index = document.MyForm.DivisionAdministrative.options.selectedIndex;
			if (index >= 0){
				var administrativeID = document.MyForm.DivisionAdministrative.options[index].value;
				var length = Row.length;
				if (length == null){
					rowLevelID = parseInt(Row.Level);
					rowAdministrativeID = parseInt(Row.Administrative);
					Row.className = ((((rowLevelID == levelID) || (levelID == 0)) && ((rowAdministrativeID == administrativeID) || (administrativeID == 0))) ? "" : "Hidden");
				}else{
					for (var stt=0; stt<length; stt++){
						rowLevelID = parseInt(Row[stt].Level);
						rowAdministrativeID = parseInt(Row[stt].Administrative);
						Row[stt].className = ((((rowLevelID == levelID) || (levelID == 0)) && ((rowAdministrativeID == administrativeID) || (administrativeID == 0))) ? "" : "Hidden");
					}
				}
			}
		}
	}catch(e){}
}

function SelectRow(row, dataObj){
	try{
		window.event.cancelBubble = true;
		if (row != rowSelected){
			if (row != null) row.className = "RowSelect";
			if (rowSelected != null) rowSelected.className = "";
			rowSelected = row;
			dataObjSelected = dataObj;
			if (document.MyForm.FileAttachment != null){
				var fileAttachments = rowSelected.Attachment;
				var stt = parseInt(rowSelected.STT);
				var allowCheck = document.MyForm.Choose[stt].checked;
				var length = document.MyForm.FileAttachment.length;
				var fileID, checked;
				
				if (length == null){
					fileID = document.MyForm.FileAttachment.value;
					checked = ((fileAttachments.indexOf("," + fileID + ",") >= 0) ? true : false);
					document.MyForm.FileAttachment.checked = (allowCheck && checked);
				}else{
					for (var stt=0; stt < length; stt++){
						fileID = document.MyForm.FileAttachment[stt].value;
						checked = ((fileAttachments.indexOf("," + fileID + ",") >= 0) ? true : false);
						document.MyForm.FileAttachment[stt].checked = (allowCheck && checked);
					}
				}
			}
		}
	}catch(e){alert(e);}
	return true;
}

function SelectDivisionAdministrative2(){
	try{
		var index = document.MyForm.DivisionLevel.options.selectedIndex;
		if (index >= 0){
			var levelID = parseInt(document.MyForm.DivisionLevel.options[index].value);
			index = document.MyForm.DivisionAdministrative.options.selectedIndex;
			if (index >= 0){
				var administrativeID = parseInt(document.MyForm.DivisionAdministrative.options[index].value);
				var currentLength = 0, stt = 0, levelID2, administrativeID2;
				document.MyForm.DivisionID.options.length = 0;
				var length = document.MyForm.DivisionID2.options.length;
				document.MyForm.DivisionID.className = "";
				for (stt = 0; stt<length; stt++){
					levelID2 = parseInt(document.MyForm.DivisionID2.options[stt].LevelID);
					administrativeID2 = parseInt(document.MyForm.DivisionID2.options[stt].AdministrativeID);
					if (((levelID2 == levelID) || (levelID == 0)) && ((administrativeID2 == administrativeID) || (administrativeID == 0))){
						document.MyForm.DivisionID.options.length = currentLength + 1;
						document.MyForm.DivisionID.options[currentLength].value = document.MyForm.DivisionID2.options[stt].value;
						document.MyForm.DivisionID.options[currentLength].text = document.MyForm.DivisionID2.options[stt].text;
						currentLength++;
					}
				}
				if (document.MyForm.DivisionID.options.length == 0){
					document.MyForm.DivisionID.options.length = 1;
					document.MyForm.DivisionID.options[0].value = 0;
					document.MyForm.DivisionID.options[0].text = document.MyForm.DivisionID.Unknown;
					document.MyForm.DivisionID.className = "InputWidth50";
				}
			}
		}
	}catch(e){alert(e);}
}

function SelectFileAttachment(obj){
	// Luu chon file dinh kem gui cho cac don vi
	window.event.cancelBubble = true;
	if (rowSelected != null){
		var fileAttachments = rowSelected.Attachment;
		var stt = parseInt(rowSelected.STT);
		var allowCheck = document.MyForm.Choose[stt].checked;
		var fileID = obj.value;
		
		if (fileAttachments == "") fileAttachments = ",";
		if (obj.checked){
			fileAttachments = fileAttachments + fileID + ",";
		}else{
			fileAttachments = strReplace(fileAttachments, "," + fileID + ",", ",");
		}
		rowSelected.Attachment = fileAttachments;
		dataObjSelected.value = ((allowCheck) ? fileAttachments : "");
	}
}
	
function Reset(){
	try{
		window.parent.Banner.document.MyForm.DocumentID.value = "";
	}catch(e){}
}

// Report function
function SelectReportGroup(startAt){
	try{
		if (startAt == null) startAt = 0;
		var index = document.MyForm.GroupID.options.selectedIndex;
		if ((index != null) && (index >= 0)){
			var value = parseInt(document.MyForm.GroupID.options[index].value);
			var currentLength = 1;
			document.MyForm.SubGroupID.options.length = currentLength;
			var length = document.MyForm.SubGroupID2.options.length;
			
			for (var i=0; i<length; i++){
				var groupID = parseInt(document.MyForm.SubGroupID2.options[i].GroupID);
				if ((groupID == value) || (value == 0)){
					currentLength++;
					document.MyForm.SubGroupID.options.length = currentLength;
					document.MyForm.SubGroupID.options[currentLength - 1].value = document.MyForm.SubGroupID2.options[i].value;
					document.MyForm.SubGroupID.options[currentLength - 1].text = document.MyForm.SubGroupID2.options[i].text;
					document.MyForm.SubGroupID.options[currentLength - 1].GroupID = groupID;
				}
			}
		}
		
		SelectReportSubGroup(startAt);
	}catch(e){}
}
		
function SelectReportSubGroup(startAt){
	try{
		if (startAt == null) startAt = 0;
		var index = document.MyForm.GroupID.options.selectedIndex;
		var index2 = document.MyForm.SubGroupID.options.selectedIndex;
		if ((index != null) && (index >= 0) && (index2 != null) && (index2 >= 0)){
			var value = parseInt(document.MyForm.GroupID.options[index].value);
			var value2 = parseInt(document.MyForm.SubGroupID.options[index2].value);
			var currentLength = startAt;
			document.MyForm.NameID.options.length = currentLength;
			var length = document.MyForm.NameID2.options.length;
			
			for (var i=0; i<length; i++){
				var groupID = parseInt(document.MyForm.NameID2.options[i].GroupID);
				var subGroupID = parseInt(document.MyForm.NameID2.options[i].SubGroupID);
				if (((groupID == value) || (value == 0)) && ((subGroupID == value2) || (value2 == 0))){
					currentLength++;
					document.MyForm.NameID.options.length = currentLength;
					document.MyForm.NameID.options[currentLength - 1].value = document.MyForm.NameID2.options[i].value;
					document.MyForm.NameID.options[currentLength - 1].text = document.MyForm.NameID2.options[i].text;
					document.MyForm.NameID.options[currentLength - 1].GroupID = groupID;
					document.MyForm.NameID.options[currentLength - 1].SubGroupID = subGroupID;
					document.MyForm.NameID.options[currentLength - 1].FieldID = document.MyForm.NameID2.options[i].FieldID;
					document.MyForm.NameID.options[currentLength - 1].ReportTitle = document.MyForm.NameID2.options[i].ReportTitle;
				}
			}
		}
		
		SelectReportName();
	}catch(e){}
}
		
function SelectReportName(){
	try{
		var index = document.MyForm.NameID.options.selectedIndex;
		if ((index != null) && (index >= 0)){
			if (document.MyForm.Name != null){
				document.MyForm.Name.value = document.MyForm.NameID.options[index].ReportTitle;
				document.MyForm.Name.title = document.MyForm.NameID.options[index].text;
			}
			if (document.MyForm.FieldID != null){
				var value = parseInt(document.MyForm.NameID.options[index].FieldID);
				var length = document.MyForm.FieldID.options.length;
				for (var i=0; i<length; i++){
					var fieldID = parseInt(document.MyForm.FieldID.options[i].value);
					if (fieldID == value){
						document.MyForm.FieldID.options[i].selected = true;
					}
				}
			}
		}
	}catch(e){alert(e);}
}

function SelectReportPeriod(){
	try{
	var index = document.MyForm.Period.options.selectedIndex;
	var value = parseInt(document.MyForm.Period.options[index].value);
	if (value == -1){
		ReportPeriodTR[0].className = "Hidden";
		ReportPeriodTR[1].className = "Hidden";
	}else{
		ReportPeriod[1 - value].className = "NotHidden";
		ReportPeriod[value].className = "Hidden";
		//try{
			if (ReportPeriodTR != null){
				ReportPeriodTR[0].className = "NotHidden";
				ReportPeriodTR[1].className = "NotHidden";
			}
			if (ReportPeriod2 != null){
				ReportPeriod2[1 - value].className = "NotHidden";
				ReportPeriod2[value].className = "Hidden";
			}
		//}catch(e){}
	}
	}catch(e){}
}

function SelectPeriod(obj, stt){
	var name = obj.name;
	if ((stt == null) || (stt == 0))
		var myPeriods = new Array(document.MyForm.Week, document.MyForm.Month, document.MyForm.Quarter);
	else
		var myPeriods = new Array(document.MyForm.Week2, document.MyForm.Month2, document.MyForm.Quarter2);
	
	for (var i=0; i<myPeriods.length; i++){
		if (myPeriods[i].name != name){
			myPeriods[i].options.selectedIndex = 0;
		}
	}
}

function SelectFigure(obj){
	try{
		var index = obj.options.selectedIndex;
		if (index >= 0){
			document.MyForm.Code.value = obj.options[index].Code;
			document.MyForm.Unit.value = obj.options[index].Unit;
		}
	}catch(e){}
}

function DateOfWeek(obj){
	DateOfWeekHTML.innerHTML = "";
}

function SelectChooseID(obj){
	try{
		var checkCount = 0;
		if (document.MyForm.ChooseID != null){
			var length = document.MyForm.ChooseID.length;
			if ((length != null) && (length > 1)){
				for (var stt = 0; stt < length; stt++){
					if (document.MyForm.ChooseID[stt].checked) checkCount++;
				}
			}
			document.MyForm.Sum.disabled = ((checkCount >= 2) ? false : true);
			//document.MyForm.Compare.disabled = ((checkCount == 2) ? false : true);
		}
	}catch(e){}
}

function SelectCompareID(obj){
	try{
		var index = obj.options.selectedIndex;
		if (index > 0){
			var length = obj.options.length;
			for (var stt = 0; stt < length; stt++){
				myObj = eval("document.MyForm.CompareID_" + obj.options[stt].value);
				if (myObj != null) myObj.options.selectedIndex = 0;
			}
			document.MyForm.Compare.disabled = false;
		}else
			document.MyForm.Compare.disabled = true;
	}catch(e){alert(e);}
}

function GetData(obj, setData){
	try{
		var code = obj.Code;
		var value = parseFloat(obj.value);
		if ((isNaN(value)) && (setData)) obj.value = 0;

		var MyDataTextbox = document.MyForm.MyDataTextbox;
		var length = MyDataTextbox.length;
		
		if ((length != null) && (length > 0)){
			var formula = "", hasData = 0, code2 = "";
			for (var stt=0; stt<length; stt++){
				formula = MyDataTextbox[stt].Formula;
				hasData = parseInt(MyDataTextbox[stt].HasData);
				if ((hasData > 0) && (formula.indexOf("{" + code + "}") >= 0)){
					for (var stt2 = 0; stt2 < length; stt2++){
						code2 = MyDataTextbox[stt2].Code;
						value = parseFloat(MyDataTextbox[stt2].value);
						if (isNaN(value)) value = 0;
						formula = strReplace(formula, "{" + code2 + "}", value)
					}
					var myData = eval(formula);
					MyDataTextbox[stt].value = myData;
					GetData(MyDataTextbox[stt]);
				}
			}
		}
	}catch(e){}
}

function setAction(value){
	try{
		document.frm.Action.value = value;
		return true;
	}catch(e){}
	return false;
}

function OpenWindow(windowURL){
	try{
		var windowConfig = 'toolbar=no, ';
    	//Menu
		windowConfig += 'menubar=no, ';
    	//Scrollbars
	    windowConfig += 'scrollbars=no, ';
    	//Resizable
		windowConfig += 'resizable=yes, ';
    	//Address Bar
	    windowConfig += 'location=no, ';
		//Favorites
		windowConfig += 'directories=no, ';
		//Statusbar
		windowConfig += 'status=no, ';
		//windowConfig += 'left=0, ';
		//windowConfig += 'top=0, ';
		//windowConfig += 'height=' + window.screen.height + ', ';
		//windowConfig += 'width=' + window.screen.width;
		window.open(windowURL, "_blank", config = windowConfig);
	}catch(e){}
}
function ChangeDay(object,month,year){
	var day=object.selectedIndex;
	month=parseInt(month);
	year=parseInt(year);
	var days=31;
	if(days < day)day=days;
	if((month==1)||(month==3)||(month==5)||(month==7)||(month==8)||(month==10)||(month==12))days=31;
	else if((month==4)||(month==6)||(month==9)||(month==11)){days=30;}
	else if(month==2){
	 if(((year%4)==0)&&((year%100)!==0)||((year%400)==0)){days=29;}
	else {days=28;}
	}	
	while(object.options.length!=0){
	object.options[(object.options.length-1)]=null;
	}
	var oOption;
	for(var i=0; i<days;i++){
	oOption=document.createElement("OPTION");
	oOption.value=i+1;
	oOption.text=i+1;
	if(i==day)oOption.selected=true;
	object.add(oOption);
	}
}
//----------Cac ham moi xu ly nhap ngay thang vao he thong----------
function isDate( s )
//Kiem tra xau s co dung dinh dang Ngay/thang/nam khong ?
	{
	 var sDay, sMonth, sYear, nMonth, nDay, nYear, nSep1,nSep2;
		s=trim(s);
		nSep1 = s.indexOf( "/" );
	if ( nSep1 < 0 ) return false;
		nSep2 = s.lastIndexOf( "/" );
	if ( nSep2 < 0 ) return false;
	if ( nSep1 == nSep2 ) return false;

		sDay = s.substring( 0, nSep1  );
		sMonth = s.substring( nSep1 + 1, nSep2 );
		sYear = s.substring( nSep2+1 );
		if (sDay.length>=3||sMonth.length>=3) return false;
		if (sYear.length>4 ) return false;
		if (sYear.length<4 ) return false;
		if ( !sMonth.length || !sDay.length || !sYear.length ) 		return false;
		// isNaN(empty) is false
		if ( isNaN(sMonth) || isNaN(sDay) || isNaN(sYear) ) 		return false;
		nMonth = parseInt(sMonth,10); nDay = parseInt(sDay,10); 		nYear = parseInt(sYear,10);
		if ( nMonth<=0 || nDay<=0 || nYear<=0 ) return false;
		if ( nMonth > 12 ) return false;
		if (nMonth==1 || nMonth==3 || nMonth==5 || nMonth==7 || nMonth==8 || nMonth==10 || nMonth==12 )
			if ( nDay > 31 ) return false; 
		if (nMonth==4 || nMonth==6 || nMonth==9 || nMonth==11 )
			if ( nDay > 30 ) return false; 
		if (nMonth==2) {
			if ( (nYear % 4 == 0) && (nYear % 100 != 0)) { // leap year
				if ( nDay > 29 ) return false;
			} else if ( nDay > 28 ) return false;
		}
		return true;
	} // isDate function

// trim blank on the two sides function

function trim( s )
{
    var i, sRetVal = "";
    i = s.length-1;
    while ( i>=0 && s.charAt(i) == ' ' )
         i--;
    s = s.substring( 0, i+1 ); // trim blanks on the right
    i = 0;
    while ( i< s.length && s.charAt(i) == ' ')
         i++;
    return s.substring( i );
}

//Ham kiem tra xem co phai day1 > day2 ? Dung sau ham isDate
function isGreaterDay(day1,day2)
{
	var ngay1,thang1,nam1;
	var ngay2,thang2,nam2;	

	ngay1=day1.substr(0,2);	
	thang1=day1.substr(3,2);
	nam1=day1.substr(6,4);

	ngay2=day2.substr(0,2);
	thang2=day2.substr(3,2);
	nam2=day2.substr(6,4);

	if((nam1>nam2)||((thang1>thang2)&&(nam1>=nam2))||((ngay1>ngay2)&&(thang1>=thang2)&&(nam1>=nam2))){
		return true;
	}	
	else{
		return false;
	}
}

function isEdit(keycode,str)
{
if ((keycode>=48 && keycode <=57 || keycode>=96) && keycode <=105 && !isDate(str) && str.length <=8 || keycode==111 || keycode==191){
	return true;
}
else{
	return false;
}	
}

function editdate(str)
{
var value;
if (str.substr(str.length-1,1)=="/" && str.substr(str.length-2,1)=="/"){
	return str.substr(0,str.length-1)
}
switch (str.length){
    case 1:
	if (str.substr(0,1)>=4) {
		value="0"+str.substr(0,1)+ "/";
	}
	else {
		value=str;
	}
    break;
    case 2:
	if (str.substr(1,1)=="/" && str.substr(0,1)>=1 && str.substr(0,1)<=9 ) {
		value="0"+str.substr(0,str.length);
	}
	else{
		if (str>=1 && str<=31) {
			value=str+"/";
		}
		else{
			value=str.substr(0,1);
		}
	}
    break;
    case 3:
	if (str.substr(1,1)=="/" && str.substr(0,1)>=1 && str.substr(0,1)<=9 ) {
		value="0"+str.substr(0,str.length);
	}
	else{
		value=str;
	}
    break;
    case 4:
		if (str.substr(3,1)>=2 && str.substr(2,1)== "/" ) {
			value=str.substr(0,3)+"0"+str.substr(3,1)+ "/";
		}
		else{
			value=str.substr(0,4);
		}
    break;
    case 5:
    		if (str.substr(str.length-1,1)=="/") {
			value=str.substr(0,str.length-2) + "0" + str.substr(str.length-2,str.length);
		}
		else {
			if (str.substr(3,2)>=1 && str.substr(3,2)<=12) {
				value=str+"/";
			}
			else{
				value=str.substr(0,str.length-1);
			}
		}
    break;
    case 8:
		if (str.substr(str.length-2,2)>=45) {
			value=str.substr(0,str.length-2)+"19"+str.substr(str.length-2,2);
		}
		else{
			if (str.substr(str.length-2,2)<=18) {
				value=str.substr(0,str.length-2)+"20"+str.substr(str.length-2,2);
			}
			else {
				value=str;
			}			
		}
    break;
    default:
	value=str;
}
    return value;
}

function IsNumeric(strString) {
//  check for valid numeric strings	
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

//  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++){
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1){
         blnResult = false;
       }
   }
   return blnResult;
}


function Date_Onkeyup(oObject,str){
var keycode;
keycode=window.event.keyCode
if (isEdit(keycode,str)){
	oObject.value=editdate(trim(str))
}
}

//-->
//--------End of cac ham moi xu ly ve ngay thang--------------

//----------Ham bat cac hanh dong mousseover va mouseout-------

function button_over(eButton){
		//cell
		eButton.style.backgroundColor = "#dddddd";
		eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
		eButton.style.cursor="hand";
		//col
		//col_Object.style.backgroundColor = "#B5BDD6";
		//col_Object.style.borderColor = "darkblue darkblue darkblue darkblue";
		//row
		//row_Oject.style.backgroundColor = "#B5BDD6";
		//row_Oject.style.borderColor = "darkblue darkblue darkblue darkblue";

	}
	
function button_out(eButton,col_Object,row_Object){
		//cell
		eButton.style.backgroundColor ="#eeeeee";
		eButton.style.borderColor ="#c1cdd8";
		//col
		//col_Object.style.backgroundColor ="#fff7e5";
		//col_Object.style.borderColor ="#c1cdd8";
		//row
		//row_Object.style.backgroundColor ="#fff7e5";
		//row_Object.style.borderColor ="#c1cdd8";
	}
function Over_Button(eButton,color){

		eButton.style.backgroundColor =color;
		eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
		eButton.style.cursor="hand";
	}
	
function Out_Button(eButton,color){
		eButton.style.backgroundColor =color;
		eButton.style.borderColor ="#c1cdd8";
	}
//----------Ket thuc cac ham bat cac hanh dong mousseover va mouseout-------
//Ham dat mot anh vao o khi co su kien click
function Image_Click(oObject,path1,path2,value){
	var TB=TO=0;
	var action="<%=Action%>";
	//document.MyForm.Modify.disabled=false;
	for (var i=0;i<MyForm.image_click.length;i++){
		var e = document.MyForm.image_click[i];
		dL_Local(document.MyForm.image_click[i]);
		e.src=path1;
	}
	hL_Local(oObject);
	oObject.src=path2;
	document.MyForm.valueStore.value=value;

}

function hL_Local(E){
	if (ie){
		while (E.tagName!="TR"){
			E=E.parentElement;
		}
	}else{
		while (E.tagName!="TR"){
			E=E.parentNode;
		}
	}
	E.className = "H";
}

function dL_Local(E){
	if (ie){
		while (E.tagName!="TR"){
			E=E.parentElement;
		}
	}else{
		while (E.tagName!="TR"){
			E=E.parentNode;
		}
	}
	E.className = "";
}
function Alert(msg,type){
	return window.showModalDialog("Include/Alert.asp?type="+type,msg,"dialogWidth:300px;dialogHeight:120px;scroll:0;help:0;status:0;center:1;edge=raised;resizable=0;");
}
function NINum(obj){
		temp = obj.value;
		if(isNaN(temp)){
			Alert("D&#7919; li&#7879;u ph&#7843;i l&#224; ki&#7875;u s&#7889;",0);
			obj.value="";
			obj.focus();
	}
}

function NINum2(obj){
		temp = obj.value;
		if(isNaN(temp)){
			alert("D&#7919; li&#7879;u ph&#7843;i l&#224; ki&#7875;u s&#7889;",0);
			obj.value="";
			obj.focus();
	}
}

function NIDate(obj){
		temp = obj.value;
		if(!isDate(temp)){
			Alert("D&#7919; li&#7879;u ph&#7843;i l&#224; ki&#7875;u ngày tháng: dd/mm/yyyy",0);
			obj.value=""
			obj.value=now.getDay;
			obj.focus();
	}
}

function Delete_File(ID){
		var OK= Alert("Bạn có muốn xoá file này không ?",2);
		if(OK){
			setAction('Delete_File');
			document.frm.ID_File.value= ID;
			document.frm.submit();
		}	
}
function OpenWinFrame(Code,ID,H,W){
	  return showModalDialog("SelectFrame.asp?Code="+Code+"&ID="+ID,"","dialogWidth:"+W+"px;dialogHeight:"+H+"px;scroll:no;help:0;status:0;center:1;edge=sunken;resizable=1;");
	//window.open("SelectFrame.asp?Code="+Code+"&ID="+ID,"","dialogWidth:600px;dialogHeight:400px;scroll:no;help:0;status:0;center:1;edge=sunken;resizable=0;");
}
function OpenFrame(fileName,Code,ID,H,W){
	return showModalDialog("OpenFrame.asp?fileName="+fileName+"&Code="+Code+"&ID="+ID+"&W="+W+"&H="+H,"","dialogWidth:"+W+"px;dialogHeight:"+H+"px;scroll:no;help:0;status:0;center:1;edge=sunken;resizable=1;");
}
function OpenFrame2(fileName,Code,ID,H,W){
	window.open("OpenFrame.asp?fileName="+fileName+"&Code="+Code+"&ID="+ID+"&W="+W+"&H="+H,"","dialogWidth:"+W+"px;dialogHeight:"+H+"px;scroll:no;help:0;status:0;center:1;edge=sunken;resizable=1;");
}
function CheckDelete(){
	var OK= Alert("Bạn có thực sự muốn xoá không ?",1);
		if(OK){
		    
			setAction('Delete');
			document.frm.submit();
	}	
}

function changeto(obj,strClass){
	if(strClass!=""){
		obj.className = strClass;
	}
}
function dropCategory(obj){
	if(obj.className == "on"){
		obj.className = "off";
		document.frm.objdrop.value = "";	
	}
	else{
		obj.className = "on";
		if(document.frm.objdrop.value != ""){
			identity=document.getElementById(document.frm.objdrop.value);
			identity.className = "off";
		}
		document.frm.objdrop.value = obj.id;
	}
}


function getImageWidth(myImage) {
	var x, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.width;
	} else {
		return getElementWidth(myImage);
	}
	return -1;
}

function getImageHeight(myImage) {
	var y, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.height;
	} else {
		return getElementHeight(myImage);
	}
	return -1;
}

