
function open_must_list(day,of_days)
{
	var http=makereq();
	http.onreadystatechange = function()
	{
		var i=0,zeilen=0,zeile=0;
		if(http.readyState == 4)
		{
			document.getElementById("day_"+day).innerHTML=http.responseText;
			document.getElementById("list_link_"+day).style.display='none';
		}
	};
	http.open('GET',main_path_.substr(0,4)+'ajax/must_do_poi&day='+day+'&of_days='+of_days, 'complete', true);
	http.send(null);
	return true;
}

function change_image(){
	document.getElementById("image").innerHTML=document.getElementById("media_code").innerHTML;
	document.getElementById("title").innerHTML=poi_name_;
	if(document.getElementById("media_title").innerHTML)
		document.getElementById("title").innerHTML=document.getElementById("title").innerHTML+" ("+document.getElementById("media_title").innerHTML+")";
	document.getElementById("cp_right").innerHTML=document.getElementById("media_cp").innerHTML;
	image_divs=document.getElementsByClassName("img_div");
	for(i=0;i<image_divs.length;i++)
		image_divs[i].style.border="#fff 2px solid";
	document.getElementById("img_div_"+document.getElementById("media_id").innerHTML).style.border="#f54c11 2px solid";
}

function guide(i)
{
	if(document.getElementById("table_"+i).style.display=='none')
	{
		document.getElementById("table_"+i).style.display='';
		document.getElementById("list_link_"+i).style.display='none';
		document.getElementById("hide_link_"+i).style.display='';
	}
	else
	{
		document.getElementById("table_"+i).style.display='none';
		document.getElementById("list_link_"+i).style.display='';
		document.getElementById("hide_link_"+i).style.display='none';
	}
	return true;
}

function update_channel(id,type)
{
	var my_location=location.toString();
	var act_count=0;
	var i=0;
	elements=getElementsByClassName(type);
	for(i=0;i<elements.length;i++)
	{
		if(
		(elements[i].src.indexOf("unchecked")==-1 && "img_"+type+id!=elements[i].id) ||
		(elements[i].src.indexOf("unchecked")!=-1 && "img_"+type+id==elements[i].id) ||
		id=="all")
			act_count=act_count+1;
	}

	if(my_location.indexOf("&")!=-1)
	{
		my_location=my_location.substr(0,my_location.indexOf("&"));
	}
	if(my_location.substr(my_location.lastIndexOf("/")+1)+0>0)
		my_location=my_location.substr(0,my_location.lastIndexOf("/"));

	if(document.getElementById('img_'+type+id).src.indexOf("unchecked")!=-1)
		var val=1;
	else
		var val=0;

	if(act_count==0 || act_count==elements.length)
	{
		if(type!="price")
		{
			for(i=0;i<elements.length;i++)
			{
				if(elements[i].src.indexOf("unchecked")==-1)
					elements[i].src = elements[i].src.replace("checked","unchecked");
			}
			if(type!="price" && document.getElementById("img_"+type+"all").src.indexOf("unchecked")!=-1)
				document.getElementById("img_"+type+"all").src = document.getElementById("img_"+type+"all").src.replace("unchecked","checked");
		}
		else
		{
			for(i=0;i<elements.length;i++)
			{
				if(elements[i].src.indexOf("unchecked")!=-1)
					elements[i].src = elements[i].src.replace("unchecked","checked");
			}
		}
	}
	else
	{
		if(document.getElementById('img_'+type+id).src.indexOf("unchecked")!=-1)
		{
			document.getElementById('img_'+type+id).src = document.getElementById('img_'+type+id).src.replace("unchecked","checked");
			if(type!="price" && document.getElementById("img_"+type+"all").src.indexOf("unchecked")==-1)
				document.getElementById("img_"+type+"all").src = document.getElementById("img_"+type+"all").src.replace("checked","unchecked");
		}
		else
		{
			document.getElementById('img_'+type+id).src = document.getElementById('img_'+type+id).src.replace("checked","unchecked");
			if(type!="price" && document.getElementById("img_"+type+"all").src.indexOf("unchecked")==-1)
				document.getElementById("img_"+type+"all").src = document.getElementById("img_"+type+"all").src.replace("checked","unchecked");
		}
	}

	my_location= my_location + '&ajax=true'
	if(order.length>0)my_location = my_location + '&order='+order;
	if(q.length>0)my_location = my_location + '&q='+q;
	if(t.length>0)my_location = my_location + '&t='+t;
	if(x.length>0)my_location = my_location + '&x='+x;
	if(y.length>0)my_location = my_location + '&y='+y;
	if(dst.length>0)my_location = my_location + '&dst='+dst;
	if(order.length>0)my_location = my_location + '&order='+order;
	my_location = my_location + '&'+ type+id + '='+val;

	var http=makereq();
	http.onreadystatechange = function()
	{
		var i=0,zeilen=0,zeile=0;
		if(http.readyState == 4)
		{
			document.getElementById("reload_div").innerHTML=http.responseText;
			document.getElementById("top_list").innerHTML=document.getElementById("new_top").innerHTML;
			zeilen = document.getElementById("num_data").value.split("\n");
			for(i=0;i<zeilen.length;i++)
			{
				zeile=zeilen[i].split(";");

				if(document.getElementById("cat_num_"+zeile[0]))
					document.getElementById("cat_num_"+zeile[0]).innerHTML="("+zeile[1].replace (/^\s+/, '').replace (/\s+$/, '')+")";
			}
			zeilen = document.getElementById("js_data").value.split("\n");
			map.clearOverlays();
			for(i=0;i<zeilen.length;i++)
			{
				zeile=zeilen[i].split(";");
				addMarker(zeile[0],zeile[1],zeile[2],poiclick,i+1);
			}
			setPointsCenter();
		}
	};
	http.open('GET', my_location, 'complete', true);
	http.send(null);
}

