//
// global variables for motor estimate
//
var qqprem = 0;



//
// global variable for LANSA partition
//
var partition = "ALL";
function setPartition(p) {
	partition = p;
}



//
// global variable for redirect URL
//
var redirect = false;
function setRedirect(val) {
	if (val == true || val == false)
		redirect = val;
}



//
// function to redirect the page
//
function Redirect(val) {
	if (redirect)
		document.location = val;
}



//
// global variable for call mode - this determines the Calculate button construction
// to make either an AJAX call or open a new window. Default is MODE_AJAX.
//
var call_mode = "MODE_AJAX";
function setCallMode(m) {
	// if MODE_WINDOW set this otherwise leave default (for default, blank, or invalid)
	if (m == "MODE_WINDOW") {
		call_mode = m;
	}
	else {
		call_mode = "MODE_AJAX";
	}
}



//
// function to open a quick quote popup
//
function QQPopUp(URL) {
	var strref = "QQ^URL=" + document.URL.substring(0,50);
	strref = strref.replace(/[^a-zA-Z 0-9/.:]+/g,'^');
	var strurl = document.referrer.substring(0,100);
	strurl = strurl.replace(/[^a-zA-Z 0-9/.:]+/g,'^');
	URL = URL + '+ASTREF(A1000):' + strref + '+ASTURL(A1000):' + strurl;
	var windowprops ="location=no,scrollbars=yes,menubars=no,toolbar=no,resizable=yes,status=yes,left=115,top=75,width=800,height=450";
	popup = window.open(URL,"MenuPopup",windowprops);
}





/******************************************* DISPLAY FUNCTIONS ********************************************************/

// boolean value to show existence of estimator object
var EXISTS_EST = false;



//
// function to add county dropdown
//
function addCountyDD(container, nameidArr) {
	addGenericDD(container, nameidArr, [["", "Please select"], ["29", "Carlow"], ["25", "Cavan"], ["26", "Clare"], ["27", "Cork City"], ["28", "Cork County"], ["30", "Donegal"], ["01", "Dublin 1"], ["02", "Dublin 2"], ["03", "Dublin 3"], ["04", "Dublin 4"], ["05", "Dublin 5"], ["06", "Dublin 6"], ["07", "Dublin 7"], ["08", "Dublin 8"], ["09", "Dublin 9"], ["10", "Dublin 10"], ["11", "Dublin 11"], ["12", "Dublin 12"], ["13", "Dublin 13"], ["14", "Dublin 14"], ["15", "Dublin 15"], ["16", "Dublin 16"], ["17", "Dublin 17"], ["18", "Dublin 18"], ["20", "Dublin 20"], ["22", "Dublin 22"], ["24", "Dublin 24"], ["23", "Dublin County"], ["32", "Galway City"], ["31", "Galway County"], ["40", "Kerry"], ["33", "Kildare - Celbridge"], ["34", "Kildare - Kilcock"], ["35", "Kildare - Leixlip"], ["21", "Kildare - Maynooth"], ["36", "Kildare - Naas"], ["37", "Kildare - Straffan"], ["38", "Kildare - Other"], ["39", "Kilkenny"], ["46", "Laois"], ["41", "Leitrim"], ["AG", "Limerick City"], ["43", "Limerick County"], ["44", "Longford"], ["45", "Louth"], ["53", "Mayo"], ["47", "Meath - Ashbourne"], ["48", "Meath - Clonee"], ["49", "Meath - Dunboyne"], ["50", "Meath - Dunshaughlin"], ["51", "Meath - Other"], ["52", "Monaghan"], ["54", "Offaly"], ["55", "Roscommon"], ["56", "Sligo"], ["57", "Tipperary"], ["58", "Waterford City"], ["59", "Waterford County"], ["60", "Westmeath"], ["61", "Wexford"], ["62", "Wicklow - Blessington"], ["63", "Wicklow - Bray"], ["64", "Wicklow - Greystones"], ["65", "Wicklow - Other"]]);
}
//
// function to add county dropdown for Motor
//
function addCountyDDMot(container, nameidArr) {
	addGenericDD(container, nameidArr, [["", "Please select"], ["29", "Carlow"], ["25", "Cavan"], ["26", "Clare"], ["27", "Cork City"], ["28", "Cork County"], ["30", "Donegal"], ["01", "Dublin 1"], ["02", "Dublin 2"], ["03", "Dublin 3"], ["04", "Dublin 4"], ["05", "Dublin 5"], ["06", "Dublin 6"], ["07", "Dublin 7"], ["08", "Dublin 8"], ["09", "Dublin 9"], ["10", "Dublin 10"], ["11", "Dublin 11"], ["12", "Dublin 12"], ["13", "Dublin 13"], ["14", "Dublin 14"], ["15", "Dublin 15"], ["16", "Dublin 16"], ["17", "Dublin 17"], ["18", "Dublin 18"], ["20", "Dublin 20"], ["22", "Dublin 22"], ["24", "Dublin 24"], ["23", "Dublin County"], ["32", "Galway City"], ["31", "Galway County"], ["40", "Kerry"], ["33", "Kildare - Celbridge"], ["34", "Kildare - Kilcock"], ["35", "Kildare - Leixlip"], ["21", "Kildare - Maynooth"], ["36", "Kildare - Naas"], ["37", "Kildare - Straffan"], ["38", "Kildare - Other"], ["39", "Kilkenny"], ["46", "Laois"], ["41", "Leitrim"], ["42", "Limerick City"], ["43", "Limerick County"], ["44", "Longford"], ["45", "Louth"], ["53", "Mayo"], ["47", "Meath - Ashbourne"], ["48", "Meath - Clonee"], ["49", "Meath - Dunboyne"], ["50", "Meath - Dunshaughlin"], ["51", "Meath - Other"], ["52", "Monaghan"], ["54", "Offaly"], ["55", "Roscommon"], ["56", "Sligo"], ["57", "Tipperary"], ["58", "Waterford City"], ["59", "Waterford County"], ["60", "Westmeath"], ["61", "Wexford"], ["62", "Wicklow - Blessington"], ["63", "Wicklow - Bray"], ["64", "Wicklow - Greystones"], ["65", "Wicklow - Other"]]);
}




//
// function to add Age dropdown
//
function addAgeDD(container) {
	var ageArr = new Array();
	ageArr[0] = new Array("", "Please select");
	for (var i=1; i<64; i++)
		ageArr[i] = new Array(i+17, i+17);
	for (var j=64; j<=83; j++)
		ageArr[j] = new Array(80, j+17);
	addGenericDD(container, ["AQAGE1", "AQAGE1"], ageArr);
}



