<!-- Begin
/** This makes available the a help system that can be used to give the user tips and advice
   
   When used it automatically creates a hidden div, containind an Iframe that can be used 
   for the display of small HTML files, passed to it. These HTML files are intended to be
   help pages to guide the user. In theory, these pages could be dynamic of required and 
   find other uses outside the scope of being a help system.
   
   This file provides a fuction to call up the help window, the function expects the following:
   
   x - x coordinate for position of window
   y - y coordinate for position of window
   width - width of window
   height - height of window
   src - HTML (or asp) file to display in window
   
   eg:
   showHelp(50,50,300,200,'../helpPages/resolveDate.html');

*/
var helpShowing = false; //records if any help dialogue is showing or not

function hideHelp(){
  if(helpShowing==true){
    helpShowing = false;
    objBody = document.getElementById('docBody');    
    objHelpDiv = document.getElementById('helpDiv');
    result = objBody.removeChild(objHelpDiv);
  }
}

function buttonbg(name, state){
  objButton = document.getElementById(name);
  if(state=='over'){
    objButton.style.backgroundColor='#ffffff';
  } else {
    objButton.style.backgroundColor='#c0efc0';
  }
}

function showHelp(x, y, h, w, src){ //x pos, y pos, height, width, url of page to show
  if(helpShowing==true){
    hideHelp();
  } else {
    helpShowing = true;
    //Create all nodes
  
    if(x<0)x=0;
    if(y<0)y=0;
    if(h<50)h=50;
    if(w<50)w=50;
    if(src=='')src='_helpFiles/error1.html';
	
    var helpDiv = document.createElement('div');
        helpDiv.setAttribute('name', 'helpDiv');
        helpDiv.setAttribute('id', 'helpDiv');
    with(helpDiv.style){
        backgroundColor='#009500';
        position='absolute';
        borderTop='1px solid #004000';
        borderRight='1px solid #004000';
        borderBottom='0px solid #004000';
        borderLeft='1px solid #004000';
        top=y+'px';
        left=x+'px';
        width=w+'px';
        height=(h+34)+'px';
    }

    var helpDivTitle = document.createElement('div');
        helpDivTitle.setAttribute('name', 'helpDivTitle');
        helpDivTitle.setAttribute('id', 'helpDivTitle');
  
    with(helpDivTitle.style){
        position='relative';
        //border='0px solid black';
        top='0px';
        left='0px';
        width=(w-10)+'px';
        margin='2 5 2 5';
        height='10px';
        fontSize='10px';
        fontFamily='Verdana, Arial, Helvetica, sans-serif';
        color='#FFFFFF';
        fontWeight='bold';
        textAlign='center';
        cursor='default';
        backgroundColor='#009500';

        borderTop='0px solid #004000';
        borderRight='0px solid #004000';
        borderBottom='1px solid #009500';
        borderLeft='0px solid #004000';
    }
   
    var frmDiv = document.createElement('div');
        frmDiv.setAttribute('name', 'frmDiv');
        frmDiv.setAttribute('id', 'frmDiv');
    with(frmDiv.style){
        border='none';
        width=w+'px';
        height=h+'px';
        overflow='auto';
        scrollbar3dlightColor='#2A5B9E';
        scrollbarArrowColor='#004000';
        scrollbarBaseColor='#009500';
        scrollbarDarkshadowColor='#e0ffe0';
        scrollbarFaceColor='#e0ffe0';
        scrollbarHighlightColor='#c0efc0';
        scrollbarShadowColor='#009500';
    }

    var helpFrm = document.createElement('iframe');
        helpFrm.setAttribute('src', src);
        helpFrm.setAttribute('id', 'helpFrm');
        helpFrm.setAttribute('name', 'helpFrm');
        helpFrm.setAttribute('frameBorder','0');
        helpFrm.setAttribute('scrolling','no');
    with(helpFrm.style){
        position='relative';
        top='0px';
        left='0px';
        width=(w-19)+'px';
        height='1000px';
        borderTop='0px solid #004000';
      }
      
    var helpDivBottom = document.createElement('div');
        helpDivBottom.setAttribute('name', 'helpDivBottom');
        helpDivBottom.setAttribute('id', 'helpDivBottom');
    with(helpDivBottom.style){
        position='relative';
        borderTop='2px solid #009500';
        borderRight='0px solid black';
        borderBottom='2px solid #009500';
        borderLeft='0px solid black';
        backgroundColor='#e0ffe0';

        top='0px';
        left='0px';
        width=w+'px';
        height='15px';
        
    }
    var helpBut1Text = document.createTextNode('Close');
    var helpDivBut1 = document.createElement('div');
        helpDivBut1.setAttribute('name', 'helpDivBut1');
        helpDivBut1.setAttribute('id', 'helpDivBut1');
        helpDivBut1.onmousedown = new Function ('hideHelp()');
        helpDivBut1.onmouseover = new Function ('buttonbg(\'helpDivBut1\', \'over\')');
        helpDivBut1.onmouseout = new Function ('buttonbg(\'helpDivBut1\', \'out\')');

    with(helpDivBut1.style){
        position='relative';
        borderTop='0px solid #004000';
        borderRight='1px solid #004000';
        borderBottom='0px solid #009500';
        borderLeft='1px solid #004000';
        backgroundColor='#c0efc0';
        fontSize='12px';
        top='0px';
        left=((w-70)/2)+'px'; //mathematically center position button to save brower arguments
        textAlign='center';
        width='70px';	
        height='15px';
        cursor='pointer';
    }
      
    // pend nodes
    document.childNodes[1].childNodes[1].appendChild(helpDiv);
    objHelpDiv = document.getElementById('helpDiv');
    objHelpDiv.appendChild(helpDivTitle);
    objHelpDiv.appendChild(frmDiv);
    objHelpDiv.appendChild(helpDivBottom);
    objFrmDiv = document.getElementById('frmDiv');
    objFrmDiv.appendChild(helpFrm);
    objHelpDivBottom = document.getElementById('helpDivBottom');
    objHelpDivBottom.appendChild(helpDivBut1);
    objHelpDivBut1 = document.getElementById('helpDivBut1');
    objHelpDivBut1.appendChild(helpBut1Text);
    objHelpFrm = document.getElementById('helpFrm');
  }
}
//End -->
