
// declare a global  XMLHTTP Request object
var XmlHttpObj;

// create an instance of XMLHTTPRequest Object, varies with browser type, try for IE first then Mozilla
function CreateXmlHttpObj()
{
	// try creating for IE (note: we don't know the user's browser type here, just attempting IE first.)
	try
	{
		XmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpObj = null;
		}
	}
	// if unable to create using IE specific code then try creating for Mozilla (FireFox) 
	if(!XmlHttpObj && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpObj = new XMLHttpRequest();
	}
}
/*
function searchPlans(limit){

	
// url of page that will send xml data back to client browser
    var requestUrl;
    
	//check all the available fieldss

    requestUrl = "ajaxPlans.php" + "?limit=" + encodeURIComponent(limit);
 	
	CreateXmlHttpObj();
	
	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
			
        // assign the StateChangeHandler function ( defined below in this file)
        // to be called when the state of the XmlHttpObj changes
        // receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = StateChangeHandlerPlans;
		
		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("GET", requestUrl,  true);
		
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);		
	}
}

function StateChangeHandlerPlans()
{
	showWorking();
	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{
		//simply comment line below to turn off debug messages
		//debug(XmlHttpObj.responseText);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{			
			populatePlans(XmlHttpObj.responseText);
			
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}
function populatePlans(response){
	if(document.getElementById("plans")){
		document.getElementById("plans").innerHTML = response;
	}
	initLightbox();
}
function searchPlansThumbs(limit){

	
// url of page that will send xml data back to client browser
    var requestUrl;
    
	//check all the available fieldss

    requestUrl = "ajaxPlansThumbs.php" + "?limit=" + encodeURIComponent(limit);
 	
	CreateXmlHttpObj();
	
	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
			
        // assign the StateChangeHandler function ( defined below in this file)
        // to be called when the state of the XmlHttpObj changes
        // receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = StateChangeHandlerPlansThumbs;
		
		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("GET", requestUrl,  true);
		
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);		
	}
}

function StateChangeHandlerPlansThumbs()
{
	showWorking();
	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{
		//simply comment line below to turn off debug messages
		//debug(XmlHttpObj.responseText);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{			
			populatePlansThumbs(XmlHttpObj.responseText);
			
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}
function populatePlansThumbs(response){
	if(document.getElementById("plans")){
		document.getElementById("plans").innerHTML = response;
	}
	initLightbox();
}
*/

function debug(response){
	document.getElementById("debug").innerHTML = response;
}
// populate the contents of the country dropdown list
function showWorking()
{
	
	if(document.getElementById("plans")){
		document.getElementById("plans").innerHTML = "<img src=images/loading.gif>";
	}
	
}










