/*
    File: ticl.js
    This file is part of the TICL library and is governed by the TICL
    distribution license. For more information, please visit
    http://www.kobrix.com.
    Copyright (c) 2001-2002 by Kobrix Software Inc. All rights reserved.
*/
var navigator4 = false;
var domobject_range = "";
createDropDown();
createListBox();
//
// Most browser will react to a re-submit of a form while one is being
// submitted. All our form submits go through the postform method below.
// The following global variable track whether a form is currently being
// submitted to prevent a user from submitting it twice before the response
// has been returned.
//
var ticl_submitting_form0123456789 = false;
var TICLTrees = new Array()

if (navigator.appName == "Netscape")
{
   navigator4 = true;
}
else
{
    domobject_range="all.";
}

function changeBox(form,cbox)
{
    if( document.layers ){
        var box = document.forms[form].elements[cbox];
        box.checked = !box.checked;
    }
    else{
        var box = document.getElementById(cbox);
        box.checked = !box.checked;
    }
}



function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		menu2_01 = newImage("images/menu2_01.gif");
		menu2_02 = newImage("images/menu2_02.gif");
		menu2_03 = newImage("images/menu2_03.gif");
		menu2_04 = newImage("images/menu2_04.gif");
		menu2_05 = newImage("images/menu2_05.gif");
		menu2_01_over = newImage("images/menu2_01-over.gif");
		menu2_02_over = newImage("images/menu2_02-over.gif");
		menu2_03_over = newImage("images/menu2_03-over.gif");
		menu2_04_over = newImage("images/menu2_04-over.gif");
		menu2_05_over = newImage("images/menu2_05-over.gif");
		preloadFlag = true;
	}
}





function changeRadio(form,group,item)
{
    if( document.layers ){
        var el = document.forms[form].elements[group];
        for( i = 0 ; i < el.length ; i++ ){
            if ( el[i].value == item )
                el[i].checked = true;
        }

    }
    else{
        for( i = 0 ; i < document.forms[form].elements.length ; i++ ){
            var el = document.forms[form].elements[i];
            if ( el == document.getElementById(item) )
                el.checked = true;
        }
    }
}

function noop()
{
    return;
}

function getObject(obj)
{
    if (typeof obj == "string")
        return eval("document." + domobject_range + obj);
    else
        return obj;
}


// create dropdown table to hold value of dropitem and ticlcmd
function createDropDown()
{
    this.dropitem = new dropItemS('', '', '', '', '', '');
    this.numDropItems = 0;
}

// add dropitem to dropdown table
function addDropItem(dropdownID, valueDropItem, ticlcmd, redirect_url, post, data)
{
    this.dropitem[this.numDropItems] = new dropItemS(dropdownID,
                                                     valueDropItem,
                                                     ticlcmd,
                                                     redirect_url,
                                                     post,
                                                     data);
    this.numDropItems++;
}

// dropitem structure
function dropItemS(dropdown_id, value, ticlcmd, url, post, data)
{
    this.id = dropdown_id;
    this.value = value;
    this.ticlcmd = ticlcmd;
    this.url = url;
    this.post = post;
    this.data = data;
}

// show dropdown table for debug purpose
function dropdown()
{
    alert("number:"+numDropItems);
    for (i=0; i < numDropItems; i++)
    {
        alert(dropitem[i].value + ":" + dropitem[i].ticlcmd);
    }
}

//get dropitem or listitem by data
function getOptionItemByData(item_id, data)
{
    for (i=0; i < numDropItems; i++)
    {
        if ((dropitem[i].id == item_id) &&
            (dropitem[i].data == data))
        {
            return dropitem[i];
        }
    }
    for (i=0; i < numListItems; i++)
    {
        if ((listitem[i].id == item_id) &&
            (listitem[i].data == data))
        {
            return listitem[i];
        }
    }
    return null;
}

/** */
function getOptionItemByIndex(ddId, index)
{
    for (i=0; i < numDropItems; i++)
    {
        if ((dropitem[i].id == ddId) &&
            (dropitem[i].value == index + 1))
        {
            return dropitem[i];
        }
    }
    for (i=0; i < numListItems; i++)
    {
        if ((listitem[i].id == ddId) &&
            (listitem[i].value == index + 1))
        {
            return listitem[i];
        }
    }
    return null;
}


function checkDropDown(formid, value, dropdown_id)
{
    var ticlcmd = "";
    var url = "";
    var post = false;
    for (i=0; i < numDropItems; i++)
    {
        if ((dropitem[i].id == dropdown_id) &&
            (dropitem[i].value == value))
        {
            ticlcmd = dropitem[i].ticlcmd;
            url = dropitem[i].url;
            post = dropitem[i].post;
        }
    }
    if (post == "true")
    {
        postform(formid, ticlcmd);
    }
    else
    {
        if (url != "") // we have client side redirect
            window.document.location.href=url;
        else
            if (ticlcmd != "")
                window.document.location.href=ticlcmd;
    }
}


//*********************************************
// create listbox table to hold value of listitem and ticlcmd
function createListBox()
{
    this.listitem = new listItemS('', '', '', '', '');
    this.numListItems = 0;
}

// add listitem to listbox table
function addListItem(listboxID, valueListItem, ticlcmd, redirect_url, post, data)
{
    this.listitem[this.numListItems] = new listItemS(listboxID,
                                                     valueListItem,
                                                     ticlcmd,
                                                     redirect_url,
                                                     post,
                                                     data);
    this.numListItems++;
}

// listitem structure
function listItemS(listbox_id, value, ticlcmd, url, post, data)
{
    this.id = listbox_id;
    this.value = value;
    this.ticlcmd = ticlcmd;
    this.url = url;
    this.post = post;
    this.data = data;
}

// show listbox table for debug purpose
function listbox()
{
    alert("number:"+numListItems);
    for (i=0; i < numListItems; i++)
    {
        alert(listitem[i].value + ":" + listitem[i].ticlcmd);
    }
}

