//@copyright : I@M - Trung tam tin hoc hanh chinh
//for more information pls contact YM! nthstone@yahoo.com or nthung.ubnd@thuathienhue.gov.vn
function mfLenErr(objPathName, lenNum, altString){
	if(objPathName.value.length<lenNum){
		if(altString!='') alert(altString);
		objPathName.focus();
		return true;
	}
	return false;
}

function mfEquals(objPathName, objPathNameChk, altStringT, altStringF){
	if(objPathName.value==objPathNameChk.value){
		if(altStringT != '') alert(altStringT);
		objPathName.focus();
		return true;	}
	else{
		objPathName.focus();
		if(altStringF != '') alert(altStringF);
		return false;
	}
}
function mfEmailAddErr(objEmailAdd, altString){
	var emailaddress = objEmailAdd.value;
	var emailaddFaile = mfLenErr(objEmailAdd, 5, '')||(emailaddress.indexOf(" ")!=-1)
		emailaddFaile = emailaddFaile ||(emailaddress.indexOf(".")==-1)||(emailaddress.indexOf("@")==-1)
	if(emailaddFaile){
		if(altString!='') alert(altString);
		objEmailAdd.focus();
		return true;
	}
	return false;
}
// Check value of option /s/
function mfCheckSelected(objOption, altString){
	if((objOption.value.toString() == "-1" || objOption.value.toString() == "-2")){
		alert (altString);
		return true;
	}
	return false;
}

function mfCheckNum(objNumber, altString){
	if(objNumber.value != ""){
		if(!isNaN(objNumber.value.toString())){
			return false;
		}
		else{
			alert (altString);
			objNumber.focus();
			return true;
		}
	}
	else{		
		return false;
	}
}

function mfCheckNum2(objPathName, altString){
	if(isNaN(objPathName.value.toString()) || objPathName.value.length == ''){
		if(altString!='') alert(altString);
		objPathName.focus();
		return true;
	}
	return false;
}

function mfCheckNumMore(number_input, objNumber, altString){
	if(parseInt(number_input) < parseInt(objNumber.value)){
		if(altString!='') alert(altString);
		objNumber.focus();
		return true;
	}
	return false;
}

function mfCheckNumLess(number_input, objNumber, altString){
	if(parseInt(number_input) > parseInt(objNumber.value)){
		if(altString!='') alert(altString);
		objNumber.focus();
		return true;
	}
	return false;
}

function mfLenErr1(objPathName1, objPathName2, altString){
	if(objPathName1.value.length == '' && objPathName2.value.length != ''){
		if(altString!='') alert(altString);
		objPathName1.focus();
		return true;
	}
	return false;
}
function mfLenErr2(objPathName1, objPathName2, altString){
	if(objPathName1.value.length != '' && objPathName2.value.length == ''){
		if(altString!='') alert(altString);
		objPathName2.focus();
		return true;
	}
	return false;
}

function mfCheckDate(objStartDate, objEndDate, altString){
	if(objEndDate.value != ""){
		var s_date = new Date(objStartDate.value);
//		var strSDate = s_date.getYear().toString();
//		strSDate += (s_date.getMonth()+1).toString();
//		strSDate += s_date.getDate().toString();

		var e_date = new Date(objEndDate.value);
//		var strEDate = e_date.getYear().toString();
//		strEDate += (e_date.getMonth()+1).toString();
//		strEDate += e_date.getDate().toString();

		if(s_date < e_date){
			return false;
		}
		else{
			alert (altString);
			return true;
		}
	}
	else{
		
		return false;
	}
}

function compareDateTime(dateFrom, dateTo, mes){
	if(dateFrom == '') dateFrom = '1/1/1900';
	if(dateTo == ''){
		var currDate = new Date();
		dateTo = (parseInt(currDate.getMonth()) + 1).toString() + '/' + currDate.getDate() + '/' + (parseInt(currDate.getYear())+1900);
	}
	
	var oDateFrom = new Date(dateFrom+ " 00:00:00");
	var oDateTo = new Date(dateTo+ " 00:00:00");
	if (oDateFrom > oDateTo){
		alert(mes);
		return false;
	}
	else{
		return true;
	}
}

function checkDateTmp(day, month, year){
	var oMonth = null;
	var DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	var lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	if(parseInt(year) % 4 == 0){//leap year
		if ((year % 100) == 0 && (year % 400) != 0) oMonth = DOMonth;
		else oMonth = lDOMonth;
	}
	else{//NOT leap year
		oMonth = DOMonth;
	}

	for(i=0; i<oMonth.length; i++){
		if(i == parseInt(month)-1)
				if (parseInt(day) <= parseInt(oMonth[i])) return true;
	} return false;
}

function checkDate(objDay, objMonth, objYear, altString){
	if(checkDateTmp(objDay.value, objMonth.value, objYear.value) == false){
		if(altString!='') alert(altString);
			if (parseInt(objMonth.value) > 12) objMonth.focus();
			else objDay.focus();
		return true;
	}
	return false;
}

