var IE = document.all?true:false;
document.onmousedown = GetMousePos;
var MousePosX = 0;
var MousePosY = 0;

function GetMousePos(Event){
  /*
   * Fired by any click on document.
   */
  if (IE) { // grab the x-y pos.s if browser is IE
    MousePosX = event.clientX + document.body.scrollLeft;
    MousePosY = event.clientY + document.body.scrollTop;
  }
  else {  // grab the x-y pos.s if browser is NS
    MousePosX = Event.pageX;
    MousePosY = Event.pageY;
  }  
  if (MousePosX < 0){MousePosX = 0;}
  if (MousePosY < 0){MousePosY = 0;}  

  return true;
}

function GetWindowWidth(){
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myWidth;
}

function ResizeTextArea(TextArea, ControlDiv){
  var ta=document.getElementById(TextArea);
  var div=document.getElementById(ControlDiv);
  var re=/\n+/g;
  var FontSize=ta.style.fontSize;
  div.style.fontSize=ta.style.fontSize;
  div.style.width=ta.offsetWidth-10+'px';
  div.innerHTML=ta.value.replace(re,'<br>')+'<br><br>';
  ta.style.height=(div.offsetHeight+FontSize)+'px';
}

function ChangeRowClass(Row, ClassName){
  var i;
  for(i=0;i<Row.cells.length;i++){
    Row.cells[i].className=ClassName;
  }
}

function setPointer(Row, Action, OriginalClass){
  switch(Action){
    case 'over':
      if(Row.cells[0].className.toLowerCase()!="tdrowselected"){
        ChangeRowClass(Row, "TDRowOver");
      }
      break;
    case 'out':
      if(Row.cells[0].className.toLowerCase()!="tdrowselected"){
        ChangeRowClass(Row, OriginalClass);
      }
      break;
    case 'click':
      var rows = Row.parentNode.getElementsByTagName("tr"); 
      for(j = 0; j < rows.length; j++){   
        if(Row.parentNode.rows[j].cells[0].className.toLowerCase()!="tdrowheader"){
          if(j % 2 == 0){
            ChangeRowClass(Row.parentNode.rows[j], "TDRow1");
          }else{
            ChangeRowClass(Row.parentNode.rows[j], "TDRow2");
          }
        }
      }
      
      if(Row.cells[0].className.toLowerCase()!="tdrowselected"){
        ChangeRowClass(Row, "TDRowSelected");
      }else{
        ChangeRowClass(Row, OriginalClass);
      }
      break;
  }
  return true;
}

function IsMaxLength(obj){
  var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
  if (obj.getAttribute && obj.value.length>mlength)
  obj.value=obj.value.substring(0,mlength)
}

var menuids=new Array();

function buildsubmenus_horizontal(){
  for (var i=0; i<menuids.length; i++){
    var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item
			ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon";
		}
		else{ //else if this is a sub level menu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    	ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon";
		}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible";
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden";
    }
    }
  }
}


function IC_ModalInit(){
  if(!document.getElementById('ICModal')){
    $("body").append('<div id="ICModal"></div><div id="ICModalForm"></div>');
  }else{
    document.getElementById('ICModal').style.display='block';
  }
  
  IC_DIVResize();
  IC_Position();
  
}

function IC_Position(){
  yPosition=GetWindowHeight()/2-225;
  xPosition=GetWindowWidth()/2-225;
  document.getElementById('ICModalForm').style.top=yPosition+'px';
  document.getElementById('ICModalForm').style.left=xPosition+'px';
}

function GetWindowWidth(){
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myWidth;
}

function GetWindowHeight(){
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function IC_ModalClose(){
  document.getElementById('ICModalForm').style.display='none';
  document.getElementById('ICModal').style.display='none';
/*  document.getElementById('ICModalForm').innerHTML=''; */
}

function IC_DIVResize(){
  if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) {
    yScroll = window.innerHeight + window.scrollMaxY;
    xScroll = window.innerWidth + window.scrollMaxX;
  } else {
    if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){
      yScroll = document.body.scrollHeight;
      xScroll = document.body.scrollWidth;
    } else { 
      yScroll = document.body.offsetHeight;
      xScroll = document.body.offsetWidth;
    }
  }
  $("#ICModal").css({"left":0 +"px", "top":0 +"px","height":yScroll +"px", "width":xScroll +"px"});
}

