var time;
var time_between_each;
var page_type;
var addition_data;

function init_time(loading_time,time_before_first,time_between_two,refresh_type,add_data)
{
  time=loading_time;
  time_between_each = time_between_two;
  page_type = refresh_type;
  addition_data = add_data;
  window.setTimeout("ask_for_refresh()",time_before_first);
}
function ask_for_refresh()
{
  var file = 'refresh_control.php';
  var data = 'time='+time+'&page_type='+page_type+addition_data;
  var aMethod = 'get';
  //window.alert('go!');
  var myAjax = new Ajax.Request(
		file,
		{
               	method: aMethod,
		parameters: data,
		onComplete : refresh_or_not_refresh
		});
}

function refresh_or_not_refresh(ajax_req)
{
  //window.alert(ajax_req.responseText);
  if(ajax_req.responseText != '')
  {
    if(page_type == 'posting')
    {
      parent.frames[0].location.reload();
      time = ajax_req.responseText
    }
    else
    {
      //window.alert('on refresh : '+ajax_req.responseText);
      document.location.reload();
    }
  }
  window.setTimeout("ask_for_refresh()",time_between_each);
}