  //variable for store current clickRow
  var clickRow=null;
  
  function setPointer(row, action) {

	var tmp_txtField;
	var obj_txtField;
	var rowIndex;
	var Role_ID;


	var cells = null;
	var rowCellsCnt  = 0;
	var c = 0;

	var objTable;
	objTable = document.getElementById("table");

    //Sets the old color for clickRow
    if (clickRow!=null && action=='click')
    {
	cells = objTable.rows[clickRow].cells;
	rowCellsCnt  = cells.length;


	rowIndex = clickRow;
	Role_ID = objTable.rows[rowIndex].cells[0].innerHTML;

	tmp_txtField = "txtCount_" + Role_ID;
	//obj_txtField = eval ("window.document.all." + tmp_txtField );
	obj_txtField = document.getElementById(eval("'" + tmp_txtField + "'"));

	if (obj_txtField != null && obj_txtField.value > 0 ){
       		for (c = 0; c < rowCellsCnt; c++) {
			cells[c].style.backgroundColor = '#ccdeff';
		}
	}
	else{
       		for (c = 0; c < rowCellsCnt; c++) {
			cells[c].style.backgroundColor = '#dddddd';
		}
	}
    }
	rowIndex = row.rowIndex;
	Role_ID = objTable.rows[rowIndex].cells[0].innerHTML;
	tmp_txtField = "txtCount_" + Role_ID;
	//alert (tmp_txtField);
	//obj_txtField = eval ("window.document.all." + tmp_txtField );
	obj_txtField = document.getElementById(eval("'" + tmp_txtField + "'"));


    cells = row.cells;
    rowCellsCnt  = cells.length;

    //Sets the new color for over
    if (action == 'over' && clickRow!=row.rowIndex)
    {
          for (c = 0; c < rowCellsCnt; c++) {
           cells[c].style.backgroundColor = '#cccccc';
       }
      row.style.cursor= 'hand';
    }


    //Sets the old color for out
    if (action == 'out' && clickRow!=row.rowIndex)
    {
	if (obj_txtField != null && obj_txtField.value > 0 ){
		for (c = 0; c < rowCellsCnt; c++) {
			cells[c].style.backgroundColor = '#ccdeff';
		}
	}
	else{
		if (cells[0].style.backgroundColor != '#99bbff')
		{
			for (c = 0; c < rowCellsCnt; c++) {
				cells[c].style.backgroundColor = '#dddddd';
			}
		}
	}
    }


    //Sets the new color for click
    if (action == 'click')
    {
       for (c = 0; c < rowCellsCnt; c++) {
           cells[c].style.backgroundColor = '#99bbff';
       }
       clickRow=row.rowIndex;
    }




  }
  function ShowData(row) {
	setPointer(row, 'click');
  }



function Add(record_id){
	var tmp_txtField;
	var obj_txtField;

	tmp_txtField = "txtCount_" + record_id;
	//obj_txtField = eval ("window.document.all." + tmp_txtField );
	obj_txtField = document.getElementById(eval("'" + tmp_txtField + "'"));


	obj_txtField.value ++;

	RefreshTeamMemberTable();

}
function Remove(record_id){
	var tmp_txtField;
	var obj_txtField;

	tmp_txtField = "txtCount_" + record_id;
	//obj_txtField = eval ("window.document.all." + tmp_txtField );
	obj_txtField = document.getElementById(eval("'" + tmp_txtField + "'"));


	if (obj_txtField.value > 0 ){
		obj_txtField.value--;
		RefreshTeamMemberTable();
	}
}