// this function called when state of  XmlHttpObj changes
// we're interested in the state that indicates data has been
// received from the server
function StateChangeHandler()
{
	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{			
			PopulateCountryList(XmlHttpObj.responseXML.documentElement);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}



function AddValue(formVal){
	
	//var test = document.forms[formVal].gross.value;
	//alert(test);
	
	var currency = document.forms[formVal].currency;
	var currencyValue = currency.options[currency.selectedIndex].value;

	var gross = document.forms[formVal].gross.value;
	var gst = document.forms[formVal].gst.value;
	var otherTax = document.forms[formVal].otherTax.value;
	var total;
	var allTax;
	var netValue;
	gst = Number((gst)/100);
	otherTax = Number((otherTax)/100);
	allTax = Number(gst + otherTax +1);
	total = Number((gross * (allTax))-gross);
	netValue =  Number(gross - total);
	document.forms[formVal].net.value = netValue;
	document.forms[formVal].total.value = Number(netValue * currencyValue);
	
	

	
}



/*function AddExpenseValue(formVal){
	//we probely want to calculate currency	
	//var currency = document.forms[formVal].currency;
	//var currencyValue = currency.options[currency.selectedIndex].value;
	alert(formVal);
	var expensePercentage = document.forms[formVal].expensePercentage.value;
	expensePercentage = Number(expensePercentage/100);
	//calculate
	var cost = document.forms[formVal].cost.value;
	var gst = document.forms[formVal].gst.value;
	var otherTax = document.forms[formVal].otherTax.value;
	var total;
	var allTax;
	var netValue;
	gst = Number((gst)/100);
	otherTax = Number((otherTax)/100);
	allTax = Number(gst + otherTax +1);
	total = Number((cost * (allTax))-cost);
	netValue =  Number(cost - total);
	//final calculation with percentage
	netValue = Number(netValue * expensePercentage);
	cost = Number(cost * expensePercentage);
	gst = Number(gst * expensePercentage);
	otherTax = Number(otherTax * expensePercentage);
	//show calculated values
	document.forms[formVal].net.value = netValue;
	document.forms[formVal].otherTaxPercentage.value = otherTax;
	document.forms[formVal].costPercentage.value = cost;
	document.forms[formVal].gstPercentage.value = Number(gst * 100);
	document.forms[formVal].otherTaxPercentage.value = Number(otherTax * 100);
	
	//rounding http://www.mediacollege.com/internet/javascript/number/round.html
	//Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
	//document.forms[formVal].total.value = Number(netValue * currencyValue);
	
}*/

function AddValueInvoiceService(formVal,workerRateHiddenID){

	var numDays = document.forms[formVal].numDays.value;
	var rate = document.getElementById(workerRateHiddenID).value;
	var totalGst;
	var allTax;
	var netValue;
	allTax = Number(1.06);
	
	totalGst = Number(((numDays * rate) * allTax) - (numDays * rate));
	netValue = Number(numDays * rate);

	document.forms[formVal].gst.value = roundNumber(totalGst,2);
	document.forms[formVal].net.value = roundNumber(netValue,2);
	document.forms[formVal].gross.value = roundNumber(Number(totalGst + netValue),2);
	
}
//This function adds values for pqiexpenses
function AddPQIValues(formVal){
	//these are the element being altered and used
	var currency = document.forms[formVal].currency;
	var currencyValue = currency.options[currency.selectedIndex].value;
	var gst;
	var allTax;
	var net;
	var cdn;
	var gross = document.forms[formVal].gross.value;
	
	
	//do our calculations
	gst = Number(gross * .06);
	document.forms[formVal].gst.value = roundNumber(gst,2);
	net = Number(gross - gst);
	document.forms[formVal].net.value = roundNumber(net,2);
	gross = Number(gross * currencyValue);
	document.forms[formVal].total.value = roundNumber(gross,2);
	
	
	
	
	
}
function AddExpenseValueGST(formVal){
	var gst = document.forms[formVal].gst.value;
	//have they checked charge gst
	var chargeGST = document.forms[formVal].chargeGST.checked;
	if(chargeGST){
		chargeGST =1;
	}
	else{
		chargeGST=0;
	}
	
	var netValue; 
	var gstValue;
	
	//percentage values
	var expensePercentage =  document.forms[formVal].expensePercentage.value;
	expensePercentage = Number(expensePercentage/100);
	//gross or cost
	var cost = document.forms[formVal].cost.value;
	

	//calculate percentages for gst
	if(chargeGST == 1){
		netValue = roundNumber(Number(cost-gst),2);
	}
	else{
		netValue = roundNumber(Number(cost),2);
		gstValue = roundNumber(Number(0),2);
	}
	//output net value
	document.forms[formVal].net.value = netValue;
	
	
	//calculate billed expenses
	var costPercentage = roundNumber(Number(cost*expensePercentage),2);
	var netPercentage = roundNumber(Number(netValue*expensePercentage),2);
	var gstPercentage = roundNumber(Number(gst*expensePercentage),2);
	
	//percentages values
	document.forms[formVal].costPercentage.value = costPercentage;
	document.forms[formVal].gstPercentage.value = gstPercentage;
	document.forms[formVal].netPercentage.value = netPercentage
	
	
}

function AddExpenseValue(formVal){
	
	var gstHard = 6;
	//have they checked charge gst
	var chargeGST = document.forms[formVal].chargeGST.checked;
	if(chargeGST){
		chargeGST =1;
	}
	else{
		chargeGST=0;
	}
	
	var netValue; 
	var gstValue;
	
	//percentage values
	var expensePercentage =  document.forms[formVal].expensePercentage.value;
	expensePercentage = Number(expensePercentage/100);
	//gross or cost
	var cost = document.forms[formVal].cost.value;
	//hardcoded gst value
	var gst = Number((gstHard/100)+1);

	//calculate percentages for gst
	if(chargeGST == 1){
		netValue = roundNumber(Number(cost/gst),2);
		gstValue = roundNumber(Number(cost-netValue),2);
	}
	else{
		netValue = roundNumber(Number(cost),2);
		gstValue = roundNumber(Number(0),2);
	}
	//output net value,gst
	document.forms[formVal].net.value = netValue;
	document.forms[formVal].gst.value = gstValue;
	
	//calculate billed expenses
	var costPercentage = roundNumber(Number(cost*expensePercentage),2);
	var netPercentage = roundNumber(Number(netValue*expensePercentage),2);
	var gstPercentage = roundNumber(Number(gstValue*expensePercentage),2);
	
	//percentages values
	document.forms[formVal].costPercentage.value = costPercentage;
	document.forms[formVal].gstPercentage.value = gstPercentage;
	document.forms[formVal].netPercentage.value = netPercentage
		
}
function roundNumber(val,persion){
	//rounding http://www.mediacollege.com/internet/javascript/number/round.html
	var num = Number(Math.round(val*Math.pow(10,persion))/Math.pow(10,persion));
	return num;
}


// called from onChange or onClick event of the continent dropdown list
function SaveConsultant() 
{
	
	var consultantID = document.getElementById("consultantID").value;
	var firstName = document.getElementById("firstName").value;
	var tt = document.getElementById("titleTypeID");
	var titleTypeID = tt.options[tt.selectedIndex].value;
	var lastName = document.getElementById("lastName").value;
	var code = document.getElementById("code").value;
	
	var emailAddress = document.getElementById("emailAddress").value;
	
	var company = document.getElementById("company").value;
	var GSTnumber = document.getElementById("GSTnumber").value;
	var WCBnumber = document.getElementById("WCBnumber").value;
	var payCollectGST = document.getElementById("payCollectGST").checked;
	if(payCollectGST){
		payCollectGST =1;
	}
	else{
		payCollectGST=0;
	}
	var core = document.getElementById("core").checked;
	if(core){
		core =1;
	}
	else{
		core=0;
	}

	var workerPercentage = document.getElementById("workerPercentage").checked;
	if(workerPercentage){
		workerPercentage =1;
	}
	else{
		workerPercentage=0;
	}
	var workerRate = document.getElementById("workerRate").value;
	var corePercent = document.getElementById("corePercent").value;
    
    // url of page that will send xml data back to client browser
    var requestUrl;
    // use the following line if using asp
    //requestUrl = "xml_data_provider.asp" + "?filter=" + encodeURIComponent(selectedContinent);
    // use the following line if using php
	
    requestUrl = "ajaxConsultantMain.php" + "?emailAddress=" + encodeURIComponent(emailAddress) +"&consultantID=" + encodeURIComponent(consultantID) + "&titleTypeID=" + encodeURIComponent(titleTypeID) + "&firstName=" + encodeURIComponent(firstName) + "&lastName=" + encodeURIComponent(lastName) + "&company=" + encodeURIComponent(company) + "&GSTnumber=" + encodeURIComponent(GSTnumber) + "&WCBnumber=" + encodeURIComponent(WCBnumber)  + "&code=" + encodeURIComponent(code) + "&company=" + encodeURIComponent(company) + "&WCBnumber=" + encodeURIComponent(WCBnumber) + "&GSTnumber=" + encodeURIComponent(GSTnumber) + "&payCollectGST=" + encodeURIComponent(payCollectGST)+ "&core=" + encodeURIComponent(core)+ "&corePercent=" + encodeURIComponent(corePercent)+ "&workerPercentage=" + encodeURIComponent(workerPercentage)+ "&workerRate=" + encodeURIComponent(workerRate);
 	
	CreateXmlHttpObj();
	
	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
        // assign the StateChangeHandler function ( defined below in this file)
        // to be called when the state of the XmlHttpObj changes
        // receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = StateChangeHandler2;
		
		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("GET", requestUrl,  true);
		
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);		
	}
}

