﻿document.onkeydown = mynKeyDown;
window.inMynResize = false;
window.onload = function() {
  winLoad();
}
/*
window.onresize = function() {  
  setSideFooter();
}
*/
document.oncontextmenu = function(){return false}
if(document.layers) {
    window.captureEvents(Event.MOUSEDOWN);
    window.onmousedown = function(e){
        if(e.target==document)return false;
    }
}
/*
else {
    document.onmousedown = function(){return false}
}
*/
document.SelectorType = 'N';
/*
// now done through css media
if (window.onbeforeprint)
{
    window.onbeforeprint = befPrint;
}
if (window.onafterprint)
{
    window.onafterprint = aftPrint;
}
function befPrint()
{
    var tm = document.getElementById("TopMenu");
    if (!(tm == null))
    {
        tm.style.display="none"        
    }
    var dm = document.getElementById("docMenuHeader");
    if (!(dm == null))
    {
        dm.style.display="none"        
    }    
}
function aftPrint()
{
    var tm = document.getElementById("TopMenu");
    if (!(tm == null))
    {
        tm.style.display="display"        
    }
    var dm = document.getElementById("docMenuHeader");
    if (!(dm == null))
    {
        dm.style.display="display"        
    }    
}
*/
/*
window.onscroll = function() {
  setSideFooter();
}
*/
/*
window.onbeforeunload = function() {
    //just the presence of this functions stops the browser caching the page
    befUL();
}
function befUL() {
    var tst = 0;
}
*/
function printForm()
{
    if (window.print)
    {
        window.print();
    }
}
function winLoad() {
/*
newobject = document.createElement('DIV');
if (newobject) {
 newobject.id = 'blankregion';
 newobject.style.position = 'absolute';
 newobject.style.visibility = 'visible';
 newobject.style.display = 'block';
 newobject.innerHTML = '&nbsp;';
 document.body.appendChild(newobject);
}
*/
//window.scrollBarWidth = getScrollbarWidth(); in Utility.js if needed
var sType = document.getElementById("FormSelectType");
if (!(sType == null))
{
    if (sType.value == "S")
    {
        document.SelectorType = "S";
    }
}
window.mainPanel = getMainPanel();
window.rightPanel = getRightPanel();
window.sidePanel = getSidePanel();
//var mainPanel = getMainPanel();
if (!(window.mainPanel == null))
{
    /*window.scrollbars.visible=false;*/
    setScrollPos(window.mainPanel);
    window.mainPanel.onscroll = function() { panelScroll(this) }
    toogleScrollbars(true);
    //document.body.style.overflow='hidden';
}
else
{
    toogleScrollbars(false);
}
/*
var gFrm = document.getElementById("genForm");
if (!(gFrm == null))
{    
    gFrm.onscroll = function() { formScroll(this) }
    //document.body.style.overflow='hidden';
}
*/
setSideFooter();
sType = document.getElementById("__MynCurrentFocus");
if (!(sType == null))
{
    var fid = sType.value;
    if (!(fid == null))
    {
        if (!(fid == ""))
        {    
            var fctl = document.getElementById(fid);
            if (!(fctl == null))
            {
                try
                {
                    if (fctl.focus)
                    {
                        fctl.focus();
                    }
                 }
                 catch(err)
                 {
                    //no action
                 }
            }
        }
    }
}
if (window.mynLoad)
{
    mynLoad();
}
}
/*
function formScroll(sce)
{
    if (sce == null)
    {
        return;
    }
    var tp = sce.scrollTop;
    var lp = sce.scrollLeft;
}
*/
function setScrollPos(sce) {
    var grdStatId = 'mainPanelXPos';
    var grdStat = document.getElementById(grdStatId);
    if (grdStat == null)
    {
        sce.scrollLeft = "0"; 
    }
    else
    {
        sce.scrollLeft = grdStat.value; 
    }
    grdStatId = 'mainPanelYPos';
    grdStat = document.getElementById(grdStatId);
    if (grdStat == null)
    {
        sce.scrollTop = "0";
    }
    else
    {
        sce.scrollTop = grdStat.value;
    }
 }
