/*******************************************/
/* Javascript-Funktionen für den Calendar  */
/*******************************************/

// blendet Ladebild ein
/*
function displayLoadingProcess(Container)
{
     /* Free Grafiks from: http://www.ajaxload.info/
     *  Possible ones:
     *  - ajax-loading-bigwheel.gif
     *  - ajax-loading-smallwheel.gif
     *  - ajax-loading-flashstandard.gif
     */ 
/*     
     var NewContent = "<img src='http://a3network-dev.alphasystems.com/wordpress/wp-content/plugins/a3network/includes/calendar/pix/ajax-loading-flashstandard.gif' alt='Loading...'>";

     document.getElementById(Container).innerHTML = NewContent;
     
}

function changeCalendarDate(Adresse, Day, Month, Year)
{
     var DateCheckFlag = false;
     var SelectedView = document.getElementById("hiddenselectedview").value;
     
     displayLoadingProcess('ajaxchangepos');

     while(DateCheckFlag == false)
     {
          checkDatum = new Date(Month+'/'+Day+'/'+Year);
          
          if(checkDatum.getMonth()!=(Month-1))
          {
               Day = 1;
          }
          else
          {
               DateCheckFlag = true;
          }
          
     }

     
     
     jQuery.ajax
     (
          {
               type: 'POST',
               url: Adresse+'/a3network_calendar.php',
               data: 'ajaxload=1&minical=1&minicalday='+Day+'&minicalmonth='+Month+'&minicalyear='+Year+'&minicalselectedview='+SelectedView,
               success: function(strResponse)
               {
                    document.getElementById('sidebar-left-calendar').innerHTML = (strResponse);
                    setMiniCalendarHeight();
               }
               
          }
          
     );

}
*/

function setPopUpToOpen(PopDivID, PopUpDefinition)
{
     OpenthisPopUp = PopDivID;
     PopUpType = PopUpDefinition;
     PopUpAction = 'MakeVisible';
     
     if(ClosethisPopUp != '' && document.getElementById(ClosethisPopUp))
     {
          document.getElementById(ClosethisPopUp).style.visibility = 'hidden';
     
     };
     
     ClosethisPopUp = OpenthisPopUp;
     
}

function PopUpPosition(Ereignis)
{
     var posx = 0;
     var posy = 0;
     
     if (!Ereignis)
     {
          Ereignis = window.event;
     
     };

     if(OpenthisPopUp != '' && PopUpAction == 'MakeVisible')
     {
          if(document.getElementById(OpenthisPopUp))
          {
               var Browsertemp = navigator.userAgent.toLowerCase();
                
               if(Browsertemp.search(/msie/) != -1)
               {
                    posx = Ereignis.clientX;
                    posy = Ereignis.clientY+document.body.scrollTop;
                    
               }
               else if((Browsertemp.search(/opera/) != -1) || (Browsertemp.search(/firefox/) != -1) || (Browsertemp.search(/khtml/) != -1))
               {
                    posx = document.all ? window.event.clientX : Ereignis.pageX;
                    posy = document.all ? window.event.clientY : Ereignis.pageY;

               };
               
               if(PopUpType == 'sidebar')
               {
                    document.getElementById(OpenthisPopUp).style.top  = (posy - 10)+"px";                    
                    document.getElementById(OpenthisPopUp).style.left = (posx - 600)+"px";
                    document.getElementById(OpenthisPopUp).style.visibility = "visible";
               
               }
               else if(PopUpType == 'calendar')
               {
                    document.getElementById(OpenthisPopUp).style.top  = (posy - 10)+"px";
                    document.getElementById(OpenthisPopUp).style.left = (posx + 30)+"px";
                    document.getElementById(OpenthisPopUp).style.visibility = "visible";
               
               };

          };

          OpenthisPopUp = '';
          PopUpAction = '';
          
     }
     else if(OpenthisPopUp == '' && PopUpAction == 'DragAndDrop')
     {
          dragobjekt = null;
          
          PopUpAction = '';
     
     };
     
}

function closePopUp(PopDivID)
{
     if(document.getElementById(PopDivID))
     {
          document.getElementById(PopDivID).style.visibility = 'hidden';
          
          PopUpAction = '';
          
     };

}

function dragstart(Element_ID)
{
     PopUpAction = 'DragAndDrop';
     dragobjekt = document.getElementById(Element_ID);
     drag_position_x = position_x - dragobjekt.offsetLeft;
     drag_position_y = position_y - dragobjekt.offsetTop;
     
}

function drag(Ereignis)
{
     position_x = document.all ? window.event.clientX : Ereignis.pageX;
     position_y = document.all ? window.event.clientY : Ereignis.pageY;
     
     if(dragobjekt != null)
     {
          dragobjekt.style.left = (position_x - drag_position_x) + "px";
          dragobjekt.style.top = (position_y - drag_position_y) + "px";
     
     };

}