// called from onChange or onClick event of the continent dropdown list
function SaveConsultantAddress() 
{
	
	var consultantID = document.getElementById("consultantID").value;
	var address = document.getElementById("addressBody").value;
	var city = document.getElementById("city").value;
	var code = document.getElementById("code").value;
	var rID = document.getElementById("regionID");
	var regionID = rID.options[rID.selectedIndex].value;
	var cID = document.getElementById("countryID");
	var countryID = cID.options[cID.selectedIndex].value;
	var homePhone = document.getElementById("homePhone").value;
	var contactPhone = document.getElementById("contactPhone").value;
    
    // url of page that will send xml data back to client browser
    var requestUrl;
    // use the following line if using asp
    //requestUrl = "xml_data_provider.asp" + "?filter=" + encodeURIComponent(selectedContinent);
    // use the following line if using php
	
    requestUrl = "ajaxConsultantAddress.php" + "?consultantID=" + encodeURIComponent(consultantID) + "&code=" + encodeURIComponent(code) + "&address=" + encodeURIComponent(address) + "&city=" + encodeURIComponent(city) + "&regionID=" + encodeURIComponent(regionID) + "&countryID=" + encodeURIComponent(countryID) + "&homePhone=" + encodeURIComponent(homePhone) + "&contactPhone=" + encodeURIComponent(contactPhone);
 	
	CreateXmlHttpObj();
	
	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
        // assign the StateChangeHandler function ( defined below in this file)
        // to be called when the state of the XmlHttpObj changes
        // receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = StateChangeHandler2;
		
		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("GET", requestUrl,  true);
		
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);		
	}
}