function checkListBox(formid, value, listbox_id)
{
    var ticlcmd = "";
    var url = "";
    var post = false;
    for (i=0; i < numListItems; i++)
    {
        if ((listitem[i].id == listbox_id) &&
            (listitem[i].value == value))
        {
            ticlcmd = listitem[i].ticlcmd;
            url = listitem[i].url;
            post = listitem[i].post;
        }
    }
    if (post == "true")
    {
        postform(formid, ticlcmd);
    }
    else
    {
        if (url != "") // we have client side redirect
            window.document.location.href=url;
        else
            if (ticlcmd != "")
                window.document.location.href=ticlcmd;
    }
}
// ***********************************************************


function postform(formid, value)
{
    if (TICLValidate() == false)
    {
        return false;
    }

    var form = getObject(formid);
    if (navigator.userAgent.indexOf('Opera') >= 0 )
        form = eval('document.'+formid);
    if (ticl_submitting_form0123456789 == true)
    {
        return false;
    }
    ticl_submitting_form0123456789 = true;
    form.elements["ticlcmd"].value = value;
    form.submit();
    // Return false in case this was triggered by a submit button, so that the
    // does not end up being submitted twice.
    return false;
}


function treeItemAddChild (idnum, type)
{
    this.children[this.numChildren] = new TreeItemChild(idnum, type)
    this.numChildren++
}

function TreeItemChild (idnum, type)
{
    this.idnum = idnum
    this.type = type
}

function treeItemAddIndent (indent)
{
    this.indents[this.numIndents] = new TreeItemIndent(indent)
    this.numIndents++
}

function TreeItemIndent (indent)
{
    this.indent = indent
}

function TreeItem (parent, idnum, type, contents, selcontents, curimage, toggleimage, expandByCapt, status)
{
    this.parent = parent
    this.idnum = idnum
    this.type = type
    this.contents = contents
    this.selcontents = selcontents
    this.curimage = curimage
    this.toggleimage = toggleimage
    this. expandByCapt = expandByCapt
    this.status = status
    this.visible = 'hidden'
    this.numChildren = 0
    this.children = new TreeItemChild(-1, '')
    this.addChild = treeItemAddChild
    this.numIndents = 0
    this.indents = new TreeItemIndent('')
    this.addIndent = treeItemAddIndent
}

function addTreeItem (parent, idnum, type, contents, selcontents, curimage, toggleimage, expandByCapt, status)
{
    this.items[this.itemsCount] = new TreeItem(parent, idnum, type, contents, selcontents, curimage, toggleimage, expandByCapt, status)
    this.itemsCount++
    if(parent != '-1' )
        for( i = 0 ; i < this.itemsCount ; i++)
            if ( this.items[i].idnum == parent )
            {
                this.items[i].addChild(idnum,type)
                break
            }
}

function TreeView (treename, lineHeight)
{
    this.name = treename
    this.itemsCount = 0
    this.numScrollSteps = 0
    this.items = new TreeItem(-1, 0, '', '', '', '', '')
    this.addItem = addTreeItem
    this.render = renderTree
    this.refresh = refreshTree
    this.rearange = rearangeTree
    this.subrefresh = refreshSubTree
    this.noderefresh = refreshNode
    this.getItemByIdnum = getItemByIdNumber
    this.scrollwin = scrollWindow
    this.changePic = changePicture
    this.lineHeight = lineHeight
    this.selected = ''
}

