// JavaScript Document

function menuRoll(e) {
	e.src = e.src.substr(0,e.src.lastIndexOf('.')) + '-over.jpg';
}

function menuRollOut(e) {
	e.src = e.src.substr(0,e.src.lastIndexOf('-')) + '.jpg';
}

function labelCountry() {

	// retrieve the part of the world that the recycling label is for
	mLocation = location.href;

	// country id is the bit after the #
	
	// if there is no # in the address...
	if (mLocation.indexOf('#') == -1) {
		
		// tell the end user they've got here in the wrong way.
		alert ('You have not come to this page through the correct channels.\nPlease select your country.');
		// and send them back to the country selection page
		window.location.href = "../country/country.htm";
		return false;
	} else {
		// the label id is the part of the address after the #
		mLabelID = mLocation.substr(mLocation.lastIndexOf('#') + 1);
	}
	
	var mCountry;

	switch (mLabelID) {
		
		/* DELETE COUNTRIES FROM THIS LIST AS APPROPRIATE */
		/* LIST SHOULD CONTAIN ONLY COUNTRIES COVERED BY WEEE COLLECTION */

		case 'at': mCountry = 'Austria'; break;
		case 'frs': mCountry = 'France (South of Paris)'; break;
		case 'frn': mCountry = 'France (North of Paris)'; break;
		case 'de': mCountry = 'Germany'; break;
		case 'it': mCountry = 'Italy'; break;
		case 'esn': mCountry = 'Spain (North East Region)'; break;
		case 'ess': mCountry = 'Spain (South Region)'; break;
		case 'esr': mCountry = 'Spain (Rest of Spain)'; break;

		
		
		default:  
			// tell the end user they've got here in the wrong way.
			alert ('You have not come to this page through the correct channels.\nPlease select your country.');
			// and send them back to the country selection page
			window.location.href = "../country/country.htm";
			return false;
	}
	
	mCountryElem = document.getElementById('lCountry');
	mCountryOldText = mCountryElem.childNodes[0];
	
	var mCountryText = document.createTextNode(mCountry);
	
	mCountryElem.replaceChild(mCountryText, mCountryOldText);
	
	document.getElementById('requestedLabel').value = mCountry;
	document.title += ' ' + mCountry;
	
	
	if (mLabelID == 'uk') {
		document.getElementById('ukDoC').style.display = 'block';
	} else {
		document.getElementById('ukDoC').style.display = 'none';
	}

} 


function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
}

function rollOver(iImg) {
/***************************************************
	Function for rollover of the WEEE logos.
	Changes image to other precachaed image.
***************************************************/
	if (iImg.tagName == 'IMG') {
		mImgID = iImg.id
	} else {
		mImgID = iImg.id.slice(0,-1);
	}
	
	var mImg = document.getElementById(mImgID);
	mImg.src = document.mImgs[mImgID].src;
	
}

function rollOut(iImg) {
/***************************************************
	Function for rollover of the WEEE logos.
	Changes image to other precachaed image.
***************************************************/	
	if (iImg.tagName == 'IMG') {
		mImgID = iImg.id
	} else {
		mImgID = iImg.id.slice(0,-1);
	}
	
	var mImg = document.getElementById(mImgID);
	mImg.src = document.mImgs[mImgID + '_'].src;
	
}

function listSubmit() {
/***************************************************
	Function for checking that a country has been
	selected on the list only version of the 
	country selection page.
***************************************************/
	var mList = document.forms['countryChoice'].countryList;
	var tSelected = mList.selectedIndex;
	if (tSelected > -1) {
		var tCountryCode = mList.options[tSelected].value.slice(0,-1);
		var tPageRef = '../customer/cust' + tCountryCode + '.php';
	
		document.forms['countryChoice'].action = tPageRef;
		
		return 1;
	} else {
		rabbit = alert('Please select a country');
		return 0;
	}
}

function countryChange() {
	var mList = document.forms['countryChoice'].countryList;
	var tSelected = mList.selectedIndex;
	if (tSelected > -1) {
		var tCountryOption = mList.options[tSelected];
		mapOver(tCountryOption);
	}
}

