    if(!window.event && window.captureEvents) 
    {
		window.captureEvents(Event.MOUSEOVER|Event.MOUSEOUT|Event.CLICK|Event.DBLCLICK);
		window.onmouseover = WM_getCursorHandler;
		window.onmouseout = WM_getCursorHandler;
		window.onclick = WM_getCursorHandler;
		window.ondblclick = WM_getCursorHandler;
		window.event = new Object;
	}
	
	function WM_getCursorHandler(e) 
	{
		window.event.clientX = e.pageX;
		window.event.clientY = e.pageY;
		window.event.x = e.layerX;
		window.event.y = e.layerY;
		window.event.screenX = e.screenX;
		window.event.screenY = e.screenY;
		if ( routeEvent(e) == false ) 
		{
			return false;
		} 
		else 
		{
			return true;
		}
	}

	document.write('<div id=dacalendar>');

    function Calender( date, minDate, maxDate )
    {
	  this.name = 'CalenderObj'+Calender.Calenders.length;
      eval(this.name+'=this');
      Calender.Calenders[Calender.Calenders.length] = this;

      // MEMBERS
      this.minDate      = minDate||null;
      this.maxDate      = maxDate||null;
      this.date         = date;
      this.tempDate     = new Date();

      this.monthNames   = GetCalendarMonths();// /ndo 25-11-2005 ['Jan','Feb','Mar','Apr','Maj','Jun','Jul','Aug','Sep','Okt','Nov','Dec'];
	  this.dayNames     = GetCalendarDays();// /ndo 25-11-2005 ['Son','Man','Tir','Ons','Tor','Fre','Lor'];
      
 	  this.div          = null;
      this.isRendered   = false;
      this.isHidden     = true;

      // METHODS
      this.onDateChange = function(){}

      this.setDate = function(y,m,d)
      {

        // set year, month, date if supplid
        if(y!=null)this.date.setYear(y);
        if(m!=null)this.date.setMonth(m);
        if(d!=null)this.date.setDate(d);

        // update tempDate
        this.tempDate.setYear( this.date.getFullYear() );
        this.tempDate.setMonth( this.date.getMonth() );
        this.tempDate.setDate( this.date.getDate() );

        // set isRendered flag
        this.isRendered = false;

        // call onDateChange method
        this.onDateChange();

      }
      // set date with constructor arguments
      this.setDate( this.date.getFullYear(), this.date.getMonth(), this.date.getDate() );

      this.setMonth = function( m, e )
      {
        // change tempDate's month
        this.tempDate.setMonth( m );
        this.isRendered = false;
        this.render();
        return this.killEvent( e );
      }

      this.render = function()
      {
        // check if this needs to be rendered
        if( this.isRendered == true ) return;

        // find the div for this calender
        if( this.div == null )
        {
          this.div = document.createElement('div');
          
          this.div.style.position='absolute';
          this.div.style.width='132px';
          this.div.style.top=window.event.clientY + 'px';
          this.div.style.left=window.event.clientX + 'px';
          this.div.id = 'content' + this.div.style.top;
          document.getElementsByTagName('body')[0].appendChild( this.div );
        }

        // setup months
        var monthDays = [31, (this.tempDate.getFullYear()%4==0?29:28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

        // build out string
        var outTop = '';
        var outBottom = '';


        // Temporary dates
        var firstDate = new Date( this.tempDate.getFullYear()+'/'+(this.tempDate.getMonth()+1)+'/1');
        firstDate.setDate( -1 );
        var currDate = new Date( this.tempDate.getFullYear()+'/'+(this.tempDate.getMonth()+1)+'/1');

        // Start output
        outTop += '<table cellspacing="0" style="font-family:verdana;font-size:10px;font-weight:bold;;border:0px solid #333333;" bgcolor="#EAEDE4" cellspacing="0" border="0" width="100%"><tr bgcolor="#D3D6CE" height="30"><td ';

        // prev month link
        if( (this.minDate != null || firstDate > this.minDate) ) {
          outTop+=' style="width:16px;color:#000000;text-align:right;cursor:pointer;" onclick="'+this.name+'.setMonth('+this.name+'.tempDate.getMonth()-1, event);">  <span style="font-weight:bold;font-size:11px;color:#333333;">&#0171;</span> '
        } else {
          outTop+='>&nbsp;'
        }

        outTop+='</td><td colspan="5" style="font-weight:bold;font-size:11px;color:#333333;text-align:center;">'+this.monthNames[this.tempDate.getMonth()]+' '+this.tempDate.getFullYear()+'</td><td style="font-weight:bold;cursor:pointer;font-size:11px;color:#333333;"'

        outBottom+='</td></tr><tr><td colspan="7"><div class="hr"></div></td></tr>';//<tr>

        var cols = 0;
        var onClick     = '';
        var cssClass    = '';
        var isInvalid   = false;
        var isSelected  = false;

        var start = firstDate.getDay()==6?-1:firstDate.getDay()
        
        // from date 1 to max...
        for( var i=-start;i<=monthDays[this.tempDate.getMonth()];i++)
        {
          if(cols++==0)outBottom+='<tr>'
          if(i<=0 || i>monthDays[this.tempDate.getMonth()])
          {
            outBottom+='<td>&nbsp;</td>';
          }
          else
          {

            currDate.setDate(i);

            // Check if the current date is within minDate and maxDate
            if( (this.minDate != null && currDate < this.minDate) || (this.maxDate != null && currDate > this.maxDate) )
            {
              isInvalid = true;              
            }
            else
            {
              isInvalid = false;
            }

            // Check if the current date is selected
            if( !isInvalid )
            {
              isSelected = (i==this.date.getDate()&&this.tempDate.getMonth()==this.date.getMonth()&&this.tempDate.getFullYear()==this.date.getFullYear());
            }
            else
            {
              isSelected = false;
            }

            cssClass  = isSelected?' style="background-color:#ffffff;"':'';
            onClick   = (isInvalid ? '' : this.name+'.click('+this.tempDate.getFullYear()+','+this.tempDate.getMonth()+','+i+');')

            outBottom+='<td '+(isInvalid?'disabled="true"':'')+cssClass+' onmouseover="bgColor=\'#ffffff\';" onmouseout="bgColor=\'#EAEDE4\';" style="cursor:pointer;width:17px;height:17px;" onclick="'+onClick+'">'+i+'</td>';

          }
          if(cols==7)
          {
            outBottom+='</tr>'
            cols=0;
          }
        }
        
        // fix to last row...
        while(cols>0&&cols++<7)
        {
          outBottom+='<td>&nbsp;</td>';
          if(cols==7)outBottom+='</tr>'
        }

        if( (this.maxDate != null && currDate >= this.maxDate) ) {
          outTop+='>&nbsp;'
        } else {
		//style="width:16px;text-align:left; cursor:pointer;"
          outTop+='  onclick="'+this.name+'.setMonth('+this.name+'.tempDate.getMonth()+1, event);"> &#0187; '
        }
      
		if (navigator.appName=='Netscape')		 
		{
			outBottom += '<tr><td colspan=10 align=right><span onclick="document.getElementById(\'content'+this.div.style.top+'\').style.display=\'none\';" title=Luk>Luk</span></td></tr></table></div></div>';
		}
		else
		{		
			outBottom += '</table></div></div>';
		}
		
        // render output, and set isRendered = true
        this.div.innerHTML = (outTop + outBottom);
        this.isRendered = true;
        
      }

      this.show = function( e, elm )
      {
        // Hide all calenders
        Calender.HideAll();
        if(document.getElementById('campaingdropdown')){
      		document.getElementById('campaingdropdown').style.visibility = 'hidden';
		}
		
		
        var t = l = 0;

        // find t'n'l ( top / left )
        if (document.documentElement && document.documentElement.scrollTop)
        {
          l = (document.documentElement.scrollLeft - e.offsetX)
	        t = (document.documentElement.scrollTop - e.offsetY)
	      }
        else if (document.body)
        {
          l = (document.body.scrollLeft - e.offsetX)
	        t = (document.body.scrollTop - e.offsetY)
	      }

        // render output and show calender
        this.render();

        if( this.div.style )
        {
          this.div.style.top=((e.clientY) + (t+(elm.offsetHeight/2)) )+'px';
          this.div.style.left=((e.clientX) + (l+(elm.offsetWidth/2)) )+'px';
          this.div.style.display='block';
        }

        // clear the event
        this.killEvent( e );

        // set isHidden to false
        this.isHidden = false;
      }

      this.hide = function()
      {
		// hide calender
		 if(document.getElementById('campaingdropdown')){
      
		document.getElementById('campaingdropdown').style.visibility = 'visible';
		}
		
		if (navigator.appName=='Netscape')		
		{
			this.isHidden = false;
		}
		else
		{
			// check div
			if( this.isHidden || this.div == null ) return;
			// hide calender
			this.div.style.display='none';
			this.isHidden = true;
		}      
	  }
  
      this.click = function( y, m, d )
      {
        // set date with the arguments, render the m*****f***** and hide it after 80/1000 seconds
        this.setDate( y, m, d );
        this.render();
        setTimeout(this.name+'.hide()',80);
      }

      this.killEvent = function( e )
      {
        // clear the event
        e.cancelBubble = true;
        e.returnValue = false;
        if(e.preventDefault)e.preventDefault();
        return false;
      } 

    }

    Calender.HideAll = function()
    {
      for( var x=0; x<Calender.Calenders.length; x++ )
      {
        Calender.Calenders[x].hide();
      }
    }
    Calender.SelectValue = function( list, val )
    {
      if(list != null && list.options != null)
      {
        for( var i=0;i<list.options.length; i++)
        {
          list.options[i].selected = (list.options[i].value == val);
        }
      }
    }

    Calender.CatchEvent = function( object, type, callback , bubble )
    {
      if( object.addEventListener )
      {
        object.addEventListener( type, callback, bubble )
      }
      else
      {
        object.attachEvent( 'on' + type, callback, bubble ) 
      }
    }

    Calender.Calenders = [];

    Calender.CatchEvent( document, "click", Calender.HideAll, true );
    
   	document.write('</div>');


