var obj;
function createXMLHttpRequest(){
    var xmlHttp = null;
    if(typeof XMLHttpRequest != "undefined"){
        xmlHttp = new XMLHttpRequest();
    }
    else if(typeof window.ActiveXObject != "undefined"){
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
        }
        catch(e){
            try {
                xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
            }
            catch(e){
                try {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(e){
                    xmlHttp = null;
                }
            }
        }
    }
    return xmlHttp;
}

function getTheContent(URL,varObj){
    obj = varObj;
    xmlHttp = createXMLHttpRequest();
    if(createXMLHttpRequest()){
		xmlHttp.onreadystatechange = function(){
			if(xmlHttp && xmlHttp.readyState == 4 && xmlHttp.status == 200){
		    	if(varObj.tagName=='INPUT'){    		
		    		if(varObj.id=='fCost'){
		    			varObj.value = formatCurrency(xmlHttp.responseText);
		    			document.getElementById('fSubTotal').value = formatCurrency(document.getElementById('fQty').value * xmlHttp.responseText);     		
		    		}
		    		else{
		    			varObj.value = xmlHttp.responseText;    		
		    		}
		    	}
		    	else{
		    		varObj.innerHTML =xmlHttp.responseText;	    	
		    	}
				
		        xmlHttp = null;
	  		}
		}
	xmlHttp.open("GET", URL, true);
	xmlHttp.send(null);
    } 
}

function getTheContent2(URL,varObj){
    obj = varObj;
    xmlHttp = createXMLHttpRequest();
    if(createXMLHttpRequest()){
	xmlHttp.onreadystatechange = contentIsReady;
	xmlHttp.open("GET", URL, true);
	xmlHttp.send(null);
    } 
}

function contentIsReady(){
    if(xmlHttp && xmlHttp.readyState == 4 && xmlHttp.status == 200){
    	if(obj.tagName=='INPUT'){    		
    		if(obj.id=='fCost'){
    			obj.value = formatCurrency(xmlHttp.responseText);
    			document.getElementById('fSubTotal').value = formatCurrency(document.getElementById('fQty').value * xmlHttp.responseText);     		
    		}
    		else{
    			obj.value = xmlHttp.responseText;    		
    		}
    	}
    	else{
    		obj.innerHTML =xmlHttp.responseText;	    	
    	}
		
        xmlHttp = null;
    }
}

function getTheContent_login(URL,varObj){
    obj = varObj;
    xmlHttp = createXMLHttpRequest();
    if(createXMLHttpRequest()){
	xmlHttp.onreadystatechange = contentIsReady_login;
	xmlHttp.open("GET", URL, true);
	xmlHttp.send(null);
    } 
}

function contentIsReady_login(){
    if(xmlHttp && xmlHttp.readyState == 4){
    	if(xmlHttp.responseText=='fail'){    		
    		alert('El Usuario y/o Password son incorrectos.')
    	}
    	else{
    		obj.innerHTML =xmlHttp.responseText;	    	
    	}
		
        xmlHttp = null;
    }
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} 
		while (obj = obj.offsetParent);
		return [curleft,curtop];
	}
}
function pause() {
//alert( "Starting something");
setTimeout( "end();", 5000);
}

function end() {
//alert( "5 seconds later?");
} 

<!-- Begin
function checkNumeric(objName,minval, maxval,comma,period,hyphen)
{
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen)
{
// only allow 0-9 be entered, plus any values passed
// (can be in any order, and don't have to be comma, period, or hyphen)
// if all numbers allow commas, periods, hyphens or whatever,
// just hard code it here and take out the passed parameters
var checkOK = "0123456789" + comma + period + hyphen;
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";

for (i = 0;  i < checkStr.value.length;  i++)
{
ch = checkStr.value.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{	
alertsay = "Solo se aceptan los siguientes valores \""
alertsay = alertsay + checkOK + "\" en el campo \"" + checkStr.name + "\"."
//alert(alertsay);
return (false);
}

// set the minimum and maximum
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
{
alertsay = "El valor tiene que ser  "
alertsay = alertsay + "igual a \"" + minval + "\" y menor que "
alertsay = alertsay + "igual a \"" + maxval + "\" en el campo \"" + checkStr.name + "\" ."
//alert(alertsay);
return (false);
}
}
//  End -->


function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$ ' + num + '.' + cents);
}