function panelScroll(sce)
{    
    if (sce == null)
    {
        return;
    }
    var theForm = document.forms[0];
    var grdStatId = 'mainPanelXPos';
    var grdStat = document.getElementById(grdStatId);
    if (grdStat == null)
    {
        grdStat = document.createElement("input");
        grdStat.type = "hidden";
        grdStat.name = grdStatId;
        grdStat.id = grdStatId;
        theForm.appendChild(grdStat);
    }
    grdStat.value = sce.scrollLeft;
    grdStatId = 'mainPanelYPos';
    grdStat = document.getElementById(grdStatId);
    if (grdStat == null)
    {
        grdStat = document.createElement("input");
        grdStat.type = "hidden";
        grdStat.name = grdStatId;
        grdStat.id = grdStatId;
        theForm.appendChild(grdStat);
    }
    grdStat.value = sce.scrollTop;
    setSideFooter();
}
function __doMynPostBack(eventTarget, eventArgument) {
    var theForm = document.forms[0];
    var trgCtl = document.getElementById("__MynEventTarget");
    var argCtl = document.getElementById("__MynEventArgument");
    if (theForm == null)
    {
        return;
    }
    if (trgCtl == null)
    {
        trgCtl = document.createElement("input");
        trgCtl.type = "hidden";
        trgCtl.name = "__MynEventTarget";
        trgCtl.id = "__MynEventTarget";
        theForm.appendChild(trgCtl);
    }
    trgCtl.value = eventTarget;
    if (argCtl == null)
    {
        argCtl = document.createElement("input");
        argCtl.type = "hidden";
        argCtl.name = "__MynEventArgument";
        argCtl.id = "__MynEventArgument";
        theForm.appendChild(argCtl);    
    }
    argCtl.value = eventArgument;
    __getMynTreeViewStatus();    
    //if (AJAXCbo)
    //{
        //AJAXCbo.DoPostBack(eventTarget, eventArgument);
    //}
    // not needed as input button will automatically postback
    //theForm.submit();
}
function __mynSelectTopic(topicCode) {
    __execMynPostBack('TopicSelect$', topicCode)
}
function __mynSelectSection(sectionCode) {
    __execMynPostBack('SectionSelect$', sectionCode)
}
function __mynCustomMenuOption(menuCode) {
    __execMynPostBack('CustomMenuSelect$', menuCode)
}
function mynSetFormAction (frmSaveWord,frmDocWord,mynFaType) {
var ctl = document.getElementById("FormActionType");
var frmSaveReq = document.getElementById("FormSaveRequired");
var answer = confirm(frmSaveWord + " " + frmDocWord + "?");
if (answer)
    {
    if (ctl != null)
        {
        ctl.value = mynFaType;
        }    
    if (frmSaveReq != null)
    {
        frmSaveReq.value = "Y";
    }        
    document.forms[0].submit();
    }
else
    {
    var ansAbandon = confirm("Close " + frmDocWord + " without saving changes?");
    if (ansAbandon)
        {
            if (ctl != null)
            {
            ctl.value = mynFaType;
            }    
            if (frmSaveReq != null)
            {
                frmSaveReq.value = "N";
            }        
        document.forms[0].submit();
        }    
    }
}
function mynSaveAction (mynFaType) {
   var ObjectSelected = false;
   var objSelect = document.getElementById("FormObjectSelected");
   if (!(objSelect == null))
   {
        if (objSelect.value == "Y")
        {
            ObjectSelected = true;
        }
   }
   if (!ObjectSelected)
   {            
        var frmSaveReq = document.getElementById("FormSaveRequired");
        if (!(frmSaveReq == null))
        {
            frmSaveReq.value = "N";
        }
        var ctl = document.getElementById("FormActionType");
        if (ctl != null)
        {
            ctl.value = mynFaType;
        }    
        document.forms[0].submit();        
        return;
    }       
   var SaveWord;
   var DocumentWord;
   var ctl = document.getElementById("FormSaveWord");
    if (ctl == null)
    {
        SaveWord = "Save";
    }
    else
    {
        SaveWord = ctl.value;
    }
    ctl = document.getElementById("FormDocumentWord");
    if (ctl == null)
    {
        DocumentWord = "Document";
    }
    else
    {
        var DocumentWord = ctl.value;
    }
    mynSetFormAction(SaveWord,DocumentWord,mynFaType);
}
function LogOnClick () {
    __execMynPostBack("Logon","");
}
function LogOnShopClick () {
    __execMynPostBack("LogonShop","");
}
function NewButtonClick () {
    mynSaveAction("New");
}
function OpenButtonClick () {
    mynSaveAction("Open");
}
function SaveButtonClick () {
    var ObjectSelected = false;
    var objSelect = document.getElementById("FormObjectSelected");
    if (!(objSelect == null))
    {
        if (objSelect.value == "Y")
        {
            ObjectSelected = true;
        }
    }
    if (!ObjectSelected)
    {
        return;
    }
    var frmSaveReq = document.getElementById("FormSaveRequired");
    var ctl = document.getElementById("FormActionType");
    var fdw = document.getElementById("FormDocumentWord");
    var DocumentWord = "Document";
    var SaveWord = "Save";
    if (!(fdw == null))
    {
        if (!(fdw.value == null))
        {
            if (!(fdw.value == ""))
            {
                DocumentWord = fdw.value;
            }
        }
    }    
    if (!(ctl == null))
    {
        if (!(ctl.value == null))
        {
            if (!(ctl.value == ""))
            {    
                SaveWord = ctl.value;
            }
        }
    }        
    var answer = confirm(SaveWord + " " + DocumentWord + "?");
    if (answer)
    {
        if (ctl != null)
        {
            ctl.value = "";
        }    
        if (frmSaveReq != null)
        {
            frmSaveReq.value = "Y";
        }        
        document.forms[0].submit();
    }
}
function DeleteButtonClick () {
   var DocumentWord;
    ctl = document.getElementById("FormDocumentWord");
    if (ctl == null)
    {
        DocumentWord = "Record";
    }
    else
    {
        var DocumentWord = ctl.value;
    }
    var ans = confirm("Are you sure you wish to delete this " + DocumentWord + "?");
    if (ans)
    {
        __execMynPostBack('DeleteRecord$', '')
    }
}
function CloseDialogClick () {
   __execMynPostBack('CloseDialog$', '')
}
function CloseButtonClick () {
    mynSaveAction("Close");
}
function __getMynTreeViewStatus()
{
    var trows = document.getElementsByTagName('input');
    for (i=0; i < trows.length; i++)
    {
        var dhid = trows[i].id;
        if (dhid)
        {
            var mp = dhid.indexOf('TreeVWMarker');
            if (mp > -1)
            {
                if (trows[i].value)
                {
                    if (window.GetViewState__AspNetTreeView)
                    {
                        var tvs = GetViewState__AspNetTreeView(trows[i].value);
                        var theForm = document.forms[0];
                        var vsid = trows[i].value + '_Status';
                        var tvStat = document.getElementById(vsid);
                        if (tvStat == null)
                        {
                            tvStat = document.createElement("input");
                            tvStat.type = "hidden";
                            tvStat.name = vsid;
                            tvStat.id = vsid;
                            theForm.appendChild(tvStat);
                        }
                        tvStat.value = tvs;
                    }
                }
            }
        }
    }
}
function UpdateOnEnter(e) {
/*
if (e.keyCode)
{
    code = e.keyCode;
    if (code == 13)
    {
        __execMynPostBack('', '');
    }	            
}
*/
    var targ;
    var arg;
    var code;
	if (!e) var e = window.event;
	// e gives access to the event in all browsers
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;				    
    if (e.keyCode)
    {
        code = e.keyCode;
    }
    else if (e.which)
    {
        code = e.which;
    }
    if (code == 13)
    {
        __execMynPostBack('UpdOnEnter$', targ.id);
    }	            
}
function ClickOnEnter(e) {
/*
if (e.keyCode)
{
    code = e.keyCode;
    if (code == 13)
    {
        __execMynPostBack('', '');
    }	            
}
*/
    var targ;
    var arg;
    var code;
	if (!e) var e = window.event;
	// e gives access to the event in all browsers
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;				    
    if (e.keyCode)
    {
        code = e.keyCode;
    }
    else if (e.which)
    {
        code = e.which;
    }
    if (code == 13)
    {
        targ.click();
    }	            
}
function mynKeyDown(e) {
    var targ;
    var arg;
    var code;    
    var fstKeyPress = false;
    if (!window.fstPress)
    {
        window.fstPress = true;
        fstKeyPress = true;
    }
	if (!e) var e = window.event;
	// e gives access to the event in all browsers
	if (e.which)
	{
	    return mynFFKeyDown(e);
	}
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;				
	//alert("key down");
    if (targ.nodeName == 'INPUT' || targ.nodeName == 'SELECT')
    {
        if (e.keyCode)
        {
            code = e.keyCode;
	        if (code == 13 && !(targ.type == 'submit'))
	        {
	            if (fstKeyPress && document.SelectorType == "S")
	            {
	                e.keyCode = 16;
                    if (__SelectKey)
                    {	                
	                    __SelectKey();
	                }
	            }
	            if (!targ.IsMultiLine)
	            {
	                e.keyCode = 9;
	            }
	        }	            
	        else if ((code == 115) || (code == 116))
	        {
	            e.keyCode = 39;	            
	        }	        	            	        
	        else if (code == 27)
	        {
	            e.keyCode = 39;
	        }
        }
	    if ((code == 115) || (code == 116))
	    {
	        if (code == 115)
	        {
	            arg = 'ImageClick$';
	        }
	        else
	        {
	            arg = 'ImageF5Click$';
	        }
	        __execMynPostBack(targ.id, arg);
         }
         else if (code == 38)
         {         
            if (window.__UpKey)
            {   
                __UpKey();
            }
         }
         else if (code == 40)
         {
            if (!(targ.type == "submit"))
            {
                if (window.__DownKey)
                {
                    __DownKey(true);
                }
            }
            else
            {
                if (window.__DownKey)
                {            
                    __DownKey(false);
                }
            }
        }
        else if (code == 27)
        {            
            __escKey();
        }    
        else if (code >112 && code < 124)
        {
            processFkey(e,code,targ.id);
        }                             
     }
     else
     {
        if (e.keyCode)
        {
            code = e.keyCode;
        }
        if (code == 13)
        {
            if  (document.SelectorType == "S")
            {
                if (__SelectKey)
                {            
                    __SelectKey();
                }
            }
        }
        else if (code == 38)
        {
            if (window.__UpKey)
            {           
                __UpKey();
            }
        }
        else if (code == 40)
        {
            if (window.__DownKey)
                {
                    __DownKey(false);
                }
        }     
        else if (code == 27)
        {
            __escKey();
        }        
        else if (code >112 && code < 124)
        {
            processFkey(e,code,targ.id);
        }                
     }
}
function mynFFKeyDown(e) {
    var targ;
    var arg;
    var code;    
    var fstKeyPress = false;
    if (!window.fstPress)
    {
        window.fstPress = true;
        fstKeyPress = true;
    }
	if (!e) var e = window.event;
	// e gives access to the event in all browsers
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;				
	//alert("key down");
    if (targ.nodeName == 'INPUT' || targ.nodeName == 'SELECT')
    {
	    if (e.which)
	    {
	        code = e.which;
	        if (code == 13 && !(targ.type == 'submit'))
	        {
	            if (fstKeyPress)
	            {
	                //e.which = 16;
                    if (__SelectKey)
                    {	                
	                    __SelectKey();
	                }
	                return;
	            }
                var idx = getIndex(targ);
                if (idx > -1)
                {
                    var nidx = getNext(idx);
                    if (nidx > -1)
                    {
                        document.forms[0][nidx].focus();
                    }
                }
                return false;
	            //e.which = 9;
	        }
	        else if ((code == 115) || (code == 116))
	        {
	            //e.which = 39;	            
	        }	            	        
	        else if (code == 27)
	        {
	            //e.which = 39;
	        }	        
	    }
	    //alert("key down" + code);
	    if ((code == 115) || (code == 116))
	    {
	        if (code == 115)
	        {
	            arg = 'ImageClick$';
	        }
	        else
	        {
	            arg = 'ImageF5Click$';
	        }
	        __execMynPostBack(targ.id, arg);
         }
         else if (code == 38)
         {         
            if (window.__UpKey)
            {               
                __UpKey();
            }
         }
         else if (code == 40)
         {
            if (!(targ.type == "submit"))
            {
                if (window.__DownKey)
                {            
                    __DownKey(true);
                 }
            }
            else
            {
                if (window.__DownKey)
                {            
                    __DownKey(false);
                }
            }
        }
        else if (code == 27)
        {            
            __escKey();
        }    
        else if (code >112 && code < 124)
        {
            processFFFkey(e,code,targ.id);
        }                             
     }
     else
     {
        if (e.which)
        {
            code = e.which;
        }
        if (code == 13)
        {
            if  (document.SelectorType == "S")
            {
                if (__SelectKey)
                {
                    __SelectKey();
                }
            }
        }
        else if (code == 38)
        {
            if (window.__UpKey)
            {           
                __UpKey();
            }
        }
        else if (code == 40)
        {
            if (window.__DownKey)
            {        
                __DownKey(false);
            }
        }     
        else if (code == 27)
        {
            __escKey();
        }        
        else if (code >112 && code < 124)
        {
            processFFFkey(e,code,targ.id);
            return false;
        }                
     }
}
function processFkey(e,code,tid)
{
    e.keyCode = 0;
    e.cancelBubble = true;
    e.returnValue = false;
    var fKey;    
    //e.stopPropagation works only in Firefox.
    if (e.stopPropagation)
    {
        e.stopPropagation();
        e.preventDefault();
    }
    if (this.mynCSKeyDown)
    {
        if (mynCSKeyDown(code))
        {
            return;
        }
    }            
    if (code == 113)
    {
        fKey = "f2";                
    }
    else if (code == 114)
    {
        fKey = "f3";
    }
    else if (code == 115)
    {
        fKey = "f4";
    }
    else if (code == 116)
    {
        fKey = "f5";
    }
    else if (code == 117)
    {
        fKey = "f6";
    }
    else if (code == 118)
    {
        fKey = "f7";
    }
    else if (code == 119)
    {
        fKey = "f8";
    }
    else if (code == 120)
    {
        fKey = "f9";
    }
    else if (code == 121)
    {
        fKey = "f10";
    }
    else if (code == 122)
    {
        fKey = "f11";
    }
    else if (code == 123)
    {
        fKey = "f12";
    }
    if (e.ctrlKey)
    {
        fKey = "^" + fKey;
    }
    if (e.shiftKey)
    {
        fKey = "+" + fKey;
    }
    if (e.altKey)
    {
        fKey = "*" + fKey;
    }    
    var rvid = "fKey$Press$:" + tid;
    __funKey(rvid,fKey);
}
function processFFFkey(e,code,tid)
{
    //e.keyCode = 0;
    //e.cancelBubble = true;
    //e.returnValue = false;
    var fKey;    
    //e.stopPropagation works only in Firefox.
    if (e.stopPropagation)
    {
        e.stopPropagation();
        e.preventDefault();
    }
    if (this.mynCSKeyDown)
    {
        if (mynCSKeyDown(code))
        {
            return;
        }
    }            
    if (code == 113)
    {
        fKey = "f2";                
    }
    else if (code == 114)
    {
        fKey = "f3";
    }
    else if (code == 115)
    {
        fKey = "f4";
    }
    else if (code == 116)
    {
        fKey = "f5";
    }
    else if (code == 117)
    {
        fKey = "f6";
    }
    else if (code == 118)
    {
        fKey = "f7";
    }
    else if (code == 119)
    {
        fKey = "f8";
    }
    else if (code == 120)
    {
        fKey = "f9";
    }
    else if (code == 121)
    {
        fKey = "f10";
    }
    else if (code == 122)
    {
        fKey = "f11";
    }
    else if (code == 123)
    {
        fKey = "f12";
    }
    if (e.ctrlKey)
    {
        fKey = "^" + fKey;
    }
    if (e.shiftKey)
    {
        fKey = "+" + fKey;
    }
    if (e.altKey)
    {
        fKey = "*" + fKey;
    }    
    var rvid = "fKey$Press$:" + tid;
    __funKey(rvid,fKey);
}
function __funKey(ctl,fKey)
{
    __execMynPostBack(ctl,fKey);
}
function __escKey()
{
    var sType = document.getElementById("FormSelectType");
    if (sType == null)
    {
        return;
    }
    if (sType.value == "S")
    {
        var inps = document.getElementsByTagName("input");
        for (i=0; i < inps.length; i++)
        {
            if (inps[i].type == "submit")
            {
                if (inps[i].id == "nb__btnCancel")
                {
                    inps[i].focus();
                    inps[i].click();
                    //__execMynPostBack(inps[i].id,'MynSubmit$');
                    return;
                }
            }
        } 
    }
}


