// JavaScript Document
function autoiFocus()
{
	autoFlashDiv('ifocus','Y',324);
}
function iFocusChange(){
	flashDivChange('ifocus','Y',324);
}
setInterval('autoiFocus()',5000);
addLoadEvent(iFocusChange);
function get_vote(id)
{
	if (parseInt(id) > 0)
	{
		Ajax.call('vote.php', 'act=view&voteid='+id, voteViewResponse, 'POST', 'JSON');
	}
	
}
function voteViewResponse(result){
  if (result.error == 0)
  {
  	js_msgbox(result.content,400,200,2);
  }else{
  	alert(result.message);
  }
}
function submit_vote()
{
  var frm     = document.forms['vote_form'];
  var type    = frm.elements['type'].value;
  var vote_id = frm.elements['vote_id'].value;
  var option_id = 0;
  if (frm.elements['option_id'].checked)
  {
    option_id = frm.elements['option_id'].value;
  }
  else
  {
    for (i=0; i<frm.elements['option_id'].length; i++ )
    {
      if (frm.elements['option_id'][i].checked)
      {
        option_id = (type == 0) ? option_id + "," + frm.elements['option_id'][i].value : frm.elements['option_id'][i].value;
      }
    }
  }
  if (option_id == 0)
  {
    return;
  }
  else
  {
    Ajax.call('vote.php', 'vote=' + vote_id + '&options=' + option_id + "&type=" + type, voteResponse, 'POST', 'JSON');
  }
  return false;
}
function voteResponse(result)
{
  if (result.message.length > 0)
  {
    alert(result.message);
  }
}