function renderTree (linePic, PicWidth, PicHeight, spacePic,
                     spacePicWidth, spacePicHeight)
{
    if ( !myBrowser.canDoDOM )
        document.writeln("<ILAYER ID='tree_" + this.name + "' HEIGHT=" + (this.itemsCount + 1)*this.lineHeight + ">")
    else if ( myBrowser.name == "Opera" )
        document.writeln("<DIV ID=tree_" + this.name + " STYLE={visibility:visible;height:" + (this.itemsCount + 1) * this.lineHeight + "}>")

    for ( i2 = 0 ; i2 < this.itemsCount ; i2++ )
    {
        var section = this.name + '_section'+i2
        var cont = this.items[i2].contents
        var selcont = this.items[i2].selcontents
        var curim = this.items[i2].curimage
        var idn = this.items[i2].idnum
        var stat = this.items[i2].status
        var name = this.name
        if ( myBrowser.canDoDOM )
            document.writeln("<DIV ID=" + section + " STYLE={position:relative; visibility:visible}>")
        else
            document.writeln("<LAYER ID=" + section + " visibility='hide'>")
        document.writeln("<table cellspacing=0 cellpadding=0 border=0>")
        document.writeln("<tr>")
        for( i22 = 0; i22 < this.items[i2].numIndents ; i22++)
        {
            var nextind = this.items[i2].indents[i22].indent
            if (nextind=='line'){
               if (linePic != null)
                  document.writeln("<td nowrap><img src='" + linePic + "' border=0 width=" + PicWidth + " height=" + PicHeight + "></td>")
            }
            else{
               if (spacePic != null)
                  document.writeln("<td nowrap><img src='" + spacePic + "' border=0 width=" + PicWidth + " height=" + PicHeight + "></td>")
            }
        }
        var imgid =  name + "togglePic"+i2
        if (this.items[i2].type == 'node')
        {
            document.writeln("<td nowrap><a href='#' onClick='"+name+".changePic("+i2+",&#39;"+imgid+"&#39;);"+name+".items["+i2+"].status=changeStatus("+name+".items["+i2+"].status);"+name+".noderefresh(&#39;"+idn+"&#39;,"+name+".items["+i2+"].status);"+name+".rearange("+name+".itemsCount+1);return "+name+".scrollwin("+i2+")'><img src='" + curim + "' name='" +imgid +"' border=0 width="
                    + PicWidth + " height=" + PicHeight + "></a></td>")
            if (this.items[i2].expandByCapt == 'true' &&
                  cont.indexOf('ticlstate=') <0 &&
                  cont.indexOf('hasSelectionTreeView') <0 &&
                  cont.indexOf('href="#"') <0 ){
                document.writeln("<td nowrap><a href='#' onClick='"+name+".changePic("+i2+",&#39;"+imgid+"&#39;);"+name+".items["+i2+"].status=changeStatus("+name+".items["+i2+"].status);"+name+".noderefresh(&#39;"+idn+"&#39;,"+name+".items["+i2+"].status);"+name+".rearange("+name+".itemsCount+1);return "+name+".scrollwin("+i2+")'>"+ cont + "</a></td>")
            }
            else if ( selcont != 'null' ){
                if ( myBrowser.canDoDOM ){
                    if ( myBrowser.name == "InternetExplorer" ){
                        document.write("<td nowrap onClick=selectNode('" + this.name + "','" + section + "')><DIV ID=" + section + "_NORM STYLE={display:inline}>")
                        document.write(cont + "</DIV>")
                        document.write("<DIV ID=" + section + "_SEL STYLE={display:none}>")
                        document.write(selcont + "</DIV>")
                        document.writeln("</td>")
                    }
                    else if ( myBrowser.name == "Opera" ){
                        document.write("<td nowrap onClick=selectNode('" + this.name + "','" + section + "')>")
                        document.write("<DIV ID=" + section + "_BASE STYLE={POSITION:relative;visibility:VISIBLE;offsetTop:0}>")
                        document.write("<DIV ID=" + section + "_NORM STYLE={POSITION:relative;visibility:hidden;offsetTop:0}>")
                        document.write(cont + "</DIV>")
                        document.write("<DIV ID=" + section + "_SEL STYLE={POSITION:absolute;visibility:hidden;top:0}>")
                        document.write(selcont + "</DIV></DIV>")
                        document.writeln("</td>")
                    }
                    else{
                        var cont1 = cont
                        if ( cont.indexOf("javascript:") >= 0 ){
                            cont1 = cont.substring(0,cont.indexOf("javascript:") + 11)
                            cont1 = cont1 + 'selectNode(&#39;' + this.name + '&#39;,&#39;' + section + '&#39;);'
                            cont1 = cont1 + cont.substring(cont.indexOf("javascript:") + 11, cont.length)
                        }
                        document.write("<td nowrap>")
                        document.write("<DIV ID=" + section + "_NORM STYLE={position:relative;visibility:inherit}>")
                        document.write(cont1 + "</DIV>")
                        document.write("<DIV ID=" + section + "_SEL STYLE={position:absolute;visibility:hidden}>")
                        document.write(selcont + "</DIV>")
                        document.writeln("</td>")
                    }
                }
                else{
                    var cont1 = cont
                    if ( cont.indexOf("javascript:") >= 0 ){
                        cont1 = cont.substring(0,cont.indexOf("javascript:") + 11)
                        cont1 = cont1 + 'selectNode(&#39;' + this.name + '&#39;,&#39;' + section + '&#39;);'
                        cont1 = cont1 + cont.substring(cont.indexOf("javascript:") + 11, cont.length)
                    }
                    document.write("<td nowrap><ILAYER ID=" + section + "_OUT>")
                    document.write("<LAYER ID=" + section + "_NORM visibility='show'>" + cont1 + "</LAYER>")
                    document.write("<LAYER ID=" + section + "_SEL visibility='hide'>")
                    document.write(selcont + "</LAYER>")
                    document.writeln("</ILAYER></td>")
                }
            }
            else
                document.write("<td nowrap>" + cont + "</td>")
        }
        else
        {
            document.write("<td nowrap><img src='" + curim + "' border=0 width="
                    + PicWidth + " height=" + PicHeight + "></td>")
            if ( selcont != 'null' ){
                if ( myBrowser.canDoDOM ){
                    if ( myBrowser.name == "InternetExplorer" ){
                        document.write("<td nowrap onClick=selectNode('" + this.name + "','" + section + "')>")
                        document.write("<DIV ID=" + section + "_NORM STYLE={display:inline}>")
                        document.write(cont + "</DIV>")
                        document.write("<DIV ID=" + section + "_SEL STYLE={display:none}>")
                        document.write(selcont + "</DIV>")
                        document.writeln("</td>")
                    }
                    else if ( myBrowser.name == "Opera" ){
                        document.write("<td nowrap onClick=selectNode('" + this.name + "','" + section + "')>")
                        document.write("<DIV ID=" + section + "_BASE STYLE={POSITION:relative;visibility:VISIBLE;offsetTop:0}>")
                        document.write("<DIV ID=" + section + "_NORM STYLE={POSITION:relative;visibility:hidden;offsetTop:0}>")
                        document.write(cont + "</DIV>")
                        document.write("<DIV ID=" + section + "_SEL STYLE={POSITION:absolute;visibility:hidden;top:0}>")
                        document.write(selcont + "</DIV></DIV>")
                        document.writeln("</td>")
                    }
                    else{
                        var cont1 = cont
                        if ( cont.indexOf("javascript:") >= 0 ){
                            cont1 = cont.substring(0,cont.indexOf("javascript:") + 11)
                            cont1 = cont1 + 'selectNode(&#39;' + this.name + '&#39;,&#39;' + section + '&#39;);'
                            cont1 = cont1 + cont.substring(cont.indexOf("javascript:") + 11, cont.length)
                        }
                        document.write("<td nowrap>")
                        document.write("<DIV ID=" + section + "_NORM STYLE={position:relative;visibility:inherit}>")
                        document.write(cont1 + "</DIV>")
                        document.write("<DIV ID=" + section + "_SEL STYLE={position:absolute;visibility:hidden}>")
                        document.write(selcont + "</DIV>")
                        document.writeln("</td>")
                    }
                }
                else{
                    var cont1 = cont
                    if ( cont.indexOf("javascript:") >= 0 ){
                        cont1 = cont.substring(0,cont.indexOf("javascript:") + 11)
                        cont1 = cont1 + 'selectNode(&#39;' + this.name + '&#39;,&#39;' + section + '&#39;);'
                        cont1 = cont1 + cont.substring(cont.indexOf("javascript:") + 11, cont.length)
                    }
                    document.write("<td nowrap><ILAYER ID=" + section + "_OUT>")
                    document.write("<LAYER ID=" + section + "_NORM visibility='show'>" + cont1 + "</LAYER>")
                    document.write("<LAYER ID=" + section + "_SEL visibility='hide'>")
                    document.write(selcont + "</LAYER>")
                    document.writeln("</ILAYER></td>")
                }
            }
            else{
                document.writeln("<td nowrap>" + cont + "</td>");
            }
        }
        document.writeln("</tr>")
        if ( myBrowser.canDoDOM )
            document.writeln("</table></DIV>")
        else
            document.writeln("</table></LAYER>")
    }
    if ( !myBrowser.canDoDOM )
        document.writeln("</ILAYER>")
    else if ( myBrowser.name == "Opera" )
        document.writeln("</DIV>")
}