//
// function to add a button
//
function addLinkButtons(container, product) {
	var div = document.createElement('div');
	div.id = "est_standardButtons";
	var ul = document.createElement('ul');
	var li = document.createElement('li');
	li.className = "menu1";
	var calc = document.createElement("a");
	var txt = document.createTextNode("Calculate");
	calc.appendChild(txt);
	calc.tabIndex = 0;
	calc.id = "Calculate_id";
	calc.onclick = function () {
		getQuickEstimate(product);
	}
	calc.onkeypress = function (e) {
	    var key; 
		if(window.event)
			key = window.event.keyCode; // IE
		else 
			key = e.which; //firefox 
		if (key==13 || key==32) {
			getQuickEstimate(product);
		}
	}
	li.appendChild(calc);
	ul.appendChild(li);
	if (call_mode == "MODE_AJAX") {
		var li2 = document.createElement('li');
		li2.className = "menu2";
		var calc2 = document.createElement("a");
		var txt2 = document.createTextNode("Quote");
		calc2.appendChild(txt2);
		calc2.tabIndex = 0;
		calc2.onkeypress = function (e) {
			var key; 
			if(window.event)
				key = window.event.keyCode; // IE
			else 
				key = e.which; //firefox 
			if (key==13 || key==32) {
				switch (product) {
				case 'Motor':
					QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+aprocmot+afnm02+Alz+funcparms+acoc(A0100):ADR');
					break;
				case 'Pet':
					QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+petproc01+ppfnlg+adi');
					break;
				case 'Travel':
					QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+aproctrv+afnt02+Alz+funcparms+acoc(A0100):TRV+asorc(A0030):ADR');
					break;
				case 'Household':
					QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+HRproc01+HRfnlg+adi');
					break;
				case 'Contents Only':
					QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+HRproc01+HRfnlg+adi');
					break;
				case 'Holiday Home':
					QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+HRproc01+HRfnlg+adi');
					break;
				case 'Landlord':
					QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+HRproc01+HRfnlg+adi');
					break;
				}
			}
		}
		calc2.onclick = function () {
			switch (product) {
			case 'Motor':
				QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+aprocmot+afnm02+Alz+funcparms+acoc(A0100):ADR');
				break;
			case 'Pet':
				QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+petproc01+ppfnlg+adi');
				break;
			case 'Travel':
				QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+aproctrv+afnt02+Alz+funcparms+acoc(A0100):TRV+asorc(A0030):ADR');
				break;
			case 'Household':
				QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+HRproc01+HRfnlg+adi');
				break;
			case 'Contents Only':
				QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+HRproc01+HRfnlg+adi');
				break;
			case 'Holiday Home':
				QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+HRproc01+HRfnlg+adi');
				break;
			case 'Landlord':
				QQPopUp('https://www.allianz.ie/CGI-BIN/lansaweb?procfun+HRproc01+HRfnlg+adi');
				break;
			}
		}
		li2.appendChild(calc2);
		ul.appendChild(li2);
	}
	div.appendChild(ul);
	container.appendChild(div);
}




//
// function to display a given estimator
//
function showEst(product, div) {
	destroyEst();
	if (!EXISTS_EST) {
		// main containers
		tease_div = document.createElement('div');
		tease_div.id = "est_portletquoteTeaser";
		// header division
		h_div = document.createElement('div');
		h_div.className = "est_portletHeaderHighlight";
		h_txt = document.createTextNode(product + " Estimator");
		h_div.innerHTML = "&nbsp; &nbsp;";
		h_div.appendChild(h_txt);
		tease_div.appendChild(h_div);
		// main div
		m_div = document.createElement('div');
		m_div.id = "est_portletQuoteCurtain";
		// empty text div
		t_div = document.createElement('div');
		t_div.id = "est_portletQuoteCurtainCol1";
		t_div.className = "est_termstext";
		t_txt = document.createTextNode("");
		t_div.appendChild(t_txt);
		// add the text div to the main div
		m_div.appendChild(t_div);
		// quote div
		var q_div = document.createElement('div');
		q_div.id = "est_fsuoteCurtainCol2";
		// create table and attributes
		var table = document.createElement("table");
		table.border = "0";
		table.id = "est_table";
		var tabBody = document.createElement("tbody");
		// add the note row to the table
		var row = document.createElement('tr');
		switch (call_mode) {
			case 'MODE_AJAX':
				addMultiColTextCell(row, "NB: This is a quick estimator and is based on your answers and some assumptions based on typical customer profiles. Estimates are only a rough guide and are not guaranteed. A quote is only guaranteed and confirmed when the quote system has been used. To do this click the 'Quote' button after getting an estimate.", 5);
				break;
			case 'MODE_WINDOW':
				addMultiColTextCell(row, "NB: This is a quick estimator and is based on your answers and some assumptions based on typical customer profiles. Estimates are only a rough guide and are not guaranteed. A quote is only guaranteed and confirmed when the quote system has been used. To do this click on 'Get Full Quote' after getting your estimate.", 5);
				break;
		}
		tabBody.appendChild(row);
		// add product specific dropdowns and buttons
		switch (product) {
			case 'Motor':
				setMotor(tabBody, table, q_div);
				break;
			case 'Pet':
				setPet(tabBody, table, q_div);
				break;
			case 'Household':
				setHou(tabBody, table, q_div);
				break;
			case 'Contents Only':
				setHouco(tabBody, table, q_div);
				break;
			case 'Holiday Home':
				setHol(tabBody, table, q_div);
				break;
			case 'Landlord':
				setLand(tabBody, table, q_div);
				break;
			case 'Travel':
				setTravel(tabBody, table, q_div);
				break;
		}
		// add the table to the form
		table.appendChild(tabBody);
		q_div.appendChild(table);
		// add buttons
		addLinkButtons(q_div, product);
		// add quote div to the main div
		m_div.appendChild(q_div);
		tease_div.appendChild(m_div);
		document.getElementById(div).appendChild(tease_div);
		EXISTS_EST = true;
	}
}



