//<!--
    /**
    * Setup initial event handlers
    */
    document.onmousemove = NotegetMouseXY;

    /**
    * Init some vars
    */
    notes_mousePosX = 0;
    notes_mousePosY = 0;

    notes_layer = '';

    notes_origX = 0;
    notes_origY = 0;

    notes_origLayerX = 0;
    notes_origLayerY = 0;
    
    notes_origWidth  = 0;
    notes_origHeight = 0;
	
    notes_minWidth = 10;
    notes_minHeight = 10;
    
    notes_resize = false;

    /**
    * Sets mouseX and mouseY coords
    */
    function NotegetMouseXY(e)
    {
        if (document.all) {
    	    notes_mousePosX = event.clientX + document.body.scrollLeft;
            notes_mousePosY = event.clientY + document.body.scrollTop;
        } else {
        	//window.status = 'x='+e.pageX+' y='+e.pageY;
	    	notes_mousePosX = e.pageX;
    	    notes_mousePosY = e.pageY;
        }
       
    }

    /**
    * Layer drag functions
    *
    * NotestartLayerDrag() - Initiates and sets up the drag
    * NoteendLayerDrag()   - Cleans up after a drag
    * NoteonLayerDrag()    - Fired when the mouse moves, updating the position of the layer
    */
    function NotestartLayerDrag(layerID)
    {
        notes_layer = document.getElementById(layerID);

        notes_origX = notes_mousePosX;
        notes_origY = notes_mousePosY;

        notes_origLayerX = Math.abs(notes_layer.style.left.substring(0, notes_layer.style.left.length - 2));
        notes_origLayerY = Math.abs(notes_layer.style.top.substring(0, notes_layer.style.top.length - 2));

        document.onmousemove = (notes_resize == true ? NoteonResize : NoteonLayerDrag);
    }

    function NoteendLayerDrag()
    {
        notes_layer = '';
        notes_origX = 0;
        notes_origY = 0;
        
        document.onmousemove = NotegetMouseXY;
    }
    
    function NoteonLayerDrag(e)
    {
        NotegetMouseXY(e);       
        diffX = notes_mousePosX - notes_origX;
        diffY = notes_mousePosY - notes_origY;

        notes_layer.style.left = notes_origLayerX + diffX + 'px';
        notes_layer.style.top  = notes_origLayerY + diffY + 'px';
    }

    /**
    * Layer resize functions
    *
    * NotestartResize() - Initiates and sets up the resize
    * NoteendResize()   - Cleans up after a resize
    * NoteonResize()    - Fired when the mouse moves, updating the size of the layer
    */
    function NotestartResize(layerID)
    {
        notes_layer = document.getElementById(layerID);

        notes_origX = notes_mousePosX;
        notes_origY = notes_mousePosY;

        notes_origWidth  = Math.abs(notes_layer.style.width.substring(0, notes_layer.style.width.length - 2));
        notes_origHeight = Math.abs(notes_layer.style.height.substring(0, notes_layer.style.height.length - 2));

        notes_resize = true;
    }

    function NoteendResize()
    {
        notes_layer = '';
        notes_origX = 0;
        notes_origY = 0;

        notes_resize = false;
        document.onmousemove = NotegetMouseXY;
    }
    
    function NoteonResize(e)
    {
        NotegetMouseXY(e);
        diffX = notes_mousePosX - notes_origX;
        diffY = notes_mousePosY - notes_origY;

		if (notes_origWidth + diffX <= notes_minWidth) {
			notes_layer.style.width  = notes_minWidth + 'px';
		} else {
        		notes_layer.style.width  = notes_origWidth + diffX + 'px';
		}
		
		if (notes_origHeight + diffY <= notes_minHeight) {
			notes_layer.style.height = notes_minHeight + 'px';
		} else {
	       		notes_layer.style.height = notes_origHeight + diffY + 'px';
		}
    }
    
    
    function saveNote(userid){    	
		notes = encodeURIComponent(document.forms['note'].note.value);
		x = document.getElementById('popupNote');
		notespos = "left:"+getAbsoluteLeft('popupNote')+"px;top:"+getAbsoluteTop('popupNote')+"px;width:"+(x.offsetWidth-22)+";height:"+(x.offsetHeight-37)+";";
        notespos = encodeURIComponent(notespos);
        new Ajax.Request('index.php',
                         {parameters: 'fuse=3&action=3031&notes='+notes+'&notespos='+notespos, method: 'post'});
    }
//--> end hide JavaScript