// this function called when state of  XmlHttpObj changes
// we're interested in the state that indicates data has been
// received from the server

function showCompleted(){
	
	document.getElementById("brander").innerHTML = "<img src=PQI.png>";

}
// this function called when state of  XmlHttpObj changes
// we're interested in the state that indicates data has been
// received from the server
function StateChangeHandler()
{
	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{			
			PopulateCountryList(XmlHttpObj.responseXML.documentElement);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}

// populate the contents of the country dropdown list
function PopulateCountryList(countryNode)
{

	var locationList = document.getElementById("consultant");
	// clear the country list 
	for (var count = locationList.options.length-1; count >-1; count--)
	{
		locationList.options[count] = null;
	}

	var countryNodes = countryNode.getElementsByTagName('country');
	var idValue;
	var textValue; 
	var optionItem;
	// populate the dropdown list with data from the xml doc
	for (var count = 0; count < countryNodes.length; count++)
	{
   		
		textValue = GetInnerText(countryNodes[count]);
		idValue = countryNodes[count].getAttribute("id");
		optionItem = new Option( textValue, idValue,  false, false);
		locationList.options[locationList.length] = optionItem;
	}
}

// returns the node text value 
function GetInnerText (node)
{
	 return (node.textContent || node.innerText || node.text) ;
}




//show parmeter is for wehere t oshow the days between
function DaysBetween(start,end,numDays,gst,net,gross,workerRateHidden,invoiceID,consultant,workerMargin,workerCore,workerMarketing,availableMargin){


	var requestUrl;
	var date1 = document.getElementById(start).value;
	var date2 = document.getElementById(end).value;
	var conID = document.getElementById(consultant);
	var conID = document.getElementById(consultant);
	var consultantID;
	if(conID.type == "hidden"){
		consultantID = conID.value;
	}
	else{
		consultantID = conID.options[conID.selectedIndex].value;
	}


	var invoiceID = document.getElementById(invoiceID).value;

    requestUrl = "ajaxDaysBetween.php" + "?start=" + encodeURIComponent(date1) + "&end=" + encodeURIComponent(date2) + "&numDays=" + encodeURIComponent(numDays)+ "&gst=" + encodeURIComponent(gst)+ "&net=" + encodeURIComponent(net)+ "&gross=" + encodeURIComponent(gross)+ "&consultantID=" + encodeURIComponent(consultantID)+ "&workerRateHidden=" + encodeURIComponent(workerRateHidden)+ "&invoiceID=" + encodeURIComponent(invoiceID)+ "&marginID=" + encodeURIComponent(workerMargin)+ "&coreID=" + encodeURIComponent(workerCore)+ "&marketingID=" + encodeURIComponent(workerMarketing)+ "&availableMarginID=" + encodeURIComponent(availableMargin);
 	
	CreateXmlHttpObj();
	
	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
			
        // assign the StateChangeHandler function ( defined below in this file)
        // to be called when the state of the XmlHttpObj changes
        // receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = StateChangeHandlerDaysBetween;
		
		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("GET", requestUrl,  true);
		
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);		
	}
	
}
// this function called when state of  XmlHttpObj changes
// we're interested in the state that indicates data has been
// received from the server
function StateChangeHandlerDaysBetween()
{

	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{			
			PopulateDaysBetween(XmlHttpObj.responseXML.documentElement);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}
// populate the contents of the country dropdown list
function PopulateDaysBetween(Node)
{

	var Nodes = Node.getElementsByTagName('service');
	var idValue;
	var textValue; 
	var optionItem;
	
	//our values
	var numDaysID;
	var numDays;
	var gstID;
	var gst;
	var netID;
	var net;
	var grossID;
	var gross;
	var marginID;
	var margin;
	var workerRateID;
	var workerRate;
	var coreID;
	var core;
	var marketingID;
	var marketing;
	var availableMarginID;
	var availableMargin;

	
	
	// populate the dropdown list with data from the xml doc
	for (var count = 0; count < Nodes.length; count++)
	{
		textValue = GetInnerText(Nodes[count]);
		idValue = Nodes[count].getAttribute("id");
		//get our values and ids
		if(idValue == "numDaysID"){
			numDaysID = textValue;
		}
		if(idValue == "numDays"){
			numDays = textValue;   
		}
		if(idValue == "gstID"){
			gstID = textValue;
		}
		if(idValue == "gst"){
			gst = textValue;
		}
		if(idValue == "netID"){
			netID = textValue;
		}
		if(idValue == "net"){
			net = textValue;
		}
		if(idValue == "grossID"){
			grossID = textValue;
		}
		if(idValue == "gross"){
			gross = textValue;
		}
		if(idValue == "marginID"){
			marginID = textValue;
		}
		if(idValue == "margin"){
			margin = textValue;
		}
		if(idValue == "workerRateID"){
			workerRateID = textValue; 
		}
		if(idValue == "workerRate"){
			workerRate = textValue;
		}
		if(idValue == "coreID"){
			coreID = textValue; 
		}
		if(idValue == "core"){
			core = textValue;
		}
		if(idValue == "marketingID"){
			marketingID = textValue; 
		}
		if(idValue == "marketing"){
			marketing = textValue;
		}
		if(idValue == "availableMarginID"){
			availableMarginID = textValue; 
		}
		if(idValue == "availableMargin"){
			availableMargin = textValue;
		}
		
	}
	//set the num days for the two calendar values
	document.getElementById(numDaysID).value = numDays;
	//set the workerRate value for the onchage event
	document.getElementById(workerRateID).value = workerRate;

	//set the core value
	document.getElementById(coreID).value = core;
	//set the margin
	document.getElementById(marginID).value = margin;
	//set the marketing value
	document.getElementById(marketingID).value = marketing;
	//set the total available margin
	document.getElementById(availableMarginID).value = availableMargin;
	
	//write gst,net, and gross
	document.getElementById(gstID).value = roundNumber(gst,2);
	document.getElementById(netID).value = roundNumber(net,2);
	document.getElementById(grossID).value = roundNumber(gross,2);
	
}




//show parmeter is for wehere t oshow the days between
function DaysBetweenConAvailability(start,end,numDays){


	var requestUrl;
	var date1 = document.getElementById(start).value;
	var date2 = document.getElementById(end).value;
	
    requestUrl = "ajaxDaysBetweenConAvailability.php" + "?start=" + encodeURIComponent(date1) + "&end=" + encodeURIComponent(date2) + "&numDays=" + encodeURIComponent(numDays);
 	
	CreateXmlHttpObj();
	
	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
			
        // assign the StateChangeHandler function ( defined below in this file)
        // to be called when the state of the XmlHttpObj changes
        // receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = StateChangeHandlerDaysBetweenConAvail;
		
		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("GET", requestUrl,  true);
		
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);		
	}
	
}
// this function called when state of  XmlHttpObj changes
// we're interested in the state that indicates data has been
// received from the server
function StateChangeHandlerDaysBetweenConAvail()
{

	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{			
			PopulateDaysBetweenConAvail(XmlHttpObj.responseXML.documentElement);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}
// populate the contents of the country dropdown list
function PopulateDaysBetweenConAvail(Node)
{

	var Nodes = Node.getElementsByTagName('service');
	var idValue;
	var textValue; 
	var optionItem;
	
	//our values
	var numDaysID;
	var numDays;
	
	
	
	// populate the dropdown list with data from the xml doc
	for (var count = 0; count < Nodes.length; count++)
	{
		textValue = GetInnerText(Nodes[count]);
		idValue = Nodes[count].getAttribute("id");
		//get our values and ids
		if(idValue == "numDaysID"){
			numDaysID = textValue;
		}
		if(idValue == "numDays"){
			numDays = textValue;   
		}
	
		
	}
	

	//set the num days for the two calendar values
	document.getElementById(numDaysID).value = numDays;
	
	
}






