<!-- Include in your html <script LANGUAGE="JavaScript" src="js\misc.js"></script> -->

var isNav;

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_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_findObj(n, d) { //v3.0
  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); 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 loadPage(sPageToLoad, sAction)  {        
        window.document.main.target = '_top'
        window.document.main.h_action.value = sAction;
        window.document.main.action = sPageToLoad;
        window.document.main.submit();
}

function logout() {
	var oCookie = new Cookie(document, 'SESSION','','/');
        oCookie.load();
        oCookie.SESSION_ID = -1;
        oCookie.store();
        
        window.document.main.target = '_top'
	window.document.main.action = '/member.asp'
	window.document.main.submit()
}

function sessioncheck() {
	var oCookie = new Cookie(document, 'SESSION','','/');
	var oCookieInst = new Cookie(document, 'INST','','/');

	oCookie.load();
	oCookieInst.load();

                
	if ( oCookie.SESSION_ID == -1) {
		window.document.main.action = '/member.asp'
		window.document.main.submit()
	} else {
		if (oCookieInst.InstanceCount >= 1) {
			window.location = '/Loaded.asp';
		}
                oCookieInst.InstanceCount = parseInt(oCookieInst.InstanceCount) + 1;
                oCookieInst.store();
        }
}

function removeInstance() {
	var oCookie = new Cookie(document, 'INST','','/');
	oCookie.load();        
        oCookie.InstanceCount = parseInt(oCookie.InstanceCount) - 1;
        oCookie.store();        
}

function checkForSave(sPageToLoad)  {
	if ( window.document.main.h_dirty.value == 1 ) {
		if ( window.confirm('Document has been modified would you like to save it now?\n\n   (Press OK to save the document\n   Press Cancel to not save and go to the new page)\n') ) {
                        formSave('SAVE');
        	} else {
	        	loadPage(sPageToLoad);						
                }	
	} else {
		loadPage(sPageToLoad);						
	}
}

function loadHelp()  {
        var HelpWin;
        var sName, sUrl;
        if (window.document.main.h_help == null) {
                sUrl = 'help/help_idx.htm';                
        } else  {
                sUrl = window.document.main.h_help.value;
        }
        sName = 'HELP';
	HelpWin = window.open(sUrl,sName,"toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,resizable=yes,width=500,height=400");
        HelpWin.focus();
}


isNav = false;
if (parseInt(navigator.appVersion) >= 4) {
        if (navigator.appName == "Netscape") {
                isNav = true;
        }        
}

function setEvents() {
        if ( isNav ) {
                document.captureEvents(Event.CHANGE);
                document.captureEvents(Event.CLICK);
        } else {
                document.onkeypress = docModified;
        }
        document.onchange = docModified;
        document.onclick = docModified;
}        
function jf_check(rbname, rbvalue)
{
	var i;
	for (i = 0; i < window.document.main.elements.length; i++) {
		if (window.document.main.elements[i].name == rbname) {
			if (window.document.main.elements[i].value == rbvalue) {
				window.document.main.elements[i].click();
				break;
			}
		}
	}
}
function checkComplete() {
	if (parent.frames[1].document != null) {
		if (parent.frames[1].document.main != null) {
			if (parent.frames[1].document.main.h_complete != null) {
				if (parent.frames[1].document.main.h_complete.value == "True") {
					window.document.main.NEXTPAGE.value = "logon.asp"
					window.document.main.DIRECTION.value = "PREV"
					window.document.main.action = "logon.asp"					
					window.document.main.target = "_top"					
					window.document.main.submit();
				}
			}
		}
	}
	return 0;
}
function docModified(evt) {                
        var sType, sEventType;
        var bModified=false;
        if (isNav) {                
                sType = evt.target.type;      
                sEventType = evt.type;
        } else {
                sType = window.event.srcElement.type;      
                sEventType = window.event.type;
        }
        
        if (sEventType == 'click') {
                if (sType == 'select-one') {
                        bModified = true;
                } else if (sType == 'checkbox') {
                        bModified = true;
                }
        } else {
                // This event is either the onChange for NN or the KeyPress for IE
                if (sType) {
                        bModified = true;
                }
        }
        
        if ( bModified ) {
                window.document.forms[0].h_dirty.value = 1;
        }
        if (isNav) {
                document.routeEvent(evt);
        }        
}

function arraydata(parentid, childid, childname, childtype)
{
  this.parentid = parentid;
  this.childid = childid;
  this.childname = childname;
  this.childtype = childtype;
}

function jf_loadChildList(parentlist, childlist, childtype, childselected)
{
   var idx;
   var ret;

   if (parentlist.options.length == 0) {
        childlist.options.length = 0;
   } else {
           if (parentlist.options[parentlist.selectedIndex].value < 0) {
               childlist.options.length = 0;           
               ret = false;
           } else {
               idx = 2;
               childlist.options.length = 0;
               childlist.options[0] = new Option('Please Select An Item','-4');
               childlist.options[1] = new Option('------------------------------------','-1');
               for (var i = 0; i < mainidx; i++) {
                   if (mainlist[i].childtype == childtype) {
                      if (mainlist[i].parentid == parentlist.options[parentlist.selectedIndex].value) {
                          childlist.options[idx] = new Option(mainlist[i].childname, mainlist[i].childid);
                          if (mainlist[i].childid == childselected) {
                                childlist.options[idx].selected = true;
                          }
                          idx = idx + 1;
                      }
                   }
               }
               ret = true;
           }
   }

   return ret;
}

function jf_open()
{
        var features;
        
        features = 'toolbar=no,location=no,left=' + (screen.width - 600) / 2 + ',top=' + (screen.height - 400) / 2 + ',height=400,width=600'
        window.open('webwizard.pl','Open',features);
}

function jf_notavailable()
{
        window.alert("This function is not available in this version");
}

function jf_webadmin()
{
        loadPage('webeditpage','wpages');
}

function jf_newweb()
{
        var features;
        
        features = 'toolbar=no,location=no,left=' + (screen.width - 600) / 2 + ',top=' + (screen.height - 400) / 2 + ',height=400,width=600'
        window.open('newweb.pl','New',features);
}

function jf_generateweb()
{
        var features;
        
        features = 'toolbar=no,location=no,left=' + (screen.width - 700) / 2 + ',top=' + (screen.height - 400) / 2 + ',height=400,width=700'
        window.open('pagegenerator.pl?h_action=gen1','WebGenerator',features);
}

function jf_saveas()
{
        var features;
        
        features = 'toolbar=no,location=no,left=' + (screen.width - 600) / 2 + ',top=' + (screen.height - 400) / 2 + ',height=400,width=600'
        window.open('saveas.pl','saveas',features);
}

function jf_webdrilldown()
{
        var features;
        
        features = 'dialogWidth=40';
        window.showModalDialog('webdrilldown.pl','WebDrillDown',features);
}

function jf_generatetable()
{
        var features;
        
        features = 'toolbar=no,location=no,left=' + (screen.width - 600) / 2 + ',top=' + (screen.height - 400) / 2 + ',height=400,width=600'
        window.open('tablegenerator.pl?h_action=gen1','TableGenerator',features);
}

function jf_fieldhelp(afield)
{
        var features;
        var openurl = '/pfradmin/securecgi/help/parameters.asp?#' + afield
        
        features = 'toolbar=no,scrollbars=yes,location=no,left=' + (screen.width - 600) / 2 + ',top=' + (screen.height - 400) / 2 + ',height=400,width=600'
        window.open(openurl,'FieldHelp',features);
}


