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];}
}


function fnformLink(sform,nPage,sACT)
{
    //alert("fnformLink Change Call!");
    eval('document.'+sform+'.PGID.value ="'+ nPage+'";');
    eval('document.'+sform+'.ACT.value ="'+ sACT +'";');
    eval('document.'+sform+'.submit();');
}
function fnformLink2(sform,strNames,strVals)
{
    
    //alert("fnformLink2 Change Call!");
    var oForm;
    sform = 'AUTOFORM'+sform;
    oForm = MM_findObj(sform);
    
    aNameList = strNames.split(",");
    aValList = strVals.split(",");

    var err;
    for (err=0;err<aNameList.length;err++)
    {
        if (aNameList[err]!='')
        {
            if (aNameList[err]=='ACT') 
            {
                if (aValList[err]=='DELETE')
                {
                    if (!confirm("Are you sure you want to delete this record"))
                    {
                        return;
                    }
                }
            }
            eval('document.'+sform+'.'+aNameList[err]+'.value="'+aValList[err]+'";');
        }
        
    }
    
    oForm.submit();
}

function fnHidePop()
{
    document.all.popIframe.className = "popframeoff"
	pop.style.display = "none";
}

var gElSelected,gElSelectedClass;
gElSelected = null;
function fnURLLinkPop(strURL)
{
    var strPopTitle="";
    //alert();
    //return;
    //alert(event);
    //return;
    if (event != null) {
        var e = event.srcElement;
        if (e.tagName == "IMG") {
            strPopTitle=e.title;
            //alert(strPopTitle);
            e = e.parentElement;
        }
        if (gElSelected != null)
        {
            gElSelected.className = gElSelectedClass;
        }
        
        if (strPopTitle == ""){strPopTitle=e.title;}
        e = e.parentElement.parentElement;
        if (e.tagName=="TR") {
            if (e.className == "resultTReven" || e.className == "resultTRodd") {
                gElSelectedClass = e.className;
                gElSelected = e;
                e.className = "resultTRSelected";
            }
            
        }
    }
    
    if (strPopTitle != "") {
        MM_findObj("popTitle").innerHTML = strPopTitle;
    }
    else{
        MM_findObj("popTitle").innerHTML = "Property Editor";
    }
    document.all.popIframe.className = "popframeon"
	pop.style.display = "block";
    document.all.popIframe.src = strURL;
}


function popSize()
{
    var sheet,nheight,ot,nwidth;
    ot = document.all.tags("TABLE");
    if (ot.length > 0)
    {
        nwidth = ot[0].clientWidth;
        nheight = ot[0].clientHeight;
        if (nwidth<100) {
            nwidth=100;
        }

        /*
        if (nwidth>760) {
            nwidth=760;
        }
        */

        if (nheight<100) {
            nheight=100;
        }

        /*
        if (nheight>560) {
            nheight=560;
            nwidth = nwidth + 30;
        }
        */
        sheet = parent.document.styleSheets["popSheet"];
    	sheet.addRule(".popframeon","height:"+nheight+"px");
    	sheet.addRule(".popframeon","width:"+nwidth+"px");
        var iy = parent.document.body.clientHeight;
        var ix = parent.document.body.clientWidth;


        iy = ((iy-nheight)/2)+parent.document.body.scrollTop;
        ix = ((ix-nwidth)/2)+parent.document.body.scrollLeft;
        parent.pop.style.left=ix+"px";
        parent.pop.style.top=iy+"px";
    }
}

function fnCenterDiv(oDiv){
    return;
    //alert();
    var nheight = oDiv.height;
    var nwidth = oDiv.width;
    var iy = screen.height;
    var ix = screen.width;
    //alert("["+nheight+","+nwidth+"]["+ix+","+iy+"]");
    iy = ((iy-nheight)/2);//+document.body.scrollTop;
    ix = ((ix-nwidth)/2);//+document.body.scrollLeft;
    oDiv.style.left=ix+"px";
    oDiv.style.top=iy+"px";
}

