var objSab = new objSelectionBasket();

function objSelectionBasket() {

	////////////////////////
	// exported constants //
	////////////////////////

	var COST_MONTHLY = "monthly";
	this.COST_MONTHLY = COST_MONTHLY;

	var COST_NOW = "now";
	this.COST_NOW = COST_NOW;

	var DISPLAY_NARROW = "Narrow";
	this.DISPLAY_NARROW = DISPLAY_NARROW;

	var DISPLAY_WIDE = "Wide";
	this.DISPLAY_WIDE = DISPLAY_WIDE;

	var ITEM_HANDSET = "hst";
	this.ITEM_HANDSET = ITEM_HANDSET;

	var ITEM_SERVICEPLAN = "svp";
	this.ITEM_SERVICEPLAN = ITEM_SERVICEPLAN;

	var ITEM_ACC = "acc";
	this.ITEM_ACC = ITEM_ACC;

	var ITEM_VAS = "vas";
	this.ITEM_VAS = ITEM_VAS;

	var STATE_ACTIVE = "Active";
	this.STATE_ACTIVE = STATE_ACTIVE;

	var STATE_EMPTY = "Empty";
	this.STATE_EMPTY = STATE_EMPTY;

	var STATE_INACTIVE = "Inactive";
	this.STATE_INACTIVE = STATE_INACTIVE;
	
	////////////////////////
	// internal variables //
	////////////////////////

	var fDebug = false;

	var isGecko = false;

	var objForm = null;

	var idxDesc = 0;
	var idxMonthlyCost = 1;
	var idxNowCost = 2;
	var idxExtra = 3;

	var currentWidth = "";
	var currentHeight = 0;

	var selSvp = 0;
	var selHst = 0;
	var selHstCost = 0;

	var selMonthlyCost = 0;
	var selNowCost = 0;

	var selAcc = new Array();
	var selVas = new Array();

	var tweakHeight = new Array();
	tweakHeight[DISPLAY_WIDE] = 90;
	tweakHeight[DISPLAY_NARROW] = 100;

	var defaultActiveState = STATE_ACTIVE;
	
	var alwaysShowAcc = false;
	
	////////////////////////
	// exported functions //
	////////////////////////

	function toggleDebug() {
		fDebug = !fDebug;
		alert('objSab: fDebug = '+fDebug);
		if (fDebug) {
			document.cookie="fDebug=true; path=/;";
		} else {
			document.cookie="fDebug=; path=/;";
		}
	}
	this.toggleDebug = toggleDebug;

	function setAlwaysShowAcc(boolAlwaysShow){
		alwaysShowAcc=boolAlwaysShow;
	}	
	this.setAlwaysShowAcc = setAlwaysShowAcc;
	
	function init(selActive) {

	    var cookies = document.cookie.split("; ");
	    for (loop = 0;loop < cookies.length; ++loop) {
	    	var cookie = cookies[loop].split("=");
	    	if (cookie[0].match("fDebug")) {
	    		fDebug = (cookie[1] == 'true') ? true : false;
	    		if (fDebug) {
	    			alert('objSab: fDebug = '+fDebug);
	    		}
	    		break;
	    	}
	    }

		isGecko = (navigator.userAgent.indexOf("Gecko") != -1) ? true : false;

		objForm = document.forms.frmSelectionBasket;

		selSvp = (objForm.elements["servicePlanId"] == null) ? null : objForm.elements["servicePlanId"].value;
		selHst = (objForm.elements["handsetId"] == null) ? null : objForm.elements["handsetId"].value;

		var elementTotalMonthlyCost = getElement("selTotalMonthlyCost");
		var elementTotalNowCost = getElement("selTotalNowCost");		
		if (fDebug) {
			alert('new'+elementTotalMonthlyCost);
		}
		if (elementTotalMonthlyCost != null){
			selMonthlyCost = (elementTotalMonthlyCost.innerHTML == "") ? 0 : unFormatPrice(getElement("selTotalMonthlyCost").innerHTML);
		}
		if (elementTotalNowCost != null){
			selNowCost = (elementTotalNowCost.innerHTML == "") ? 0 : unFormatPrice(getElement("selTotalNowCost").innerHTML);
		}

		currentWidth = (getElement("sabMain").className == "sabNarrow") ? DISPLAY_NARROW : DISPLAY_WIDE;
		currentHeight = parseInt(getElement("sabMid").style.height.toString().replace(/\D/g,"")) + parseInt(tweakHeight[currentWidth]);

		if (objForm != null && objForm.elements != null) {
			for(i=0; i < objForm.elements.length; i++) {
				var objElement = objForm.elements[i];
				if (objElement.name != null && (objElement.name.match(/accessoryValues/))) {
					var index = objElement.name.value+"|"+ITEM_ACC;
					selAcc[index] = objElement.name.value;
				} else if (objElement.name != null && (objElement.name.match(/primaryServiceId/) || objElement.name.match(/additionalServiceId/))) {
					var thisType = objElement.name.slice(objElement.name.indexOf("["),objElement.name.indexOf("]"));
					
					// do not add to array if is broadband type
					if(thisType!="[111") {
						var index = objElement.name.value+"|"+ITEM_VAS+"|"+thisType;
						selVas[index] = new Array(objElement.name.value, thisType);
					}
				}
			}
		}

		var selState = (selActive) ? STATE_ACTIVE : STATE_INACTIVE;

		refreshDisplay(selState);

	}
	this.init = init;

	function getItem(itemType,itemSubType) {
		if (itemType == ITEM_SERVICEPLAN) {
			return getSvp();
		} else if (itemType == ITEM_HANDSET) {
			return getHst();
		} else if (itemType == ITEM_ACC) {
			return getAcc(itemType);
		} else if (itemType == ITEM_VAS) {
			return getVas(itemSubType);
		}
		return null;
	}
	this.getItem = getItem;

	function addItem(itemId,itemType,itemSubType) {
		if (fDebug) {
			alert('objSab: addItem('+itemId+',"'+itemType+'",'+itemSubType+')');
		}
		if (itemType == ITEM_SERVICEPLAN) {
			setSvp(itemId);
		} else if (itemType == ITEM_HANDSET) {
			setHst(itemId);
		} else if (itemType == ITEM_ACC) {
			addAcc(itemId);
		} else if (itemType == ITEM_VAS) {
			addVas(itemId,itemSubType);
		}
	}
	this.addItem = addItem;

	function toggleItem(bCheckState,itemId,itemType,itemSubType) {
		if (bCheckState) {
			addItem(itemId,itemType,itemSubType);
		} else {
			removeItem(itemId,itemType,itemSubType);
		}
	}
	this.toggleItem = toggleItem;
	
	function AddToTotalizer(itemId,itemType,itemSubType){		
		addItem(itemId,itemType,itemSubType);
	}
	this.AddToTotalizer = AddToTotalizer;	
	
	function RemoveFromTotalizer(itemId,itemType,itemSubType){
		removeItem(itemId,itemType,itemSubType);
	}
	this.RemoveFromTotalizer = RemoveFromTotalizer;
	

	function removeItem(itemId,itemType,itemSubType) {
		if (itemType == ITEM_SERVICEPLAN) {
			setSvp(null);
		} else if (itemType == ITEM_HANDSET) {
			setHst(null);
		} else if (itemType == ITEM_ACC) {
			removeAcc(itemId);
		} else if (itemType == ITEM_VAS) {
		
			for (existingIndex in selVas) {
			
				itemString = "|"+ITEM_VAS+"|"+itemSubType;
				
				if ((existingIndex.indexOf(itemString) >= 0)) {
					
					start = existingIndex.indexOf(itemString);
					if(existingIndex.substring(start) == itemString){
						
						var remVas = existingIndex.split("|"+ITEM_VAS+"|");
						removeVas(remVas[0],remVas[1]);						
						
					}
				
				}
			}
		}
	}
	this.removeItem = removeItem;

	function getCost(costType) {
		if (costType == COST_MONTHLY) {
			return selMonthlyCost;
		} else if (costType == COST_NOW) {
			return selNowCost;
		}
		return null;
	}
	this.getCost = getCost;

	function changeWidth(newWidth) {
		if (newWidth == DISPLAY_WIDE || newWidth == DISPLAY_NARROW) {
			currentWidth = "";
			getElement("sabMain").className = "sab"+newWidth;
			if (currentHeight > 0) {
				changeHeight(currentHeight);
			}
			if (newWidth == DISPLAY_NARROW) {
				hideElement("selHeaderWide");
				showElement("selHeaderNarrow");
				if (checkElement("bktHeaderWide") && checkElement("bktHeaderNarrow")) {
					hideElement("bktHeaderWide");
					showElement("bktHeaderNarrow");
				}
			} else {
				hideElement("selHeaderNarrow");
				showElement("selHeaderWide");
				if (checkElement("bktHeaderWide") && checkElement("bktHeaderNarrow")) {
					hideElement("bktHeaderNarrow");
					showElement("bktHeaderWide");
				}
			}
			currentWidth = newWidth;
			refreshDisplay();
		}
	}
	this.changeWidth = changeWidth;

	function changeHeight(newHeight) {
		var lCurrentWidth = (currentWidth != "") ? currentWidth : (getElement("sabMain").className == "sabNarrow") ? DISPLAY_NARROW : DISPLAY_WIDE;
		currentHeight = 0;
		newHeight = newHeight - tweakHeight[lCurrentWidth];
		newHeight = (newHeight < 200) ? 200 : newHeight;
		if (isGecko) {
			getElement("sabMid").style.minHeight = newHeight+"px";
		} else {
			getElement("sabMid").style.height = newHeight+"px";
		}
		if (currentWidth != "") {
			changeWidth(currentWidth);
		}
		currentHeight = newHeight + tweakHeight[lCurrentWidth];
		refreshDisplay();
	}
	this.changeHeight = changeHeight;

	function getDefaultActiveState() {
		return defaultActiveState;
	}
	this.getDefaultActiveState = getDefaultActiveState;

	function setDefaultActiveState(activeState) {
		if (activeState == STATE_ACTIVE || activeState == STATE_INACTIVE) {
			defaultActiveState = activeState;
		}
	}
	this.setDefaultActiveState = setDefaultActiveState;

	function refreshDisplay(selState) {
		if (fDebug) {
			alert('objSab: refreshDisplay('+selState+');');
		}
		if (selHst == null && selSvp == null && !areVas()) {
			selState = STATE_EMPTY;
		}
		if (selState == STATE_EMPTY) {
			setCost(0,COST_MONTHLY);
			setCost(0,COST_NOW);
			hideElement("selPlan");
			hideElement("selHandset");
			hideElement("selServices");
			hideElement("selAccessories");
			showElement("selEmpty");
			showElement("selBtnEmpty");
			hideElement("selBtnActive");
			getElement("selTotals").className = getElement("selTotals").className.replace("Active","Empty");
		} else {
			refreshCost(selMonthlyCost,COST_MONTHLY);
			refreshCost(selNowCost,COST_NOW);
			hideElement("selEmpty");
			getElement("selTotals").className = getElement("selTotals").className.replace("Empty","Active");
			if (selSvp != null) {
				showElement("selPlan");
			}
			if (selHst != null) {
				showElement("selHandset");
			}
			if (areVas()) {
				showElement("selServices");
			}
			if (areAcc()) {
				showElement("selAccessories");
			}
			if (selState == STATE_INACTIVE) {
				showElement("selBtnEmpty");
				hideElement("selBtnActive");
			} else if (selState == STATE_ACTIVE) {
				showElement("selBtnActive");
				hideElement("selBtnEmpty");
			}
		}
	}
	this.refreshDisplay = refreshDisplay;

	////////////////////////
	// internal functions //
	////////////////////////

	function getSvp() {
		return selSvp;
	}

	function setSvp(newSvp) {
		var decVal = 0;
		var index;
		if (selSvp) {
			index = selSvp+"|"+ITEM_SERVICEPLAN;
			decVal = getSelItem(index,idxMonthlyCost);
		}
		decrementCost(decVal,COST_MONTHLY);
		if (newSvp == null) {
			selSvp = 0;
			refreshSvp(selSvp);
		} else {
			var newIndex = newSvp+"|"+ITEM_SERVICEPLAN;
			if (selItem[newIndex] != null) {
				selSvp = newSvp;
				if (selItem[newIndex] != null) {
					incrementCost(getSelItem(newIndex,idxMonthlyCost),COST_MONTHLY);
				}
			}
		}
		refreshSvp(selSvp);
		if (selHst) {
			setHst(selHst);
		}
	}

	function getHst() {
		return selHst;
	}

	function setHst(newHst) {
		if (selHst) {
			decrementCost(selHstCost,COST_NOW);
		}
		if (newHst == null) {
			selHst = 0;
			selHstCost = 0;
		} else {
			var newIndex = newHst+"|"+ITEM_HANDSET;
			if (selItem[newIndex] != null) {
				selHst = newHst;
				if (selItem[newIndex] != null) {
					if (selSvp) {
						var svpIndex = selSvp+"|"+ITEM_SERVICEPLAN;
						selHstCost = getSelItem(svpIndex,idxNowCost);
					} else {
						selHstCost = getSelItem(newIndex,idxNowCost);
					}
					incrementCost(selHstCost,COST_NOW);
				}
			}
		}
		refreshHst(selHst);
	}

	function getAcc(accId) {
		for (index in selAcc) {
			var thisAcc = index.split("|"+ITEM_ACC);
			if (thisAcc[0] == accId) {
				return accId;
			}
		}
		return null;
	}

	function addAcc(accId) {
		var index = accId+"|"+ITEM_ACC;
		var compIndex = index+"|"+getSelItem(index,idxExtra);
		if (selItem[index] != null) {
			for (existingIndex in selAcc) {
				var remAcc = existingIndex.split("|"+ITEM_ACC);
				if (existingIndex == compIndex || remAcc[0] == accId) {
					removeAcc(accId);
				}
			}
			selAcc[compIndex] = accId;
			incrementCost(getSelItem(index,idxNowCost),COST_NOW)
			refreshAcc(accId,true);
		}
	}

	function removeAcc(accId) {
		var compIndex = accId+"|"+ITEM_ACC;
		var index = compIndex+"|null";
		if (selAcc[index] != null) {
			decrementCost(getSelItem(compIndex,idxNowCost),COST_NOW)
		}
		selAcc[index] = null;
		refreshAcc(accId,false);
	}

	function getVas(vasType) {
		for (index in selVas) {
			var thisVas = index.split("|"+ITEM_VAS+"|");
			if (thisVas[1] == vasType) {
				return thisVas[0];
			}
		}
		return null;
	}

	function addVas(vasId,vasType) {
		var index = vasId+"|"+ITEM_VAS;
		var compIndex = index+'|'+getSelItem(index,idxExtra);
		
		if (fDebug) {
			alert('vas id '+vasId+' vasType '+vasType+' index '+index+' compIndex '+compIndex+ ' selItem[index] '+selItem[index]);
		}
		
		if (selItem[index] != null) {
			for (existingIndex in selVas) {
				var remVas = existingIndex.split("|"+ITEM_VAS+"|");
				if (existingIndex == compIndex || remVas[1] == vasType) {
					var remVas = existingIndex.split("|"+ITEM_VAS+"|");
					removeVas(remVas[0],remVas[1]);
				}
			}
			selVas[compIndex] = new Array(vasId,vasType);
			if (getSelItem(index,idxMonthlyCost) != null) {
				if (fDebug) {
					alert('idxmonthlycost '+idxMonthlyCost+ COST_MONTHLY);
				}
				incrementCost(getSelItem(index,idxMonthlyCost),COST_MONTHLY);
			} else {
				if (fDebug) {
					alert('idxnewcost '+idxNowCost+ COST_NOW);
				}
				incrementCost(getSelItem(index,idxNowCost),COST_NOW);
			}
			refreshVas(vasId,vasType,true);
		}
	}

	function removeVas(vasId,vasType) {
		var compIndex = vasId+"|"+ITEM_VAS;
		var index = compIndex+"|"+vasType;
		if (selVas[index] != null) {
			selVas[index][0] = "";
			selVas[index][1] = 0;
			if (getSelItem(compIndex,idxMonthlyCost) != null) {
				decrementCost(getSelItem(compIndex,idxMonthlyCost),COST_MONTHLY);
			} else {
				decrementCost(getSelItem(compIndex,idxNowCost),COST_NOW);
			}
		}
		selVas[index] = null;
		refreshVas(vasId,vasType,false);
	}

	function incrementCost(newCost,costType) {
		if (fDebug) {
			alert('new cost '+ newCost+' costType '+costType);
		}
		//document.write(newCost);
		newCost = unFormatPrice(newCost);
		if (costType == COST_MONTHLY) {
			selMonthlyCost += newCost;
			selMonthlyCost = Math.round(selMonthlyCost*100)/100;
			//document.write(selMonthlyCost);
		} 
		else if (costType == COST_NOW) {
			selNowCost += newCost;
		}
		refreshCost(costType);
	}

	function decrementCost(newCost,costType) {
		newCost = unFormatPrice(newCost);
		if (costType == COST_MONTHLY) {
			selMonthlyCost -= newCost;
			selMonthlyCost = Math.round(selMonthlyCost*100)/100;
		} else if (costType == COST_NOW) {
			selNowCost -= newCost;
		}
		refreshCost(costType);
	}

	function setCost(newCost,costType) {
		newCost = unFormatPrice(newCost);
		if (costType == COST_MONTHLY) {
			selMonthlyCost = newCost;
		} else if (costType == COST_NOW) {
			selNowCost = newCost;
		}
		refreshCost(costType);
	}

	function refreshCost(costType) {
		if (costType == COST_MONTHLY) {
			if(getElement("selTotalMonthlyCost") && getElement("selTotalMonthlyCost").innerHTML){
				getElement("selTotalMonthlyCost").innerHTML = formatPrice(selMonthlyCost);
			}
		} else if (costType == COST_NOW) {
			if(getElement("selTotalNowCost") && getElement("selTotalNowCost").innerHTML){
				getElement("selTotalNowCost").innerHTML = formatPrice(selNowCost);
			}
		}
	}

	function refreshSvp(svpId) {
		var index = svpId+"|"+ITEM_SERVICEPLAN;
		var divSel = getElement("sabSelection");
		if (selItem[index] != null) {
			hideElement("selEmpty");
			getElement("selPlanDetail").innerHTML = getSelItem(index,idxDesc);
			getElement("selPlanExtra").innerHTML = getSelItem(index,idxExtra);
			getElement("selPlanCost").innerHTML = formatPrice(getSelItem(index,idxMonthlyCost));
			showElement("selPlan");

			if (objForm.elements["servicePlanId"] == null) {
				var divFld = document.createElement("div");
				divFld.id = "selFldSvp";
				divFld.className = "sabFormField";
				divSel.appendChild(divFld);
				var createElementStr = (isGecko) ? "input" : '<input name="servicePlanId">';
				var divInput = document.createElement(createElementStr);
				divInput.type = "hidden";
				divInput.name = "servicePlanId";
				divInput.value = svpId;
				divFld.appendChild(divInput);
			} else {
				objForm.elements["servicePlanId"].value = svpId;
			}
		} else {
			hideElement("selPlan");
			if (objForm.elements["servicePlanId"] != null) {
				divSel.removeChild(getElement("selFldSvp"));
			}
		}
		refreshDisplay();
	}

	function refreshHst(hstId) {
		var index = hstId+"|"+ITEM_HANDSET;
		var divSel = getElement("sabSelection");
		if (selItem[index] != null) {
			hideElement("selEmpty");
			getElement("selHandsetDetail").innerHTML = getSelItem(index,idxDesc);
			if (getSelItem(index,idxExtra) != null) {
				getElement("selHandsetImage").innerHTML = '<img src="'+getSelItem(index,idxExtra)+'" width="71" height="111" alt="'+getSelItem(index,idxDesc)+'" />';
				showElement("selHandsetImage");
			} else {
				hideElement("selHandsetImage");
			}
			getElement("selHandsetCost").innerHTML = formatPrice(selHstCost);
			showElement("selHandset");
			if (objForm.elements["handsetId"] == null) {
				var divFld = document.createElement("div");
				divFld.id = "selHstSvp";
				divFld.className = "sabFormField";
				divSel.appendChild(divFld);
				var createElementStr = (isGecko) ? "input" : '<input name="handsetId">';
				var divInput = document.createElement(createElementStr);
				divInput.type = "hidden";
				divInput.name = "handsetId";
				divInput.value = hstId;
				divFld.appendChild(divInput);
			}
			objForm.elements["handsetId"].value = hstId;
		} else {
			hideElement("selHandset");
			if (objForm.elements["handsetId"] != null) {
				divSel.removeChild(getElement("selFldHst"));
			}
		}
		refreshDisplay();
	}

	function refreshAcc(accId,fShow) {
		var index = accId+"|"+ITEM_ACC;
		var divAcc = getElement("selAccessories");
		var divThisId = "selAccessory"+accId;
		if (checkElement(divThisId)) {
			divAcc.removeChild(getElement(divThisId));
		}
		if (fShow) {
			hideElement("selEmpty");
			var divThis = document.createElement("div");
			divThis.id = divThisId;
			divThis.className = "sabItem";

			divAcc.appendChild(divThis);
			var divThisFld = document.createElement("div");
			divThisFld.id = "selFldAccessory"+accId;
			divThisFld.className = "sabFormField";
			divThis.appendChild(divThisFld);
			var createElementStr = (isGecko) ? "input" : '<input name="accessoryValues('+accId+')">';
			var divThisInput = document.createElement(createElementStr);
			divThisInput.type = "hidden";
			divThisInput.name = "accessoryValues("+accId+")";
			divThisInput.value = 1;
			divThisFld.appendChild(divThisInput);
			var divThisDetail = document.createElement("div");
			divThisDetail.id = "selAccessory"+accId+"Detail";
			divThisDetail.className = "sabDesc";
			divThisDetail.innerHTML = getSelItem(index,idxDesc);
			divThis.appendChild(divThisDetail);
			var divThisCost = document.createElement("div");
			divThisCost.id = "selAccessory"+accId+"Cost";
			divThisCost.className = "sabCost";
			divThisCost.innerHTML = formatPrice(getSelItem(index,idxNowCost));
			divThis.appendChild(divThisCost);
			var divClear1 = document.createElement("div");
			divClear1.className = "clear";
			divThis.appendChild(divClear1);
			var divClear2 = document.createElement("div");
			divClear2.className = "clear";
			divAcc.appendChild(divClear2);
		}
		if (areAcc()) {
			showElement("selAccessories");
		} else if (!alwaysShowAcc){
			hideElement("selAccessories");
		}
		refreshDisplay();
	}

	function refreshVas(vasId,vasType,fShow) {
		var index = vasId+"|"+ITEM_VAS;
		var divVas = getElement("selServices");
		var divThisId = "selService"+vasId;
		if (checkElement(divThisId)) {
			divVas.removeChild(getElement(divThisId));
		}
		if (fShow) {
			hideElement("selEmpty");
			var divThis = document.createElement("div");
			divThis.id = divThisId;
			divThis.className = "sabItem";
			divVas.appendChild(divThis);
			var divThisFld = document.createElement("div");
			divThisFld.id = "selFldService"+vasId;
			divThisFld.className = "sabFormField";
			divThis.appendChild(divThisFld);
			var createElementStr = (isGecko) ? "input" : '<input name="additionalServiceId('+vasType+')">';
			var divThisInput = document.createElement(createElementStr);
			divThisInput.type = "hidden";
			divThisInput.name = "additionalServiceId["+vasType+"]";
			divThisInput.value = vasId;
			divThisFld.appendChild(divThisInput);
			var divThisDetail = document.createElement("div");
			divThisDetail.id = "selService"+vasId+"Detail";
			divThisDetail.className = "sabDesc";
			divThisDetail.innerHTML = getSelItem(index,idxDesc);
			divThis.appendChild(divThisDetail);
			var divThisCost = document.createElement("div");
			divThisCost.id = "selService"+vasId+"Cost";
			divThisCost.className = "sabCost";
			if (getSelItem(index,idxMonthlyCost) != null) {
				divThisCost.innerHTML = formatPrice(getSelItem(index,idxMonthlyCost));
			} else {
				divThisCost.innerHTML = formatPrice(getSelItem(index,idxNowCost));
			}
			divThis.appendChild(divThisCost);
			var divClear1 = document.createElement("div");
			divClear1.className = "clear";
			divThis.appendChild(divClear1);
			var divClear2 = document.createElement("div");
			divClear2.className = "clear";
			divVas.appendChild(divClear2);
		}
		if (areVas()) {
			showElement("selServices");
		} else {
			hideElement("selServices");
		}
		refreshDisplay();
	}

	function checkElement(strId) {
		var obj = getElement(strId);
		if (obj != null) {
			return true;
		} else {
			return false;
		}
	}
	
	function showElement(strId) {
		var obj = getElement(strId);
		if (obj != null) {
			obj.style.display = "block";
		}
	}

	function hideElement(strId) {
		var obj = getElement(strId);
		if (obj != null) {
			obj.style.display = "none";
		}
	}

	// GET OBJECT BY ID
	function getElement(strId) {
		if (document.getElementById) {
			return document.getElementById(strId);
		} else if (document.all) {
			return document.all[strId];
		}
		return null;
	}

	/* FORMAT PRICE (WITHOUT FREE) */
	function formatPrice(price) {
		if (price != null) {
			price = price.toString();
			if (price == 0) {
				price = 'FREE';
			} else if (price.indexOf(".") == -1) {
				price = price+".00";
			} else if (price.indexOf(".") == price.length-2) {
				price = price+"0";
			} else if (price.indexOf(".") != -1) {
				price = price.substring(0,price.indexOf(".")+3);
			}
			price = (price == 'FREE') ? price : "&pound;"+price;
			return price;
		}
		return '';
	}

	function unFormatPrice(price) {
		if (price != null) {
			price = price.toString();
			price = price.replace(/\D/g,"");
			price = price / 100;
			return price;
		}
		return '';
	}

	function areAcc() {
		for (index in selAcc) {
			if (selAcc[index] != null) {
				return true;
			}
		}
		return false;
	}

	function areVas() {
		for (index in selVas) {
			if (selVas[index] != null) {
				return true;
			}
		}
		return false;
	}
	
	function getSelItem(index,subIndex) {
		if (selItem[index] != null) {
			if (selItem[index][subIndex] != null) {
				return selItem[index][subIndex];
			}
		}
		if (fDebug) {
			alert('objSab: selItem["'+index+'"]['+subIndex+'] does not exist');
		}
		return null;
	}

	return this;

}