//
// function to add the motor specific dropdowns and buttons
//
function setMotor(tabBody, table, q_div) {
	// add the gender row to the table
	var row1 = document.createElement('tr');
	addTextCell(row1, "Gender: ");
	addGenericDD(getNewCell(row1), ["AGENDC1", "AGENDC1"], [["", "Please select"], ["M", "Male"], ["F", "Female"]]);
	addMultiRowTextCell(row1, "Press calculate to get your estimate", 5, 130);
	addMultiRowTextCell(row1, "", 5, 24);
	tabBody.appendChild(row1);
	// add the age row to the table
	var row2 = document.createElement('tr');
	addTextCell(row2, "Age: ");
	addAgeDD(getNewCell(row2));
	tabBody.appendChild(row2);
	// add the county row to the dropdown
	var row3 = document.createElement('tr');
	addTextCell(row3, "County: ");
	addCountyDDMot(getNewCell(row3), ["AQCOUNTY1", "AQCOUNTY1"]);
	tabBody.appendChild(row3);
	// add car type row the the dropdown
	var row4 = document.createElement('tr');
	addTextCell(row4, "Car Type: ");
	addGenericDD(getNewCell(row4), ["AQCART1", "AQCART1"], [["0", "Please select"], ["3", "Compact - Nissan Micra 1.0"], ["8", "Family - Toyota Corolla 1.4"], ["10", "Mid size family- Ford Focus 1.6"], ["12", "Full size - Toyota Avensis 1.8"], ["16", "Executive - BMW 318 2.0"]]);
	tabBody.appendChild(row4);
	// add ncd row to the table
	var row5 = document.createElement('tr');
	addTextCell(row5, "NCD: ");
	addGenericDD(getNewCell(row5), ["AQNCB1", "AQNCB1"], [["", "Please select"], ["1", "1 Year"], ["2", "2 Years"], ["3", "3 Years"], ["4", "4 Years"], ["5", "5 Years"], ["6", "6+ Years"]]);
	tabBody.appendChild(row5);
}



//
// function to add the pet specific dropdowns and buttons
//
function setPet(tabBody, table, q_div) {
	// add the pet type row to the table
	var row1 = document.createElement('tr');
	addTextCell(row1, "Pet Types: ");
	addGenericDD(getNewCell(row1), ["AAQPET", "AAQPET"], [["X", "Please Select"], ["CAT", "Cat"], ["DOG", "Dog"]]);
	addMultiRowTextCell(row1, "Premium Estimate is:", 5, 130);
	addMultiRowTextCell(row1, "", 5, 24);
	tabBody.appendChild(row1);
	// add the breed type row to the table
	var row2 = document.createElement('tr');
	addTextCell(row2, "Breed Type: ");
	addGenericDD(getNewCell(row2), ["AAQBRD", "AAQBRD"], [["X", "Please Select"], ["CBC", "Cross breed cat"], ["PEC", "Pedigree cat"], ["CBD", "Cross breed dog"], ["PED", "Pedigree dog"], ["BEU", "Special Breed: Beauceron"], ["BUD", "Special Breed: Bulldog"], ["DRH", "Special Breed: Deerhound"], ["DDB", "Special Breed: Dogue de Bourdeaux"], ["OES", "Special Breed: Old English Sheepdog"], ["AMB", "Special Breed: All Mastiff breeds"], ["AMD", "Special Breed: All mountain dogs"], ["NFL", "Special Breed: New Found Land"], ["SBR", "Special Breed: St.Bernard"], ["GRD", "Special Breed: Great Dane"], ["IWH", "Special Breed: Irish WOlf Hound"], ["LEO", "Special Breed: Leonberger"], ["SHP", "Special Breed: Shar-pei"]]);
	tabBody.appendChild(row2);
	// add the micro chipped row to the dropdown
	var row3 = document.createElement('tr');
	addTextCell(row3, "Micro Chipped: ");
	addGenericDD(getNewCell(row3), ["AAQMIC", "AAQMIC"], [["X", "Please Select"], ["Y", "Yes"], ["N", "No"]]);
	tabBody.appendChild(row3);
	// add owners age row the the dropdown
	var row4 = document.createElement('tr');
	addTextCell(row4, "Owners Age: ");
	addGenericDD(getNewCell(row4), ["AAQOWA", "AAQOWA"], [["X", "Please Select"], ["Y", "Under 60 Years"], ["N", "60 Years and over"]]);
	tabBody.appendChild(row4);
	// add pet age row to the table
	var row5 = document.createElement('tr');
	addTextCell(row5, "Pets Age: ");
	addGenericDD(getNewCell(row5), ["AAQPTA", "AAQPTA"], [["X", "Please Select"], ["A", "Up to 1 Year Old"], ["B", "Up to 2 Years Old"], ["C", "Up to 3 Years Old"], ["D", "Up to 4 Years Old"], ["E", "Up to 5 Years Old"], ["F", "Up to 6 Years Old"], ["G", "Up to 7 Years Old"], ["H", "Up to 8 Years Old"], ["N", "8 Years and over"]]);
	tabBody.appendChild(row5);
}