function ColorSelectorInit(DivID,InnerHTML,IsPlanner){
  var SelectorDIV=DivID;
  //InnerHTML="<input type=\'text\'  name=\'Unique_Color\' id=\'Unique_Color\' size=\'17\'>";
  InnerHTML="";
  document.getElementById(SelectorDIV).innerHTML='';
  var Content="<div style=\'float:left;\' name=\'ColorPattern\' id=\'ColorPattern\'></div>"+InnerHTML;
  document.getElementById(SelectorDIV).innerHTML=Content;
  if(IsPlanner!=1){
    $('#ColorPattern').empty()
      .addColorPicker({
        clickCallback: function(c) {
              var InfoID= document.getElementById('infoid').value;
              xajax_SetAttribute(InfoID, 'style','color', c, 'string');
              //document.getElementById('nodeATag'+document.getElementById('infoid').value).style.color=c;
              document.getElementById('ColorPicker').style.display='none';
        },
      
        colors: [ '#FDDDCE','#FFD990','#FFF799','#C4DF9B','#B3FFB2',
                  '#7FCBAE','#81D3EB','#ADCDEC','#D3B6D7','#FCDEE0','#CC6666','#FF9900',
                  '#D3BD2A','#8FB73E','#6DB286','#4F9BAA','#6D9AB4','#6F85C2','#897AB9',
                  '#B7798E','#ED1C24','#FF6600','#FFFF00','#9ACA3C','#00FF00','#00FFFF',
                  '#0000FF','#4F57A6','#800080','#FF00FF','#FFFFFF','#E5E5E5',
                  '#D9D9D9','#CCCCCC','#B3B3B3','#999999','#808080','#666666','#000000']

      });
  }else{
    $('#'+DivID).empty()
      .addColorPicker({
        clickCallback: function(c) {
            var ID= document.getElementById('editedappointmentid').value;
            if(SelectorDIV=='ColorPicker_bg'){
              document.getElementById('color_bg').value=c;
              document.getElementById('title').style.backgroundColor=c;
            }else{
              document.getElementById('color_text').value=c;
              document.getElementById('title').style.color=c;
            }
            document.getElementById(SelectorDIV).style.display='none';
        },
      
        colors: [ '#FDDDCE','#FFD990','#FFF799','#C4DF9B','#B3FFB2',
                  '#7FCBAE','#81D3EB','#ADCDEC','#D3B6D7','#FCDEE0','#CC6666','#FF9900',
                  '#D3BD2A','#8FB73E','#6DB286','#4F9BAA','#6D9AB4','#6F85C2','#897AB9',
                  '#B7798E','#ED1C24','#FF6600','#FFFF00','#9ACA3C','#00FF00','#00FFFF',
                  '#0000FF','#4F57A6','#800080','#FF00FF','#FFFFFF','#E5E5E5',
                  '#D9D9D9','#CCCCCC','#B3B3B3','#999999','#808080','#666666','#000000']

      });
  }
  
  $("#Unique_Color").keyup(function(){
    var color=isThatAColor($("#Unique_Color").val());
    if(color){
      var InfoID= document.getElementById('infoid').value;
      xajax_SetAttribute(InfoID, 'style', 'color',color, 'string');
      //document.getElementById('selected_tree_element').style.color=color;
      document.getElementById('ColorPicker').style.display='none';
    }
  });
}

  function ColorSelectorClose(){
    document.getElementById('ColorSelector').innerHTML='';
    document.getElementById('ColorSelector').style.display='none';
  }

  function ColorSelectorInitNew(DivID, SampleObject, CSSElement, Mode){
    document.getElementById(DivID).innerHTML='';
    var Content="<div style=\'float:left;\' name=\'ColorPattern\' id=\'ColorPattern\'></div>";
    document.getElementById(DivID).innerHTML=Content;
    $('#'+DivID).empty()
      .addColorPicker({
        clickCallback: function(c) {
            
            switch(CSSElement){
              case "backgroundColor":
                document.getElementById(DivID+'_hidden').value=c;
                document.getElementById(SampleObject).style.backgroundColor=c;
                document.getElementById(DivID).style.display='none';
                break;
              case "color":
                document.getElementById(DivID+'_hidden').value=c;
                document.getElementById(SampleObject).style.color=c;
                document.getElementById(DivID).style.display='none';
                break;  
              case "chatcolor":
                document.getElementById(DivID+'_hidden').value=c;
                document.getElementById(SampleObject).style.backgroundColor=c;
                xajax_SetSettings('chatcolor', c);
                document.getElementById(DivID).style.display='none';
                break;
              case "categorybgcolor":
                document.getElementById(SampleObject).style.backgroundColor=c;
                Temp=SampleObject.split('_');
                xajax_SavePlannerCategoryProperty(Temp[1], 'categorybgcolor', c);
                break;
              case "categorycolor":
                document.getElementById(SampleObject).style.color=c;
                Temp=SampleObject.split('_');
                xajax_SavePlannerCategoryProperty(Temp[1], 'categorycolor', c);
                break;
              case "infotreecolor":
                document.getElementById(SampleObject).style.backgroundColor=c;
                //xajax_SaveInfotreeProperty('color',c,document.getElementById('infoid').value);
                xajax_SetAttribute(document.getElementById('infoid').value, 'style','color', c, 'string');
                document.getElementById(DivID).style.display='none';
                break;
            }
            switch(Mode){
              case "appointmentedit":
                xajax_LoadRightMenuLevel2("category", document.getElementById('editedappointmentid').value, "", "DataSheetCategory", document.getElementById("addedcategory").value,"addedcategory" );
                break;
            }
            
        },
      
        colors: [ '#FDDDCE','#FFD990','#FFF799','#C4DF9B','#B3FFB2',
                  '#7FCBAE','#81D3EB','#ADCDEC','#D3B6D7','#FCDEE0','#CC6666','#FF9900',
                  '#D3BD2A','#8FB73E','#6DB286','#4F9BAA','#6D9AB4','#6F85C2','#897AB9',
                  '#B7798E','#ED1C24','#FF6600','#FFFF00','#9ACA3C','#00FF00','#00FFFF',
                  '#0000FF','#4F57A6','#800080','#FF00FF','#FFFFFF','#E5E5E5',
                  '#D9D9D9','#CCCCCC','#B3B3B3','#999999','#808080','#666666','#000000']

      });

  }

  function isThatAColor(s) {
    var color = new RGBColor(s);
    if (color.ok) {
          return color.toHex();
    } else {
        return false;
    }
  }

  /*
   * Megjelen�ti azt a DIV-et amelyikben van egy iframe a felt�lt�s h�tt�rben val� elv�g�z�s�re
   * �s be�ll�tja az iframe-nek a forr�s�t
   * 
   */
  
  function IMGUpload(src){
    document.getElementById('UploadIframe').src=src;
    document.getElementById('ImageUploadDiv').style.display='block';
    document.getElementById('ImageUploadDiv').style.top=MousePosY+'px';
    document.getElementById('ImageUploadDiv').style.left=MousePosX+'px';
  }
  

  function ChangeNoteMode(NextNoteID){
    if(NextNoteID==0){
      if($('#NoteContentText').css("display")=="none"){
        if(notechanged==1){//save
          xajax_SaveNote($('#NoteContentTA').val(), CurrentNoteTab, 'view');
        }else{
          xajax_LoadNote(CurrentNoteTab, 'view');
        }
      }else{//edit
        xajax_LoadNote(CurrentNoteTab, 'edit');
      }
    }else{
      if(notechanged==0){
        xajax_LoadNote(parseInt(NextNoteID), 'view');
      }else{
        xajax_SaveNote($('#NoteContentTA').val(), CurrentNoteTab, 'view',parseInt(NextNoteID));
      }
    }
  }

  function ActualCurrentDay(){
    var JSCurrentDateTemp= new Date();
    var CurrentDayTemp=JSCurrentDateTemp.getDay();
    if(CurrentDayTemp==0)CurrentDayTemp=7;
    CurrentDayTemp=CurrentDayTemp-1;
    return CurrentDayTemp;
  }


  function InitMaskedInput_old(){
    $('#eventstarttimeedit').unmask();
    $('#eventendtimeedit').unmask();
    /*
    $('#eventstartedit').unmask();
    $('#eventendedit').unmask();
    */
    
    $.mask.addPlaceholder('~','[012]');
    $.mask.addPlaceholder('!','[012345]');
    $('#eventstarttimeedit').mask('~9:!9');
    $('#eventendtimeedit').mask('~9:!9');
   /*
    $.mask.addPlaceholder('~','[01]');
    $.mask.addPlaceholder('%','[0123]');
    $('#eventstartedit').mask('9999-~9-%9');
    $('#eventendedit').mask('9999-~9-%9');
    */
    InitMaskedInputDate('eventstartedit');
    InitMaskedInputDate('eventendedit');
  }
  
  function InitMaskedInput(fieldname){
    InitMaskedInputTime(fieldname);
    
    $('#'+fieldname+'date').unmask();
    
    $.mask.addPlaceholder('=','[01]');
    $.mask.addPlaceholder('%','[0123]');
    $('#'+fieldname+'date').mask('9999-=9-%9');
  }
  
  function InitMaskedInputDateTime(fieldname, ShortYear){
    $('#'+fieldname).unmask();
    $.mask.addPlaceholder('=','[01]');
    $.mask.addPlaceholder('%','[0123]');
    $.mask.addPlaceholder('~','[012]');
    $.mask.addPlaceholder('!','[012345]');
    if(ShortYear!=1){
      $('#'+fieldname).mask('9999-=9-%9 ~9:!9');
    }else{
      $('#'+fieldname).mask('99-=9-%9');
    }
  }
  
  function InitMaskedInputDate(fieldname, ShortYear){
    $('#'+fieldname).unmask();
    $.mask.addPlaceholder('=','[01]');
    $.mask.addPlaceholder('%','[0123]');
    if(ShortYear!=1){
      $('#'+fieldname).mask('9999-=9-%9');
    }else{
      $('#'+fieldname).mask('99-=9-%9');
    }
  }
  
  function InitMaskedInputTime(fieldname){
    $('#'+fieldname+'time').unmask();
    $.mask.addPlaceholder('~','[012]');
    $.mask.addPlaceholder('!','[012345]');
    $('#'+fieldname+'time').mask('~9:!9');
  }
  
  /*
    ezt a f�ggv�nyt musz�ly php-b�l kigener�lni hogy el�rhet� legyen a $SETTINGS
  */
  /*
  function MakeDraggableWindow(DivID, Mode){
    
    $("#"+DivID).draggable({
      handle: "#"+DivID+"Header",
      start: function(){
        $("#"+DivID).css('z-Index', ActualZIndex+10);
      },
      stop: function(){
              ActualZIndex=ActualZIndex+1;
              $("#"+DivID).css('z-Index', ActualZIndex);
              var Mod;
              var Temp;
              var Left=$("#"+DivID).css('left');
              Temp=Left.split('px');
              Temp=parseInt(Temp[0]);
              Mod=Temp % 5;
              if(Mod>=3){
                Left=Temp+(5-Mod);
              }else{
                Left=Temp-Mod;
              }

              $("#"+DivID).css('left', Left+'px');
              
              var Top=$("#"+DivID).css('top');
              Temp=Top.split('px');
              Temp=parseInt(Temp[0]);
              Mod=Temp % 5;
              if(Mod>=3){
                Top=Temp+(5-Mod);
              }else{
                Top=Temp-Mod;
              }
              Top=Temp+Mod;
              $("#"+DivID).css('top', Top+'px');
              if(Mode=='bookmark'){
                xajax_SaveWindowsPosition(DivID, Left+'px', Top+'px', 'bookmark' );
              }else{
                xajax_SaveWindowsPosition(DivID, Left+'px', Top+'px');
              }
            }
    });
  }
  */

  function RightClickMenuOver(obj){
    obj.className+=" rightclickmenuover";
  }
  
  
  function RightClickMenuOut(obj){
    var cls;
    cls='rightclickmenuover';
    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
      obj.className=obj.className.replace(reg,' ');  
  }
  
  
  function RightClickMenuOverLevel2(obj){
    clearTimeout(rightclickmenuhidden);
    clearTimeout(rightclickmenulevel2hidden);
  }
  
  
  function RightClickMenuOutLevel2(obj){
    rightclickmenuhidden=setTimeout("document.getElementById('RightClickMenu').style.display='none';document.getElementById('RightClickMenuLevel2').style.display='none';",1000);
  }
  
  function HintMenuOut(obj){
    setTimeout("document.getElementById('hint').style.display='none';",1000);
  }
  
  function FloatMenuOver(obj){
    clearTimeout(floatmenuhidden);
  }
  
  function FloatMenuOut(obj){
    floatmenuhidden=setTimeout("document.getElementById('FloatMenu').style.display='none';",1000);
  }
  
  function DeleteRightClickMenuLevel2(obj){
    var cls;
    cls='rightclickmenuover';
    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    obj.className=obj.className.replace(reg,' ');  
    rightclickmenulevel2hidden=setTimeout("document.getElementById('RightClickMenuLevel2').style.display='none';",500);
  }
  
  
  function DrawRightClickMenuLevel2(obj, DivID, Mode){
    obj.className+=" rightclickmenuover";
    var MenuObjLevel1=obj;
    var Temp=obj.id;
    Temp=Temp.split('_');
    Temp=Temp[0];
    /*Temp= color vagy category*/
    //var ParentObj=$('#'+obj.id).parent();
    var ParentObj=$('#'+obj.id);
    var ParentPos = ParentObj.offset();
    
    var Width=$("#"+ParentObj.id).css('width');
    var Height=$("#"+ParentObj.id).css('height');
    if (IE){
      var Left=ParentPos.left+91;
    }else{
      var Left=ParentPos.left+95;
    }
    var Top=ParentPos.top;
    //document.getElementById('RightClickMenuLevel2').style.display='none';
    setTimeout("$('#RightClickMenuLevel2').html('');"+
               "xajax_LoadRightMenuLevel2('"+Temp+"','"+DivID+"', '"+Mode+"');"+
               "$('#RightClickMenuLevel2').css('top','"+Top+"');"+
               "$('#RightClickMenuLevel2').css('left','"+Left+"');"+
               "$('#RightClickMenuLevel2').css('display','block');"+
               " ",500);
  }
  
  function ClearAllJsFeature(Container){
    $("#"+Container+" div.WindowDiv").each(function(){
      var DivID;
      DivID=this.id;
      $('#'+DivID).resizable('destroy');
    });
    
  }
  
  function MakeDragable(Container){
    $("#"+Container+" div.WindowDiv").each(function(){
      var DivID;
      DivID=this.id;
      MakeDraggableWindow(DivID, 'infoboard');
      SetResizable(DivID,'',1);
    });
  }
  
  function SetResizable(DivID, Callback, SpecialResizable){
    
    $('#'+DivID).resizable({
      //autohide: true,
      minHeight: 100, 
      minWidth: 100 ,

      stop: function (){
        if(SpecialResizable==1){
          var Height;
          var Width;
          Width=$('#'+DivID).css('width');
          Width=Width.split('px');
          Width=Width[0];
          
          Height=$('#'+DivID).css('height');
          Height=Height.split('px');
          Height=Height[0];
          
          xajax_SaveWindowsSize(DivID, Width, Height);
          
          Height=Height-30;
          Width=Width-12;
          if(Callback.length>0)eval(Callback);
        }
      },
      resize: function(e, ui) {
        if(SpecialResizable==1){
          var Height;
          var Width;
          Width=$('#'+DivID).css('width');
          Width=Width.split('px');
          Width=Width[0];
          
          Height=$('#'+DivID).css('height');
          Height=Height.split('px');
          Height=Height[0];
          
          Height=Height-30;
          Width=Width-12;
          if (IE) {
            $('#'+DivID+'_DIV').css('height', Height+20);
            $('#'+DivID+'_DIV').css('width', Width+6);
            $('#'+DivID+'_TA').css('height', Height+20);
            $('#'+DivID+'_TA').css('width', Width+8);
          }else{
            $('#'+DivID+'_DIV').css('height', Height);
            $('#'+DivID+'_DIV').css('width', Width);
            $('#'+DivID+'_TA').css('height', Height);
            $('#'+DivID+'_TA').css('width', Width+8);
          }
        }
      }
    });
  }
  
  function SetDivPosition(DIVID){
    var intY = document.getElementById(DIVID).scrollTop;
    DivScrollPosition=intY;
    //document.title = intY;
  }
  
  function OpenWindowOnTop(WindowID){
    if(WindowID!='hint'){
      ActualZIndex=ActualZIndex+1;
      $("#"+WindowID).css('z-Index', ActualZIndex);
    }else{
      $("#"+WindowID).css('display', 'block');
    }
    xajax_OpenWindow(WindowID);
  }
  
  function AddClass(obj, classname){
    var cls;
    cls=classname;
    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    obj.className=obj.className.replace(reg,' ');  
    obj.className+=" "+classname;
  }
  
  
  function RemoveClass(obj,classname){
    var cls;
    cls=classname;
    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    obj.className=obj.className.replace(reg,' ');  
  }
  
  
  function displaytime(Mode){
    var curDateTime = new Date()
    var curHour = curDateTime.getHours()
    var curMin = curDateTime.getMinutes()
    var curSec = curDateTime.getSeconds()
    var curTime = 
      ((curHour < 10) ? "0" : "") + curHour + ":" 
      + ((curMin < 10) ? "0" : "") + curMin + ":" 
      + ((curSec < 10) ? "0" : "") + curSec
    if(Mode=='Box'){
      if(document.getElementById('currenttimeBox')){
        document.getElementById('currenttimeBox').innerHTML=curTime;
      }
    }else{
      if(document.getElementById('currenttime')){
        document.getElementById('currenttime').innerHTML=curTime;
      }
    }
    clearTimeout(currtimeTimeout);
    currtimeTimeout=setTimeout('displaytime("'+Mode+'")',1000);
    if(curSec==0){
      xajax_RefreshLogBookSumTime(Mode);
    }
  }
  
  function OpenInfoBoard(Type, ID, CallBack){
    var ModalDivID=Type+'_'+ID;
    if(!document.getElementById(ModalDivID)){
      //create window
      xajax_CreateWindow(Type, ID,CallBack);
    }else{
      if($('#'+ModalDivID).css("display")=="none"){
        xajax_DrawInfoBoard(Type, ID,CallBack);
      }else{
        $('#'+ModalDivID).css("display", "none");
      }
    }
  }
  
  function ProjectParameterToggle(){
    if(document.getElementById('ProjectParameter').style.display=='none'){
      document.getElementById('ProjectParameter').style.display='block';
      RemoveClass(document.getElementById('infocontentdescription'), 'InfoContent_long');
      xajax_SetSettings('ProjectParameterOpen', 1); 
    }else{
      document.getElementById('ProjectParameter').style.display='none';
      AddClass(document.getElementById('infocontentdescription'), 'InfoContent_long');
      xajax_SetSettings('ProjectParameterOpen', 0); 
    }
  }
 
  function EventStack(){
    if(ScriptList.length){
      for (i=0;i<ScriptList.length;i++){
        eval(ScriptList.pop());
      }
      ScriptListInformationFlag=0;
      ScriptListChecklistFlag=0;
    }
  }
  
  function EmptyEventStack(){
    if(ScriptList.length){
      for (i=0;i<ScriptList.length;i++){
        ScriptList.pop();
      }
      ScriptListInformationFlag=0;
      ScriptListChecklistFlag=0;
    }
  }