function selectNode(name,section){
    if ( myBrowser.canDoDOM )
    {
        if ( myBrowser.name == "InternetExplorer" ){
            eval('document.getElementById("' + section + '_NORM").style').display='none'
            eval('document.getElementById("' + section + '_SEL").style').display='inline'
            if ( document.getElementById(this.selected) && this.selected != section ){
                eval('document.getElementById("' + this.selected + '_NORM").style').display='inline'
                eval('document.getElementById("' + this.selected + '_SEL").style').display='none'
            }
            this.selected = section
        }
        else if ( myBrowser.name == "Opera" )
        {
            eval('document.getElementById("' + section + '_NORM").style').visibility='hidden'
            eval('document.getElementById("' + section + '_SEL").style').visibility='inherit'
            if ( document.getElementById(this.selected) && this.selected != section ){
                eval('document.getElementById("' + this.selected + '_NORM").style').visibility='inherit'
                eval('document.getElementById("' + this.selected + '_SEL").style').visibility='hidden'
            }
            this.selected = section
        }
        else
        {
            eval('document.getElementById("' + section + '_NORM").style').position='absolute'
            eval('document.getElementById("' + section + '_NORM").style').visibility='hidden'
            eval('document.getElementById("' + section + '_SEL").style').position='relative'
            eval('document.getElementById("' + section + '_SEL").style').visibility='inherit'
            if ( document.getElementById(this.selected) && this.selected != section ){
                eval('document.getElementById("' + this.selected + '_NORM").style').position='relative'
                eval('document.getElementById("' + this.selected + '_NORM").style').visibility='inherit'
                eval('document.getElementById("' + this.selected + '_SEL").style').position='absolute'
                eval('document.getElementById("' + this.selected + '_SEL").style').visibility='hidden'
            }
            this.selected = section
        }
    }
    else
    {
        var selsec = eval( name )
        eval('document.tree_' + name + '.layers["' + section + '"]').layers[0].layers[1].visibility='show'
        eval('document.tree_' + name + '.layers["' + section + '"]').layers[0].layers[0].visibility='hide'
        if ( selsec.selected != '' && selsec.selected != section ){
            eval('document.tree_' + name + '.layers["' + selsec.selected + '"]').layers[0].layers[1].visibility='hide'
            eval('document.tree_' + name + '.layers["' + selsec.selected + '"]').layers[0].layers[0].visibility='show'
        }
        selsec.selected = section
    }
}

function rearangeTree(visitems)
{
    var lineHeight = this.lineHeight
    var hidpos = (visitems)*lineHeight
    var lineNumber = 0

    for ( i1 = 0 ; i1 < this.itemsCount ; i1++ )
    {
        var section = this.name + '_section'+i1
        if (this.items[i1].visible == 'visible')
        {
            lineNumber ++
            if ( myBrowser.canDoDOM )
            {
                if ( myBrowser.name == "InternetExplorer" ){
                    eval('document.getElementById("' + section + '").style').display='inline'
                }
                else if ( myBrowser.name == "Opera" )
                {
                    document.getElementById(section).style.visibility = 'visible'
                    if ( eval('document.getElementById("' + section + '_NORM")') ){
                        eval('document.getElementById("' + section + '_NORM").style').visibility='inherit'
                    }
                    document.getElementById(section).style.top=(lineNumber)*lineHeight
                }
                else
                {
                    eval('document.getElementById("' + section + '").style').position='relative'
                    eval('document.getElementById("' + section + '").style').visibility='visible'
                }
            }
            else
            {
                eval('document.tree_' + this.name + '.layers["' + section + '"]').top=(lineNumber)*lineHeight
                eval('document.tree_' + this.name + '.layers["' + section + '"]').visibility='show'
            }
        }
        else
        {
            if ( myBrowser.canDoDOM )
            {
                if ( myBrowser.name == "InternetExplorer" ){
                    eval('document.getElementById("' + section + '").style').display='none'
                }
                else if ( myBrowser.name == "Opera" )
                {
                    document.getElementById(section).style.visibility = 'hidden'
                    document.getElementById(section).style.top=hidpos
                }
                else
                {
                    eval('document.getElementById("' + section + '").style').position='absolute'
                    eval('document.getElementById("' + section + '").style').visibility='hidden'
                }
            }
            else
            {
                eval('document.tree_' + this.name + '.layers["' + section + '"]').top=hidpos
                eval('document.tree_' + this.name + '.layers["' + section + '"]').visibility='hide'
            }
        }
    }
}



function getItemByIdNumber (number)
{
    for ( i3 = 0 ; i3 < this.itemsCount ; i3++ )
        if ( this.items[i3].idnum == number )
            return eval(this.items[i3])
}


function refreshSubTree ( num, stat )
{
    var thisItem = this.getItemByIdnum(num)
    thisItem.visible = (stat == 'true')?'visible':'hidden'
    if ( thisItem.visible == 'visible')
        this.numScrollSteps++
    if ( thisItem.numChildren > 0 ){
        var nextstate = (stat == 'true') ? thisItem.status : 'false'
        for ( i4 = 0 ; i4 < thisItem.numChildren ; i4++ )
        {
            var memo = i4
            var thisEl = this.getItemByIdnum(thisItem.children[i4].idnum)
            this.subrefresh(thisEl.idnum, nextstate)
            i4 = memo
        }
    }
}


function refreshTree ()
{
    for ( i5 = 0 ; i5 < this.itemsCount ; i5++ )
    {
        if ( this.items[i5].parent == -1 )
        {
            this.items[i5].visible = 'visible'
            for ( i6 = 0 ; i6 < this.items[i5].numChildren ; i6++ )
            {
                this.subrefresh(this.getItemByIdnum(this.items[i5].children[i6].idnum).idnum, this.items[i5].status)
            }
        }
    }
}