//modifies the action of the named form to include ACT=LIST XPG_MINID=  XPG_MAXID=
//Modified from code that manipulated
//hidden fields that caused problems with Opera7 and select lists
//RRH 16 June 2003
//Opera 7.11 now correctly supports  form handling mods removed
function fnListSubmit(strFormName){
    if (fnCheckFormName(strFormName)) {
        var oForm=document.forms[strFormName];
        /*
        var strAction = oForm.action;
        strAction+=((strAction.indexOf("?") != -1)?"&":"?")+"ACT=LIST";
        strAction+="&XPG_MAXID=";
        strAction+="&XPG_MINID=";
        oForm.action=strAction;
        */
        for(var i=0;i<oForm.length;i++){
            switch (oForm[i].name) {
            case "XPG_MINID":
                oForm[i].value="";
            case "XPG_MAXID":
                oForm[i].value="";
            case "ACT":
                oForm[i].value="";
            }
        }
        oForm.submit();
    }
}

//modifies the action of the named form to include ACT=LIST
//Modified from code that manipulated
//hidden fields that caused problems with Opera7 and select lists
//RRH 16 June 2003
//Opera 7.11 now correctly supports  form handling mods removed

function fnBackToListSubmit(strFormName){
    if (fnCheckFormName(strFormName)) {
        var oForm=document.forms[strFormName];
        /*
        var strAction = oForm.action;
        strAction+=((strAction.indexOf("?") != -1)?"&":"?")+"ACT=LIST";
        oForm.action=strAction;
        */
        oForm.ACT.value = "LIST";
        oForm.submit();
    }
}

//modifies the action of the named form to include ACT=LIST XPG_MINID=  XPG_MAXID=sID
//Modified from code that manipulated
//hidden fields that caused problems with Opera7 and select lists
//RRH 16 June 2003
//Opera 7.11 now correctly supports  form handling mods removed

function fnPageUp(strFormName,sID){
    if (fnCheckFormName(strFormName)) {
        var oForm=document.forms[strFormName];
        /*
        var strAction = oForm.action;
        strAction+=((strAction.indexOf("?") != -1)?"&":"?")+"ACT=LIST";
        strAction+="&XPG_MAXID="+sID;
        strAction+="&XPG_MINID=";
        oForm.action=strAction;
        */
        oForm.ACT.value = "LIST";
        oForm.XPG_MAXID.value = sID;
        oForm.XPG_MINID.value = "";
        oForm.submit();
    }
}

//modifies the action of the named form to include ACT=LIST XPG_MINID=sID  XPG_MAXID=
//Modified from code that manipulated
//hidden fields that caused problems with Opera7 and select lists
//RRH 16 June 2003
//Opera 7.11 now correctly supports  form handling mods removed

function fnPageDown(strFormName,sID){
    if (fnCheckFormName(strFormName)) {
        var oForm=document.forms[strFormName];
        /*
        var strAction = oForm.action;
        strAction+=((strAction.indexOf("?") != -1)?"&":"?")+"ACT=LIST";
        strAction+="&XPG_MINID="+sID;
        strAction+="&XPG_MAXID=";
        oForm.action=strAction;
        */
        oForm.ACT.value = "LIST";
        oForm.XPG_MAXID.value = "";
        oForm.XPG_MINID.value = sID;
        oForm.submit();
    }
}

//modifies the action of the named form to include ACT=DELETE
//Modified from code that manipulated
//hidden fields that caused problems with Opera7 and select lists
//RRH 16 June 2003
//Opera 7.11 now correctly supports  form handling mods removed

function fnDeleteRecord(strFormName){
    if (fnCheckFormName(strFormName)) {
        if (!confirm("Are you sure you want to delete this record")){
            return;
        }
        var oForm=document.forms[strFormName];
        /*
        var strAction = oForm.action;
        strAction+=((strAction.indexOf("?") != -1)?"&":"?")+"ACT=DELETE";
        oForm.action=strAction;
        */
        oForm.ACT.value = "DELETE";
        oForm.submit();
    }
}

//modifies the action of the named form to include ACT=UPDATE
//Modified from code that manipulated
//hidden fields that caused problems with Opera7 and select lists
//RRH 16 June 2003
//Opera 7.11 now correctly supports  form handling mods removed

function fnUpdateRecord(strFormName){
    if (fnCheckFormName(strFormName)) {
        var oForm=document.forms[strFormName];
        /*
        var strAction = oForm.action;
        strAction+=((strAction.indexOf("?") != -1)?"&":"?")+"ACT=UPDATE";
        */

        if (oForm.onsubmit() !=false){
            
            //oForm.action=strAction;
            oForm.ACT.value = "UPDATE";
            oForm.submit();
        }
    }
}

//modifies the action of the named form to include ACT=ADD
//Modified from code that manipulated
//hidden fields that caused problems with Opera7 and select lists
//RRH 16 June 2003
//Opera 7.11 now correctly supports  form handling mods removed

