var mouse_x=0;
var mouse_window_x=0;
var mouse_y=0;
var mouse_window_y=0;
var load_flag=0;

var active_event_id="";
var active_day_timestamp="";

var info_window = new Object;
var info_window_width = 400;
var info_window_height = 450;

var page_width=0;
var page_height=0;
var event_target= null;
var name;

// I hate this kludge!
var already_showed_context_menu=false;

if (name == "")
{
  name="cal_mainwindow";
}

var main_window_name=name;

document.onmousemove = mousemove;
document.onclick = hide_contextmenus;

function page_loaded()  {
  load_flag=1;
  do_on_load();
  window.self.name = main_window_name;
}
function do_on_load() {return;}

function page_unloaded()  {
  if (info_window.close)
  {
    info_window.close();
  }
}
function daymenu(datestring) {
if (event.ctrlKey){
	return true;
}
else {
	show_day_contextmenu(datestring);
	return false;
}
}

function hide_contextmenus()
{
    //document.getElementById("event_contextmenu").style.visibility = "hidden";
	var obj = MM_findObj("event_contextmenu")
	obj.style.visibility = "hidden";
}

function context_menuitem_highlight(element, color)
{
    element.className = "context_menuitem_highlight";
}

function context_menuitem_unhighlight(element)
{
    element.className = "context_menuitem";
}
function view_event(event_id) {
  var info_window_x = window_x()-400;
  var info_window_y = window_y();
  info_window = this.open("event_view.asp?evt_id=" + event_id, "info_window", "resizable=yes,status=no,scrollbars=yes,top="+info_window_y+",left="+info_window_x+",width=400,height=400");
  info_window.focus();
}
function edit_event()
{
  window.location.href="event_edit.asp?evt_id="+active_event_id;
}

function delete_event()
{
  hide_contextmenus();
  var info_window_x = window_x()-400;
  var info_window_y = window_y();
  //alert(event_id);
  info_window = this.open("event_delete.asp?evt_id=" + active_event_id, "info_window", "resizable=yes,status=yes,scrollbars=yes,top="+info_window_y+",left="+info_window_x+",width=400,height=400");
  info_window.focus();
}