// JavaScript Document
function checkTextAreaKeyDown(evt, obj, len) {
	var status=false;
	var chrCode;
	if(evt.which) { chrCode=evt.which; }
	else if(evt.keyCode) { chrCode=evt.keyCode}
	else { chrCode=0; }
	if(chrCode==8 || chrCode==46 || chrCode==40 || chrCode==39 ||
	   chrCode==38 || chrCode==37 || chrCode==9 || chrCode==36 || chrCode==35 || chrCode==116) {
		status=true;
	}
	if(!status) {
 	 if(obj.value.length>=len) {
		obj.value=obj.value.substring(0,len);
		return false;
	 }
	 else {
		return true;
	 }
	}
}
function checkTextAreaKeyUp(obj, len, objDiv) {
	objDiv.innerHTML="Characters: " + obj.value.length + " of " + len;
}
function checkTextAreaBlur(obj, len, objDiv) {
	if(obj.value.length>len) {
		obj.value=obj.value.substring(0,len);
		objDiv.innerHTML="Characters: " + obj.value.length + " of " + len;
	}
}
function textAreaLoad(obj, len, objDiv) {
	objDiv.innerHTML="Characters: " + obj.value.length + " of " + len;
}
function setComboItem(objId, text, value) {
	var obj=document.getElementById(objId);
	var x;
	if(trim(value)!='') {
		for(x=0;x<obj.options.length;x++) {
			if(obj.options[x].value==value) {
				obj.selectedIndex=x;
				break;
			}
		}
	}
	else if(trim(text)!='') {
		for(x=0;x<obj.options.length;x++) {
			if(obj.options[x].text==text) {
				obj.selectedIndex=x;
				break;
			}
		}
	}
	else { }
}
function displayDivCentered(divId) {
	var objDiv=document.getElementById(divId);
	var objDivUnderLay=document.getElementById('MsgBoxUnderLay');
	var x
	var y
	var divWidth
	var divHeight
	var innerHeight
	var innerWidth
	var scrollTop
	divWidth=parseInt(objDiv.style.width);
	divHeight=parseInt(objDiv.style.height);
	scrollTop=parseInt(document.documentElement.scrollTop);
	if(document.all) {
		innerHeight=parseInt(document.documentElement.clientHeight);
		innerWidth=parseInt(document.documentElement.clientWidth);
	}
	else {
		innerHeight=parseInt(window.innerHeight);
		innerWidth=parseInt(window.innerWidth);
	}
	x=parseInt(parseFloat(innerWidth)/2)-parseInt(parseFloat(divWidth)/2);
	y=parseInt(parseFloat(innerHeight)/2)-parseInt(parseFloat(divHeight)/2)+scrollTop;
	//
	objDivUnderLay.style.top=y+'px';
	objDivUnderLay.style.left=x+'px';
	objDivUnderLay.style.visibility='visible';
	//
	objDiv.style.top=y+'px';
	objDiv.style.left=x+'px';
	objDiv.style.visibility='visible';
}
function hideDivCentered(divId) {
	var objDiv=document.getElementById(divId);
	var objDivUnderLay=document.getElementById('MsgBoxUnderLay');
	objDivUnderLay.style.visibility='hidden';
	objDiv.style.visibility='hidden';
}
/* string related functions - Start */
function trim(strOld) {
	var x;
	var len=strOld.length;
	for(x=0;x<len;x++) {
		if(strOld.charAt(0)==' ') {
			strOld=strOld.substring(1);
		}
		else {
			break;
		}
	}
	len=strOld.length;
	for(x=len-1;x>=0;x--) {
		if(strOld.charAt(strOld.length-1)==' ') {
			strOld=strOld.substring(0,strOld.length-1);
		}
		else {
			break;
		}
	}
	return strOld;
}
function allowChars(chrType, chrCode) {
	var status=false;
	if(chrCode==8 || chrCode==46 || chrCode==40 || chrCode==39 ||
	   chrCode==38 || chrCode==37 || chrCode==9) {
		status=true;
	}
	else {
		if(chrType=='f') {
			if((chrCode>=48 && chrCode<=57) || (chrCode>=96 && chrCode<=105) || chrCode==190 || chrCode==110 || chrCode==16 || chrCode==35 || chrCode==36) {
				status=true;
			}
			else {
				status=false;
			}
		}
		else if(chrType=='p') {
			if((chrCode>=48 && chrCode<=57) || (chrCode>=96 && chrCode<=105) || chrCode==110 || chrCode==109 || chrCode==16 || chrCode==35 || chrCode==36) {
				status=true;
			}
			else {
				status=false;
			}
		}
		else if(chrType=='d') {
			if((chrCode>=48 && chrCode<=57) || (chrCode>=96 && chrCode<=105) || chrCode==110 || chrCode==16 || chrCode==35 || chrCode==36) {
				status=true;
			}
			else {
				status=false;
			}
		}
		else if(chrType=='x') {
			if((chrCode>=65 && chrCode<=90) || chrCode==32 || chrCode==190 || chrCode==110 || chrCode==16 || chrCode==35 || chrCode==36) {
				status=true;
			}
			else {
				status=false;
			}
		}
		else { }
	}
	return status;
}
function getCharCode(evt) {
	var charCode;
	if(evt.which) { charCode=evt.which; }
	else if(evt.keyCode) { charCode=evt.keyCode}
	else { charCode=0; }
	return charCode;
}
function forEnterKey(forSubmit, evt) {
	var	status=false;
	var charCode;
	if(evt.which) { charCode=evt.which; }
	else if(evt.keyCode) { charCode=evt.keyCode}
	else { charCode=0; }
	if(charCode==13) {
		if(forSubmit) {
			status=true;
		}
		else {
			status=false;
		}
	}
	else {
		status=false;
	}
	return status;
}
/* string related functions - End */