/********************************* AJAX *********************************/

function getHTTPObject(){
	var xmlhttp;
	// Attempt to initialize xmlhttp object
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
    catch (e) {
		// Try to use different activex object
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E) {
			xmlhttp = false;
		}
	}
	// If not initialized, create XMLHttpRequest object
	if (!xmlhttp) {
		if (typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		else {
			alert("This browser does not support AJAX.");
			return null;
		}
	}
	return xmlhttp;
}

// Implement business logic
function change_hint(cat_id){
	httpObject = getHTTPObject();
	if (httpObject != null) {
		loc = '/adauga_anunt/change_hint/' + cat_id;
		httpObject.open("GET", loc, true);
		httpObject.onreadystatechange = setOutputHint;
		httpObject.send(null);
	}
}

function setOutputHint(){
	var title_hint = document.getElementById('title_hint');
	if(httpObject.readyState == 4){
		title_hint.innerHTML = httpObject.responseText;
		title_hint.style.display = 'block';
	}
}

function change_desc_hint(cat_id){
	httpObject = getHTTPObject();
	if (httpObject != null) {
		loc = '/adauga_anunt/change_desc_hint/' + cat_id;
		httpObject.open("GET", loc, true);
		httpObject.onreadystatechange = setOutputDescHint;
		httpObject.send(null);
	}
}

function setOutputDescHint(){
	var desc_hint = document.getElementById('desc_hint');
	if(httpObject.readyState == 4){
		desc_hint.innerHTML = httpObject.responseText;
		desc_hint.style.display = 'block';
	}
}

function change_tip_hint(cat_id, tip){
	httpObject = getHTTPObject();
	if (httpObject != null) {
		loc = '/adauga_anunt/change_tip_hint/' + cat_id + '/' + tip;
		httpObject.open("GET", loc, true);
		httpObject.onreadystatechange = setOutputDescHint;
		httpObject.send(null);
	}
}