// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

/**********new ******************/

function nothing(){
 ''
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function mouseCoords(ev){
        if(ev.pageX || ev.pageY){
                return {x:ev.pageX, y:ev.pageY};
        }
        return {
                x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
                y:ev.clientY + document.documentElement.scrollTop  - document.body.clientTop
        };
}

function findPos(obj) {
        var curleft = curtop = 0;
        if (obj.offsetParent) {
                curleft = obj.offsetLeft
                curtop = obj.offsetTop
                while (obj = obj.offsetParent) {
                        curleft += obj.offsetLeft
                        curtop += obj.offsetTop
                }
        }
        return [curleft,curtop];
}

function getScreenSize(){//will be used for layout purposes will return the active screen dimensions
var screenDim = new Array()
//screenDim[0] = width screenDim[1]= height
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    screenDim[0] = window.innerWidth;
    screenDim[1] = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    screenDim[0] = document.documentElement.clientWidth;
    screenDim[1] = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    screenDim[0] = document.body.clientWidth;
    screenDim[1] = document.body.clientHeight;
  }
  return screenDim;
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function setNecHour(){
  i = 0;
    for(j = 1; j <= parseInt($F('assignment_num_subsections')); j++)
        i += parseFloat($F('nec'+j+'_hour'));
    i = i + (i - parseInt(i) != 0 ? "" : ".0")

  div = $('nec_hour').value = i;

}

function add_day(num){
    v = parseInt($F(num));
    $(num).value = v + 1;
    lst = $$('.day' + (v + 1));
    for(j = 0; j < lst.length; j++)
      lst[j].show();
    if(num != 'assignment_num_subsections'){

    }
    if(num == 'assignment_num_subsections'){
        setNecHour();
        $('nec_hour').disabled = true;
    }
    if(num == 'assignment_num_subsections' ? v == 3 : v == 4)
        $('add_day').hide();
    $('remove_day').show();
}

function remove_day(num){
    v = parseInt($F(num));
    $(num).value = v - 1;
    lst = $$('.day' + v);
    for(j = 0; j < lst.length; j++)
      lst[j].hide();
    if(num == 'assignment_num_subsections'){
        if(v == 1)
          $('nec_hour').disabled = false;
        setNecHour();
    }
    if(num == 'assignment_num_subsections' ? v == 1 : v == 1)
        $('remove_day').hide();
    $('add_day').show();
}

function is_repeat(){
    return ($F('event_repeat0') || $F('event_repeat1') || $F('event_repeat2') || $F('event_repeat3') || $F('event_repeat4') || $F('event_repeat5') || $F('event_repeat6') || $F('event_repeat_month') || $F('event_repeat_year') || $F('event_repeat_daily'))
}

function set_repeat_end(){
    $('repeat_freq').style.display = 'none';
    $('repeat_start_date').style.display = is_repeat() ? '' : 'none';
    $('repeat_end_date').style.display = is_repeat() ? '' : 'none';
    $('event_repeat_month').checked = 0;
    $('event_repeat_year').checked = 0;
    $('event_repeat_daily').checked = 0;
}

function clear_days(){
    $('event_repeat0').checked = 0;
    $('event_repeat1').checked = 0;
    $('event_repeat2').checked = 0;
    $('event_repeat3').checked = 0;
    $('event_repeat4').checked = 0;
    $('event_repeat5').checked = 0;
    $('event_repeat6').checked = 0;
}

function set_repeat_month(){
    clear_days();
    $('freq_type').innerHTML = "months"
    $('repeat_start_date').style.display = is_repeat() ? '' : 'none';
    $('repeat_end_date').style.display = is_repeat() ? '' : 'none';
    $('repeat_freq').style.display = is_repeat() ? '' : 'none';
    $('event_repeat_year').checked = 0;
    $('event_repeat_daily').checked = 0;
}

function set_repeat_year(){
    clear_days();
    $('freq_type').innerHTML = "years"
    $('repeat_start_date').style.display = is_repeat() ? '' : 'none';
    $('repeat_end_date').style.display = is_repeat() ? '' : 'none';
    $('repeat_freq').style.display = is_repeat() ? '' : 'none';
    $('event_repeat_month').checked = 0;
    $('event_repeat_daily').checked = 0;
}

function set_repeat_daily(){
    clear_days();
    $('freq_type').innerHTML = "days"
    $('repeat_start_date').style.display = is_repeat() ? '' : 'none';
    $('repeat_end_date').style.display = is_repeat() ? '' : 'none';
    $('repeat_freq').style.display = is_repeat() ? '' : 'none';
    $('event_repeat_month').checked = 0;
    $('event_repeat_year').checked = 0;
}

function set_delete_mode(){
    val = parseInt($F('delete_type'));
    dels = $$('.delete_button');
    for(i = 0; i < dels.length; i++){
        dels[i].hide();
    }
    dels[val].show();
}

function toTutorial(){
    $('blockerbox').style.display='none';
    $('wiz_box').style.display='none';
    window.location = "/view/render_page/tutorial2?quick=1";
}

function blockCalendar(){
    $('calendar_blockerbox').style.display='block';
}

function allowCalendar(){
    $('calendar_blockerbox').style.display='block';
}


function toggle_type_field(){
    if($('addr_tr').style.display != 'none'){
        $('addr_tr').hide();
        $('file_tr').show();
    }else{
        $('addr_tr').show();
        $('file_tr').hide();
    }
}


function multical(){
    if($F('calendar_id') == 0){
        popup_multical();
        return true;
    }else
        return false;
}


/**************** quickstart **************/

function loadQuick(){
    $('blockerbox').style.display='block';
    $('wiz_box').style.display='block';
    new Ajax.Updater('wiz_inner', '/view/render_page/wizard1?ajax=true', {method: 'get', evalScripts:true});
}

function loadQuick2(){
    $('blockerbox').style.display='block';
    $('wiz_box').style.display='block';
    new Ajax.Updater('wiz_inner', '/view/render_page/wizard1a?ajax=true', {method: 'get', evalScripts:true});
}

function closeQuick(){
    $('blockerbox').style.display='none';
    $('wiz_box').style.display='none';
}

function add_wizard_day(i){
    val = parseInt($F('sub' + i + '[num_dates]'));
    $('sub' + i + '[num_dates]').value = val + 1;
    if(val + 1 == 5)
        $('add_wizard_day_' + i).hide();
    $(('day'+i)+(val+1)).show();
}

function remove_wizard_day(i, j){
    val = parseInt($F('sub' + i + '[num_dates]'));
    $('sub' + i + '[num_dates]').value = val - 1;
    $(('day'+i)+val).hide();
    $('add_wizard_day_' + i).show();
    for(k = j; k < 4; k++){
        $('sub'+i+'[date'+k+'_wday]').value = $F('sub'+i+'[date'+(k+1)+'_wday]');
        $('sub'+i+'[date'+k+'_st]').value = $F('sub'+i+'[date'+(k+1)+'_st]');
        $('sub'+i+'[date'+k+'_len]').value = $F('sub'+i+'[date'+(k+1)+'_len]');
    }
}


/**************** help *******************/

var win

function doHelp(id){// show study rails online help
    win = new Window({className: "alphacube", title: "Study Rails Help", maximizable:false, minimizable:false, width:600, height:400, url: "/view/render_page/help?ajax=true&page="+id, showEffectOptions: {duration:0.5}, onClose:unhilite});
  win.showCenter({modal:true});
  }

function helpIndexReset(){//this resets the selected help index items
  var thelist = $('helpindexlist');
  thelist.childElements().each(function(s) {
  s.removeClassName('selected');
      });
}

function setHelpIndex(id){//this sets the current help index
  helpIndexReset();
  $('hindex_'+id).addClassName('selected');
  new Ajax.Updater('helpcontents', '/view/get_inner_help_data?id='+id, { method: 'get', evalScripts:true });
}


function helphilite(theItem){ //this will take the specified item locate it and its dimensions then hilight it.
  var dest = $(theItem);
  var hilite = $('helphilite');
  pt = findPos(dest);
  //hilite.style.left = pt[0] + 'px';
  //hilite.style.top = pt[1] + 'px';
  //hilite.style.width = dest.offsetWidth;
  //hilite.style.height = dest.offsetHeight;

  Element.clonePosition(hilite, dest);

  hilite.style.display='block';
  hilite.setOpacity(0.4);
}

function unhilite(){
  var hilite = $('helphilite');
  hilite.style.display = 'none';
}


/*************** event popup ***************/

function popup_helper(){
    var popheight=285;
    var popwidth=420;
    var screenDim = new Array();
    screenDim =getScreenSize();
    var thebody=$$('body')[0];
    var popupframe = $('popbox');
    var theblocker = $('blockerbox');

    var fullwidth=screenDim[0];
    var fullheight=screenDim[1];

    theblocker.style.width = fullwidth +"px";
    theblocker.style.height = fullheight +"px";
    theblocker.style.display = 'block';

    newleft = (fullwidth - popwidth)/2;
    newtop = (fullheight - popheight)/2 + getScrollXY()[1];
    popupframe.style.left = newleft + "px";
    popupframe.style.top = newtop + "px";
    popupframe.style.width = popwidth + "px";
    popupframe.style.height = popheight +"px";
}

function popup_multical(){
    popup_helper();
    new Ajax.Updater('popbox', '/view/render_page/popup_multical?ajax=true', { method: 'get', onComplete:showframe });
}

function popup_new_subject(){
    if(global_data.listener)
        return;
    popup_helper();
    new Ajax.Updater('popbox', '/view/render_page/popup_new_subject?ajax=true', { method: 'get', onComplete:showframe });
}

function popup_new_calendar(){
    if(global_data.listener)
        return;
    popup_helper();
    new Ajax.Updater('popbox', '/view/render_page/popup_new_calendar?ajax=true', { method: 'get', onComplete:showframe });
}

function popup_paypal(){
    if(global_data.listener)
        return;
    popup_helper();
    new Ajax.Updater('popbox', '/view/render_page/popup_paypal?ajax=true', { method: 'get', onComplete:showframe });
}

function popup_new_event(popwidth,popheight, is_asgn){
    if(global_data.listener)
        return;
    popup_new_event_internal(popwidth, popheight, is_asgn, '')
}

var subject = '';
var due_date_s = '';
var due_time = '';
var simple_type = false;



function popup_new_event_internal(popwidth, popheight, is_asgn, daten, st, et){
    if(global_data.listener)
        return;
  var newleft, newtop;
  var screenDim = new Array();
  screenDim =getScreenSize();
  var thebody=$$('body')[0];
  var popupframe = $('popbox');
  var theblocker = $('blockerbox');
  var fullwidth=screenDim[0];
  var fullheight=screenDim[1]
  theblocker.style.width = fullwidth +"px";
  theblocker.style.height = 2.0 * fullheight +"px";
  theblocker.style.display = 'block';
  newleft = (fullwidth - popwidth)/2;
  newtop = (fullheight - popheight)/2 + getScrollXY()[1];
  popupframe.style.left = newleft + "px";
  popupframe.style.top = newtop + "px";
  popupframe.style.width = popwidth + "px";
  //popupframe.style.height = popheight +"px";

  if(simple_type){
      new Ajax.Updater('popbox', '/view/render_page/popup_new_' + simple_type + '?ajax=true', { method: 'get', onComplete:showframe});
      simple_type = false;
      return;
  }

  if(daten != '')
    new Ajax.Updater('popbox', '/view/render_page/popup_new_st?ajax=true&isasgn=' + is_asgn + '&datestr=' + daten + '&st=' + st + '&et=' + et, { method: 'get', onComplete:showframe});
  else{
      new Ajax.Updater('popbox', '/view/render_page/popup_new_ass?ajax=true&isasgn=' + is_asgn+'&subject='+subject + '&due_date_s='+due_date_s+'&due_time='+due_time, { method: 'get', onComplete:showframe, evalScripts:true});
  }
}

function hideNewEventpop(){ //closes the new event popup
  $$("body")[0].style.overflow='auto';
  $("popbox").hide();
  $("blockerbox").hide();
  global_data.mouse_border.hide()
  clicking = false
  dragging = false
}

function popup_edit_subject(id){
    if(global_data.listener)
        return;
  pt = findPos($('subject_' + id));
  popupEditEvent(-130, pt[1] - 30,'subject', id, 0)
}

function popupEditEvent(theleft,thetop, type, id, x_start){
    if(global_data.listener)
        return;
  // first find the screen dimensions and open the blocker box
  var popheight=285;
  var popwidth=420;
  var screenDim = new Array();
  screenDim =getScreenSize();
  var thebody=$$('body')[0];
  var popupframe = $('popbox');
  var theblocker = $('blockerbox');

  var fullwidth=screenDim[0];
  var fullheight=screenDim[1]
  theblocker.style.width = fullwidth +"px";
  theblocker.style.height = (type == 'subject' ? 1.0 : 2.0) * fullheight +"px";
  theblocker.style.display = 'block';

  popupframe.style.left = theleft + "px";
  popupframe.style.top = thetop + "px";
  popupframe.style.width = popwidth + "px";
  popupframe.style.height = popheight +"px";
  new Ajax.Updater('popbox', '/view/render_page/popup_new_' + type + '?ajax=true&edit=true&'+(type == 'st' ? 'event' : type == 'ass' ? 'assignment' : type) +'_id=' + id + '&left=' + (global_data.is_week ? x_start : 0) + '&x=' + global_data.x_start , { method: 'get', onComplete:showframe });
}

function showframe(){
  $('popbox').style.display = 'block'
  pngfix();
}

function edit_asgn1(id){
    if(global_data.listener)
        return;
    pt = findPos($('edit_'+ id))
  popupEditEvent(pt[0] - 480, pt[1] - 20, 'ass', id, true);
}

/**************** drag & drop ****************/

var asgn_click = false;
var no_mb = false;
var clicking = false;
var dragging = false;
var global_data = new Array();
var no_event_down = false;

function update_calendar_left(pseudo){
    new Ajax.Updater('leftcolumn', '/view/render_page/calendar_left?ajax=true')
}

function dd_init(is_week, indices, dba, listener){
  global_data.is_week = is_week
  global_data.indices = indices
  global_data.dba = dba
  global_data.listener = listener

  global_data.safari = (navigator.userAgent.indexOf("Safari") != -1)
  global_data.ie = (navigator.appName.indexOf("Microsoft") != -1)
  if(global_data.ie){
      global_data.ie7 = (typeof document.body.style.maxHeight != "undefined");
      global_data.ie6 = !global_data.ie7;
  }
  global_data.ff = !global_data.safari && !global_data.ie
  global_data.ref = $$('.ref')[0];

  global_data.pp = findPos(global_data['ref']);

  global_data.w = global_data['ref'].offsetWidth - (global_data.ie7 ? 1 : 0);
  global_data.h = global_data['ref'].offsetHeight - (global_data.safari ? 1 : 0);
  global_data.mouse_border = $('mouse_border');
  global_data.mouse_border.style.width = (global_data['ref'].offsetWidth - (global_data.ff ? 3 : 4)) + 'px';
  global_data.mouse_border.style.height = (global_data['ref'].offsetHeight - 3) + 'px';
}

function event_down(event, repeat, id, x, y){
    if(global_data.listener)
        return;
  if(no_event_down){
     no_event_down = false
     return
  }
  no_mb = true
  if(global_data.safari)
    event.preventDefault();
  d = new Date()
  global_data.click_start = 1000 * d.getSeconds() + d.getMilliseconds()
  global_data.x_start = x
  global_data.y_start = y
  global_data.event_id = id
  global_data.drag_id = id
  if(repeat != 0){
      pp = global_data.pp;
      pt = findPos($("event_" + repeat));
      popupEditEvent(pt[0] - pp[0] - 50, pt[1] - pp[1] + 150, 'event', global_data.drag_id, (global_data.x_start < 4 ? 0 : 1));
      return;
  }
  dragging = true
  $("event_" + id).addClassName('dragging')
  divs = $$('st_event_' + id)
  for(i = 0; i < divs.length; i++)
    divs[i].hide();
}

function off_mb(){
    no_mb = true;
}

function dd_down(e){
    if(global_data.listener)
        return;
  if(no_mb){
    no_mb = false
    return
  }
  if(dragging)
    return
  if(global_data.safari)
    e.preventDefault();
  if(clicking){
    dd_up(e)
    return
  }
  clicking = true;
  if (!e) var e = window.event
  w = global_data.w;
  h = global_data.h;
  pp = global_data.pp;
  mouse_pos = mouseCoords(e);
  if(global_data.ie6)
        mouse_pos.x -= 230;
  global_data.x_start = parseInt((mouse_pos.x - pp[0]) / w);
  global_data.y_start = parseInt((mouse_pos.y - pp[1]) / h);
  if(global_data.x_start < 0 || global_data.y_start < 0)
    return;
  mouse_bor = global_data.mouse_border;
  mouse_bor.style.left = ((w + (global_data.safari ? 0 : 1) - (global_data.ff ? 0.6 : 0.0)) * global_data.x_start) + 'px';
  mouse_bor.style.top = (h * global_data.y_start) + 'px';
  mouse_bor.style.height = (h - 3) + 'px';
  mouse_bor.show();
}

function dd_move(e){
    if(global_data.listener)
        return;
  if(!clicking && !dragging)
    return
  if(global_data.ie)
    document.selection.empty();

  mouse_pos = mouseCoords(e);
  if(global_data.ie6)
        mouse_pos.x -= 230;
  pp = global_data['pp'];
  //show_time('loc' + v_x_i + '_' + v_y_i, "week");

  if(clicking){
    v = parseInt((mouse_pos.y - pp[1] - global_data.y_start * global_data.h) / global_data.h);
    global_data.mouse_border.style.height = ((v + 1) * (global_data.h)- 3) + 'px';
  }else if(dragging){
    d = $("event_" + global_data.drag_id)
        v = findPos(d)
        //alert(v[1] - pp[1])
    s_y = d.offsetHeight / global_data['h']
    v_y = (mouse_pos.y - pp[1]) / global_data['h']
    v_x = (mouse_pos.x - pp[0]) / global_data['w']
    if(v_y < 0) v_y = 0
    if(v_y > 48 - s_y){v_y = 48 - s_y}
    if(v_x < 0) v_x = 0
    if(v_x > 6) v_x = 6
    v_x_i = parseInt(v_x)
    v_y_i = parseInt(v_y)
    ocl = false;


    if(!ocl){
        y_adjust = 100 * (global_data.h + (global_data.ie7 ? 0 : 0.07)) / (global_data.h);
        d.style.top = 2 * y_adjust * (v_y_i - global_data.y_start) + '%';
        if(global_data.is_week){
            x_adjust = 100 * (global_data.w + (global_data.x_start == 6 ? 2 : (global_data.ie7 ? 1 : 1))) / global_data.w;
            d.style.left =  x_adjust * (v_x_i - global_data.x_start) + '%';
        }
    }
  }
}

function dd_up(e){
    if(global_data.listener)
        return;
    ref = global_data['ref'];
    h = global_data['h'];
    pp = global_data['pp'];

  if(clicking){
    mouse_pos = mouseCoords(e);
    pt = [mouse_pos.x - pp[0], mouse_pos.y - pp[1]];
    clicking = false;
    st = global_data.y_start
    et = parseInt(pt[1] / global_data.h) + 1;

    if(et - st < 1)
      et = st + 1;
    m = global_data.indices[global_data.x_start][0];
    d = global_data.indices[global_data.x_start][1];
    y = global_data.indices[global_data.x_start][2];
    str = (m < 10 ? "0" :"") + m + "/" + (d < 10 ? "0" : "") + d + "/" + (y < 10 ? "0" : "") + y
    popup_new_event_internal(360,366,false, str,(st + 2 * global_data.dba) % 48,(et + 2 * global_data.dba) % 48)
    global_data['mp'] = mouseCoords(e)
  }else if(dragging){
      d = $("event_" + global_data.drag_id)
      date = new Date()
      dragging = false
      d.removeClassName('dragging')
      divs = $$('.st_event_' + global_data.drag_id)
      for(i = 0; i < divs.length; i++)
        divs[i].show();
      if(1000 * date.getSeconds() + date.getMilliseconds() - global_data.click_start < 700){
          pp = global_data.pp;
          pt = findPos(d);
          popupEditEvent(pt[0] - pp[0] - 50, pt[1] - pp[1] + 150, $("event_type_" + global_data.drag_id).innerHTML, global_data.drag_id, (global_data.x_start < 4 ? 0 : 1));
        return;
      }

      pt = findPos(d);
      v_x = parseInt((pt[0] - pp[0]) / global_data.w);
      v_y = (parseInt((pt[1] - pp[1]) / h) + 2 * global_data.dba) % 48;
      ht = Math.ceil(d.offsetHeight / h)

      m = global_data.indices[v_x][0];
      d = global_data.indices[v_x][1];
      y = global_data.indices[v_x][2];
      str = (m < 10 ? "0" :"") + m + "/" + (d < 10 ? "0" : "") + d + "/" + (y < 10 ? "0" : "") + y;
      blockCalendar();
      new Ajax.Updater('contents', '/actions/do_action/edit_cal?event[id]=' + global_data.drag_id + '&event[due_date_s]=' + str + '&event[start_hour]=' + v_y + '&event[end_hour]=' + ((1.0 * v_y + 1.0 * ht) % 48) + '&event[is_frozen]=1', {method:'post', evalScripts:true})
  }
}


/*************** old ************/

function set_color(id, val, box, is_sub){
  $$('.submit_c5')[0].style.border = "solid 2px #F33"
  if(is_sub == 1){
    vals = $F('user_color_subjects').split(',')
    vals[parseInt(id)] = val
    $('user_color_subjects').value = vals.join(",")
  }else{
    $(id).value = val
  }
    vals = $$('.' + id)
    for(i = 0; i < vals.length; i++){
      //vals[i].style.border = "solid 1px black;"
      vals[i].style.opacity = 0.3
      vals[i].style.filter = "alpha(opacity=30)"
      //vals[i].style.MozOpacity = 0.3
    }
    //$$('.' + box + '_' + id)[0].style.border = "solid 1px red;"
    $$('.' + box + '_' + id)[0].style.opacity = 1.0
    $$('.' + box + '_' + id)[0].style.filter = "alpha(opacity=100)"
}

/******************* Assignment2 ************************/




/********* calendar ***************/

function show_time(id, str){
  //if(global_data.safari)
  //  return
  //vals = $$('.time')
  //for(i = 0; i < vals.length; i++){
  //  vals[i].removeClassName('time')
  //  vals[i].innerHTML = ''
  //}

  //a.addClassName('time')
  if(clicking || dragging) return
  a = $$('.' + id)[0]
  a.innerHTML = str

}

function out_time(id){
  if(clicking || dragging) return
  a = $$('.' + id)[0]
  a.innerHTML = ""
}