function refreshNode ( numb, status )
{
    this.numScrollSteps = 0
    var thisNode = this.getItemByIdnum(numb)
    if ( thisNode.numChildren > 0 )
    {
        var nextstat = (status == 'true') ? thisNode.status : 'false'
        for ( i7 = 0 ; i7 < thisNode.numChildren ; i7++ )
        {
            var nextNode = this.getItemByIdnum(thisNode.children[i7].idnum)
            this.subrefresh(nextNode.idnum, nextstat)
        }
    }
}


function browserData()
{
    var useragnt = navigator.userAgent
    this.canDoDOM = (document.getElementById) ? true : false
    if ( useragnt.indexOf('Opera') >= 0)
        this.name = 'Opera'
    else if (  useragnt.indexOf('MSIE') >= 0 )
        this.name = 'InternetExplorer'
    else
        this.name = 'Another'
}


function changePicture(section, picture)
{
    var sect = this.name + '_section' + section
    var srcbase = ""
    var source = ""
    if ( myBrowser.canDoDOM )
    {
        if ( myBrowser.name == 'InternetExplorer' )
        {
            source = eval('document.getElementById("' + picture + '")').src
            srcbase = source.substring(0,source.lastIndexOf("/") + 1)
            if ( source.indexOf(this.items[section].curimage) >= 0 )
                source = this.items[section].toggleimage
            else
                source = this.items[section].curimage
            source = source.substring(source.lastIndexOf("/") + 1)
            eval('document.getElementById("' + picture + '")').src = srcbase + source
        }
        else
        {
            source = document.images[picture].src
            srcbase = source.substring(0,source.lastIndexOf("/") + 1)
            if ( source.indexOf(this.items[section].curimage) >= 0 )
                source = this.items[section].toggleimage
            else
                source = this.items[section].curimage
            source = source.substring(source.lastIndexOf("/") + 1)
            document.images[picture].src = srcbase + source
        }
    }
    else
    {
        var holder = eval('document.tree_' + this.name + '.layers["' + sect + '"]')
        source = holder.document.images[picture].src
        srcbase = source.substring(0,source.lastIndexOf("/") + 1)
        if ( source.indexOf(this.items[section].curimage) >= 0 )
            source = this.items[section].toggleimage
        else
            source = this.items[section].curimage
        source = source.substring(source.lastIndexOf("/") + 1)
        holder.document.images[picture].src = srcbase + source
    }
    srcbase = ""
    source = ""
}


function changeStatus(status)
{
    return  status == 'true' ? 'false' : 'true'
}


function scrollWindow(section)
{
    var sect = this.name + '_section' + section
    var lineHeight = this.lineHeight
    if ( this.items[section].status == 'true' )
    {
        var thisSection = ''
        if ( myBrowser.canDoDOM )
            thisSection = eval('document.getElementById("' + sect + '").style')
        else
            thisSection = eval('document.tree_' + this.name + '.layers["' + sect + '"]')

        if (myBrowser.canDoDOM){
            if ( myBrowser.name == 'InternetExplorer' )
                var sectionTop = document.body.scrollTop + this.lineHeight * section
            else
                var sectionTop = window.pageYOffset + this.lineHeight * section
        }
        else
              var sectionTop = thisSection.pageY
        var sectionBottom = sectionTop + lineHeight*this.numScrollSteps
        if ( myBrowser.name == 'InternetExplorer')
        {
            var clientAreaTop = document.body.scrollTop;
            var clientAreaBottom = clientAreaTop + document.body.clientHeight
        }
        else
        {
            var clientAreaTop = window.pageYOffset;
            var clientAreaBottom = clientAreaTop + window.innerHeight;
        }
        var scrollValue = sectionBottom - clientAreaBottom;

        if ((sectionBottom > clientAreaBottom) || (sectionTop < clientAreaTop))
        {
            if ((sectionTop - clientAreaTop) > lineHeight*this.numScrollSteps)
                scrollValue = lineHeight*this.numScrollSteps + 10
            else if (sectionTop < (clientAreaTop + scrollValue))
                scrollValue = sectionTop - clientAreaTop + 10
            setTimeout('scrollBy(0, ' + scrollValue + ')', 50)
        }
    }
    return false
}

function hasSelectionTreeView(id, item){

    if ( TICLTrees[id] != item ){
       TICLTrees[id] = item
       return true
    }
    else
        return false
}



