function insData(sTable, oForm){
	var sValues=frmValues(oForm);
	//alert(sValues);
	var ReqObj=send2URL("POST", "/xmlSQL.php", "SQL=REPLACE "+sTable+" SET "+sValues, null, null);
	if(ReqObj.responseText.indexOf("<xml")>=0){
		oForm.reset();	
	}else {
		alert(ReqObj.responseText);
	}

}

function frmValues(oForm){
	var sValues="";
	for(var i=0; i<oForm.elements.length; i++){
		if(oForm.elements[i].type!="button") {
			//oForm.elements[i].value=oForm.elements[i].value.replace(/&/g,'and');
			if(oForm.elements[i].getAttribute("num")!=null) 
				sValues+=", "+oForm.elements[i].name+"="+oForm.elements[i].value;
			else if(oForm.elements[i].getAttribute("esc")!=null) 
				sValues+=", "+oForm.elements[i].name+"='"+escape(oForm.elements[i].value.replace(/'/g,"''"))+"'";
			else 	
				sValues+=", "+oForm.elements[i].name+"='"+oForm.elements[i].value.replace(/'/g,"''")+"'";
		}
			
	} 
	if(sValues!="") sValues=sValues.substr(2);
	return sValues; 
}

// Ajax rutines

function execURL(sURL){
	eval(loadURL(sURL,null,null));
}

// loadURL(sURL)
function loadURL(sURL,sUid,sPwd){
	if(sURL==null) return "";
	var ReqObj=send2URL("GET", sURL, null, sUid, sPwd);
	return ReqObj.responseText;
}

// ------------------------------------------------------------------
// GetHTTPObj() Gets the HTTP object
// ------------------------------------------------------------------
function getAjaxObj(){
 var AjaxCon=false;
 // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			AjaxCon= new XMLHttpRequest();
        } catch(e) {
			AjaxCon= false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	AjaxCon= new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		AjaxCon= new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		AjaxCon= false;
        	}
		}
    }
 return AjaxCon;
}

// ------------------------------------------------------------------
// send2URL(Method, URL, Content,User, Pass) Send reques to a URL
// Method: GET, PUT, POST
// URL: Server URL to send content to
// Content: Data that is to be send
// User & Password
// ------------------------------------------------------------------
function send2URL(sMethod, sURL, sContent, sUser, sPass){
 
 var objAjax=getAjaxObj();
 if(objAjax){
	objAjax.open(sMethod, sURL, false, sUser, sPass);
	objAjax.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=iso-8859-9");
	objAjax.setRequestHeader("referer", window.location.host);
	objAjax.send(sContent);
 }
 
 return objAjax;
}

// ------------------------------------------------------------------
// sendASync2URL(Method, URL, Content,UID, Pass, ResHandler) Send reques to a URL
// Method: GET, PUT, POST
// URL: Server URL to send content to
// Content: Data that is to be send
// User & Password
// ResHandler: Rutine that is to handle the response
// ------------------------------------------------------------------
function sendASync2URL(Method, URL, Content,UID, Pass, ResHandler){
 var objAjax=getAjaxObj();
 if(objAjax){
	objAjax.onreadystatechange=ResHandler;
	objAjax.open(Method, URL, true, User, Pass);
	objAjax.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=iso-8859-9");
	objAjax.setRequestHeader("referer", window.location.host);
	objAjax.send(Content);
 }
 
 return obAjax;
}