function mapOver(e) {
	removeOldCountry();
	
	var countryID = e.id.slice(0,-1);
	var mOptIndex = document.getElementById(countryID + 'f').index;
	var mapHolder = document.getElementById('eui').parentNode;
	var mList = document.forms['countryChoice'].countryList;
	
	mStateI[countryID].className = "weeeRollMap";
	mapHolder.appendChild(mStateI[countryID]);
	mList.options[mOptIndex].selected = true;	
}

function removeOldCountry() {
	var mapHolder = document.getElementById('eui').parentNode;
	var mapImages = mapHolder.getElementsByTagName('img');
	if (mapImages.length > 2) {
		for (i = 2; i < mapImages.length; i++) {
			mapHolder.removeChild(mapImages[i]);
		}
	}
}

function setCellWidths(e, staticCols) {
	var mHeadCells = e.getElementsByTagName('th');
	var mHCSW = 0;
	if (staticCols) {
		for (i = 0; i < staticCols; i++) {
			mHCSW += mHeadCells[i].offsetWidth;
		}
	}
	var mHCRW = (e.offsetWidth - mHCSW) / (mHeadCells.length - staticCols);
/*	
	for (i = staticCols; i < mHeadCells.length; i++) {
		mHeadCells[i].style.width = mHCRW + 'px';
	}
*/
}

function setCellColours() {
	var mTables = document.getElementsByTagName('table');
	
	for (i = 0; i < mTables.length; i++) {
		var mTable = mTables[i];
		
		mTDs = mTable.getElementsByTagName('tbody')[0].getElementsByTagName('td');
		nRows = mTable.getElementsByTagName('tbody')[0].getElementsByTagName('tr').length;
		nCols = mTDs.length / nRows;
		
		if (document.styleSheets[1].rules) {
			mRules = document.styleSheets[1].rules;
		} else {
			mRules = document.styleSheets[1].cssRules;
		}
		
		nStyles = mRules.length;
		
		sLL = mRules[nStyles - 4].style.backgroundColor;
		sLD = mRules[nStyles - 3].style.backgroundColor;
		sDL = mRules[nStyles - 2].style.backgroundColor;
		sDD = mRules[nStyles - 1].style.backgroundColor;
		
		var x = 0, y = 0;
		
		while ((nCols * y + x) < mTDs.length) {
			nCell = nCols * y + x;
			if (y % 2 == 0) {
				if (x % 2 == 0) {
					mTDs[nCell].style.backgroundColor = sLL;
				} else {
					mTDs[nCell].style.backgroundColor = sLD;
				}
			} else {
				if (x % 2 != 0) {
					mTDs[nCell].style.backgroundColor = sDL;
				} else {
					mTDs[nCell].style.backgroundColor = sDD;
				}

			}
			x++;

			if (x % nCols == 0) {
				y++;
				x = 0;
			}
		}
	}
}

function logisticsTableWidths() {
	var mHR = document.getElementById('weeeLogisticsHR');
	setCellWidths(mHR, 0);
}

function dataTableWidths() {
	var mHR = document.getElementById('weeeDataHR');
	setCellWidths(mHR, 1);
}

function recyclerTableWidths() {
	var mHR = document.getElementById('weeeRecyclerHR');
	setCellWidths(mHR, 0);
}

function tableSize() {
/***************************************************
	Function for dynamically resizing tables.
	Called by the onload() event.
	Requires arguments to be passed.
	Arguments are to be passed as id of tableCells,
		number of columns, number of rows.
	The id of tableCells is a prefix for each tableCell
		and contained element that is part of the table
	Cell numbering for id is of the form:
		$prefix$columnNumber-$rowNumber
	The last contained element in the "cell" should 
		have the same id with a "p" suffix.
***************************************************/
	
	var thisCell, thisElem, mTabID;
	var mTab = 0;
	
	// need a browser that understands the W3C DOM
	if (document.getElementById) {

		// set variables for types of table, and cells for the tables
		document.mTables = new Array();
		document.mCells = new Array();
		
		// write the id prefixes of the tables into mTables array
		for (i = 0; i < arguments.length; i += 3) {
			document.mTables[mTab] = arguments[i];
			mTab++;
		}
		
		/*
			write the number of rows and columns for each table
			into an array of arrays
		*/
		for (i = 0; i < document.mTables.length; i++) {
			mCols = arguments[(3 * i) + 1];
			mRows = arguments[(3 * i) + 2];
			mTabID = document.mTables[i];
			document.mCells[mTabID] = new Array();
			document.mCells[mTabID][0] = mCols;
			document.mCells[mTabID][1] = mRows;
			
			/*
				for each table, add a set of cells and last elements
				contained by those cells to an array
			*/
			for (j = 0; j < mRows; j++) {
				for (k = 0; k < mCols; k++) {
					thisID = mTabID + k + '-' + j;
					thisCell = document.getElementById(thisID);
					
					if (thisCell) {
						thisElem = document.getElementById(thisID + 'p');
					}
					
					
					if (thisCell && thisElem) {
						document.mCells[mTabID][document.mCells[mTabID].length] = thisCell;
						document.mCells[mTabID][document.mCells[mTabID].length] = thisElem;
					}		
				}
			}
		}	
		
		// every 12 ms call the sizeChanged() function
		setInterval('sizeChanged()', 12);		
	}
}
						
