/*  
 * Author: Raphael (netbox.co.nr)
 * Version: 1.0 (30.10.06) 
 */
var xmlHttpReq = null; 	 
function getAjaxObject(){
	if(window.XMLHttpRequest){
		xmlHttpReq = new XMLHttpRequest();
	} 
	else if(window.ActiveXObject){ 
		try {
			xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			 xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else {  
		alert("Votre navigateur ne supporte pas AJAX, les services ne seront pas disponibles"); 
		xmlHttpReq = false; 
	} 
}			
function processDo(){
	
	if(testServices(document.getElementById("services").value)==0 || testData(document.getElementById("data").value)==0){
		alert("Choisir un service et/ou entrer des données" );			
	}
	else{
	getAjaxObject();				
	xmlHttpReq.onreadystatechange = function(){
		if(xmlHttpReq.readyState == 4 && xmlHttpReq.status == 200){
			resp = xmlHttpReq.responseText;
			document.getElementById('resultat').innerHTML = resp;
		}
	}
	xmlHttpReq.open("POST","services.do.php",true);
	xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	var data = document.getElementById('data').value;
	var services = document.getElementById("services").value;
	xmlHttpReq.send("s="+services+"&d="+data);
	}
}

function testServices(str){
	var array = new Array();
	var isExisting = 0;
	array[0] = "md5";
	array[1] = "sha1";
	array[2] = "crc32";
	array[3] = "urlencode";
	array[4] = "urldecode";
	array[5] = "encrypt";
	array[6] = "hostbyip";
	array[7] = "hostbyname";
	

	for(var i=0; i<array.length;i++){
		if(array[i]==str){
			isExisting=1;
		}
	}
	return isExisting;
}
function testData(str){
	var isExisting = 0;
	if(str.length>0){
		isExisting=1;
	}	
	return isExisting;
}

