var pageWidth=0;
var pageHeight=0;
var reqA, reqB;

function newXmlDoc() {
	var xdoc;
	
	if (document.implementation && document.implementation.createDocument)
	{
		xdoc = document.implementation.createDocument("", "", null);
	}
	else if (window.ActiveXObject)
	{
		xdoc = new ActiveXObject("Microsoft.XMLDOM");
 	}
	return xdoc;
}

function movePopup(id, x, y, w, h) {
	document.getElementById(id).style.position="absolute";
	document.getElementById(id).style.left="" + x + "px";
	document.getElementById(id).style.top="" + y + "px";
	document.getElementById(id).style.width="" + w + "px";
	document.getElementById(id).style.height="" + h + "px";
}

function isNumeric(strString) {
 	//  check for valid numeric strings	

  var strValidChars = "0123456789.-";
  var strChar;
  var blnResult = true;

  if (strString.length == 0) return false;

  //  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 Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;

} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function


function maxBrowser() {
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth,screen.availHeight);
}

function pageSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  pageWidth = myWidth;
  pageHeight = myHeight;
  
//  window.alert( 'Width = ' + myWidth + ', Height = ' + myHeight);
}

function getMsgFromXml(xmldoc) {
	var eles;
	eles = xmldoc.getElementsByTagName("msg");
	if (eles.length > 0) {
		return eles[0].childNodes[0].nodeValue;
	}
	else {
		return "";
	}
}

function getRecordCountFromXml(xmldoc) {
	var eles, st;
	eles = xmldoc.getElementsByTagName("recordcount");
	if (eles.length > 0) {
		st = eles[0].childNodes[0].nodeValue;
		if (st == null) return 0;
		else return st - 0;
	}
	else {
		return 0;
	}
}


function getErrorFromXml(xmldoc) {
	var eles, st, inodes, i;
	
	st = "";
	eles = xmldoc.getElementsByTagName("error");
	if (eles.length > 0) {
		inodes = eles[0].childNodes;
		for (i=0; i < inodes.length; i++) {
			inode = inodes[i];
			st += inode.nodeName + " : " + inode.childNodes[0].nodeValue + "<br>";
		}
	}
	return st;
}



function dspmsg(msg) {
	document.getElementById("DIV_msg").innerHTML = msg;
}


function initHttpReqA() {
	reqA = false;
  if(window.XMLHttpRequest) {
  	try {
			reqA = new XMLHttpRequest();
    }
    catch(e) {
			reqA = false;
		}
  } 
  else if(window.ActiveXObject) {
		try {
			reqA = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			try {
				reqA = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(e) {
				reqA = false;
			}
		}
	}
}

function initHttpReqB() {
	reqB = false;
  if(window.XMLHttpRequest) {
  	try {
			reqB = new XMLHttpRequest();
    }
    catch(e) {
			reqB = false;
		}
  } 
  else if(window.ActiveXObject) {
		try {
			reqB = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			try {
				reqB = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(e) {
				reqB = false;
			}
		}
	}
}


function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}