//
// function to add the household specific dropdowns and buttons
//
function setHou(tabBody, table, q_div) {
	// add the building sum insured row to the table
	var row1 = document.createElement('tr');
	addTextCell(row1, "Building Sum Insured: ");
	addGenericDD(getNewCell(row1), ["SLSBLSI", "LSBLSI_S"], [["0" , "Please select"], ["140000", "140,000"], ["145000", "145,000"], ["150000", "150,000"], ["155000", "155,000"], ["160000", "160,000"], ["165000", "165,000"], ["170000", "170,000"], ["175000", "175,000"], ["180000", "180,000"], ["185000", "185,000"], ["190000", "190,000"], ["195000", "195,000"], ["200000", "200,000"], ["205000", "205,000"], ["210000", "210,000"], ["215000", "215,000"], ["220000", "220,000"], ["225000", "225,000"], ["230000", "230,000"], ["235000", "235,000"], ["240000", "240,000"], ["245000", "245,000"], ["250000", "250,000"], ["260000", "260,000"], ["270000", "270,000"], ["280000", "280,000"], ["290000", "290,000"], ["300000", "300,000"], ["310000", "310,000"], ["320000", "320,000"], ["330000", "330,000"], ["340000", "340,000"], ["350000", "350,000"], ["360000", "360,000"], ["370000", "370,000"], ["380000", "380,000"], ["390000", "390,000"], ["400000", "400,000"], ["410000", "410,000"], ["420000", "420,000"], ["430000", "430,000"], ["440000", "440,000"], ["450000", "450,000"], ["475000", "475,000"], ["500000", "500,000"], ["525000", "525,000"], ["550000", "550,000"], ["575000", "575,000"], ["600000", "600,000"], ["625000", "625,000"], ["635000", "635,000"]]);
	addMultiRowTextCell(row1, "Premium Estimate is:", 5, 130);
	addMultiRowTextCell(row1, "", 5, 24);
	tabBody.appendChild(row1);
	// add the contents sum insured row to the table
	var row2 = document.createElement('tr');
	addTextCell(row2, "Contents Sum Insured: ");
	addGenericDD(getNewCell(row2), ["SWKCSIN", "LWKCSIN"], [["0", "Please select"], ["10", "10%"], ["11", "11%"], ["12", "12%"], ["13", "13%"], ["14", "14%"], ["15", "15%"], ["16", "16%"], ["17", "17%"], ["18", "18%"], ["19", "19%"], ["20", "20%"], ["21", "21%"], ["22", "22%"], ["23", "23%"], ["24", "24%"], ["25", "25%"], ["26", "26%"], ["27", "27%"], ["28", "28%"], ["29", "29%"], ["30", "30%"], ["31", "31%"], ["32", "32%"], ["33", "33%"], ["34", "34%"], ["35", "35%"], ["36", "36%"], ["37", "37%"], ["38", "38%"], ["39", "39%"], ["40", "40%"], ["41", "41%"], ["42", "42%"], ["43", "43%"], ["44", "44%"], ["45", "45%"], ["46", "46%"], ["47", "47%"], ["48", "48%"], ["49", "49%"], ["50", "50%"]]);
	tabBody.appendChild(row2);
	// add the area row to the dropdown
	var row3 = document.createElement('tr');
	addTextCell(row3, "Area: ");
	addCountyDD(getNewCell(row3), ["AHRLOCC", "HRLOCC_S"]);
	tabBody.appendChild(row3);
	// add accidental damage row the the dropdown
	var row4 = document.createElement('tr');
	addTextCell(row4, "Accidental Damage: ");
	addGenericDD(getNewCell(row4), ["AWKADCR", "WKADCR_S"], [["", "Please select"], ["YES", "Yes on contents"], ["NO", "No on contents"]]);
	tabBody.appendChild(row4);
	// add age row to the table
	var row5 = document.createElement('tr');
	addTextCell(row5, "Age: ");
 	addGenericDD(getNewCell(row5), ["AWKAGEN", "WKAGEN_S"], [["", "Please select"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"], ["32", "32"], ["33", "33"], ["34", "34"], ["35", "35"], ["36", "36"], ["37", "37"], ["38", "38"], ["39", "39"], ["40", "40"], ["41", "41"], ["42", "42"], ["43", "43"], ["44", "44"], ["45", "45"], ["46", "46"], ["47", "47"], ["48", "48"], ["49", "49"], ["50", "50"], ["51", "51"], ["52", "52"], ["53", "53"], ["54", "54"], ["55", "55"], ["56", "56"], ["57", "57"], ["58", "58"], ["59", "59"], ["60", "60"], ["61", "61"], ["62", "62"], ["63", "63"], ["64", "64"], ["65", "65"], ["66", "66"], ["67", "67"], ["68", "68"], ["69", "69"], ["70", "70"], ["71", "71"], ["72", "72"], ["73", "73"], ["74", "74"], ["75", "75"], ["76", "76"], ["77", "77"], ["78", "78"], ["79", "79"], ["80", "80"]]);
	tabBody.appendChild(row5);
}


//
// function to add the contents only specific dropdowns and buttons
//
function setHouco(tabBody, table, q_div) {
	// add the contents sum insured row to the table
	var row1 = document.createElement('tr');
	addTextCell(row1, "Contents Sum Insured: ");
	addGenericDD(getNewCell(row1), ["SLSCTSI", "LSCTSI_C"], [["0", "Please select"], ["20000", "20,000"], ["25000", "25,000"], ["30000", "30,000"], ["35000", "35,000"], ["40000", "40,000"], ["45000", "45,000"], ["50000", "50,000"], ["55000", "55,000"], ["60000", "60,000"], ["65000", "65,000"], ["70000", "70,000"], ["75000", "75,000"], ["80000", "80,000"], ["85000", "85,000"], ["90000", "90,000"], ["95000", "95,000"], ["100000", "100,000"], ["105000", "105,000"], ["110000", "110,000"], ["115000", "115,000"], ["120000", "120,000"], ["125000", "125,000"], ["130000", "130,000"], ["135000", "135,000"], ["140000", "140,000"], ["145000", "145,000"], ["150000", "150,000"]]);
	addMultiRowTextCell(row1, "Premium Estimate is:", 5, 130);
	addMultiRowTextCell(row1, "", 5, 24);
	tabBody.appendChild(row1);
	// add the area row to the dropdown
	var row3 = document.createElement('tr');
	addTextCell(row3, "Area: ");
	addCountyDD(getNewCell(row3), ["AHRLOCC", "HRLOCC_C"]);
	tabBody.appendChild(row3);
	// add accidental damage row the the dropdown
	var row4 = document.createElement('tr');
	addTextCell(row4, "Accidental Damage: ");
	addGenericDD(getNewCell(row4), ["AWKADCR", "WKADCR_C"], [["", "Please select"], ["YES", "Yes on contents"], ["NO", "No on contents"]]);
	tabBody.appendChild(row4);
	// add age row to the table
	var row5 = document.createElement('tr');
	addTextCell(row5, "Age: ");
 	addGenericDD(getNewCell(row5), ["AWKAGEN", "WKAGEN_C"], [["", "Please select"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"], ["32", "32"], ["33", "33"], ["34", "34"], ["35", "35"], ["36", "36"], ["37", "37"], ["38", "38"], ["39", "39"], ["40", "40"], ["41", "41"], ["42", "42"], ["43", "43"], ["44", "44"], ["45", "45"], ["46", "46"], ["47", "47"], ["48", "48"], ["49", "49"], ["50", "50"], ["51", "51"], ["52", "52"], ["53", "53"], ["54", "54"], ["55", "55"], ["56", "56"], ["57", "57"], ["58", "58"], ["59", "59"], ["60", "60"], ["61", "61"], ["62", "62"], ["63", "63"], ["64", "64"], ["65", "65"], ["66", "66"], ["67", "67"], ["68", "68"], ["69", "69"], ["70", "70"], ["71", "71"], ["72", "72"], ["73", "73"], ["74", "74"], ["75", "75"], ["76", "76"], ["77", "77"], ["78", "78"], ["79", "79"], ["80", "80"]]);
	tabBody.appendChild(row5);
}



//
// function to add the holiday home specific dropdowns and buttons
//
function setHol(tabBody, table, q_div) {
	// add the building sum insured row to the table
	var row1 = document.createElement('tr');
	addTextCell(row1, "Building Sum Insured: ");
	addGenericDD(getNewCell(row1), ["SLSBLSI", "LSBLSI_H"], [["0", "Please select"], ["140000", "140,000"], ["145000", "145,000"], ["150000", "150,000"], ["155000", "155,000"], ["160000", "160,000"], ["165000", "165,000"], ["170000", "170,000"], ["175000", "175,000"], ["180000", "180,000"], ["185000", "185,000"], ["190000", "190,000"], ["195000", "195,000"], ["200000", "200,000"], ["205000", "205,000"], ["210000", "210,000"], ["215000", "215,000"], ["220000", "220,000"], ["225000", "225,000"], ["230000", "230,000"], ["235000", "235,000"], ["240000", "240,000"], ["245000", "245,000"], ["250000", "250,000"], ["260000", "260,000"], ["270000", "270,000"], ["280000", "280,000"], ["290000", "290,000"], ["300000", "300,000"], ["310000", "310,000"], ["320000", "320,000"], ["330000", "330,000"], ["340000", "340,000"], ["350000", "350,000"], ["360000", "360,000"], ["370000", "370,000"], ["380000", "380,000"], ["390000", "390,000"], ["400000", "400,000"], ["410000", "410,000"], ["420000", "420,000"], ["430000", "430,000"], ["440000", "440,000"], ["450000", "450,000"], ["475000", "475,000"], ["500000", "500,000"], ["525000", "525,000"], ["550000", "550,000"], ["575000", "575,000"], ["600000", "600,000"], ["625000", "625,000"], ["635000", "635,000"]]);
	addMultiRowTextCell(row1, "Premium Estimate is:", 5, 130);
	addMultiRowTextCell(row1, "", 5, 24);
	tabBody.appendChild(row1);
	// add the contents sum insured row to the table
	var row2 = document.createElement('tr');
	addTextCell(row2, "Contents Sum Insured: ");
	addGenericDD(getNewCell(row2), ["SLSCTSI", "LSCTSI_H"], [["0", "Please select"], ["20000", "20,000"], ["25000", "25,000"], ["30000", "30,000"], ["35000", "35,000"], ["40000", "40,000"], ["45000", "45,000"], ["50000", "50,000"], ["55000", "55,000"], ["60000", "60,000"], ["65000", "65,000"], ["70000", "70,000"], ["75000", "75,000"], ["80000", "80,000"], ["85000", "85,000"], ["90000", "90,000"], ["95000", "95,000"], ["100000", "100,000"], ["105000", "105,000"], ["110000", "110,000"], ["115000", "115,000"], ["120000", "120,000"], ["125000", "125,000"]]);
	tabBody.appendChild(row2);
	// add the area row to the dropdown
	var row3 = document.createElement('tr');
	addTextCell(row3, "Area: ");
	addCountyDD(getNewCell(row3), ["AHRLOCC", "HRLOCC_H"]);
	tabBody.appendChild(row3);
	// add age row to the table
	var row5 = document.createElement('tr');
	addTextCell(row5, "Age: ");
 	addGenericDD(getNewCell(row5), ["AWKAGEN", "WKAGEN_H"], [["", "Please select"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"], ["32", "32"], ["33", "33"], ["34", "34"], ["35", "35"], ["36", "36"], ["37", "37"], ["38", "38"], ["39", "39"], ["40", "40"], ["41", "41"], ["42", "42"], ["43", "43"], ["44", "44"], ["45", "45"], ["46", "46"], ["47", "47"], ["48", "48"], ["49", "49"], ["50", "50"], ["51", "51"], ["52", "52"], ["53", "53"], ["54", "54"], ["55", "55"], ["56", "56"], ["57", "57"], ["58", "58"], ["59", "59"], ["60", "60"], ["61", "61"], ["62", "62"], ["63", "63"], ["64", "64"], ["65", "65"], ["66", "66"], ["67", "67"], ["68", "68"], ["69", "69"], ["70", "70"], ["71", "71"], ["72", "72"], ["73", "73"], ["74", "74"], ["75", "75"], ["76", "76"], ["77", "77"], ["78", "78"], ["79", "79"], ["80", "80"]]);
	tabBody.appendChild(row5);
}



//
// function to add the landlordspecific dropdowns and buttons
//
function setLand(tabBody, table, q_div) {
	// add the building sum insured row to the table
	var row1 = document.createElement('tr');
	addTextCell(row1, "Building Sum Insured: ");
	addGenericDD(getNewCell(row1), ["SLSBLSI", "LSBLSI_L"], [["0", "Please select"], ["140000", "140,000"], ["145000", "145,000"], ["150000", "150,000"], ["155000", "155,000"], ["160000", "160,000"], ["165000", "165,000"], ["170000", "170,000"], ["175000", "175,000"], ["180000", "180,000"], ["185000", "185,000"], ["190000", "190,000"], ["195000", "195,000"], ["200000", "200,000"], ["205000", "205,000"], ["210000", "210,000"], ["215000", "215,000"], ["220000", "220,000"], ["225000", "225,000"], ["230000", "230,000"], ["235000", "235,000"], ["240000", "240,000"], ["245000", "245,000"], ["250000", "250,000"], ["260000", "260,000"], ["270000", "270,000"], ["280000", "280,000"], ["290000", "290,000"], ["300000", "300,000"], ["310000", "310,000"], ["320000", "320,000"], ["330000", "330,000"], ["340000", "340,000"], ["350000", "350,000"], ["360000", "360,000"], ["370000", "370,000"], ["380000", "380,000"], ["390000", "390,000"], ["400000", "400,000"], ["410000", "410,000"], ["420000", "420,000"], ["430000", "430,000"], ["440000", "440,000"], ["450000", "450,000"], ["475000", "475,000"], ["500000", "500,000"], ["525000", "525,000"], ["550000", "550,000"], ["575000", "575,000"], ["600000", "600,000"], ["625000", "625,000"], ["635000", "635,000"]]);
	addMultiRowTextCell(row1, "Premium Estimate is:", 5, 130);
	addMultiRowTextCell(row1, "", 5, 24);
	tabBody.appendChild(row1);
	// add the contents sum insured row to the table
	var row2 = document.createElement('tr');
	addTextCell(row2, "Contents Sum Insured: ");
	addGenericDD(getNewCell(row2), ["SLSCTSI", "LSCTSI_L"], [["0", "Please select"], ["20000", "20,000"], ["25000", "25,000"], ["30000", "30,000"], ["35000", "35,000"], ["40000", "40,000"], ["45000", "45,000"], ["50000", "50,000"], ["55000", "55,000"], ["60000", "60,000"], ["65000", "65,000"], ["70000", "70,000"], ["75000", "75,000"], ["80000", "80,000"], ["85000", "85,000"], ["90000", "90,000"], ["95000", "95,000"], ["100000", "100,000"], ["105000", "105,000"], ["110000", "110,000"], ["115000", "115,000"], ["120000", "120,000"], ["125000", "125,000"]]);
	tabBody.appendChild(row2);
	// add the area row to the dropdown
	var row3 = document.createElement('tr');
	addTextCell(row3, "Area: ");
	addCountyDD(getNewCell(row3), ["AHRLOCC", "HRLOCC_L"]);
	tabBody.appendChild(row3);
	// add age row to the table
	var row5 = document.createElement('tr');
	addTextCell(row5, "Age: ");
 	addGenericDD(getNewCell(row5), ["AWKAGEN", "WKAGEN_L"], [["", "Please select"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"], ["32", "32"], ["33", "33"], ["34", "34"], ["35", "35"], ["36", "36"], ["37", "37"], ["38", "38"], ["39", "39"], ["40", "40"], ["41", "41"], ["42", "42"], ["43", "43"], ["44", "44"], ["45", "45"], ["46", "46"], ["47", "47"], ["48", "48"], ["49", "49"], ["50", "50"], ["51", "51"], ["52", "52"], ["53", "53"], ["54", "54"], ["55", "55"], ["56", "56"], ["57", "57"], ["58", "58"], ["59", "59"], ["60", "60"], ["61", "61"], ["62", "62"], ["63", "63"], ["64", "64"], ["65", "65"], ["66", "66"], ["67", "67"], ["68", "68"], ["69", "69"], ["70", "70"], ["71", "71"], ["72", "72"], ["73", "73"], ["74", "74"], ["75", "75"], ["76", "76"], ["77", "77"], ["78", "78"], ["79", "79"], ["80", "80"]]);
	tabBody.appendChild(row5);
}



//
// function to add the travel specific dropdowns and buttons
//
function setTravel(tabBody, table, q_div) {
	// add the age row to the table
	var row1 = document.createElement('tr');
	addTextCell(row1, "Age: ");
	addGenericDD(getNewCell(row1), ["AQAGE", "AQAGE_T"], [["X", "Please Select"], ["A", "18-49"], ["B", "50-59"], ["C", "60-64"], ["D", "65"], ["E", "66"], ["F", "67"], ["G", "68"], ["H", "69"], ["I", "70"], ["J", "71"], ["K", "72"], ["L", "73"], ["M", "74"], ["N", "75"], ["O", "76-99"]]);
	addMultiRowTextCell(row1, "Premium Estimate is:", 5, 130);
	addMultiRowTextCell(row1, "", 5, 24);
	tabBody.appendChild(row1);
	// add the who is ot be insured row to the table
	var row2 = document.createElement('tr');
	addTextCell(row2, "Who is to be insured: ");
	addGenericDD(getNewCell(row2), ["AQWHO", "AQWHO_T"], [["X", "Please Select"], ["A", "Insured Only"], ["B", "Individual " + "\u0026" + " Spouse/Partner"], ["C", "Insured " + "\u0026" + " Family"], ["D", "Individual, Partner " + "\u0026" + " Family"]]);
	tabBody.appendChild(row2);
	// add the geography row to the dropdown
	var row3 = document.createElement('tr');
	addTextCell(row3, "Geography: ");
	addGenericDD(getNewCell(row3), ["AQGEO", "AQGEO_T"], [["X", "Please Select"], ["A", "Europe Only"], ["B", "Worldwide Incl USA/Canada/Caribbean"], ["C", "Worldwide Excl USA/Canada/Caribbean"]]);
	tabBody.appendChild(row3);
	// add optional extras row the the dropdown
	var row4 = document.createElement('tr');
	addTextCell(row4, "Optional extras: ");
	addGenericDD(getNewCell(row4), ["AQOPE", "AQOPE_T"], [["X","Please Select"], ["A", "Winter Sports Cover"], ["B", "Winter Sports Equipment"], ["C", "Golf Extension"], ["D", "All Of The Above"], ["F", "Winter Sports " + "\u0026" + " Winter Sports Equipment"], ["G", "Winter Sports " + "\u0026" + " Golf Cover"], ["E", "None Of The Above"]]);
	tabBody.appendChild(row4);
	// add allianz policyholder row to the table
	var row5 = document.createElement('tr');
	addTextCell(row5, "Journey Duration: ");
	addGenericDD(getNewCell(row5), ["AQCUR", "AQCUR_T"], [["X", "Please Select"], ["A", "Up To 35 Days"], ["B", "Up To 60 Days"], ["C", "Up To 90 Days"]]);
	tabBody.appendChild(row5);
}



// function to list all child objects in the motor div
function destroyEst() {
	if (EXISTS_EST) {
		while (document.getElementById('est_portletquoteTeaser').childNodes.length > 0) {
			traverseDomTree_recurse(document.getElementById('est_portletquoteTeaser'), 0);
		}
		document.getElementById('est_portletquoteTeaser').parentNode.removeChild(document.getElementById('est_portletquoteTeaser'));
		EXISTS_EST = false;
	}
}



//
// function to get an estimate
//
function getQuickEstimate(product) {
	if (call_mode == "MODE_AJAX") {
		switch (product) {
			case 'Motor':
				var ret = sendQEAjaxRequest('/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN02+'+partition+'+funcparms+WKSC(A0010):+WKGE(A0010):'+document.getElementById('AGENDC1').value+'+WKAG(S0030):'+document.getElementById('AQAGE1').value+'+WKAR(A0020):'+document.getElementById('AQCOUNTY1').value+'+WKGP(S0020):'+document.getElementById('AQCART1').value+'+WKNC(S0020):'+document.getElementById('AQNCB1').value, product);
				break;
			case 'Pet':
				var ret = sendQEAjaxRequest('/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN05+'+partition+'+funcparms+AQPET(A0030):'+document.getElementById('AAQPET').value+'+AQBRD(A0030):'+document.getElementById('AAQBRD').value+'+AQMIC(A0010):'+document.getElementById('AAQMIC').value+'+AQOWA(A0010):'+document.getElementById('AAQOWA').value+'+AQPTA(A0010):'+document.getElementById('AAQPTA').value, product);
				break;
			case 'Travel':
				var ret = sendQEAjaxRequest('/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN04+'+partition+'+funcparms+WKSC(A0010):+AQAGE(A0010):'+document.getElementById('AQAGE_T').value+'+AQWHO(A0010):'+document.getElementById('AQWHO_T').value+'+AQGEO(A0010):'+document.getElementById('AQGEO_T').value+'+AQOPE(A0010):'+document.getElementById('AQOPE_T').value+'+AQCUR(A0010):'+document.getElementById('AQCUR_T').value, product);
				break;
			case 'Household':
				var ret = sendQEAjaxRequest('/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN03+'+partition+'+funcparms+WKCOVC(A0030):BAC+HRPROD(A0030):DCR+ASTRS(A0030):ROI+WKSC(A0010):+LSBLSI(S0070):'+document.getElementById('LSBLSI_S').value+'+WKCSIN(S0020):'+document.getElementById('LWKCSIN').value+'+HRLOCC(A0020):'+document.getElementById('HRLOCC_S').value+'+WKADCR(A0030):'+document.getElementById('WKADCR_S').value+'+WKAGEN(P0030):'+document.getElementById('WKAGEN_S').value, product);
				break;
			case 'Contents Only':
				var ret = sendQEAjaxRequest('/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN03+'+partition + '+funcparms+WKCOVC(A0030):BAC+HRPROD(A0030):DHR+ASTRS(A0030):ROI+WKSC(A0010):+LSBLSI(S0070):0+LSCTSI(S0070):'+document.getElementById('LSCTSI_C').value+'+HRLOCC(A0020):'+document.getElementById('HRLOCC_C').value+'+WKADCR(A0030):'+document.getElementById('WKADCR_C').value+'+WKAGEN(P0030):'+document.getElementById('WKAGEN_C').value, product);
				break;
			case 'Holiday Home':
				var ret = sendQEAjaxRequest('/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN03+'+partition+'+funcparms+WKCOVC(A0030):HBC+HRPROD(A0030):DHR+ASTRS(A0030):ROI+WKSC(A0010):+LSBLSI(S0070):'+document.getElementById('LSBLSI_H').value+'+LSCTSI(S0070):'+document.getElementById('LSCTSI_H').value+'+HRLOCC(A0020):'+document.getElementById('HRLOCC_H').value+'+WKAGEN(P0030):'+document.getElementById('WKAGEN_H').value, product);
				break;
			case 'Landlord':
				var ret = sendQEAjaxRequest('/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN03+'+partition+'+funcparms+WKCOVC(A0030):LBC+HRPROD(A0030):DHR+ASTRS(A0030):ROI+WKSC(A0010):+HROCCU(A0020):L1+LSBLSI(S0070):'+document.getElementById('LSBLSI_L').value+'+LSCTSI(S0070):'+document.getElementById('LSCTSI_L').value+'+HRLOCC(A0020):'+document.getElementById('HRLOCC_L').value+'+WKAGEN(P0030):'+document.getElementById('WKAGEN_L').value, product);
				break;
			default:
				document.getElementById('calc_result').innerHTML ="An error has occurred. No product selected.";
				break;
		}
	}
	if (call_mode == "MODE_WINDOW") {
		switch (product) {
			case 'Motor':
				if (document.getElementById('AGENDC1').value != '' && document.getElementById('AQAGE1').value != '' && document.getElementById('AQCOUNTY1').value != '' && document.getElementById('AQCART1').value != 0 && document.getElementById('AQNCB1').value != '') {
					Redirect('/Estimators/?QE=HOU');
					var ret = window.open('https://www.allianz.ie/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN02+'+partition+'+funcparms+WKSC(A0010):S+WKGE(A0010):'+document.getElementById('AGENDC1').value+'+WKAG(S0030):'+document.getElementById('AQAGE1').value+'+WKAR(A0020):'+document.getElementById('AQCOUNTY1').value+'+WKGP(S0020):'+document.getElementById('AQCART1').value+'+WKNC(S0020):'+document.getElementById('AQNCB1').value+'+ACOC(A0100):ADR');
				} else {
					alert("Please answer all questions");
				}
				break;
			case 'Pet':
				var ret = window.open('https://www.allianz.ie/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN05+'+partition+'+funcparms+AQPET(A0030):'+document.getElementById('AAQPET').value+'+AQBRD(A0030):'+document.getElementById('AAQBRD').value+'+AQMIC(A0010):'+document.getElementById('AAQMIC').value+'+AQOWA(A0010):'+document.getElementById('AAQOWA').value+'+AQPTA(A0010):'+document.getElementById('AAQPTA').value);
				break;
			case 'Travel':
				if (document.getElementById('AQAGE_T').value != 'X' && document.getElementById('AQWHO_T').value != 'X' && document.getElementById('AQOPE_T').value != 'X' && document.getElementById('AQCUR_T').value != 'X' && document.getElementById('AQGEO_T').value != 'X') {
					Redirect('/Estimators/?QE=MOT');
					var ret = window.open('/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN04+'+partition+'+funcparms+WKSC(A0010):S+AQAGE(A0010):'+document.getElementById('AQAGE_T').value+'+AQWHO(A0010):'+document.getElementById('AQWHO_T').value+'+AQGEO(A0010):'+document.getElementById('AQGEO_T').value+'+AQOPE(A0010):'+document.getElementById('AQOPE_T').value+'+AQCUR(A0010):'+document.getElementById('AQCUR_T').value);
				} else {
					alert("Please answer all questions");
				}
				break;
			case 'Household':
				var ret = window.open('https://www.allianz.ie/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN03+'+partition+'+funcparms+WKCOVC(A0030):BAC+HRPROD(A0030):DCR+ASTRS(A0030):ROI+WKSC(A0010):+LSBLSI(S0070):'+document.getElementById('LSBLSI_S').value+'+WKCSIN(S0020):'+document.getElementById('LWKCSIN').value+'+HRLOCC(A0020):'+document.getElementById('HRLOCC_S').value+'+WKADCR(A0030):'+document.getElementById('WKADCR_S').value+'+WKAGEN(P0030):'+document.getElementById('WKAGEN_S').value);
				break;
			case 'Contents Only':
				var ret = window.open('https://www.allianz.ie/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN03+'+partition + '+funcparms+WKCOVC(A0030):BAC+HRPROD(A0030):DHR+ASTRS(A0030):ROI+WKSC(A0010):+LSBLSI(S0070):0+LSCTSI(S0070):'+document.getElementById('LSCTSI_C').value+'+HRLOCC(A0020):'+document.getElementById('HRLOCC_C').value+'+WKADCR(A0030):'+document.getElementById('WKADCR_C').value+'+WKAGEN(P0030):'+document.getElementById('WKAGEN_C').value);
				break;
			case 'Holiday Home':
				var ret = window.open('https://www.allianz.ie/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN03+'+partition+'+funcparms+WKCOVC(A0030):HBC+HRPROD(A0030):DHR+ASTRS(A0030):ROI+WKSC(A0010):+LSBLSI(S0070):'+document.getElementById('LSBLSI_H').value+'+LSCTSI(S0070):'+document.getElementById('LSCTSI_H').value+'+HRLOCC(A0020):'+document.getElementById('HRLOCC_H').value+'+WKAGEN(P0030):'+document.getElementById('WKAGEN_H').value);
				break;
			case 'Landlord':
				var ret = window.open('https://www.allianz.ie/CGI-BIN/LANSAWEB?procfun+MQQPROC+MQQFN03+'+partition+'+funcparms+WKCOVC(A0030):LBC+HRPROD(A0030):DHR+ASTRS(A0030):ROI+WKSC(A0010):+HROCCU(A0020):L1+LSBLSI(S0070):'+document.getElementById('LSBLSI_L').value+'+LSCTSI(S0070):'+document.getElementById('LSCTSI_L').value+'+HRLOCC(A0020):'+document.getElementById('HRLOCC_L').value+'+WKAGEN(P0030):'+document.getElementById('WKAGEN_L').value);
				break;
			default:
				document.getElementById('calc_result').innerHTML ="An error has occurred. No product selected.";
				break;
		}
	}
}


/******************************************** GENERAL FUNCTIONS **************************************************************/



//
// function to add a cell with text to a row
//
function addTextCell(row, text){
	var txt = document.createTextNode(text);
	var cell = document.createElement('td');
	cell.appendChild(txt);
//	cell.width = "189";
	cell.className = "est_tableCellText";
	row.appendChild(cell);
}



//
// function to add a cell with text to a row
//
function addTextCellWidth(row, text, width){
	var txt = document.createTextNode(text);
	var cell = document.createElement('td');
	cell.appendChild(txt);
	cell.width = width;
	cell.className = "est_tableCellText";
	row.appendChild(cell);
}


//
// function to add a multi-column cell with text to a row
//
function addMultiColTextCell(row, text, cols){
	var txt = document.createTextNode(text);
	var cell = document.createElement('td');
	cell.appendChild(txt);
	cell.className = "est_tableText";
	cell.colSpan = cols;
	row.appendChild(cell);
}



//
// function to add a multi-row cell with text to a row
//
function addMultiRowTextCell(row, text, rows, width){
	var txt = document.createTextNode(text);
	var cell = document.createElement('td');
	cell.appendChild(txt);
	cell.className = "est_tableText";
	cell.rowSpan = rows;
	if (text != "") {
		cell.className = "est_tableCellPremiumText";
		cell.id = "calc_result";
	}
	cell.width = width;
	row.appendChild(cell);
}



//
// function to add a cell with an object to a row
//
function getNewCell(row) {
	var cell = document.createElement('td');
	row.appendChild(cell);
	return cell;
}



//
// function to create a new Select object
//
function createSelect(name, id) {
	var sel = document.createElement('select');
	sel.name = name;
	sel.className = 'est_tableDropdown';
	sel.id = id;
	return sel;
}



//
// generic function to create dropdowns dynamically
//
function addGenericDD(container, select, options) {
	var seltemp = createSelect(select[0], select[1]);
	for (i=0; i<options.length; i++) {
		addSelectItem(seltemp, options[i][0], options[i][1]);
	}
	container.appendChild(seltemp);
}



//
// function to add a select item to a dropdown
//
function addSelectItem(select, itemvalue, itemtext) {
	var option = document.createElement('option');
	option.value = itemvalue;
	option.text = itemtext;
	try {
		select.add(option,null);
	} catch(ex) {
		select.add(option);
	}
}



//
// function to send the Ajax request
//
function sendQEAjaxRequest(url, product) {
	document.getElementById('calc_result').innerHTML = "Generating Estimate. <br /><br /> Please wait...";
	var req = null;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		if (req.overrideMimeType) {
			req.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)  {}
		}
	}
	req.onreadystatechange = function() {
		if(req.readyState == 4) {
			if(req.status == 200) {
				var ajaxIn = req.responseText;
				var loc = ajaxIn.indexOf(':');

				if (ajaxIn.substring(0, loc) > 1) {
					document.getElementById('calc_result').innerHTML = "Premium Estimate is: &euro;" + ajaxIn.substring(0, loc);
				}
				else {
					ajaxIn = ajaxIn.substring(loc+1, ajaxIn.length - loc + 2);
					var loc2 = ajaxIn.indexOf(':');
					if (loc2 > 1) {
						ajaxIn = ajaxIn.substring(0, loc2);
					}
					document.getElementById('calc_result').innerHTML = ajaxIn;
				}
			}
			else {
				alert("Error: returned status code " + req.status + " " + req.statusText);
			}
		}
	};
	try {
		req.open("GET", url, true);
		req.send(null);
	}
	catch (ex) {
		alert("Error: returned status code " + req.status + " " + req.statusText);
	}
}



//
// function to remove all of the document nodes
//
function traverseDomTree_recurse(curr_element, level) {
	var i;
	if(curr_element.childNodes.length <= 0) {
		curr_element.parentNode.removeChild(curr_element);
		curr_element = null;
	} else {
		try {
			for(i=0; curr_element.childNodes.item(i); i++) {
				traverseDomTree_recurse(curr_element.childNodes.item(i), level+1);
			}
		} catch (e) {  }
	}
}