function __doMynImageClick(e)
{
	var rightclick;
	var sce;
	var prnt;
	if (!e) var e = window.event;
	if (e.which) rightclick = (e.which == 3);
	else if (e.button) rightclick = (e.button == 2);
	if (e.target) sce = e.target;
	else if (e.srcElement) sce = e.srcElement;
	if (sce.nodeType == 3) // defeat Safari bug
		sce = sce.parentNode;				    
    if (!(sce == null))
    {
        if (rightclick)
        {            
            var posx = 0;
	        var posy = 0;
	        if (e.pageX || e.pageY) 	{
		        posx = e.pageX;
		        posy = e.pageY;
	        }
	        else if (e.clientX || e.clientY) 	{
		        posx = e.clientX + document.body.scrollLeft
			        + document.documentElement.scrollLeft;
		        posy = e.clientY + document.body.scrollTop
			        + document.documentElement.scrollTop;
	        }
            mynImgMenu(sce,posx,posy);     
        }        
    }    
}
function mynImgMenu(sce,x,y) {
  var imgMenuId = 'imgMenu';
  var imgMenu = document.getElementById(imgMenuId);
  if (imgMenu == null)
  {   var ctxtmenuStyle = 'grdMenu';
      var ctxtmenuUlStyle = 'grdMenuList';
      var ctxtmenuLiStyle = 'grdMenuButton';
      imgMenu = document.createElement('div');
      imgMenu.className = ctxtmenuStyle;
      imgMenu.style.position = 'absolute';
      imgMenu.style.left = x + 'px';
      imgMenu.style.top = y + 'px';              
      imgMenu.id = imgMenuId;
      var imgMenuList = document.createElement('ul');
      imgMenuList.className = ctxtmenuUlStyle;
/*  newdiv.style.height = '20px'
  newdiv.style.width = '200px'; */
      var imgMenuOptId = 'imgMenuOpt1';
      var imgOpt = document.createElement('li');
      imgOpt.id = imgMenuOptId;
      imgOpt.className = ctxtmenuLiStyle;
      imgOpt.innerHTML = "Set Picture";
      imgOpt.onclick = function() { mynImgPic(sce) }
      imgMenuList.appendChild(imgOpt);

      var imgMenuOptId = 'imgMenuOpt2';
      var imgOpt = document.createElement('li');
      imgOpt.id = imgMenuOptId;
      imgOpt.className = ctxtmenuLiStyle;
      imgOpt.innerHTML = "Remove Picture";
      imgOpt.onclick = function() { mynImgDel(sce) }
      imgMenuList.appendChild(imgOpt);
      
      imgMenuOptId = 'imgMenuOpt3';
      imgOpt = null;
      imgOpt = document.createElement('li');
      imgOpt.id = imgMenuOptId;
      imgOpt.className = ctxtmenuLiStyle;
      imgOpt.innerHTML = "Hide";
      imgOpt.onclick = function() { mynImgHideMenu() }
      imgMenuList.appendChild(imgOpt);
      imgMenu.appendChild(imgMenuList);
      
      var theForm = document.forms[0];
      theForm.appendChild(imgMenu);
  }      
  imgMenu.style.display = 'list-item';
  imgMenu.style.position = 'absolute';
  imgMenu.style.left = x + 'px';
  imgMenu.style.top = y + 'px';                
  /* newdiv.setAttribute('id',divIdName);
  newdiv.setAttribute('style','position: absolute; left: ' + x + 'px; top: ' + y + 'px ; height 10px; width 100px ; z-index: 1000 ;');
  */
}
function mynImgPic(sce)
{
    var answer = confirm("Set Picture?");
    if (answer)
    {   
        var sid = sce.id;     
        if (sce.nodeName == 'IMG')
        {
            sid = sce.parentNode.id;
        }
      __execMynPostBack(sid,'SetBindPic$');
    }
    else
    {
        mynImgHideMenu();
    }
}
function mynImgDel(sce)
{
    var answer = confirm("Remove Picture?");
    if (answer)
    {        
        var sid = sce.id;     
        if (sce.nodeName == 'IMG')
        {
            sid = sce.parentNode.id;
        }
      __execMynPostBack(sid,'DelBindPic$');
    }
    else
    {
        mynImgHideMenu();
    }
}
function mynImgHideMenu()
{
  var grdMenuId = 'imgMenu';
  var grdMenu = document.getElementById(grdMenuId);
  if (!(grdMenu == null))
  {
    grdMenu.style.display = 'none';
  }
}
function __setCmdFocus()
{
    window.focus();
    /*var inps = document.getElementsByTagName("");
    for (i=0; i < inps.length; i++)
    {
        if (inps[i].type == "submit")
        {
            inps[i].focus();
            return;
        }
    } 
    */       
}
function __mainSelectorKd(e) {
    var targ;
    var arg = "NewSelect$";
    var code;
    var doPost = false;
    //var isIE = false;
    //function ft(tid, tag) { return ffTest(tid, tag) };
    //ft('', '');
	if (!e) var e = window.event;
	// e gives access to the event in all browsers
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;				
	var snd = false;
	if (e.keyCode) {
        code = e.keyCode;
        if (code == 13 && targ.value != "")
        {
            snd = true;            
        }	            
    }
    else if (e.which)
    {
        code = e.which;
        if (code == 13 && targ.value != "")
        {
            snd = true;
        }
    }
    if (snd)
    {
        var DocumentWord;
        var ctl = document.getElementById("FormDocumentWord");
        if (ctl == null)
        {
            DocumentWord = "Document";
        }
        else
        {
            var DocumentWord = ctl.value;
        }        
        doPost = confirm('Create or open ' + DocumentWord + ' with ref ' + targ.value);
    }
    if (doPost) {
        window.__execMynPostBack(targ.id, arg);
    }
}
//function __execFFPostBack(eventTarget, eventArgument) {
    //alert('Dummy');
