/* +--------------------------------------------------------------------------+
// | Orginial Code Care Of:                                                   |
// +--------------------------------------------------------------------------+
// | Copyright (c) 2004 Bitflux GmbH                                          |
// +--------------------------------------------------------------------------+
// | Licensed under the Apache License, Version 2.0 (the "License");          |
// | you may not use this file except in compliance with the License.         |
// | You may obtain a copy of the License at                                  |
// | http://www.apache.org/licenses/LICENSE-2.0                               |
// | Unless required by applicable law or agreed to in writing, software      |
// | distributed under the License is distributed on an "AS IS" BASIS,        |
// | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or          |
// | implied. See the License for the specific language governing             |
// | permissions and limitations under the License.                           |
// +--------------------------------------------------------------------------+
// | Author: Bitflux GmbH <devel@bitflux.ch>                                  |
// |         http://blog.bitflux.ch/p1735.html                                |
// | Modified by: Jeff Minard <jeff-js@creatimation.net>                      |
// |         http://jrm.cc/archives/blog/programming/how-to-use-liverequestjs/|                               
// +-------------------------------------------------------------------------*/
								
var pURL = './main.php?module=tender&function=suppliersearch';
var lsReq = false; var t = null; var inID; var tenderid; var organisationid;

if (window.XMLHttpRequest) {
	lsReq = new XMLHttpRequest();
}

function lsInit(id, orgid) {
	tenderid = id;
	organisationid = orgid;
	inID = document.getElementById('area');	
	lsStart();
}
	
function lsStart() {
	if (t) {
		window.clearTimeout(t);
	}
	t = window.setTimeout("lsDoSearch()",400);
}

function lsDoSearch() {
	if (lsReq && lsReq.readyState < 4) {
		lsReq.abort();
	}
	if (window.ActiveXObject) {
		lsReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	lsReq.onreadystatechange= lsProcessReqChange;
	var len1 = itemcatids.length;
	var i = 0;
	var pextra = "";
	for(i = 0; i < len1; i++) {
		var element1 = document.getElementById(itemcatids[i]);
		var element2 = document.getElementById(itemsubcatids[i]);
		pextra += "&category[" + i + "]=" + encodeURI(element1.value) + "&subcategory[" + i + "]=" + encodeURI(element2.value);
	}

	lsReq.open("GET", pURL + "&tenderid=" + encodeURI(tenderid) + "&organisationid=" + encodeURI(organisationid) + "&area=" + encodeURI(inID.value) + pextra);
		 
	lsReq.send(null);
}

function lsProcessReqChange() {
	if (lsReq.readyState == 4) {
		var  sh = document.getElementById("data1");
		sh.innerHTML = lsReq.responseText;
	}
}
