function getCookie(c_name)
{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=")
	  if (c_start!=-1)
	    { 
	    c_start=c_start + c_name.length+1 
	    c_end=document.cookie.indexOf(";",c_start)
	    if (c_end==-1) c_end=document.cookie.length
	    return unescape(document.cookie.substring(c_start,c_end))
	    } 
	  }
	return "";
}

function init_poll(id,image_class,type,show_result)
{
	$("poll"+id).innerHTML = '<img src="/design/ellehk/images/ajax-loader-poll.gif" alt="Loading" title="Loading" /></div>';
	var url = "/ajaxext/get_poll";
	var cookietime = getCookie("poll"+id);
	var today=new Date();
	if (cookietime==(today.getDate()))
	{
		show_result = 1;
	}	
	var param = "id=" + id + "&image_class=" + image_class + "&type=" + type + "&show_result=" + show_result;
	new Ajax.Updater("poll"+id,url,{method: 'get',parameters: param});

}

function send_2choices(id,image_class,type)
{
	if(!$("yes"+id).checked&&!$("no"+id).checked)
	{
		alert('请选择一个选项');
		return false;
	}
	else
	{
		res = ($("yes"+id).checked)?1:2;
		sendResult(id,image_class,type,res);
	}
}
function poll_2photos(id,image_class,type,res)
{
	if(!$F("can_poll"+id))
	{
		return false;
	}
	else
	{
		sendResult(id,image_class,type,res)
	}
}
function sendResult(id,image_class,type,res)
{
	var today=new Date();
	$('poll'+id).innerHTML = '<img src="/design/ellehk/images/ajax-loader-poll.gif" alt="Loading" title="Loading" /></div>';
	var url = "/ajaxext/set_poll";
	var param = "id=" + id + "&image_class=" + image_class + "&type=" + type + "&res=" + res + "&time=" + today.getTime();
	new Ajax.Updater("poll"+id,url,{method: 'post',parameters: param});
}