function act_dist()
{
	var elements=getElementsByClassName("distance");
	for(i=0;i<elements.length;i++)
		elements[i].style.color='#00B3ED';
}

function use_div(id)
{
	var elements=getElementsByClassName("chan_name");
	for(i=0;i<elements.length;i++){
		elements[i].style.background='';
		elements[i].style.color='';
		}
	var elements=getElementsByClassName("chan_descr");
	for(i=0;i<elements.length;i++)
		elements[i].style.display='none';
	document.getElementById("chan_descr_"+id).style.display='';
	document.getElementById("chan_name_"+id).style.backgroundColor="#FFF";
	document.getElementById("chan_name_"+id).style.color="#0E3566";
	document.getElementById("chan_name_"+id).blur();
}

function use_cal(month,element)
{
	var elements=getElementsByClassName("month_descr");
	for(i=0;i<elements.length;i++)
		elements[i].style.display='none';
	var elements=getElementsByClassName("cal_a");
	for(i=0;i<elements.length;i++)
		elements[i].className='cal_i';
	element.className='cal_a';
	if(document.getElementById("month_descr_"+month))
		document.getElementById("month_descr_"+month).style.display='block';
}

function set_dist(dist,element)
{
	document.getElementById("dst").value=dist;
	var elements=getElementsByClassName("distance");
	for(i=0;i<elements.length;i++)
		elements[i].style.color='#CDCDCD';
	element.style.color="#00B3ED";
}

function cat_flip(id)
{
	flip('sub_'+id);
	if(document.getElementById('img_'+id).src.indexOf("open")==-1)
		document.getElementById('img_'+id).src = document.getElementById('img_'+id).src.replace("close","open");
	else
		document.getElementById('img_'+id).src = document.getElementById('img_'+id).src.replace("open","close");
	return false;
}

