var xhrStatus = null;

function ShowLoadStatus() {
	$('#statusDiv').show();
	return false;
}
function HideLoadStatus() {
	$('#statusDiv').hide();
	return false;
}
function ShowMsg() {
	$('#warningDiv').show();
	return false;
}
function HideMsg() {
	$('#warningDiv').hide();
	return false;
}

function SetInterest(inRelId, inInterestId) {
	var reqUrl = '/ajax.php?aa=setstatus&obj=relation&objid='+inRelId+'&statobj=hr_interestlevel&statobjid='+inInterestId+'&mailtemplateid=85&lang='+lang;
	HideMsg();
	xhrStatus = $.ajax( {
		type: 'GET',
		dataType: 'xml',
		url: reqUrl,
		beforeSend: function(inXHR) {
			ShowLoadStatus();
		},
		success: function(inXml) {
			if (inXml.documentElement.getElementsByTagName('msg')[0]) {
				$('#warningTextDiv').html(inXml.documentElement.getElementsByTagName('msg')[0].firstChild.nodeValue);
				$('#warningIcon').attr('src', '/images2/lvivconsult/ico-'+inXml.documentElement.getElementsByTagName('msg')[0].getAttribute('icon')+'.gif');
				$('#int'+(3-inInterestId)).show();
				$('#int'+inInterestId).hide();
				ShowMsg();
			}
			$('#interestLevel').html(inXml.documentElement.getElementsByTagName('data')[0].firstChild.nodeValue);
			HideLoadStatus();
		},
		error: function(inXml) {
			HideLoadStatus();
		}
	});
	return false;
}

function SetInterview(inRelId, inInterviewStatusId) {
	var reqUrl = '/ajax.php?aa=setstatus&obj=relation&objid='+inRelId+'&statobj=hr_interviewstatus&statobjid='+inInterviewStatusId+'&mailtemplateid=85&lang='+lang;
	HideMsg();
	xhrStatus = $.ajax( {
		type: 'GET',
		dataType: 'xml',
		url: reqUrl,
		beforeSend: function(inXHR) {
			ShowLoadStatus();
		},
		success: function(inXml) {
			if (inXml.documentElement.getElementsByTagName('msg')[0]) {
				$('#warningTextDiv').html(inXml.documentElement.getElementsByTagName('msg')[0].firstChild.nodeValue);
				$('#warningIcon').attr('src', '/images2/lvivconsult/ico-'+inXml.documentElement.getElementsByTagName('msg')[0].getAttribute('icon')+'.gif');
				$('#res'+inInterviewStatusId).hide();
				ShowMsg();
			}
			$('#interviewStatus').html(inXml.documentElement.getElementsByTagName('data')[0].firstChild.nodeValue);
			HideLoadStatus();
		},
		error: function(inXml) {
			HideLoadStatus();
		}
	});
	return false;
}