//}
function __execMynPostBack(eventTarget, eventArgument) {
    // use for controls that don't automatically submit
    //alert('In start post back');
    __doMynPostBack(eventTarget, eventArgument);
    //alert('In post back');
    var theForm = document.forms[0];
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        //alert('In submit');
        theForm.submit();
    }
}
//function ffTest(tid,targ) {
   //alert('ffTest tid ' + tid + ' targ ' + targ);
//}
function __itemSelectorKd(e) {
    var targ;
    var arg = "ItemSelect$";
    var code;
	if (!e) var e = window.event;
	// e gives access to the event in all browsers
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;				
	var snd = false;
    if (e.keyCode)
    {
        code = e.keyCode;
        if (code == 13 && targ.value != "")
        {
            snd = true;            
        }	            
    }
    else if (e.which)
    {
        code = e.which;
        if (code == 13 && targ.value != "")
        {
            snd = true;
        }
    }
    if (snd)
    {
        __execMynPostBack(targ.id, arg);
    }
}
function __chargeSelectorKd(e) {
    var targ;
    var arg = "ChargeSelect$";
    var code;
	if (!e) var e = window.event;
	// e gives access to the event in all browsers
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;				
	var snd = false;
    if (e.keyCode)
    {
        code = e.keyCode;
        if (code == 13 && targ.value != "")
        {
            snd = true;            
        }	            
    }
    else if (e.which)
    {
        code = e.which;
        if (code == 13 && targ.value != "")
        {
            snd = true;
        }
    }
    if (snd)
    {
        __execMynPostBack(targ.id, arg);
    }
}
function __mynImageClick(id, e) {
	var rightclick;
	//if (!e) var e = window.event;
	if (e.which) rightclick = (e.which == 3);
	else if (e.button) rightclick = (e.button == 2);
	/*
	var targ;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;				
    */
	var arg = "ImageClick$"	
	if (rightclick)
	{
	    arg = "ImageRightClick$"	
	}
	__execMynPostBack(id, arg);
	//alert('Rightclick: ' + rightclick); // true or false
}
function setSideFooter() {
//work around ie infinite loop bug
window.onresize = null;
try
{
    if (document.getElementById)
    {
        /*
        var mainPanel = document.getElementById('mainContentPanel');
        if (!(mainPanel == null))
        {
            var pn = mainPanel.parentNode;
            if (!(pn == null))
            {
                alert('id is ' + pn.id);
                if (!(pn.parentNode == null))
                {
                    alert('parent id is ' + pn.parentNode.nodeName + ' ' + pn.parentElement.id);
                }
            }
        }
        */
        var windowHeight=getWindowHeight();
        if (windowHeight>0)
        {    
            var sWidth = 0;
            var wTop = 0;
            var wHeight = 0;                        
            var wWidth = 0;                        
            var contentElement = window.sidePanel;;
            if (contentElement)
            {
                sWidth = contentElement.offsetWidth;
                var contentTop = contentElement.offsetTop;
                //var contentHeight = document.getElementById('sideContent').offsetHeight;
                var footerElement = document.getElementById('sideFooter');
                var footerHeight = 0;
                if (footerElement)
                {
                    footerHeight = footerElement.offsetHeight;
                }
                if (windowHeight - (footerHeight + contentTop)>=0)
                {
                    wTop = windowHeight - footerHeight;
                    wHeight = windowHeight - (footerHeight + contentTop);                                
                    contentElement.style.height = wHeight + "px";                
                    if (footerElement)
                    {
                        footerElement.style.top = wTop + "px";
                    }
                }
                if (footerElement)
                {
                    footerElement.style.left = 0 + "px";
                }
             }
             //contentElement = getMainPanel();
             contentElement = window.mainPanel;
             var windowWidth=getWindowWidth();
             if (windowWidth>0 && contentElement)
             {
                    var mpTop = contentElement.offsetTop;
                    var mpLeft = contentElement.offsetLeft;                
                    wHeight = windowHeight - mpTop;
                    wWidth = windowWidth - mpLeft;
                    contentElement.style.height = wHeight + "px";
                    contentElement.style.width = wWidth + "px";
                    //contentElement.scrollTop = 0;
                    //contentElement.scrollLeft = 0;
             }              
             contentElement = window.rightPanel;
             //var windowWidth=getWindowWidth();
             if (windowWidth>0 && contentElement)
             {
                    var mpWid = contentElement.offsetWidth;
                    var mpLeft = windowWidth - mpWid - sWidth - 25;
                    contentElement.style.right = null;
                    contentElement.style.left = mpLeft + "px";
             }
                                
             contentElement = document.getElementById('repContentPanel');
             //var windowWidth=getWindowWidth();
             if (windowWidth>0 && contentElement)
             {
                    var mpTop = contentElement.offsetTop;
                    var mpLeft = contentElement.offsetLeft;
                    wHeight = windowHeight - mpTop;
                    wWidth = windowWidth - mpLeft;
                    contentElement.style.height = wHeight + "px";
                    contentElement.style.width = wWidth + "px";
                    //contentElement.scrollTop = 0;
                    //contentElement.scrollLeft = 0;
             } 
             contentElement = document.getElementById('selectorGrid');
             if (!(contentElement == null))
             {
                var sgTop = contentElement.offsetTop;
                var prnt = contentElement;
                while (!(prnt.parentNode == null))
                {
                    if (prnt.parentNode.offsetTop)
                    {
                        sgTop += prnt.parentNode.offsetTop;
                    }
                    prnt = prnt.parentNode;                                
                }
                if ((windowHeight - sgTop - 35) > 0)
                {
                    wHeight = windowHeight - sgTop - 35;                
                    contentElement.style.height = wHeight + "px";                
                    contentElement.style.overflow = "auto";                                
                    var tbls = contentElement.getElementsByTagName('table');
                    if (tbls.length > 0)
                    {                    
                        if (tbls[0].offsetHeight > wHeight)
                        {
                            tbls[0].style.height = wHeight;
                        }
                    } 
                                   
                }
             }
             if (window.__SetSplitters)
             {
                __SetSplitters();
             }
        }
    }
    //work around ie infinite loop bug
    window.onresize = setSideFooter;
}
catch(err)
{
    //work around ie infinite loop bug
    window.onresize = setSideFooter;
}
}
function resetResize()
{
setTimeout("window.onresize = setSideFooter", 2000);
}
function __chkGrdScroll(tr)
{
    if (tr == null)    
    {
        return;
    }
    var mainPanel = window.mainPanel;
    if (mainPanel == null)
    {
        return;
    }  
    var prnt = tr.parentNode;
    var sgTop = tr.offsetTop;
    while (!(prnt == null))
    {
        sgTop += prnt.offsetTop;
        prnt = prnt.parentNode;
    }
    sgTop += 35;
    var windowHeight=getWindowHeight();
    if (!(windowHeight>0))    
    {    
        return;
    }
    if (sgTop > (windowHeight + mainPanel.scrollTop))
    {
        mainPanel.scrollTop = sgTop - (windowHeight / 2);
    }
    else if (mainPanel.scrollTop > (sgTop - 200))
    {
        if (mainPanel.scrollTop < (windowHeight / 2))
        {
            mainPanel.scrollTop = "0";
        }
        else
        {
            mainPanel.scrollTop = mainPanel.scrollTop - (windowHeight / 2);
        }
    }
}
function getScrollX() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfX;
}
function getWindowHeight() {
var windowHeight=0;
if (typeof(window.innerHeight)=='number')
{
    windowHeight=window.innerHeight;
}
else
{
    if (document.documentElement && document.documentElement.clientHeight)
    {
        windowHeight = document.documentElement.clientHeight;
    } 
    else
    {
        if (document.body&&document.body.clientHeight)
        {
            windowHeight=document.body.clientHeight;
        }
    }
}
return windowHeight;
}