function writeTreeSelection(tree, item, cont, selcont){
    if ( selcont != 'null' ){
        if ( myBrowser.canDoDOM ){
            if ( myBrowser.name == "InternetExplorer" ){
                document.write("<td nowrap onClick=selectTreeItem('" + tree + "','" + item + "')>")
                document.write("<DIV ID=" + tree + "_" + item + "_NORM STYLE={display:inline}>")
                document.write(cont + "</DIV>")
                document.write("<DIV ID="  + tree + "_" + item + "_SEL STYLE={display:none}>")
                document.write(selcont + "</DIV>")
                document.writeln("</td>")
            }
            else if ( myBrowser.name == "Opera" ){
                document.write("<td nowrap onClick=selectTreeItem('" + tree + "','" + item + "')>")
                document.write("<DIV ID=" + tree + "_" + item + "_BASE STYLE={POSITION:relative;visibility:VISIBLE;offsetTop:0}>")
                document.write("<DIV ID=" + tree + "_" + item + "_NORM STYLE={POSITION:relative;visibility:visible;offsetTop:0}>")
                document.write(cont + "</DIV>")
                document.write("<DIV ID=" + tree + "_" + item + "_SEL STYLE={POSITION:absolute;visibility:hidden;top:0}>")
                document.write(selcont + "</DIV></DIV>")
                document.writeln("</td>")
            }
            else{
                var cont1 = cont
                if ( cont.indexOf("javascript:") >= 0 ){
                    cont1 = cont.substring(0,cont.indexOf("javascript:") + 11)
                    cont1 = cont1 + 'selectTreeItem(&#39;' + tree + '&#39;,&#39;' + item + '&#39;);'
                    cont1 = cont1 + cont.substring(cont.indexOf("javascript:") + 11, cont.length)
                }
                document.write("<td nowrap>")
                document.write("<DIV ID=" + tree + "_" + item + "_NORM STYLE={position:relative;visibility:inherit}>")
                document.write(cont1 + "</DIV>")
                document.write("<DIV ID=" + tree + "_" + item + "_SEL STYLE={position:absolute;visibility:hidden}>")
                document.write(selcont + "</DIV>")
                document.writeln("</td>")
            }
        }
        else{
            var cont1 = cont
            if ( cont.indexOf("javascript:") >= 0 ){
                cont1 = cont.substring(0,cont.indexOf("javascript:") + 11)
                cont1 = cont1 + 'selectTreeItem(&#39;' + tree + '&#39;,&#39;' + item + '&#39;);'
                cont1 = cont1 + cont.substring(cont.indexOf("javascript:") + 11, cont.length)
            }
            document.write("<td nowrap><ILAYER ID=" + tree + "_" + item + "_OUT>")
            document.write("<LAYER ID=" + tree + "_" + item + "_NORM visibility='show'>" + cont1 + "</LAYER>")
            document.write("<LAYER ID=" + tree + "_" + item + "_SEL visibility='hide'>")
            document.write(selcont + "</LAYER>")
            document.writeln("</ILAYER></td>")
        }
    }
    else
        document.writeln(cont)
}


function selectTreeItem(tree,section){
    var sel = TICLTrees[tree]
    if ( myBrowser.canDoDOM )
    {
        if ( myBrowser.name == "InternetExplorer" ){
            eval('document.getElementById("' + tree + '_' + section + '_NORM").style').display='none'
            eval('document.getElementById("' + tree + '_' + section + '_SEL").style').display='inline'
            if ( eval('document.getElementById("' + tree + '_' + sel + '_NORM")') &&  sel != section ){
                eval('document.getElementById("' + tree + '_' + sel + '_NORM").style').display='inline'
                eval('document.getElementById("' + tree + '_' + sel +'_SEL").style').display='none'
            }
            TICLTrees[tree] = sel
        }
        else if ( myBrowser.name == "Opera" )
        {
            eval('document.getElementById("' + tree + '_' + section + '_NORM").style').visibility='hidden'
            eval('document.getElementById("' + tree + '_' + section + '_SEL").style').visibility='inherit'
            if ( sel != '0'  &&  sel != section ){
                eval('document.getElementById("' + tree + '_' + sel + '_NORM").style').visibility='inherit'
                eval('document.getElementById("' + tree + '_' + sel + '_SEL").style').visibility='hidden'
            }
            TICLTrees[tree] = sel
        }
        else
        {
            eval('document.getElementById("' + tree + '_' + section + '_NORM").style').position='absolute'
            eval('document.getElementById("' + tree + '_' + section + '_NORM").style').visibility='hidden'
            eval('document.getElementById("' + tree + '_' + section + '_SEL").style').position='relative'
            eval('document.getElementById("' + tree + '_' + section + '_SEL").style').visibility='inherit'
            if ( sel != '0' && sel != section ){
                eval('document.getElementById("' + tree + '_' + sel + '_NORM").style').position='relative'
                eval('document.getElementById("' + tree + '_' + sel + '_NORM").style').visibility='inherit'
                eval('document.getElementById("' + tree + '_' + sel + '_SEL").style').position='absolute'
                eval('document.getElementById("' + tree + '_' + sel + '_SEL").style').visibility='hidden'
            }
            TICLTrees[tree] = sel
        }
    }
    else
    {
        eval('document.layers["' + tree + '_' + section + '_OUT"]').layers[1].visibility='show'
        eval('document.layers["' + tree + '_' + section + '_OUT"]').layers[0].visibility='hide'
        if ( sel != '0' && sel != section ){
            eval('document.layers["' + tree + '_' + sel + '_OUT"]').layers[1].visibility='hide'
            eval('document.layers["' + tree + '_' + sel + '_OUT"]').layers[0].visibility='show'
        }
        TICLTrees[tree] = sel
    }
}



////////////////////Tooltip////////////////////

/* IMPORTANT: Put script after tooltip div or
     put tooltip div just before </BODY>. */

var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

// avoid error of passing event object in older browsers
if (nodyn) event = "nope";

///////////////////////  CUSTOMIZE HERE   ////////////////////
// settings for tooltip
// Do you want tip to move when mouse moves over link?

var tipFollowMouse	= true;
var tipWidth 			 	= 240;
var tipFontFamily 	= "Verdana, arial, helvetica, sans-serif";
var tipFontSize			= "8pt";
var tipFontColor		= "#000000";
var tipBgColor 			= "#DDECFF";
var tipBorderColor 	= "#000000";
var tipBorderWidth 	= 1;
var tipBorderStyle 	= "solid";
var tipPadding		 	= 4;
var tipHideAfter                = 5;

//document.writeln('<DIV id=tipDiv style="POSITION: absolute; VISIBILITY: hidden; Z-INDEX: 100"></DIV>');

var offX					 	= 8;	// how far from mouse to show tip
var offY					 	= 12;
var tipFontSizeNum = 8;

////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip.
//		Set styles for all but ns4. Set width of tooltip.
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
    if (nodyn) return;
    tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
    tipcss = (ns4)? document.tipDiv: tooltip.style;
    if (ns4) tooltip.width = tipWidth;
    else if (ns5) tipcss.width = tipWidth;
    else if (ie4||ie5) tipcss.pixelWidth = tipWidth;
    if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
        tipcss.fontFamily = tipFontFamily;
        tipcss.fontSize = tipFontSize;
        tipcss.fontColor = tipFontColor;
        tipcss.backgroundColor = tipBgColor;
        tipcss.borderColor = tipBorderColor;
        tipcss.borderWidth = tipBorderWidth;
        tipcss.padding = tipPadding;
        tipcss.borderStyle = tipBorderStyle;
    }
    if (tipFollowMouse) {
        if (ns4) document.captureEvents(Event.MOUSEMOVE);
        document.onmousemove = trackMouse;
    }
}
window.onload = initTip;

