var windowWidth = 250;
var deleteIconWidth = 16;
var ns6=document.getElementById && !document.all;
var ie=document.all;
var shownPopup = 0;

function getPositionLeft(This){
    var el = This; var pL = 0;
    while (el) { pL+=el.offsetLeft; el=el.offsetParent; }
    return pL;
}
function getPositionTop(This){
    var el = This; var pT = 0;
    while (el) { pT+=el.offsetTop; el=el.offsetParent; }
    return pT;
}
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showContextHelpWindow(num_item, title) {
    if (num_item == shownPopup) {
        closeContextHelpWindow();
        return ;
    }
    
    var img = document.getElementById('help_img_'+num_item);
    var imgX = getPositionLeft(img)+16;
    var imgY = getPositionTop(img)+16;
    var rightedge=ie&&!window.opera? ietruebody().clientWidth-windowWidth : window.innerWidth-windowWidth-20;
    if (imgX > rightedge) imgX = rightedge;
    var text = '<table width="'+windowWidth+'" border="0" cellpadding="0" cellspacing="0" class="ch_table">' +
        '<tr class="ch_header">' +
        ' <td class="ch_header" width="'+(windowWidth-deleteIconWidth-4)+'">'+title+'</td>' +
        ' <td align="right" width="'+(deleteIconWidth+4)+'"><a href="javascript:closeContextHelpWindow();"><img src="/resources/images/Modules/ContextHelp/close.gif" border="0" alt="Close" title="Close" hspace=1 vspace=1></a></td>' +
        '</tr>' +
        '<tr>' +
        ' <td class="ch_body" colspan="2" width="'+windowWidth+'">'+texts[num_item]+'</td>' +
        '</tr>' +
        '</table>';
    var contextWindow = document.getElementById('ContextWindow');
    contextWindow.innerHTML = text;
    contextWindow.style.left = imgX + 'px';
    contextWindow.style.top = imgY + 'px';
    contextWindow.style.visibility = 'visible';
    shownPopup = num_item;
}
function closeContextHelpWindow() {
    document.getElementById('ContextWindow').style.visibility = 'hidden';
    shownPopup = 0;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
