var CurField = "";
var Content = Array();
var CurWhere = "";
var CurId = "";
var CurAction = "";


/*  XML HTTP request rework - rest kept for backward compatibility */
function createRequestObject(){
	// create the XML object
	var request_o;
	var browser = navigator.appName;
	if( browser == "Microsoft Internet Explorer"){
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		request_o = new XMLHttpRequest();
	}
	return request_o;
}
    
var http = createRequestObject(); 
    


function handleResponse(){
	if(http.readyState == 4){ //Finished loading the response
		
		if(http.responseText!=""){
			//alert(http.responseText);
		}
		
		if(CurAction == "saveUserCfg" && http.responseText==""){
			//alert("ok");
			window.setTimeout("document.getElementById('loading').src=eval('loading_done.src')", 500);
		} else if(CurAction == "reorder_task"){
			document.getElementById("edit_content").innerHTML = http.responseText;
		} else {
			alert(http.responseText);
		}
	}
}

function strip_spaces(thisString){
	for (i=0; i<=thisString.length; i++) {
		thisString = thisString.replace(/\s+/,"");
	}
	return thisString;
}



function showSave(){
	//alert('showing: ' + CurField);
	//document.getElementById(CurField).style.display = "";
	if(CurField!=""){
		document.getElementById(CurField + "_save").style.display = "";
		//document.getElementById("saving").style.display = "";
	}	
}
	
function hideSave(){
	//document.getElementById("working").style.display = "none";
	if(CurField!=""){
		//document.getElementById(CurField + "_save").innerHTML = "<div><img src=img/ind_saving_done.gif width=10 height=10 id='theSaving' /><br /><br /><br /><strong><font color='#090'>Saving done.</font>.</strong></div>";
		document.getElementById(CurField + "_save").innerHTML = "<img src=img/ind_saving_done.gif width=10 height=10 id='theSaving' />&nbsp;Done.";
		//document.getElementById("saving").style.display = "none";
		// initImage('theSaving','out');
		// window.setTimeout(hideElement(CurField + "_save"), 50000);
		window.setTimeout("initImage('theSaving','out')", 500);
	}
}

function saveUserCfg(where,what){
	
	document.getElementById('loading').src=eval('loading_anim_save.src');
	CurAction 	= "saveUserCfg";
	CurWhere 	= where;
	
	//var str = "&where=" + where + "&what=" + what + "&whataction=" + CurAction + '';
	var str = "/" + where + "/" + what + "/" + CurAction + '/';
	//alert (ServerPath +'/in.config.php?'+ str);
	http.open('post',  ServerPath + '/index.php');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponse; 
	http.send(str);
	
}

