// Size of horizontal indent per level
var indentPixels = 20

// Image files and thier width and height
var collapsedWidget = "../images/COMON0200plus.JPG"
var expandedWidget = "../images/COMON0200minus.JPG"
var endpointWidget = "../images/COMON0200end.gif"
var widgetWidth = 14
var widgetHeight = 14
// Target frame in which details are displayed on click of menu item
var displayTarget = "frData"

// Array object containing menu content and attributes
// The order of the five parameters :
// 	1. Boolean (true or false) to indicate whether next submenu item is indented or not
//	2. String to display as Menu name
//	3. URL of the link for menu item. Use empty string for no link
//	4. Integer of indentation level(0 is leftmost margin level)
//	5. String for status line onMouseOver
// Change these entries as per your need
var db = new Array()
var i=0

// Privacy Menu
//i+=1; db[i] = new dbRecord(false,"Privacy<br>","../COMON0230Privacy.asp",0,"","#ffffff")
 	
// About Us Menu
//i+=1; db[i] = new dbRecord(false,"About Us<br>","../COMON0210About.asp",0,"","#ffffff")
 
// Disclaimer
//i+=1; db[i] = new dbRecord(false,"Disclaimer<br>","../COMON0220Disclaimer.asp",0,"","#ffffff")

// Registration
i+=1; db[i] = new dbRecord(true,"<strong><font color=white size=2>Registration</font><br></strong>","",0,"","#ffffff")
	i+=1; db[i] = new dbRecord(false,"Member<br>","https://www.panhealth.com/member/MEMBR0200Registration.asp",1,"","#ffffff")
	i+=1; db[i] = new dbRecord(false,"Physicians<br>","https://www.panhealth.com/ADMIN/Admin1500RegNonCredPhy.asp",1,"","#ffffff")
//	i+=1; db[i] = new dbRecord(false,"Practice<br>","https://www.panhealth.com/DvOff/DvOff0300login.asp?hdnregntype=G",1,"","#ffffff")
	i+=1; db[i] = new dbRecord(false,"Pharmacy<br>","https://www.panhealth.com/DvOff/DvOff0300login.asp?hdnregntype=P",1,"","#ffffff")
				
// Login Menu
i+=1; db[i] = new dbRecord(false,"Login<br>","https://www.panhealth.com/member/MEMBR0300Login.asp",0,"","#ffffff")
i+=1; db[i] = new dbRecord(false,"Practice Login<br>","https://www.panhealth.com/member/MEMBR0300Login.asp?hdnPractice=Y",0,"","#ffffff")

// Object constructor for each menu/submenu item
function dbRecord(mother,display,URL,indent,statusMsg,target) {
    this.mother = mother	// is this item a parent?
    this.display = display	// text to display
    this.URL = URL		// link tied to text
    this.indent = indent	// how deeply nested?
    this.statusMsg = statusMsg	// descriptive text for status bar
    this.target = target        // the target frame to open the documents
    return this
}

// pre-load all images into cache
var fillerImg = new Image(1,1)
fillerImg.src = ""
var collapsedImg = new Image(widgetWidth,widgetHeight)
collapsedImg.src = collapsedWidget
var expandedImg = new Image(widgetWidth,widgetHeight)
expandedImg.src = expandedWidget
var endpointImg = new Image(widgetWidth,widgetHeight)
endpointImg.src = endpointWidget

// set cookie data
function setCurrState(setting) {
    document.cookie = "currState=" + escape(setting)
}

// get cookie data
function getCurrState() {
    var label = "currState="
    var labelLen = label.length
    var cLen = document.cookie.length
    var i = 0
    while(i < cLen) {
	var j = i + labelLen
	if(document.cookie.substring(i,j) == label) {
	    var cEnd = document.cookie.indexOf(";",j)
	    if(cEnd == -1) {
		cEnd = document.cookie.length
	    }
	    return unescape(document.cookie.substring(j,cEnd))
	}
	i++
    }
    return ""
}

// Toggles an menu outline mother entry, storing new value in the cookie
function toggle(n) {
    if(n != 0) {
	var newString = ""
	var currState = getCurrState()		// of whole outline
	var expanded = currState.charAt(n-1)	// of clicked item
	newString += currState.substring(0,n-1)
	newString += expanded ^ 1		// Bitwise XOR clicked item
	newString += currState.substring(n,currState.length)
	setCurrState(newString)			// Write new state back to cookie
    }
}

// Returns the proper JPG file name for each entry's control
function getJPG(n) {
    var mom = db[n].mother	// is entry a parent?
    var expanded = getCurrState().charAt(n-1)	// of clicked item
    if(!mom) {
	return endpointWidget
    } else {
	if(expanded == 1) {
	    return expandedWidget
	}
    }
    return collapsedWidget
}

// returns the proper status line text based on the icon style
function getJPGStatus(n) {
    var mom = db[n].mother
    var expanded = getCurrState().charAt(n-1)
    if(!mom) {
 	return "No further items"
    } else {
	if(expanded == 1) {
	    return "Click to collapse nested items"
	}
    }
    return "Click to expand nested items"
}

// initialize 'current state' storage field
if(getCurrState() == "" || getCurrState().length != (db.length -1)) {
    initState = ""
    for(i = 1;i < db.length; i++) {
	initState += "0"
    }

    setCurrState(initState)
}