function sizeChanged() {
	
	// if the window dimensions have changed from what is on record, calculate the new size of the table.
	// Will calculate the table size on first call as there is no record of previous dimensions.
	if (document.mCurrentHeight != document.body.offsetHeight || document.mCurrentWidth != document.body.offsetWidth) {
		sizeCalc();
	}
	
}

function sizeCalc() {
/***************************************************
	Function calculates the size of the cells for the
		tables registered by the tableSize() function.	
***************************************************/

	var mOffHt, mMaxHt = 0, mDelHt, mCols;
	
	// do this for each table
	for (i = 0; i < document.mTables.length; i++) {
		mTabID = document.mTables[i];	
		mCols = document.mCells[mTabID][0];
		mRows = document.mCells[mTabID][1];

		// then for each row in the table
		for (r = 0; r < mRows; r++) {
			
			// change the padding of the last element in the cell to 0px
			// this sizes the cell to its natural height
			for (j = (mCols * 2 * r + 2); j < (mCols * 2 * (r + 1) + 2); j+=2) {
				document.mCells[mTabID][j+1].style.paddingBottom = '0px';
			}
			
			// for each of the cells, check the height.
			// if it's the largest value so far, set mMaxHt
			for (j = (mCols * 2 * r + 2); j < (mCols * 2 * (r + 1) + 2); j+=2) {
				mOffHt = document.mCells[mTabID][j].offsetHeight;
				mMaxHt = (mOffHt > mMaxHt) ? mOffHt : mMaxHt;
			}
			
			// for each of the cells, calculate the difference between the 
			// cell height and the max height just calculated.
			// call the resizeCell() function with that height difference passed as an argument
			for (j = (mCols * 2 * r + 2); j < (mCols * 2 * (r + 1) + 2); j+=2) {
				mOffHt = document.mCells[mTabID][j].offsetHeight;
				if (mOffHt < mMaxHt) {
					mDelHt = mMaxHt - mOffHt;
					resizeCell(document.mCells[mTabID][j+1].id, 0, mDelHt)
				}
			}
			
			// reset the max height variable after performing calculations for each row.
			mMaxHt = 0;

		}
	}
	
	// make a record of the document dimensions that we've just done the calculations for.
	document.mCurrentHeight = document.body.offsetHeight;
	document.mCurrentWidth = document.body.offsetWidth;
}

function resizeCell(iCellElemID, iSetDelHt, iDelHt) {
/***************************************************
	Function resizes the cells for the
		tables registered by the tableSize() function.	
	Resizing is done by adding bottom padding to the
		last element contained by the cell.
***************************************************/

	// get the element to be resized
	mElem = document.getElementById(iCellElemID);
	// add the relevant amount of padding to the element.
	mElem.style.paddingBottom = iDelHt + 'px';

}


function removeSpaces(e) {
	var tstring = "";
	string = '' + e;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}

Array.prototype.indexOf = function (e) {
	
	var present = -1;
	for (var i = 0; i < this.length; i++) {
		if (removeSpaces(this[i].toLowerCase()) == removeSpaces(e.toLowerCase())) {
			present = i;
		}
	}
	return present;
};

function unique(a) {
	b = new Array();
	
	for (var i = 0; i < a.length; i++) {
		if (b.indexOf(a[i], 0) < 0) {
			b.push(a[i]);
		}
	}	
	return b;
}

function compare (a, b) {
	return a - b;
}