/////////////////////////////////////////////////////////////
//  Note on tipFollowMouse:
//		If tipFollowMouse is set true, positionTip is called
//		from trackMouse and tooltip is made visible at end of
//		doTooltip function.
//		If tipFollowMouse is set false, positionTip is called
//		from doTooltip and the tooltip is made visible at the
//		end of the positionTip function.
/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
//  showtip function
//			Assembles content for tooltip and writes it to tipDiv.
//			Call positionTip function from here if tipFollowMouse
//			is set to false.
//////////////////////////////////////////////////////////////
var t1,t2;	// for setTimeouts
function showtip(evt,txt) {
    if (!tooltip) return;
    if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);

    //Un ugly workaround for the case when the passed text is
    //considerably smaller that the defined tipWidth
    //Must be a better way to do this
    var tempWidth=tipWidth;
    if ((txt.length * tipFontSizeNum)<(0.8*tipWidth))
       tipWidth=txt.length * tipFontSizeNum;

    if (ns4) {
        tip = '<TABLE BGCOLOR="' + tipBorderColor + '" WIDTH="' + tipWidth + '" CELLSPACING="0" CELLPADDING="' + tipBorderWidth + '" BORDER="0"><TR><TD><TABLE BGCOLOR="' + tipBgColor + '" WIDTH="100%" CELLSPACING="0" CELLPADDING="' + tipPadding + '" BORDER="0"><TR><TD><SPAN STYLE="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + tipFontColor + ';">' + txt  + '</SPAN></TD></TR></TABLE></TD></TR></TABLE>';
        tooltip.write(tip);
        tooltip.close();
    } else if (ie4||ie5||ns5) {
        tip = txt;
        tipcss.width = tipWidth;
        tooltip.innerHTML = tip;
    }
    tipWidth=tempWidth;
    if (!tipFollowMouse) positionTip(evt);
    else {
        if (t1) clearTimeout(t1); if (t2) clearTimeout(t2);
        t1=setTimeout("tipcss.visibility='visible'",1000);
            t2=setTimeout("tipcss.visibility='hidden'",((tipHideAfter+1)*1000));
    }
}

var mouseX, mouseY;
function trackMouse(evt) {
    if (ns4||ns5) {
        mouseX = evt.pageX;
        mouseY = evt.pageY;
    } else if (ie4||ie5) {
        mouseX = window.event.clientX + document.body.scrollLeft;
        mouseY = window.event.clientY + document.body.scrollTop;
    }
    positionTip(evt);
}

/////////////////////////////////////////////////////////////
//  positionTip function
//		If tipFollowMouse set false, so trackMouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position,
//		offset amounts and tooltip width to position
//		tooltip within window space available.
/////////////////////////////////////////////////////////////
function positionTip(evt) {
    if (ns4) {
        if (!tipFollowMouse) {mouseX=evt.pageX; mouseY=evt.pageY;	}
        if ((mouseX+offX+tooltip.width) > (window.innerWidth-20 + window.pageXOffset)) tipcss.left = mouseX - (tooltip.width + offX);
        else tipcss.left = mouseX + offX;
        if ((mouseY+offY+tooltip.height) > (window.innerHeight-20 + window.pageYOffset)) tipcss.top = mouseY - (tooltip.height + offY);
        else tipcss.top = mouseY + offY;
    }

    else if (ie4||ie5) {
        if (!tipFollowMouse) {
            mouseX = window.event.clientX + document.body.scrollLeft;
            mouseY = window.event.clientY + document.body.scrollTop;
        }
        if ((mouseX+offX+tooltip.clientWidth) > (document.body.clientWidth + document.body.scrollLeft))
            tipcss.pixelLeft = mouseX-(tooltip.clientWidth + offX);
        else tipcss.pixelLeft = mouseX + offX;

        if ((mouseY+offY+tooltip.clientHeight) > (document.body.clientHeight+document.body.scrollTop))
            tipcss.pixelTop = mouseY-(tooltip.clientHeight + offY);
        else tipcss.pixelTop = mouseY + offY;
    }

    else if (ns5) {
        if (!tipFollowMouse) {mouseX=evt.pageX; mouseY=evt.pageY;}
        if ((mouseX+offX+tooltip.offsetWidth) > (window.innerWidth-20 + window.pageXOffset))
            tipcss.left = mouseX - (tooltip.offsetWidth + offX);
      else tipcss.left = mouseX + offX;

        if ((mouseY+offY+tooltip.offsetHeight) > (window.innerHeight-20 + window.pageYOffset))
            tipcss.top = mouseY - (tooltip.offsetHeight + offY);
      else tipcss.top = mouseY + offY;
    }
    if (!tipFollowMouse) {
        if (t1) clearTimeout(t1); if (t2) clearTimeout(t2);
        t1=setTimeout("tipcss.visibility='visible'",800);
            t2=setTimeout("tipcss.visibility='hidden'",(tipHideAfter+1)*1000);
    }
}

function hidetip() {
    if (!tooltip) return;
    tipcss.visibility = "hidden";
    if (t1) clearTimeout(t1); if (t2) clearTimeout(t2);
}
///////////// end tooltip code ///////////////

// This function toggles the visibility state of the panel componnent

