var rate_sender=null;
function inquiry_rate(btn)
{
	var form=btn.form;
	selected_value=-1;
	if(form.i_opt.length!=undefined)
	{
		for(i=0;form.i_opt.length>i;i++) 
		{
			if(form.i_opt[i].checked) selected_value=form.i_opt[i].value;
		}
	}
	else if(form.i_opt.checked) selected_value=form.i_opt.value;
	if(selected_value==-1){alert('Oylamak istediğiniz seçeneği seçiniz.');return false;}
	btn.disabled=true;
	rate_sender=new Ajax();
	if(rate_sender===false) {return true;}
	rate_sender.state_changing=rate_sending;
	rate_sender.send_way='POST';
	data='http_request=1&inquiry_id='+form.inquiry_id.value+'&i_opt='+selected_value;
	rate_sender.send(get_host_name()+'inquiry.php',data);
	return false;
}
function rate_sending()
{
	if(rate_sender.http_object.readyState==4)
	{
		document.getElementById('inquiry_btn').disabled=false;
		if(rate_sender.http_object.status==200)
		{
			if(rate_sender.http_object.responseText=='0')
			{
				alert('Oylama işlemi yapılamadı.');
			}
			else if(rate_sender.http_object.responseText=='3')
			{
				var i_id=document.getElementById('inquiry_btn').form.inquiry_id.value;
				document.getElementById('inquiry_btn').form.getElementsByTagName('div')[0].innerHTML='<p>Bu ankette oy kullanmışsınız.<br /><a href="inquiry.php?inquiry_id='+i_id+'" target="_blank"  onclick="return show_inquiry_detail(this);">Anket sonuçlarını görmek için tıklayınız.</a></p>';
			}
			else if(rate_sender.http_object.responseText=='1')
			{
				var i_id=document.getElementById('inquiry_btn').form.inquiry_id.value;
				document.getElementById('inquiry_btn').form.getElementsByTagName('div')[0].innerHTML='<p>Oylama işlemi tamamlandı.<br /><a href="inquiry.php?inquiry_id='+i_id+'" target="_blank" onclick="return show_inquiry_detail(this);">Anket sonuçlarını görmek için tıklayınız.</a></p>';
			}
		}
	}
}
function show_inquiry_detail(link)
{
	window.open(link.href,'','width=540,height=800,resizable=yes,scrollbars=yes');
	return false;
}
function search_economy_popup()
{
	window.open('data/economy_help.htm','','width=570,height=500,resizable=yes,scrollbars=yes');
	return false;
}
function close_notification()
{
	if(!confirm('Duyuruları kapatmak istiyor musunuz?')) return false;
	var date = new Date();
	var notification_time=document.getElementById('critical_notification').childNodes[0].id.substring(2,12);
	document.getElementById('critical_notification').parentNode.removeChild(document.getElementById('critical_notification'));
	date.setTime(date.getTime()+(24*60*60*1000));
	document.cookie='notification_clsosed='+notification_time+'; expires='+date.toGMTString()+'; path=/';
}
function showOtherAuthors()
{
	if(document.getElementById('other_authors').style.visibility=='visible')
	{
		document.getElementById('other_authors').style.visibility='hidden';
		document.getElementById('other_authors').style.display='none';
	}
	else
	{
		document.getElementById('other_authors').style.visibility='visible';
		document.getElementById('other_authors').style.display='block';
	}
	return false;
}

function show_next_comment(direction)
{
	clearTimeout(comment_timer);
	var active_id=document.getElementById('lates_comments').getElementsByTagName('div')[0].className.substr(10);
	if (direction==0 && (active_id=active_id-2)==-1) active_id=document.getElementById('comment_list').getElementsByTagName('li').length-1;
	else if(direction==1 && active_id==document.getElementById('comment_list').getElementsByTagName('li').length) active_id=0;
	
	document.getElementById('lates_comments').getElementsByTagName('div')[0].innerHTML=document.getElementById('comment_list').getElementsByTagName('li')[active_id].getElementsByTagName('div')[0].innerHTML;
	document.getElementById('lates_comments').getElementsByTagName('p')[0].innerHTML=document.getElementById('comment_list').getElementsByTagName('li')[active_id].getElementsByTagName('p')[0].innerHTML;
	document.getElementById('lates_comments').getElementsByTagName('div')[0].setAttribute('class',document.getElementById('comment_list').getElementsByTagName('li')[active_id].getElementsByTagName('div')[0].className);
	document.getElementById('lates_comments').getElementsByTagName('div')[0].setAttribute('className',document.getElementById('comment_list').getElementsByTagName('li')[active_id].getElementsByTagName('div')[0].className);
	comment_timer=setTimeout('show_next_comment(1)',6500);
}
