/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
     
/* some handly Javascript functions, collected (rather than written...) by Graham Stark
 * build a pop-up window and give it focus.
 **/

function ExampleWindow( mypage, rowTitle, colTitle ){
       myname = "Examples of"+rowTitle+"; "+colTitle;
       LeftPosition=(screen.width)?(screen.width-950)/2:100;
       TopPosition=(screen.height)?(screen.height-450)/2:100;
       settings='width=900,height=550,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
       w = window.open(mypage,myname,settings);
       w.focus();
}

function HelpWindow( mypage ){
       LeftPosition=(screen.width)?(screen.width-950)/2:100;
       TopPosition=(screen.height)?(screen.height-450)/2:100;
       settings='width=400,height=400,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
       w = window.open(mypage, 'help' ,settings);
       w.focus();
}

function PictureWindow( mypage ){
       LeftPosition=(screen.width)?(screen.width-950)/2:100;
       TopPosition=(screen.height)?(screen.height-450)/2:100;
       settings='width=800,height=500,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
       w = window.open(mypage, 'help' ,settings);
       w.focus();
}

function ForumWindow( mypage ){
       LeftPosition=(screen.width)?(screen.width-950)/2:100;
       TopPosition=(screen.height)?(screen.height-450)/2:100;
       settings='width=700,height=800,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
       w = window.open(mypage, 'help' ,settings);
       w.focus();     
}

function trimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

/**
 *  Call the overlib with the given help text if 
 *  there is a checkbox with Id 'HoverhelpOn' and the value is checked,
 *  or a hidden field with id HoverHelpSwitch and value 'true'
 *  or if neither field exists and the help text is not null or blank
*/
function overlibConditional( helpStr ){
       var showHelp = 0;
       // alert('overlib started showHelp=' + showHelp + " helpStr "+helpStr );
       // bale out if we have no string.
       if( helpStr == null ){
                return 0;       
       }
       var helpStr = trimString(helpStr);
       if( helpStr.length == 0 ){
                return 0;       
       }
       //alert('overlib ; not returning ' );
       
       mycheckbox = document.getElementById('HoverhelpOn');
       
       //alert( 'checkbox = ' + mycheckbox );
       
       if( mycheckbox != null){
                showHelp = mycheckbox.checked;
       } else {
                helpBox = document.getElementById('HoverhelpSwitch');
                //alert( "got helpBox as " + helpBox );
                if(helpBox != null){ 
                        showHelp = ((helpBox.value == 'true' ) || (helpBox.value == '1' ));
                }
       }
       // alert( "showHelp="+showHelp );
       if( showHelp ){
               return overlib( helpStr );
       }
       
}