function toggleShowHide(panel_id2){
    var myBrowser = new browserData()
    if (document.getElementById){
        if ( myBrowser.name == "InternetExplorer" ){
            if ( eval('document.getElementById("panel_' + panel_id2 + '")').style.display == 'none'){
                eval('document.getElementById("panel_' + panel_id2 + '")').style.display='inline';
                eval('document.getElementById("show_' + panel_id2 + '")').style.display='none';
                eval('document.getElementById("hide_' + panel_id2 + '")').style.display='inline';
            }
            else{
                eval('document.getElementById("panel_' + panel_id2 + '")').style.display='none';
                eval('document.getElementById("hide_' + panel_id2 + '")').style.display='none';
                eval('document.getElementById("show_' + panel_id2 + '")').style.display='inline';
            }
        }
        else if ( myBrowser.name == "Opera" ){
            if ( document.getElementById("panel_" + panel_id2).style.visibility == 'visible' ){
                document.getElementById("panel_" + panel_id2).style.visibility = 'hidden'
                document.getElementById("show_" + panel_id2).style.visibility = 'visible'
                document.getElementById("hide_" + panel_id2).style.visibility = 'hidden'
            }
            else{
                document.getElementById("panel_" + panel_id2).style.visibility = 'visible'
                document.getElementById("show_" + panel_id2).style.visibility = 'hidden'
                document.getElementById("hide_" + panel_id2).style.visibility = 'visible'
            }
        }
        else{
            if ( eval('document.getElementById("panel_' + panel_id2 + '")').style.position == 'absolute'){
                eval('document.getElementById("panel_' + panel_id2 + '")').style.position='relative';
                eval('document.getElementById("panel_' + panel_id2 + '")').style.visibility='visible';
                eval('document.getElementById("hide_' + panel_id2 + '")').style.position='relative';
                eval('document.getElementById("show_' + panel_id2 + '")').style.position='absolute';
                eval('document.getElementById("hide_' + panel_id2 + '")').style.visibility='visible';
                eval('document.getElementById("show_' + panel_id2 + '")').style.visibility='hidden';
            }
            else{
                eval('document.getElementById("panel_' + panel_id2 + '")').style.position='absolute';
                eval('document.getElementById("panel_' + panel_id2 + '")').style.visibility='hidden';
                eval('document.getElementById("show_' + panel_id2 + '")').style.position='relative';
                eval('document.getElementById("hide_' + panel_id2 + '")').style.position='absolute';
                eval('document.getElementById("show_' + panel_id2 + '")').style.visibility='visible';
                eval('document.getElementById("hide_' + panel_id2 + '")').style.visibility='hidden';
            }
        }
        return false;
    }
    else{
        if(eval('document.panel_' + panel_id2 ).visibility == 'hide'){
            eval('document.panel_' + panel_id2 ).visibility='show'
            eval('document.blank_' + panel_id2).layers[1].visibility='hide'
            eval('document.blank_' + panel_id2).layers[0].visibility='show'
        }
        else{
            eval('document.panel_' + panel_id2 ).visibility='hide'
            eval('document.blank_' + panel_id2).layers[0].visibility='hide'
            eval('document.blank_' + panel_id2).layers[1].visibility='show'
        }
    }
}


function renderHeaderLinks(link_id, active, pasive){
   myBrowser = new browserData()
   if ( document.getElementById ){
       if (myBrowser.name == 'InternetExplorer' ) {
           document.writeln("<DIV ID='active_" + link_id + "' STYLE='position:relative;visibility:visible;display:inline'> &nbsp;&nbsp;" + active + "&nbsp;&nbsp;</DIV>")
           document.writeln("<DIV ID='pasive_" + link_id + "' STYLE='position:relative;visibility:visible;display:none'>&nbsp;&nbsp;" + pasive + "&nbsp;&nbsp;</DIV>")
       }
       else{
           document.writeln("<DIV ID='active_" + link_id + "' STYLE='position:relative;visibility:visible'>&nbsp;&nbsp;" + active + "&nbsp;&nbsp;</DIV>")
           document.writeln("<DIV ID='pasive_" + link_id + "' STYLE='position:absolute;visibility:hidden'>&nbsp;&nbsp;" + pasive + "&nbsp;&nbsp;</DIV>")
       }
   }
   else{
       document.writeln("<ILAYER ID='blank_" + link_id + "' >")
       document.writeln("<LAYER ID='active_" + link_id + "' visibility='show'>&nbsp;&nbsp;" + active + "&nbsp;&nbsp;</LAYER>")
       document.writeln("<LAYER ID='pasive_" + link_id + "' visibility='hide'>&nbsp;&nbsp;" + pasive + "&nbsp;&nbsp;</LAYER>")
       document.writeln("</ILAYER>")
   }
}


function deactivateLink(link_id2){
    if (document.getElementById){
        if ( myBrowser.name == "InternetExplorer" ){
                eval('document.getElementById("active_' + link_id2 + '")').style.display='none';
                eval('document.getElementById("pasive_' + link_id2 + '")').style.display='inline';
        }
        else{
                eval('document.getElementById("active_' + link_id2 + '")').style.position='absolute';
                eval('document.getElementById("pasive_' + link_id2 + '")').style.position='relative';
                eval('document.getElementById("active_' + link_id2 + '")').style.visibility='hidden';
                eval('document.getElementById("pasive_' + link_id2 + '")').style.visibility='visible';
        }
    }
    else{
            eval('document.blank_' + link_id2 + '.layers["active_' + link_id2 +'"]' ).visibility='hide'
            eval('document.blank_' + link_id2 + '.layers["pasive_' + link_id2 +'"]' ).visibility='show'
    }
}


///////////// end panel

function getFormFieldLabel(formid, fieldid){
    if ( document.getElementById ){
            alert(formid + "_" + fieldid);
            alert(document.getElementById(formid + "_" + fieldid).style);

        return document.getElementById(formid + "_" + fieldid).style ;
    }
    else{
        var inl = formid + "_" + fieldid;
        var outl = formid + "___" + fieldid;
        return eval('document.'+outl+'.layers["'+inl+'"]');
    }
}

///////////// change days when change month
function change_days(year, month, day)
{
    if (day == null)
      return;
    var monthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    var year = year.selectedIndex;
    selind = day.selectedIndex;
    if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
        monthDays[1] = 29;
    else
        monthDays[1] = 28;
    days = monthDays[month.selectedIndex];
    for (i=0 ; i<31; i++)
    {
        day.options[i]=null;
    }
    for (i=0 ; i<days; i++)
    {
        var optionName = new Option(i+1,i+1);
        eval("day.options[i]=optionName")
    }
    if (selind<days)
        day.options[selind].selected = true;

}

function switchTabItem(paneid, itemname)
{
    eval("toggleTabuserTabs('" + paneid + "_" + itemname + "');");
}