function checkProducts() {
/**************************************************
	function called by fCheck()
	Checks that valid product numbers have been
	supplied by the customer.
	Returns boolean: true = all products are valid.
**************************************************/
	var pList = document.getElementById('products').value;
	var regex = / *, */;
	var pEntered = pList.split(regex);
	var pValid = pNumber.join(',');
	pValid += ',';
		
//	rabbit = alert(pValid + '\n' + pList + '\n' + document.getElementById('products').value);
	
	pEntered = unique(pEntered);
	
	rFalse = false;
	var pSplice = new Array();
	
	errorMessage =  '';
	
	for (var i = 0; i < pEntered.length; i++) {
		var pHigh = new Array()
		pTemp = pEntered[i];
		
		for (var j = 0; j < pTemp.length; j++) {
			pHigh[j] = (pTemp.charCodeAt(j) > 127) ? true : false;
		}
				
		for (var j = 0; j < pHigh.length; j++) {
			if (pHigh[j]) {
				pCode = pTemp.charCodeAt(j);
				pTemp3 = pTemp.slice(j + 1);
				pTemp1 = (j !== 0) ? pTemp.substring(0,j) : '';
				pReplace = '&#';
				pReplace += pCode;
				pReplace += ';';
				pEntered[i] = pTemp1 + pReplace + pTemp3;
			}
		}		

//	rabbit = alert (pTemp + '\n' + pEntered[i]);

	while (pNumber.indexOf(pEntered[i]) == -1) {
	
		var resultArray = pEntered[i].match(/&#[0-9]{2,3};/g);
		if (resultArray) {
	  	for (j = 0; j < resultArray.length; j++) {
		  	var index = pEntered[i].indexOf(resultArray[j]);
				pCode = pEntered[i].substr(index+2,resultArray[j].length-3);
			
				pReplace = String.fromCharCode(pCode);
				p1 = pEntered[i].substring(0,index);
				p3 = pEntered[i].substring(index+resultArray[j].length);
			
				pPrompt = p1 + pReplace + p3;
			}
		} else {
			pPrompt = pEntered[i];
		}
	
		errorMessage = 'Incorrect product number: ' + pPrompt + '\n';
		errorMessage += 'Please correct or cancel it.'
		prompted = prompt(errorMessage, pPrompt);	
		if (prompted == null) {
			pEntered.splice(i, 1);
			pSplice[i] = true;
			rFalse = true;
		} else {
			pSplice[i] = false;
		//	rabbit = alert(prompted);

			var pHigh = new Array()
			pTemp = prompted;
			
			for (var j = 0; j < pTemp.length; j++) {
				pHigh[j] = (pTemp.charCodeAt(j) > 127) ? true : false;
			}
					
			pReplaced = false;
			for (var j = 0; j < pHigh.length; j++) {
				if (pHigh[j]) {
					pCode = pTemp.charCodeAt(j);
					pTemp3 = pTemp.slice(j + 1);
					pTemp1 = (j !== 0) ? pTemp.substring(0,j) : '';
					pReplace = '&#';
					pReplace += pCode;
					pReplace += ';';
					pEntered[i] = pTemp1 + pReplace + pTemp3;
					pReplaced = true;
				}
			}
			if (!pReplaced) pEntered[i] = prompted;
		}
		if (pSplice[i])
			break;
		}	
	}
	
	for (var j = 0; j < pEntered.length; j++) {
		if (pSplice[j]) {
			pEntered.splice(j, 1);
		}
	}
	
	pEntered = unique(pEntered);
	pEntered.sort(compare);
	var pNew = pEntered.join(', ');
	var resultArray = pNew.match(/&#[0-9]{2,3};/g);
	if (resultArray) {
	  for (i = 0; i < resultArray.length; i++) {
		  var index = pNew.indexOf(resultArray[i]);
			pCode = pNew.substr(index+2,resultArray[i].length-3);
			
			pReplace = String.fromCharCode(pCode);
			p1 = pNew.substring(0,index);
			p3 = pNew.substring(index+resultArray[i].length);
			
			pNew = p1 + pReplace + p3;
		}
	}
				
	document.getElementById('products').value = pNew;
	
	return rFalse;
	
}


function toggleVis(iObject, oGroup, iMode) {
/**************************************************
	Function toggles display of text box
	iObject is calling object
	oGroup is id of element containing textbox
	iMode is boolean corresponds to whether text box
		should be displayed when iObject is checked
**************************************************/	
  var mVisTag = ((iObject.checked) == (iMode)) ? "inline" : "none";
  var mTarget = document.getElementById(oGroup);
  mTarget.style.display = mVisTag;
  if (mVisTag == "none") {
    with (document.getElementById("recycleReasonDetail")) {
      value = defaultValue;
    }
  }
}


function detailCheck() {
	setInterval("toggleVis(document.getElementById('recycleReason3'), 'recycleReasonOther', true)", 10);
}

function emailCheck(iTestVal) {
/**************************************************
	function called by fCheck()
	Checks iTestVal input string against mFormat
	mFormat defines the allowed email address format
	Returns boolean: true = good email
**************************************************/
  var mFormat = /(^[a-z]([a-z_\-\.]*)@([a-z_\-\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\-\.]*)@([a-z_\-\.]*)(\.[a-z]{2,3})(\.[a-z]{2})*$)/i;
  return (mFormat.test(iTestVal));
}

function fConfirmReset() {
/**************************************************
	Function runs when form reset is actioned
	Sends confirmation message to user
	Will cancel resetting of form if answer is "no"
**************************************************/
  if (confirm('Are you sure you wish to clear the form?')) {
		document.getElementById('fReason').style.borderStyle = "none";
		document.getElementById('fPerformance').style.borderStyle = "none";
		document.getElementById('fSatisfaction').style.borderStyle = "none";
		return true;
	} else {
		return false;
	}
}


function fCheckSubmit() {
	
/**************************************************
	Function runs on submission of form
	Checks that all fields are filled with data
	Uses fCheck() to fill text boxes where necessary
	Highlights radio groups that need to be filled
	Cancels submission if outstanding data
***************************************************/

	var mForm = document.forms['fLabel'];
	mRecycle = mPerformance = mService = mDetail = false;
	
	for (var j = 0; j < mForm.elements.length; j++) {
		/*
			run fCheck() on all elements
			to make sure text fields
			are filled in correctly
		*/
		if (!fCheck(mForm.elements[j])) {
			return false;
		}
	}
	
	
	for (var i = 0; i < 3; i++) {
		/*
			Only three options for each radio group
			For each group, set tag to true if an
			option has been selected
		*/		
		if (!mRecycle) {
			mRecycle = mForm.elements['reason_for_recycling'][i].checked;
		}
		if (!mPerformance) {
			mPerformance = mForm.elements['product_performance_during_operational_life'][i].checked;
		}
		if (!mService) {
			mService = mForm.elements['satisfaction_with_service_during_operational_life'][i].checked;
		}
	}
	
	if (!mRecycle) {
		/*
			Has the recycle reason been given?
			If not, highlight the radio button group
		*/
		
		with (document.getElementById('fReason').style) {
			color = "red";
			borderWidth = "1px";
			borderStyle = "solid";
		}

	}

	if (!mPerformance) {
		/*
			Has the performance assessment been given?
			If not, highlight the radio button group
		*/
		with (document.getElementById('fPerformance').style) {
			color = "red";
			borderWidth = "1px";
			borderStyle = "solid";
		}
	}
	
	if (!mService) {
		/*
			Has the service assessment been given?
			If not, highlight the radio button group
		*/
			with (document.getElementById('fSatisfaction').style) {
			color = "red";
			borderWidth = "1px";
			borderStyle = "solid";
		}
	}
	
	if ((!mRecycle) || (!mPerformance) || (!mService)) {
		/*
			if any of the button groups don't have a selected option
			send a message to the user to complete them
			and then cancel the form submission
		*/
		alert('Please complete highlighted sections');

		return false;
	}
	
	// retrieve the part of the world that the recycling label is for
	mLocation = window.location.href;

	// country id is the bit after the #
	
	// if there is no # in the address...
	if (mLocation.indexOf('#') == -1) {
		
		// tell the end user they've got here in the wrong way.
		alert ('You have not come to this page through the correct channels.\nPlease select your country.');
		// and send them back to the country selection page
		window.location.href = "../country/country.htm";
		return false;
	} else {
		// the label id is the part of the address after the #
		mLabelID = window.location.hash.substr(1);
		
		// set the page location to the URI of the recycling label
		window.location.href = '../labels/label' + mLabelID.toLowerCase() + '.pdf';

		return true;
	}
	
}



function fCheck(iObject) {
/**************************************************
	Function checks that text fields are filled
	Uses emailCheck()to check that 
		email address is valid format
	Uses prompt boxes to require user to fill in 
		missing data.
	Prompts will continue until data is provided
***************************************************/	
  var mTestVal = iObject.value;
	var rFalse = false;

	bSwitch:

  switch (iObject.id) {
    case "user":
		// has a user's name been supplied?
      if ((mTestVal == "null") || (mTestVal == "")) {
        do {
					var mRetry = prompt('Please enter your name', '');
					if (mRetry != null) {
						// put the supplied name in the right place
						iObject.value = mRetry;
					} else {
						// or cancel the operation
						rFalse = true;
						break bSwitch;
					}
        } while ((iObject.value == "null") || (iObject.value == ""))
      }
      break;
    case "company":
		// has an end-user company been supplied?
      if ((mTestVal == "null") || (mTestVal == "")) {
        do {
					var mRetry = prompt('Please enter your company name', '');
					if (mRetry != null) {
						// put the supplied name in teh right place
						iObject.value = mRetry;
					} else {
						// or cancel the operation
						rFalse = true;
						break bSwitch;
					}
        } while ((iObject.value == "null") || (iObject.value == ""))
      }
      break;
    case "email":
		// has an email address been supplied?
      if (!emailCheck(mTestVal)) {
				// check for validity
        do {
					// ask for a new address until a valid one is supplied
					var mRetry = prompt('Please enter a valid email address', '');
					if (mRetry != null) {
	          if (emailCheck(mRetry)) {
							// put the valid address in the right place
  	          iObject.value = mRetry;
	          }
					} else {
						// or cancel the operation
						rFalse = true;
						break bSwitch;
					}
        } while (!emailCheck(iObject.value))
      }
      break;
		case "products":
		// have any products been specified?
			if ((mTestVal == "null") || (mTestVal == "")) {
        do {
					var mRetry = prompt('Please enter the products being recycled', '');
					// ask for the products
					if (mRetry != null) {
						// put them in the right place
						iObject.value = mRetry;
					} else {
						// or cancel
						rFalse = true;
						break bSwitch;
					}
        } while ((iObject.value == "null") || (iObject.value == ""))
      } else {
				rFalse = checkProducts();
				if (rFalse)
					break bSwitch;
			}
      break;
		case "recycleReasonDetail":
			// do we need to supply an "other" reason for recycling?
			if (iObject.form.elements['reason_for_recycling'][2].checked) {
				while ((iObject.value == null) || (iObject.value == "") || (iObject.value == "n/a")) {
					// prompt for a reason if there isn't one
					var mRetry = prompt('Please enter a reason for recycling', '');
					if (mRetry != null) {
						// put the reason in the right place
						iObject.value = mRetry;
					} else {
						// or cancel the operation
						rFalse = true;
						break bSwitch;
					}
				}
			}
			break;
    case "resellerName":
		// has a reseller name been provided?
      if ((mTestVal == null) || (mTestVal == "")) {
        do {
					// prompt for a reseller name
					var mRetry = prompt('Please enter the reseller\'s name', '');
					if (mRetry != null) {
						// put the reseller name in the right place
						iObject.value = mRetry;
					} else {
						// or cancel
						rFalse = true;
						break bSwitch;
					}
        } while ((iObject.value == null) || (iObject.value == ""))
      }
      break;
    case "resellerCity":
		// has a reseller city been provided
      if ((mTestVal == null) || (mTestVal == "")) {
        do {
					// prompt for reseller location
					var mRetry = prompt('Please enter the reseller\'s city / location', '');
					if (mRetry != null) {
						// put reseller location in the right place
						iObject.value = mRetry;
					} else {
						// or cancel the operation.
						rFalse = true;
						break bSwitch;
					}
        } while ((iObject.value == null) || (iObject.value == ""))
      }
      break;
    default:
      break;
  }
	
	if (rFalse) {
		// if a prompt has been cancelled somewhere, return false
		return false;
	} else {		
		// otherwise, carry on as usual
		return true;
	}
}
