﻿/* Registers functionality to pop up a help window for all help link */
function registerHelpPopups(helpPagePath) {
    var helpWindow;
      
    jQuery('a.help').click(function() {
        var title = 'blank';
        var width = 250;
        var height = screen.height>=400 ? screen.height-300 : screen.height-150;
        var left = 10;
		var top = 150;
		
		//var link = jQuery(this);
        var helpHtmlStr = jQuery(this).next('span.help').html();
		   
        var options = 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',toolbar=0,resizable=1,scrollbars=1,directories=0,menubar=0,location=0,status=1';
        
        if((jQuery.browser.msie)) {
			//for IE6 & IE7		
            if (helpWindow == null)
            {            
                helpWindow = window.open(helpPagePath, title, '' + options + '');		
            }
            else
            {
                if (helpWindow.closed)
                {
                   helpWindow = window.open(helpPagePath, title, '' + options + '');	 
                }
            }	   
            //Needed due to an IE bug.         
            do { } while (helpWindow.document.readyState != "complete" ) ;                       				
            jQuery(helpWindow.document).find('#helpArea').html(helpHtmlStr);
		} else {
			// for all browsers other than IE			
			if (helpWindow) helpWindow.close();
			helpWindow = window.open(helpPagePath, title, '' + options + '');
			jQuery(helpWindow).load(function() {
				jQuery(helpWindow.document).find('#helpArea').html(helpHtmlStr);
			});			
		}		
        helpWindow.focus();
        return false;
    });
}
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();