function RefreshTeamMemberTable(){
		var new_table = "";
		var price_table = "";
		var i;
		var rowIndex;

		var Role_ID ;
		var Role_Name ;
		var Role_Salary = 0;
		var Role_Extras = 0;
		var Role_Profit = 0;

		var totalMemberSalary=0;
		var totalAllMembersPrice=0;
		var totalPriceWithDiscount=0;
		var countOfAllMembers=0;
		var TeamDiscount=0;
		var DiscountComment="";

		var tmp_txtField;
		var obj_txtField;

		var objTable;
		objTable = document.getElementById("table");
		for (i=1; i<objTable.rows.length; i++){
			rowIndex = i;

			Role_ID = objTable.rows[rowIndex].cells[0].innerHTML;
			Role_Name = objTable.rows[rowIndex].cells[1].innerHTML;
			Role_Salary = objTable.rows[rowIndex].cells[5].innerHTML; Role_Salary = 1*Role_Salary;
			Role_Extras = objTable.rows[rowIndex].cells[6].innerHTML; Role_Extras = 1*Role_Extras;
			Role_Profit = objTable.rows[rowIndex].cells[7].innerHTML; Role_Profit = 1*Role_Profit;

			tmp_txtField = "txtCount_" + Role_ID;
			//obj_txtField = eval ("window.document.all." + tmp_txtField );
			obj_txtField = document.getElementById(eval("'" + tmp_txtField + "'"));

			totalMemberSalary = ((Role_Salary+Role_Extras) + (((Role_Salary+Role_Extras)*Role_Profit)/100)) * obj_txtField.value; totalMemberSalary = Math.round(totalMemberSalary);
			totalAllMembersPrice += (1*totalMemberSalary); totalAllMembersPrice = Math.round(totalAllMembersPrice);
			countOfAllMembers += (1*obj_txtField.value);

		}
		//
		//
		//
		//Get discount from XML file
		var TeamSizeMin=0;
		var TeamSizeMax=0;
		var discount=0;
		var comment="";

		TeamDiscount=0;
		var objDiscount;
		objDiscount = document.getElementById("discount");

		for (i=1; i < objDiscount.rows.length; i++){
			TeamSizeMin = objDiscount.rows[i].cells[1].innerHTML;
			TeamSizeMax = objDiscount.rows[i].cells[2].innerHTML;
			discount = objDiscount.rows[i].cells[3].innerHTML;
			comment = objDiscount.rows[i].cells[4].innerHTML;
			if ((countOfAllMembers >= TeamSizeMin) && (countOfAllMembers <=TeamSizeMax)){
				TeamDiscount = discount;
				DiscountComment = comment;
				break;
			}
		}

		//
		//
		//
		//Get currency rate from XML file
		var PoundRate=0;
		var EuroRate=0;
		var totalAllMembersPricePound = 0;
		var totalPriceWithDiscountPound = 0;
		var totalAllMembersPriceEuro = 0;
		var totalPriceWithDiscountEuro = 0;

		var objExchangeRate;
		objExchangeRate = document.getElementById("ExchangeRate");

		PoundRate = objExchangeRate.rows[1].cells[1].innerHTML ;
		EuroRate = objExchangeRate.rows[2].cells[1].innerHTML ;

		totalAllMembersPricePound = totalAllMembersPrice / PoundRate; totalAllMembersPricePound = Math.round(totalAllMembersPricePound);
		totalPriceWithDiscountPound = totalAllMembersPricePound - (totalAllMembersPricePound*TeamDiscount)/100; totalPriceWithDiscountPound = Math.round(totalPriceWithDiscountPound);
		totalAllMembersPriceEuro = totalAllMembersPrice / EuroRate; totalAllMembersPriceEuro = Math.round(totalAllMembersPriceEuro);
		totalPriceWithDiscountEuro = totalAllMembersPriceEuro - (totalAllMembersPriceEuro*TeamDiscount)/100; totalPriceWithDiscountEuro = Math.round(totalPriceWithDiscountEuro);

		totalPriceWithDiscount = totalAllMembersPrice - (totalAllMembersPrice*TeamDiscount/100); totalPriceWithDiscount = Math.round(totalPriceWithDiscount);


		price_table="";
		price_table += '	<table cellPadding="2" align="right" border="0">';
		price_table += '		<tr>';
		price_table += '			<td bgColor="#eeeeee" align="center"><b>Totals</b></td>';
		price_table += '			<td bgColor="#eeeeee" align="right" nowrap><b>$, USD</b></td>';
		price_table += '			<td bgColor="#eeeeee" align="right" nowrap><b>&euro;, EURO</b></td>';
		price_table += '			<td bgColor="#eeeeee" align="right" nowrap><b>&pound;, GBP</b></td>';
		price_table += '		</tr>';
		//Price
		//price_table += '		<tr>';
		//price_table += '			<td bgColor="#dddddd" align="right">Estimated price</td>';
		//price_table += '			<td bgColor="#dddddd" align="right">' + totalAllMembersPrice + '</td>';
		//price_table += '			<td bgColor="#dddddd" align="right">' + totalAllMembersPriceEuro + '</td>';
		//price_table += '			<td bgColor="#dddddd" align="right">' + totalAllMembersPricePound + '</td>';
		//price_table += '		</tr>';
		//Discount
		//price_table += '		<tr>';
		//price_table += '			<td bgColor="#dddddd" align="right">Discount</td>';
		//price_table += '			<td bgColor="#dddddd" align="center" colspan=3>' + TeamDiscount + '% '  + DiscountComment + '</td>';
		//price_table += '		</tr>';
		//Total Price
		//price_table += '		<tr>';
		//price_table += '			<td bgColor="#dddddd" align="right">Sales prices</td>';
		//price_table += '			<td bgColor="#dddddd" align="right">' + totalPriceWithDiscount + '</td>';
		//price_table += '			<td bgColor="#dddddd" align="right">' + totalPriceWithDiscountEuro + '</td>';
		//price_table += '			<td bgColor="#dddddd" align="right">' + totalPriceWithDiscountPound + '</td>';
		//price_table += '		</tr>';
		//Estimated monthly cost
		price_table += '		<tr>';
		price_table += '			<td bgColor="#dddddd" align="right" nowrap>Estimated monthly cost</td>';
		price_table += '			<td bgColor="#dddddd" align="right">' + totalPriceWithDiscount + '</td>';
		price_table += '			<td bgColor="#dddddd" align="right">' + totalPriceWithDiscountEuro + '</td>';
		price_table += '			<td bgColor="#dddddd" align="right">' + totalPriceWithDiscountPound + '</td>';
		price_table += '		</tr>';
		price_table += "	</table>";


		TeamSize_table="";
		TeamSize_table += '	<table cellPadding="2" align="right" border="0">';
		TeamSize_table += '		<tr>';
		TeamSize_table += '			<td bgColor="#eeeeee" align="center" nowrap>Total team size</td>';
		TeamSize_table += '			<td bgColor="#eeeeee" align="right"><b>' + countOfAllMembers + '</b></td>';
		TeamSize_table += '		</tr>';


		var objTotalPriceList;
		objTotalPriceList = document.getElementById("TotalPriceList");
		objTotalPriceList.innerHTML = price_table;

		var objTotalTeamSize;
		objTotalTeamSize = document.getElementById("TotalTeamSize");
		objTotalTeamSize.innerHTML = TeamSize_table;



}
