// ****************************************************************************************
// *****************************                       ************************************
// *****************************  Initial Setup Begin  ************************************
// *****************************                       ************************************
// ****************************************************************************************

// **********
// Set Arrays
// **********
//var mpsctns= Found on the page that calls this script!
var mpsctnsstate=new Array();
var mpsctnshght=new Array();
var maxmpitms = mpsctns.length - 1;

// *************
// Set Variables
// *************
var heightst_one = null;
var heightst_two = null;
var incme = 0;
var usrinpt = false;
var notyet = false;
var intlanispeed = 1;
var actlanispeed = 0;
var intlincspeed = .01;
var incspeed = intlincspeed;
var mltspeed = 1.5;
var stpani = false;
var anitime = null;

// ****************
// Get/Set Defaults
// ****************
for(var mpamntone = 0; mpamntone <= maxmpitms; mpamntone++){

heightst_one = document.getElementById(mpsctns[mpamntone]).scrollHeight;
heightst_two = document.getElementById(mpsctns[mpamntone]).offsetHeight;

if(heightst_one > 0){
mpsctnshght[mpamntone] = heightst_one;
}else if(heightst_two > 0){
mpsctnshght[mpamntone] = heightst_two;
}else{
mpsctnshght[mpamntone] = "na";
};

mpsctnsstate[mpamntone] = "off";

};

shwhdmapsec(null);

// ****************************************************************************************
// *****************************                       ************************************
// *****************************   Initial Setup End   ************************************
// *****************************                       ************************************
// ****************************************************************************************

// ****************************************************************************************
// *****************************                       ************************************
// *****************************    Functions Begin    ************************************
// *****************************                       ************************************
// ****************************************************************************************

// *************************
// Determin New On/Off State
// *************************
function mponoffst(thsec){

if(usrinpt == true){
usrinpt = false;

for(key in mpsctns){
if(mpsctns[key] == thsec){

if(mpsctnsstate[key] == "off"){
mpsctnsstate[key] = "on";
}else{
mpsctnsstate[key] = "off";
};

};
};

};

shwhdmapsec(thsec);

};

// ***********************
// Show / Hide Map Item(s)
// ***********************
function shwhdmapsec(seccalld){

for(var mpamnttwo = 0; mpamnttwo <= maxmpitms; mpamnttwo++){

if(mpsctnsstate[mpamnttwo] == "off"){
document.getElementById(mpsctns[mpamnttwo]).style.display = "none";
document.getElementById(mpsctns[mpamnttwo]).style.height = "0px";
}else{

if((seccalld != null && seccalld == mpsctns[mpamnttwo]) && mpsctnsstate[mpamnttwo] == "on"){

if(mpsctnshght[mpamnttwo] > 0 && mpsctnshght[mpamnttwo] != "na"){
document.getElementById(mpsctns[mpamnttwo]).style.height = "0px";
document.getElementById(mpsctns[mpamnttwo]).style.display = "block";
toanmte = mpsctns[mpamnttwo];
atoamnthght = mpsctnshght[mpamnttwo];
notyet = true;

}else{
document.getElementById(mpsctns[mpamnttwo]).style.display = "block";
};

}else{
document.getElementById(mpsctns[mpamnttwo]).style.display = "block";
};

};

};

if(notyet == false){
usrinpt = true;
}else{
animmestrt(toanmte,atoamnthght);
};

};

// *********************
// Intial Amination Call
// *********************
function animmestrt(thanmtd,hght){
anitime = setTimeout("animmefnsh("+"'"+thanmtd+"'"+","+"'"+hght+"'"+")",2);
};

// ********************
// Final Amination Call
// ********************
function animmefnsh(thanmtdgo,hghtgo){

clearTimeout(anitime);

if(stpani == false){

if(actlanispeed <= 0){
actlanispeed = intlanispeed;
};

incme = incme + actlanispeed;

tstrang = hghtgo - incme;

if(tstrang <= actlanispeed){
incme = incme + tstrang;
stpani = true;
};

document.getElementById(thanmtdgo).style.height = incme + "px";

actlanispeed = intlanispeed + incspeed;
incspeed = incspeed * mltspeed;
animmestrt(thanmtdgo,hghtgo);

}else{
incme = 0;
actlanispeed = 0;
incspeed = intlincspeed;
stpani = false;
notyet = false;
usrinpt = true;
};

};

// ****************************************************************************************
// *****************************                       ************************************
// *****************************     Functions End     ************************************
// *****************************                       ************************************
// ****************************************************************************************