function resetProportions(picture,MaxDim){
    if(picture.width>picture.height){
        if(picture.width>MaxDim){
            picture.height=Math.round(((MaxDim)/picture.width)*picture.height)
            picture.width=(MaxDim)
        }
    }
    else {
        if(picture.height>MaxDim){
            picture.width=Math.round(((MaxDim)/picture.height)*picture.width)
            picture.height=(MaxDim)
        }
    }
}

var offsetfromcursorX=12      //Offset from cursor to show pointer and tipbox
var offsetfromcursorY=20      //Offset from cursor to show pointer and tipbox
var offsetdivfrompointerX=20  //Offset from cursor to show tipbox
var offsetdivfrompointerY=14  //Offset from cursor to show tipbox

document.write('<div id="dhtmltooltip"></div>')
document.write('<img id="dhtmlpointer"   src="images/tooltip/arrow.tr.gif">')

//document.write('<img id="dhtmlpointertl"  src="images/tooltip/border.tl.gif">')
//document.write('<img id="dhtmlpointertr"  src="images/tooltip/border.tr.gif">')
//document.write('<img id="dhtmlpointerbl"  src="images/tooltip/border.bl.gif">')
//document.write('<img id="dhtmlpointerbr"  src="images/tooltip/border.br.gif">')
//document.write('<img id="dhtmlpointertop" src="images/tooltip/border.top.gif">')
//document.write('<img id="dhtmlpointerbot" src="images/tooltip/border.bot.gif">')

document.write('<img id="dhtmlpointertl"  src="images/spacer.gif">')
document.write('<img id="dhtmlpointertr"  src="images/spacer.gif">')
document.write('<img id="dhtmlpointerbl"  src="images/spacer.gif">')
document.write('<img id="dhtmlpointerbr"  src="images/spacer.gif">')
document.write('<img id="dhtmlpointertop" src="images/spacer.gif">')
document.write('<img id="dhtmlpointerbot" src="images/spacer.gif">')

var ie=document.all
var ns6=document.getElementById&&!document.all
var enabletip=false

var CONST_moveTipBoxWithCursor = true //This determines if the tipbox should move with the cursor.

