var cur_day = 0;

function load_program_by_day (id,day)
{ document.getElementById("program").innerHTML = "";

  var req = new Array();
  req.push ({field:"venue",value:id});
  req.push ({field:"day",value:day});
  
  RemoteServiceCall (req,"helper.php?do=do_show_program","POST",false,function(xmlhttp){   
    document.getElementById("program").innerHTML = xmlhttp.responseText;

    document.getElementById("day_"+cur_day).className = "day";
    cur_day = day;
    document.getElementById("day_"+day).className = "day_selected";
    
    //RESIZE THE CONTAINER WINDOW
    window.top.resize(window.name);
  });
}

function load_venue(id)
{ document.getElementById("venue").innerHTML = "";

  var req = new Array();
 
  req.push ({field:"id",value:id});
  RemoteServiceCall (req,"helper.php?do=do_show_venue","POST",false,function(xmlhttp){
     document.getElementById("venue").innerHTML = xmlhttp.responseText;
  });
  load_program_by_day (id,cur_day);
}

function init_program ()
{ //get day today
  var d = new Date();
  cur_day = d.getDay()-1;
  cur_day = (cur_day < 0) ? 6 : cur_day;

  //load today program of first venue
  var obj = document.venue.venue;

  if (obj.options.length)
  { obj.options[0].selected = "selected";
    load_venue(obj.options[0].value);
  }
}

function show_program (id)
{ var path = "http://www.today.com.gr/administrator/modules/mod_program/helper.php?do=do_show_content_program&id="+id
  var wnd = window.open(path,"_program","status=0,toolbar=0,menubar=0,resizable=1,scrollbars=1,width=1010,height=140");
}

function highlight_cur_date ()
{ var d = new Date();
  cur_day = d.getDay()-1;
  cur_day = (cur_day < 0) ? 6 : cur_day;
  if (elem = document.getElementById("d_"+cur_day))
    elem.className = "day_selected";
}