/* ---------------------------- */
/* XMLHTTPRequest Enable 		*/
/* ---------------------------- */

function createObject() {
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
	request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_type = new XMLHttpRequest();
	}
		return request_type;
}

var http = createObject();

/* -------------------------- */
/* SEARCH					 */
/* -------------------------- */
function sokcadang(lg) {
q = document.getElementById('caritext').value;
//q.setAttribute( "autocomplete","off" );
//neg = document.getElementById('neg');
//kat = kat_value;
//alert(q);//alert(neg);
//q = q + '|' + kat_nilai + '|' + neg_nilai;
//alert(lg);//lg ialah pilihan bahasa
//alert(kat_nilai);
//alert(neg_nilai);
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'webcari.php?q='+ q + '&lg=' + lg + '&nocache = '+nocache);
http.onreadystatechange = sokcadangReply;
http.send(null);
}


function sokcadangReply() {
if(http.readyState == 4){
    var z=1000;
	var response = http.responseText;
    var matchList = document.getElementById('jumpa'); 
	var areamenu1 = document.getElementById('carian'); 
	var areamenu3 = document.getElementById('topmenu3'); 
	var areamenu4 = document.getElementById('myjquerymenu'); 
	
	jaw = response.split("||");
	matchList.size = 0;
	matchList.style.visibility = 'hidden';
    areamenu3.style.zIndex = 1;    	
	//alert(response);
	//alert(jaw[0]);
		if(jaw[0]>0){
		//alert(response);
		areamenu1.style.zIndex = z;
		matchList.style.visibility = 'visible';
		matchList.options.length = 0; //reset the states dropdown
        matchList.size = jaw[0];
		//arsize = jaw[0]-1;
		//alert(matchList.size);
	    for (var i = 0; i < matchList.size; i++)

       {
        //alert(jaw[i+1]);
		if ((jaw[i].length)>0) {
        matchList.options[matchList.options.length] =new Option(trime(jaw[i+1]));
                               }
       }
	
	
}
}
}



function jumpacari(matches) {
//alert(matches);
var txttype = document.getElementById("caritext");

txttype.value = matches.options[matches.selectedIndex].text;
//document.form1.cariall.focus();
//alert(txttype.value);
}


function whatkeypress(event) {

var yeskey = event.keyCode;

if (yeskey==40) {document.form1.jumpa.focus();}
if (yeskey==9) {document.form1.jumpa.focus();}
//if (yeskey==13) {jumpacari(document.frm1.jumpa.selectedIndex);}


                         }
						 
						 
function whatkeypress1(event,matches) {

var yeskey = event.keyCode;

if (yeskey==13) {jumpacari(matches);matches.style.visibility = 'hidden';document.form1.cariall.focus();}
//alert(yeskey);


                         }						


function jtutup() {
    var matchList = document.getElementById('jumpa');
	var areamenu1 = document.getElementById('carian');
        matchList.options.length = 0; //reset the states dropdown
        matchList.style.visibility = 'hidden';
		//document.getElementById('caritext').value="";
		areamenu1.style.zIndex = 1;
                          }

function trime(varmasuk) {
    return varmasuk.replace(/^\s*/, "").replace(/\s*$/, "");

                  }



function hidetahun(val) {
    var bor = document.frmborang.jborang.selectedIndex;
	//var tahbor = document.getElementById('tahunbor');
    //alert(bor);
	//alert(val);
	if (bor>=4 && bor<=8) {document.frmborang.tahunbor.selectedIndex = (val-1)} else {document.frmborang.tahunbor.selectedIndex = 0}  
		
}


				  
						 