function fnAddRecord(strFormName){
    if (fnCheckFormName(strFormName)) {
        var oForm=document.forms[strFormName];
        /*
        var strAction = oForm.action;
        strAction+=((strAction.indexOf("?") != -1)?"&":"?")+"ACT=ADD";
        oForm.action=strAction;
        */
        oForm.ACT.value = "ADD";
        oForm.submit();
    }
}

//modifies the action of the named form to include name value pairs 
//from the strnames and strval strings. Modified from code that manipulated
//hidden fields that caused problems with Opera7 and select lists

//not changed as other fns re opera7.11

function fnEditSelect(strFormName,strNames,strVals)
{
    var aNameList = fnDelimSplit(strNames);
    var aValList = fnDelimSplit(strVals);
    if (aNameList.length!=aValList.length) {
        alert("Error in Name:Value Arrays");
        return;
    }
    if (fnCheckFormName(strFormName)) {
        var oForm=document.forms[strFormName];
        //var strAction = oForm.action;
        //strAction+=((strAction.indexOf("?") != -1)?"&":"?")+"ACT=EDIT";
        oForm.ACT.value="EDIT";
        for (var err=0;err<aNameList.length;err++)
        {
            if (aNameList[err] != "ACT") {
                //strAction+="&"+aNameList[err]+"="+aValList[err];
                eval('document.' + strFormName + '.'+aNameList[err]+'.value="'+aValList[err]+'";');
            }
            
        }
        //oForm.action=strAction;
        oForm.submit();
    }
}
//Splits a string on a comma (after removing trailing comma)
//and returns the split string as an array
function fnDelimSplit(strVal){
    if (strVal.lastIndexOf(",") == strVal.length-1) {
        strVal = strVal.substring(0,strVal.length-1); 
    }
    return strVal.split(",");
}
//checks for the existance of named form on the page
function fnCheckFormName(strFormName){
    if (typeof document.forms[strFormName] == "undefined") {
        alert("["+strFormName+"] is not a valid form");
        return false;
    }
    return true;
}


function displayWindow(theURL,winName,width,height,features) { //v3.1
    var window_width = width;
    var window_height = height;
    var newfeatures= features;
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
    //alert('"width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',' + newfeatures + '"');
    newWindow=window.open(theURL,winName,'width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',' + newfeatures,false);
    newWindow.focus();
}

function fnPop800(strURL){
    displayWindow(strURL,'pop800','760','570','scrollbars=yes,resizable=yes'); 
}

var gobjLastDiv = null;
//show property debug div
function fnShowdiv(sdiv)
{
    if (gobjLastDiv != null) {
        //alert(gobjLastDiv.id);
        gobjLastDiv.style.display = "none";
        gobjLastDiv = null;

    } 
    /*
    else {
        alert("null");
    }
    */

    var odiv;
    odiv = document.getElementById(sdiv);
    gobjLastDiv = odiv;
    if (odiv.style.display == "none") {
        odiv.style.display = "";
    } else {
        odiv.style.display = "none";
    }  
}

function fnUrlPopUpWin(strURL)
{
    displayWindow(strURL,'','760','500','scrollbars=yes,resizable=yes');
    
}

function fnSetMSHChanged()
{
    var field = document.forms[0];
    var i;
    for (i = 0; i < field.length; i++)
    {
        document.forms[0].elements[i].onchange=fnMSHchanged;
    }
}
function fnMSHchanged(){
document.changedwarn.src = "/rkDom/unsaved.gif";
}


function fnXPageNo(strFormName,selObj){
    if (fnCheckFormName(strFormName)) {
        var oForm=document.forms[strFormName];
        oForm.ACT.value = "LIST";
        oForm.XPAGENO.value = selObj.options[selObj.selectedIndex].value;
        oForm.submit();
    }
}

function fnXPageSize(strFormName,selObj){
    if (fnCheckFormName(strFormName)) {
        var oForm=document.forms[strFormName];
        oForm.ACT.value = "LIST";
        oForm.XPAGENO.value = "1";
        oForm.XPAGESIZE.value = selObj.options[selObj.selectedIndex].value;
        oForm.submit();
    }
}

function fnXPageLink(strFormName,nPage){
    if (fnCheckFormName(strFormName)) {
        var oForm=document.forms[strFormName];
        oForm.ACT.value = "LIST";
        oForm.XPAGENO.value = nPage;
        oForm.submit();
    }
}










