var isFrameTopInit = false;
var isFrameCalInit = false;

var applTotal = 0.00;
var applPowerTotal = 0;
// ***************************************************************************************
// March 16, 2004 - iStudio - KH.
// - added a running total variable for the  kWh
// ***************************************************************************************

//// appliance list cache arrays ////
var applListNameArr = new Array();
var applListCostArr = new Array();
var applListQty = new Array();
var applListHD = new Array();
var applListMD = new Array();
var applListDM = new Array();
var applListMY = new Array();
var applListPower = new Array();
var applListRate = new Array();
var clientBrouser = window.navigator.appName;
var clientBrouserVer = parseFloat(navigator.appVersion);
var isClientBrouserIE50x = false;
var isClientBrouserNN47 = false;
var isClientBrouserIE = false;

////resolve version 
if (clientBrouser == "Microsoft Internet Explorer"){
	isClientBrouserIE = true;
	clientBrouserVer = parseFloat(window.navigator.userAgent.substr(window.navigator.userAgent.indexOf("MSIE ")+5));
	clientBrouser = "IE";
	if (clientBrouserVer >= 5.0 && clientBrouserVer < 5.5) isClientBrouserIE50x = true;
} else {
	if ((clientBrouser == "Netscape") && (clientBrouserVer == 4.7)) {
		isClientBrouserNN47 = true
	}
}
//alert(clientBrouser);
//alert(clientBrouserVer)
//alert(isClientBrouserIE50x);

//// manage cache arrays ////

function removeElement(idx){
	//idx is bound to selectedIndex
	var i;
	var arrLength = applListNameArr.length;
	//overlap
	for (i = idx; i <  arrLength - 1; i++) {
		applListNameArr[i] = applListNameArr[i+1];
		applListCostArr[i] = applListCostArr[i+1];
		applListQty[i] = applListQty[i+1];
		applListHD[i] = applListHD[i+1];
		applListMD[i] = applListMD[i+1];
		applListDM[i] = applListDM[i+1];
		applListMY[i] = applListMY[i+1];
		applListPower[i] = applListPower[i+1];
		applListRate[i] = applListRate[i+1];        
	}
	//slash last element
	i = arrLength - 1;
	applListNameArr = applListNameArr.slice(0,i);
	applListCostArr = applListCostArr.slice(0,i);
	applListQty = applListQty.slice(0,i);
	applListHD = applListHD.slice(0,i);
	applListMD = applListMD.slice(0,i);
	applListDM =applListDM.slice(0,i);
	applListMY = applListMY.slice(0,i);
	applListPower = applListPower.slice(0,i);
	applListRate = applListRate.slice(0,i); 
}   

function storeElement(idx, last, cost, qty, hd, md, dm, my, power, rate) {
	//idx is bound to selectedIndex value property
	var i = last;
	if (i== -1) i = 0;
	applListNameArr[i] = idx;
	applListCostArr[i] = cost;
	applListQty[i] = qty;
	applListHD[i] = hd;
	applListMD[i] = md;
	applListDM[i] = dm;
	applListMY[i] = my;
	applListPower[i] = power;
	applListRate[i] = rate;     
}

function resetCache(){
	var i = 0;
	applListNameArr = applListNameArr.slice(0,i);
	applListCostArr = applListCostArr.slice(0,i);
	applListQty = applListQty.slice(0,i);
	applListHD = applListHD.slice(0,i);
	applListMD = applListMD.slice(0,i);
	applListDM =applListDM.slice(0,i);
	applListMY = applListMY.slice(0,i);
	applListPower = applListPower.slice(0,i);
	applListRate = applListRate.slice(0,i); 

}

function computeTotal(){
	applTotal = 0;
	
	for(i=0; i<applListCostArr.length;i++){
		applTotal = applTotal + parseFloat(applListCostArr[i]);
	}
}
//// stop manage cache arrays ////

function isSupported(brName, brVer){
	if (brName != "Netscape" && brName != "IE") return false;
	if (parseInt(brVer) < 4) return false;
	return true;
}

function denyService(){
	top.fra_cal.document.location.href='blank.htm';
}

function init(){
	//when both loaded initialize frames in the right sequence
	
	//check browser compatibility
	if (isSupported(clientBrouser,clientBrouserVer)) {
		isFrameTopInit = false;
		isFrameCalInit = false;
		top.fra_cal.init();
		top.fra_top.init();
		isFrameTopInit = true;
		isFrameCalInit = true;
	}
	else {
		denyService();
	}
}