function getWindowWidth() {
var windowWidth=0;
if (typeof(window.innerWidth)=='number')
{
    windowWidth=window.innerWidth;
}
else
{
    if (document.documentElement && document.documentElement.clientWidth)
    {
        windowWidth = document.documentElement.clientWidth;
    } 
    else
    {
        if (document.body && document.body.clientWidth)
        {
            windowWidth=document.body.clientWidth;
        }
    }
}
return windowWidth;
}
function crnd (ivl)
{
    if (isNaN(ivl))
    {
        return 0;
    }
    var rr;
    rr = Math.round(ivl * 100);
    rr = rr/100;
    return rr;
}
function vcrnd (ivl)
{
    if (isNaN(ivl))
    {
        return 0;
    }
    if (ivl == 0)
    {
        return 0;
    }
    var rv = crnd(ivl);
    if (rv == 0)
    {
        if (ivl < 0)
        {
            return (-1) * .01;
        }
        else
        {
            return .01;
        }
    }
    return rv;
}
function toogleScrollbars(hide) 
{
return;
var theRules = new Array(); 
if (document.styleSheets[0].cssRules) 
{
    theRules = document.styleSheets[0].cssRules
}
else if (document.styleSheets[0].rules)
{
    theRules = document.styleSheets[0].rules
}
if(hide) 
{
    window.scrollbars = "false";
    theRules[0].style.overflow = "hidden";
    theRules[0].style.overflowX = "hidden"; 
    theRules[0].style.overflowX = "hidden";
}
else
{
    window.scrollbars = "true";
    document.body.style.overflow = "auto";
    theRules[0].style.overflow = "auto";
    theRules[0].style.overflowX = "auto"; 
    theRules[0].style.overflowY = "auto"; 
}
}
function grdFirstPage()
{
//not just used by grids
alert("You are on the first page");
}
function grdLastPage()
{
//not just used by grids
alert("You are on the last page");
}
function getMainPanel()
{
var mainPanel = document.getElementById("mainContentPanel");
if (mainPanel == null)
{
    mainPanel = document.getElementById("mainContentPanelNSM");
}
if (mainPanel == null)
{
    mainPanel = document.getElementById("mainGenContentPanel");
}
if (mainPanel == null)
{
    mainPanel = document.getElementById("mainGenContentPanelNSM");
}
/*
if (mainPanel == null)
{
    mainPanel = document.getElementById("wscentercontent");
}
*/
return mainPanel;
}
function getRightPanel()
{
var rightPanel = document.getElementById("rightcontent");
/*
if (rightPanel == null)
{
    rightPanel = document.getElementById("wsrightcontent");
}
*/
return rightPanel;
}
function getSidePanel()
{
var contentElement = document.getElementById('sideContent');
/*
if (contentElement == null)
{
    contentElement = document.getElementById("wsleftcontent");
}
*/
return contentElement;
}
/*
function InitForm()
{
    var theForm = document.forms[0];
    var trgCtl = document.getElementById("__MynEventTarget");
    var argCtl = document.getElementById("__MynEventArgument");
    if (!(trgCtl == null))
    {
        trgCtl.value = '';
    }
    if (!(argCtl == null))
    {
        argCtl.value = '';
    }
}
InitForm()
*/
function getIndex(input)
{
    try
    {
        var index = -1, i = 0, found = false;
        while (i < document.forms[0].length && index == -1)
        {
            if (document.forms[0][i] == input)
            {
                index = i;
                break;
            }
            else
            {
                i++;
            }
        }
        return index;
    }
    catch(err)
    {
    }
}
function getNext(myind)
{
    try
    {
        //var field = form;
        var i = myind + 1;
        var index = myind ;
        var nif = false;
        while (i < document.forms[0].length )
        {
            switch (document.forms[0].elements[i].type)
            {
                case "text":
                case "textarea":
                case "radio":
                case "select-one":
                case "select-multiple":
                case "button":
                case "submit":
                    index = i;
                    nif = true;
                    break;                
                default:
                    i++;
                    break;                
            }
            if (nif)
            {
                break;
            }
        }
        return index;
    }
    catch(err)
    {
    }
}
