function wGetXmlHttpRequest() {
	var xmlHttpObj;
	if (window.XMLHttpRequest) {
		xmlHttpObj = new XMLHttpRequest();
	} else {
		try {
			xmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				xmlHttpObj = false;
			}
		}
	}
	return xmlHttpObj;
}

var xmlhttp;

function wFav(f_id,f_st,f_ss) {
	if (!xmlhttp) xmlhttp = wGetXmlHttpRequest();
	if (!xmlhttp) return;
	var url = 'ajax/aj_work_fav.php?' + f_st + '=' + f_id + '&sid=' + f_ss;
	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange = wFav_r;
	xmlhttp.send(null);
	return false;
}

function wSh(s_id,s_st,s_ss) {
	if (!xmlhttp) xmlhttp = wGetXmlHttpRequest();
	if (!xmlhttp) return;
	var url = 'ajax/aj_work_sh.php?' + s_st + '=' + s_id + '&sid=' + s_ss;
	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange = wSh_r;
	xmlhttp.send(null);
	return false;
}

function wFav_r() {
	if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		var statusObj = eval("(" + xmlhttp.responseText + ")");
		var f_st = statusObj['f_st'];
		var f_id = statusObj['f_id'];
		var f_ss = statusObj['f_ss'];
		
		if (f_st == 'on') {
			document.getElementById('f'+f_id).innerHTML='<img src="images/favorite.gif">';
			document.getElementById('fd'+f_id).innerHTML='<a href="javascript:void(0);" onclick="javascript:wFav(\''+f_id+'\',\'favd_id\',\''+f_ss+'\');" title="Удалить из избранного"><img src="images/favorite_del.gif" style="border:0"></a>';
		}
		if (f_st == 'off') {
			document.getElementById('f'+f_id).innerHTML='';
			document.getElementById('fd'+f_id).innerHTML='<a href="javascript:void(0);" onclick="javascript:wFav(\''+f_id+'\',\'fav_id\',\''+f_ss+'\');" title="Добавить в избранное"><img src="images/favorite_add.gif" style="border:0"></a>';
		}
		if (f_st == 'on2') {
			document.getElementById('f'+f_id).innerHTML='<img src="images/favorite2.gif">';
			document.getElementById('fdv'+f_id).innerHTML='<a href="javascript:void(0);" onclick="javascript:wFav(\''+f_id+'\',\'favd2_id\',\''+f_ss+'\');" title="Удалить из Важного"><img src="images/favorite2_del.gif" style="border:0"></a>';
		}
		if (f_st == 'off2') {
			document.getElementById('f'+f_id).innerHTML='<img src="images/favorite.gif">';
			document.getElementById('fdv'+f_id).innerHTML='<a href="javascript:void(0);" onclick="javascript:wFav(\''+f_id+'\',\'fav2_id\',\''+f_ss+'\');" title="Добавить в Важное"><img src="images/favorite2_add.gif" style="border:0"></a>';
		}
	}
}

function wSh_r() {
	if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		var statusObj = eval("(" + xmlhttp.responseText + ")");
		var s_st = statusObj['s_st'];
		var s_id = statusObj['s_id'];
		var s_ss = statusObj['s_ss'];
		
		if (s_st == 'on') {
			document.getElementById('sh'+s_id).innerHTML='<img src="images/sh1.gif" title="Задание скрыто">';
			document.getElementById('shd'+s_id).innerHTML='<a href="javascript:void(0);" onclick="javascript:wSh(\''+s_id+'\',\'shd_id\',\''+s_ss+'\');" title="Не скрывать задание"><img src="images/sh3.gif" style="border:0"></a>';
		}
		if (s_st == 'off') {
			document.getElementById('sh'+s_id).innerHTML='';
			document.getElementById('shd'+s_id).innerHTML='<a href="javascript:void(0);" onclick="javascript:wSh(\''+s_id+'\',\'sh_id\',\''+s_ss+'\');" title="Скрыть задание"><img src="images/sh4.gif" style="border:0" onmouseover="this.src=\'images/sh2.gif\'" onmouseout="this.src=\'images/sh4.gif\'"></a>';
		}
	}
}