function update_quest(id,user_id,value)
{
	var new_val=0;
	if(document.getElementById('img_'+id).src.indexOf("unchecked")!=-1)
	{
		document.getElementById('img_'+id).src = document.getElementById('img_'+id).src.replace("unchecked","checked");
		new_val=1;
	}
	else
	{
		document.getElementById('img_'+id).src = document.getElementById('img_'+id).src.replace("checked","unchecked");
		new_val=0;
	}

	var http=makereq();
	http.onreadystatechange = function()
	{
		if(http.readyState == 4)
		{
			http.responseText;
		}
	};
	http.open('GET', main_path_.substr(0,4)+'ajax/poi_quest_admin&poi_id='+poi_id+'&new_val=' + new_val +  '&value='+value + '&user_id=' + user_id, 'complete', true);
	http.send(null);
}

function hide_erros()
{
	document.getElementById('dirError_G_GEO_UNKNOWN_ADDRESS').style.display='none';
	document.getElementById('dirError_G_GEO_SERVER_ERROR').style.display='none';
	document.getElementById('dirError_G_GEO_MISSING_QUERY').style.display='none';
	document.getElementById('dirError_G_GEO_BAD_REQUEST').style.display='none';
	document.getElementById('dirError_G').style.display='none';
	document.getElementById('dirError_NONE').style.display='none';
}

function update_cat(id)
{
	var new_val=0;

	if(document.getElementById('img_'+id).src.indexOf("unchecked")!=-1)
		new_val='add';
	else
		new_val='del';

	var http=makereq();
	http.onreadystatechange = function()
	{
		var i=0,zeilen=0,zeile=0;
		if(http.readyState == 4)
		{
			if(http.responseText=='to_many')
				alert(text1);
			else
			{
				if(document.getElementById('img_'+http.responseText).src.indexOf("unchecked")!=-1)
					document.getElementById('img_'+http.responseText).src = document.getElementById('img_'+http.responseText).src.replace("unchecked","checked");
				else
					document.getElementById('img_'+http.responseText).src = document.getElementById('img_'+http.responseText).src.replace("checked","unchecked");
			}
		}
	};
	http.open('GET', main_path_.substr(0,4)+'ajax/poi_cat_admin&action='+new_val+'&poi_id='+poi_id+'&location_id=' + location_id + '&cat_id='+id, 'complete', true);
	http.send(null);
}

function update_prop(id,prop)
{
	var new_val=0;

	if(document.getElementById('img_'+id).src.indexOf("unchecked")==-1)
	{
		document.getElementById('img_'+id).src = document.getElementById('img_'+id).src.replace("checked","unchecked");
		new_val='del';
	}
	else
	{
		document.getElementById('img_'+id).src = document.getElementById('img_'+id).src.replace("unchecked","checked");
		new_val='add';
	}
	var http=makereq();
	http.onreadystatechange = function()
	{
		var i=0,zeilen=0,zeile=0;
		if(http.readyState == 4)
		{
			http.responseText;
		}
	};
	http.open('GET', main_path_.substr(0,4)+'ajax/poi_prop_admin&action='+new_val+'&prop_id='+prop+'&poi_id='+poi_id, 'complete', true);
	http.send(null);
}

function update_arround(id,arround_id)
{
	var new_val=0;
	var i=0,count=0;
	for(i=1;i<document.getElementsByName('cat').length;i++)
	{
		if(document.getElementsByName('cat')[i].src.indexOf("unchecked")==-1)count++;
	}
	if(document.getElementById('img_'+id).src.indexOf("unchecked")!=-1)
	{
		if(count>=8)
		{
			alert(text1);
			return false;
		}
		document.getElementById('img_'+id).src = document.getElementById('img_'+id).src.replace("unchecked","checked");
		new_val='add';
	}
	else
	{
		document.getElementById('img_'+id).src = document.getElementById('img_'+id).src.replace("checked","unchecked");
		new_val='del';
	}
	var http=makereq();
	http.onreadystatechange = function()
	{
		if(http.readyState == 4)
		{
			http.responseText;
		}
	};
	http.open('GET', main_path_.substr(0,4)+'ajax/poi_arround_admin&action='+new_val+'&arround_id='+arround_id+'&poi_id='+poi_id, 'complete', true);
	http.send(null);
}