if(ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip"): ""
var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer"): ""

var pointerobjtl =document.all? document.all["dhtmlpointertl"]  : document.getElementById? document.getElementById("dhtmlpointertl"): ""
var pointerobjtr =document.all? document.all["dhtmlpointertr"]  : document.getElementById? document.getElementById("dhtmlpointertr"): ""
var pointerobjbl =document.all? document.all["dhtmlpointerbl"]  : document.getElementById? document.getElementById("dhtmlpointerbl"): ""
var pointerobjbr =document.all? document.all["dhtmlpointerbr"]  : document.getElementById? document.getElementById("dhtmlpointerbr"): ""
var pointerobjtop=document.all? document.all["dhtmlpointertop"] : document.getElementById? document.getElementById("dhtmlpointertop"): ""
var pointerobjbot=document.all? document.all["dhtmlpointerbot"] : document.getElementById? document.getElementById("dhtmlpointerbot"): ""

tipobj.style.width='150px'

//*************************************************************************************************************************
//* Detemine if this a an IE compatible browser
//*************************************************************************************************************************
function ietruebody(){
    return(document.compatMode&&document.compatMode!="BackCompat")? document.documentElement : document.body
}

//*************************************************************************************************************************
//* Create the text that goes into the popup box
//*************************************************************************************************************************
function ddrivetip(pci_title, pci_celltext1, pci_celltext2, thewidth,thecolor){
var lc_tipText=""
    if(ns6||ie){
        if(typeof thewidth!="undefined")tipobj.style.width=thewidth+"px"
        if(typeof thecolor!="undefined"&&thecolor!="")tipobj.style.backgroundColor=thecolor

        lc_tipText  = ""
        lc_tipText += "            <table class=bgwhite width=100% border=0 cellspacing=0 cellpadding=0 >"
        lc_tipText += "                <tr><td colspan=5><img src='images/spacer.gif' height=8></td></tr>"

        lc_tipText += "                <tr class=smalltext>"

        lc_tipText += "                    <td valign=top align=center>"
        lc_tipText +=                          "<b>" + pci_title + "</b><br>" + pci_celltext1
        lc_tipText += "                    </td>"

        lc_tipText += "                </tr>"

        lc_tipText += "                <tr><td colspan=5><img src='images/spacer.gif' height=8></td></tr>"
        lc_tipText += "            </table>"

//alert(lc_tipText);

        tipobj.innerHTML=lc_tipText

        enabletip=true
        return false
    }
}

//*************************************************************************************************************************
//* Set the position of the tip box and associated graphics based on cursor location
//*************************************************************************************************************************
function positiontip(e){
    if(enabletip){
        var nondefaultpos=false
        var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft
        var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop
        var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
        var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20
        var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
        var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY
        var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1):-1000

        if(rightedge<tipobj.offsetWidth){
            //This code is executed when the cursor goes over the right-hand boundary
            tipobj.style.left=curX-tipobj.offsetWidth+"px"
            pointerobj.style.left=curX-offsetfromcursorX-15+"px"

            pointerobj.src= (bottomedge<tipobj.offsetHeight) ? "images/tooltip/arrow.bl.gif" : "images/tooltip/arrow.tl.gif"

            // nondefaultpos=true  //set this to true to not display pointer arrow
        }
        else {
            pointerobj.src= (bottomedge<tipobj.offsetHeight) ? "images/tooltip/arrow.br.gif" : "images/tooltip/arrow.tr.gif"

            if(curX<leftedge)
                tipobj.style.left="5px"
            else {
                tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
                pointerobj.style.left=curX+offsetfromcursorX+"px"
            }
        }

        if(bottomedge<tipobj.offsetHeight) {
            //This code is executed when the cursor goes below the bottom boundary
            tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
            pointerobj.style.top=curY-offsetfromcursorY-9+"px"
            // nondefaultpos=true
        }
        else {
            tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
            pointerobj.style.top=curY+offsetfromcursorY+"px"
        }


        //Determine if tipbox should move with cursor or be stationary
        if (CONST_moveTipBoxWithCursor == false ) {
            tipobj.style.left=20 + "px"
            tipobj.style.top =20 + "px"
        }

        //Position and size all the corner and border pieces
        li_tipBoxHeight        = tipobj.offsetHeight
        li_tipBoxWidth         = tipobj.offsetWidth

        li_tipBoxLeft          = parseInt(tipobj.style.left)
        li_tipBoxTop           = parseInt(tipobj.style.top)

        li_tipBoxRight         = li_tipBoxLeft+ li_tipBoxWidth
        li_tipBoxBottom        = li_tipBoxTop + li_tipBoxHeight

        li_cornerGraphicWidth   = 10
        li_cornerGraphicHeight  = 9

        li_cornerGraphicOffsetX = 0
        li_cornerGraphicOffsetY = -li_cornerGraphicHeight + 1

        if (ns6) {
            li_shadowSizeX          = 0
            li_shadowSizeY          = 1
        }
        else {
            li_shadowSizeX          = 8
            li_shadowSizeY          = 9
        }

        pointerobjtl.style.left=tipobj.style.left
        pointerobjtl.style.top =parseInt(tipobj.style.top)  + li_cornerGraphicOffsetY + "px"

        pointerobjbl.style.left=tipobj.style.left
        pointerobjbl.style.top =parseInt(tipobj.style.top)  + li_tipBoxHeight - li_shadowSizeY + "px"

        pointerobjtr.style.left=parseInt(tipobj.style.left) + li_tipBoxWidth  - li_cornerGraphicWidth - li_shadowSizeX + "px"
        pointerobjtr.style.top =parseInt(tipobj.style.top)  + li_cornerGraphicOffsetY + "px"

        pointerobjbr.style.left=parseInt(tipobj.style.left) + li_tipBoxWidth  - li_cornerGraphicWidth - li_shadowSizeX + "px"
        pointerobjbr.style.top =parseInt(tipobj.style.top)  + li_tipBoxHeight - li_shadowSizeY + "px"

        pointerobjtop.style.left=parseInt(tipobj.style.left)+ li_cornerGraphicWidth   + "px"
        pointerobjtop.style.top =parseInt(tipobj.style.top) + li_cornerGraphicOffsetY + "px"
        pointerobjtop.style.width=li_tipBoxWidth  - (li_cornerGraphicWidth*2) - li_shadowSizeX + "px"
        pointerobjtop.style.height=li_cornerGraphicHeight + "px"

        pointerobjbot.style.left=parseInt(tipobj.style.left)+ li_cornerGraphicWidth + "px"
        pointerobjbot.style.top =parseInt(tipobj.style.top) + li_tipBoxHeight - li_shadowSizeY + "px"
        pointerobjbot.style.width=li_tipBoxWidth  - (li_cornerGraphicWidth*2) - li_shadowSizeX + "px"
        pointerobjbot.style.height=li_cornerGraphicHeight + "px"

        //tipobj.innerHTML = "tipobj.top=" + tipobj.style.top.replace("px","") + "<br><br>" + "tipobj.top+20=" + (tipobj.style.top.replace("px","")*-1-20)*-1 + "px"
        //tipobj.innerHTML = "pointerobjtop.style.left=" + pointerobjtop.style.left + "<br><br>" + "pointerobjtop.style.top=" + pointerobjtop.style.top
        //tipobj.innerHTML = "tipobj.offsetHeight=" + li_tipBoxHeight + "<br><br>" + "tipobj.offsetWidth=" + li_tipBoxWidth




        tipobj.style.visibility="visible"

        if(!nondefaultpos) {
            //pointerobj.style.visibility="visible"

            pointerobjtl.style.visibility="visible"
            pointerobjtr.style.visibility="visible"
            pointerobjbl.style.visibility="visible"
            pointerobjbr.style.visibility="visible"
            pointerobjtop.style.visibility="visible"
            pointerobjbot.style.visibility="visible"
        }
        else
            pointerobj.style.visibility="hidden"
    }


    //**********************************************************************************
    //This call the getXYPosition is used to position the hidden layer on the events page
    getXYPosition(e)
    //**********************************************************************************
}


//*************************************************************************************************************************
//* Hide the tip popup box and the associated graphics
//*************************************************************************************************************************
function hideddrivetip(){
    if(ns6||ie){
        enabletip=false
        tipobj.style.visibility="hidden"
        tipobj.style.left="-1000px"
        tipobj.style.backgroundColor=''
        tipobj.style.width=''

        pointerobj.style.visibility="hidden"

        pointerobjtl.style.visibility="hidden"
        pointerobjtr.style.visibility="hidden"
        pointerobjbl.style.visibility="hidden"
        pointerobjbr.style.visibility="hidden"
        pointerobjtop.style.visibility="hidden"
        pointerobjbot.style.visibility="hidden"
    }
}

//This capture of the onmousemove event has to be coordinated with the other one in commonheader.asp for positioning the details box on the events page
document.onmousemove=positiontip