function checkDate2(objDate, altString){
	var s_date = new Date(objDate.value);
	var numDay = parseInt(s_date.getDate());
	var numMonth = parseInt(s_date.getMonth()+1);
	var numYear = parseInt(s_date.getFullYear());
if(checkDateTmp(numDay, numMonth, numYear) == false){
		if(altString!='') alert(altString);
			objDate.focus();
		return true;
	}
	return false;
}
function confirmDelete(alertString){
	if(confirm(alertString)==true){
		return true;
	}
	return false;
}

function display_more(id){
f = document.getElementById(id)
	if (f.style.display == ''){
		f.style.display = 'none';
	}else{f.style.display = '';}
}
function display_box(div, href, offx, offy, bid) {
	var e = document.getElementById(div);
	if (e.className.indexOf('hiddenlayer') != -1) {
		e.className = "showlayer";
		box_location(div, href, offx, offy);
		yreg_createBeacon(bid)
	} else if (e.className.indexOf('showlayer') != -1) {
		e.className = "hiddenlayer";
	}
}
function box_location(div, href, offx, offy){
	var e = document.getElementById(div);
	var x=ylib_getPageX(href);//get position of div
	var y=ylib_getPageY(href);
	
	x= offx ? x + offx : x;//if (x = offx){x = x + offx;else{x = x;}}
	y= offy ? y + offy : y;
	ylib_moveTo(e,x,y);
	}
function ylib_getPageX(o) {
	var x=0; 
	while(eval(o)) {
		x+=o.offsetLeft;//similar x= x + o.offserLeft
		o=o.offsetParent;
		} 
	
	return x; 
	}
function ylib_getPageY(o) {
	var y=0; 
		while(eval(o)) {
			y+=o.offsetTop; o=o.offsetParent; 
			} 
	return y; 
	}
function ylib_moveTo(o,x,y) {
	ylib_setX(o,x);
	ylib_setY(o,y);
	}
function yreg_createBeacon(bid) {
	//var r=Math.random();
	e=document.getElementById('yregbcn');	
	if (e) e.innerHTML='<img alt="nthstone Image" width=50 height=1 border=0 src="/images/ymknb_lb.gif"> '; // create beacon img
}
function ylib_setX(o,x) {
		thisPos = parseInt(x);// preventing NS UNcaught Exception Error in strict.dtd mode: converting value to integer in case passed as string
		//for more information pls contact YM! nthstone@yahoo.com or nthung.ubnd@thuathienhue.gov.vn
		thisPos += "px";
		o.style.left = thisPos;

}
function ylib_setY(o,y) {
		thisPos = parseInt(y);			// preventing NS UNcaught Exception Error in strict.dtd mode: converting value to integer in case passed as string
		thisPos += "px";
		o.style.top = thisPos;
	
}
function open_popup(id)
{
window.open("treetTypeElmPopup.asp?opt=sss&iStreetElmTypeId="+id,"_blank","toolbar=no, location=no,  directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=400, height=210")
}
    function displayInfo(tabId){
        if(document.getElementById){
            var infoId = 'info_' + tabId;
            for (i = 1; i < 4; i++ ){
                var info = 'info_' + i;
                if (tabId == i) {
                    document.getElementById(info).style.display = '';
                    document.getElementById(i).style.backgroundColor = '#379FD2';
					document.getElementById(i).style.color = '#ffFFFF';
                    }
							//for more information pls contact YM! nthstone@yahoo.com or nthung.ubnd@thuathienhue.gov.vn
                else {
                document.getElementById(info).style.display = 'none';
                document.getElementById(i).style.backgroundColor = '';
				document.getElementById(i).style.color = '#0B4E75';
                }
            }
        }
    }
function changeColor(id){
if (id != 0) {
	document.getElementById(id).style.backgroundColor = '#1c86ae';
	a_id = id+'_a';
	text_id = id+'_text';

	document.getElementById(a_id).href = '#';
	document.getElementById(a_id).style.color = '#FFFFFF'
	document.getElementById(text_id).style.color = '#FFFFFF'
//	text_id = id+'_text';
//	document.getElementById(a_id).style.font = 'bold';
	}
}
function onMouseOver_Event(id){
	if (id != 0){
	current_color = document.getElementById(id).style.backgroundColor;
	if (current_color != '#1c86ae'){
			document.getElementById(id).style.backgroundColor = '#e4d1e6';	
		}
	}
}
		//for more information pls contact YM! nthstone@yahoo.com or nthung.ubnd@thuathienhue.gov.vn
function onMouseOut_Event(id){
	if (id != 0){
	current_color = document.getElementById(id).style.backgroundColor;
	if (current_color != '#1c86ae'){
			document.getElementById(id).style.backgroundColor = '#D7E7EE';	
		}
	}
}

