
function IeTrueBody()
{
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function GetScrollTop()
{
    var w3c=(document.getElementById)? true: false;
    var agt=navigator.userAgent.toLowerCase();
    var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1) && (agt.indexOf("omniweb") == -1));

        return ie ? IeTrueBody().scrollTop : window.pageYOffset;
}

function openHelp(id,marginTop)
{       
    HideControls('select');
    if (marginTop == "undefined" || marginTop == null)
		marginTop = true;
    
    var width = window.getWidth();
    var height = window.getHeight();
    var screenwid = window.getScrollWidth();
    var screenhgt = window.getScrollHeight();
       
    if (screenwid > width) width = screenwid;
    if (screenhgt > height) height = screenhgt;
            
    $('divGrayOut').setStyles({
        top: 0,
        left: 0, 
        display: 'block'
    });
    
    $('contextHelp').setStyles({
        display: 'block'
    });
    
    var effects = $('divGrayOut').effects({duration: 200, transition: Fx.Transitions.linear, onComplete: function (control) { swc_showPanel(id); centerPanel(id, width, height,marginTop);  }});
    effects.start({
        'height': [0, height], 
        'width': [0, width], 
        'top' : [height/2, 0],
        'left': [width/2, 0],
        'opacity': [0, .5]        
    });               
}



function closeHelp(id)
{   
    var width = window.getWidth();
    var height = window.getHeight();
    var screenwid = window.getScrollWidth();
    var screenhgt = window.getScrollHeight();
    
    if (screenwid > width) width = screenwid;
    if (screenhgt > height) height = screenhgt;
    
    
    var effects = $('divGrayOut').effects({duration: 200, transition: Fx.Transitions.linear, onStart: function () { swc_hidePanel(id);new Fx.Style(id, 'opacity').set(0);  } });
    effects.start({
        'top': [0, height/2], 
        'left': [0, width/2], 
        'width': [width, 0],
        'height': [height, 0],
        'opacity': [.5, 0]
    });   
   
    new Fx.Style('contextHelp', 'opacity').set(0);
    new Fx.Style('contextHelp', 'width').set(0);
    new Fx.Style('contextHelp', 'height').set(0);
    new Fx.Style('contextHelp', 'left').set(0);
    new Fx.Style('contextHelp', 'top').set(0);  

    $('divGrayOut').setStyles({
        display: 'none'
    });
    
    $('contextHelp').setStyles({
        display: 'none'
    });
    
   ShowControls('select');       
}

function centerPanel(id, pageWidth, pageHeight,marginTop)
{
    
    if (marginTop == "undefined" || marginTop == null)
		marginTop = true;
    var coords = $(id).getCoordinates();
    
    var width = coords.width;
    var height = coords.height;    
    
    var left = Math.ceil((pageWidth - width)/2);
    var top = (GetScrollTop() + 155) + "px";
    if (!marginTop)
		top = GetScrollTop() + "px";
           
    new Fx.Style(id, 'left').set(left);
    new Fx.Style(id, 'top').set(top);
    
    new Fx.Style('contextHelp', 'width').set(width);
    new Fx.Style('contextHelp', 'height').set(height);
    new Fx.Style('contextHelp', 'left').set(left);
    new Fx.Style('contextHelp', 'top').set(top);
    new Fx.Style('contextHelp', 'opacity').set(0);
    
    new Fx.Style(id, 'opacity').set(1);  
}

function swc_showPanel(panelID)
{
    var control = swc_getById(panelID);
    
    if ( control != null )
    {
	    control.style.display = "block";
	    control.setAttribute("Displayed", "true");	    
	}
}

function swc_getById(sID)
{
	return (sID ? document.getElementById(sID) : null);
}

function swc_hidePanel(panelID)
{
    var control = swc_getById(panelID);
    
    if ( control != null )
    {
	    control.style.display = "none";
	    control.setAttribute("Displayed", "false");	    
	}
}

//Òþ²Ø
function ShowHide(panelID)
{
	var control = swc_getById(panelID);
    
    if ( control != null )
    {
		if (control.style.display == "none")
		{
			control.style.display = "";
		}
		else
		{
			control.style.display = "none";
	    }
	}
}
