// #### START WEB SERVICES FUNCTIONS
var RsltElem;
var chkElement;
function updateShortlist(shortlistCheckboxElement, id) {
	// update shortlist element text
	var shortlistTextElement = document.getElementById(id);
	chkElement = shortlistCheckboxElement;
	RsltElem = document.getElementById("shortListText");
	if (shortlistCheckboxElement.checked) {
		shortlistTextElement.innerHTML = 'Saved&nbsp;To&nbsp;Shortlist&nbsp;';
		//add to the shortlist
		manageShortlist.add(shortlistCheckboxElement.value, SucceededCallback, FailedCallback);
	}
	else {
		shortlistTextElement.innerHTML = 'Save&nbsp;&amp;&nbsp;Compare&nbsp;';
		//remove from the shortlist
		manageShortlist.remove(shortlistCheckboxElement.value, SucceededCallback, FailedCallback);
	}
}
//search form validation
function validateSearch(frm, cType) {
    document.getElementById('errorDIV').innerHTML = '';
    if (frm.asStateRegionID.selectedIndex == 0) {
		document.getElementById('errorDIV').style.display = 'block';
		document.getElementById('errorDIV').innerHTML = '! Please Select Your Destination.';
		alert('You must select your destination.');
		return(false);
	}
    else {
        var arrLocation = new Array()
        if (frm.asLocationID.value == 0) {
    	    arrLocation = frm.asStateRegionID.value.split('|');
    	}
    	else {
    	    arrLocation = frm.asLocationID.value.split('|');
    	}
		if ((frm.ctl00_conBody_dtCheckin.value == '') || (frm.ctl00_conBody_dtCheckout.value == '')) {
			document.getElementById('errorDIV').style.display = 'block';
			document.getElementById('errorDIV').innerHTML = 'Please Enter Your Dates.';
			alert('You must select your checkin and checkout dates.');
			return(false);
		}
		else if (frm.ctl00_conBody_dtCheckin.value == serverDateToday) {
		    document.getElementById('errorDIV').style.display = 'block';
		    document.getElementById('errorDIV').innerHTML = '! Sorry, you cannot checkin today.';
		    alert('Sorry, your dates are invalid.\r\n\r\n - You cannot checkin today, please select another date.\r\n');
		    return (false);
		}
		else if ((frm.ctl00_conBody_dtCheckin.value == '2009-06-06') || (frm.ctl00_conBody_dtCheckin.value == '2009-06-07')) {
			document.getElementById('errorDIV').style.display = 'block';
			document.getElementById('errorDIV').innerHTML = '! Sorry, you cannot checkin today.';
			alert('Sorry, your dates are invalid.\r\n\r\n - You cannot checkin today, please select a date after today.\r\n');
			return(false);
		}
		else if (Date.parse(frm.ctl00_conBody_dtCheckin.value) < Date.parse(serverDateToday)) {
			document.getElementById('errorDIV').style.display = 'block';
			document.getElementById('errorDIV').innerHTML = '! Sorry, you must select a date in the future.';
			alert('Sorry, your dates are invalid.\r\n\r\n - You must select a date in the future.\r\n');
			return(false);
		}
		else if ((serverDay == 'SATURDAY') && (serverHour > 10) && ((sunMon == frm.ctl00_conBody_dtCheckin.value) || (satMon == frm.ctl00_conBody_dtCheckout.value))) {
			document.getElementById('errorDIV').style.display = 'block';
			document.getElementById('errorDIV').innerHTML = '! Sorry, your dates are invalid.';
			alert('Sorry, your dates are invalid.\r\n\r\n - You are unable to checkin until Tuesday due to processing resraints.'); 
			return(false);
		}
		else if ((serverDay == 'SUNDAY') && (sunMon == frm.ctl00_conBody_dtCheckin.value)) {
			document.getElementById('errorDIV').style.display = 'block';
			document.getElementById('errorDIV').innerHTML = '! Sorry, your dates are invalid.';
			alert('Sorry, your dates are invalid.\r\n\r\n - You are unable to checkin until Tuesday due to processing resraints.'); 
			return(false);
		}
		else if (frm.cChildren.selectedIndex > 0) {
            if(document.aspnetForm.cChildAges.value == ""){
	            alert('Please select your child ages');
	            return(false);
            }
            else {
	            var arStr = frm.cChildAges.value + "-";
	            var ar = frm.cChildAges.value.split("-");	
	            if(frm.cChildren.selectedIndex > ar.length){
		            alert('Please select your child ages');
		            return(false);
	            }
            }
    	}
        RsltElem = document.getElementById("accomBox");
        RsltElem.innerHTML='<table id=\"tblLoading\" class=\"fs1\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"100px\" align=\"center\" style=\"color:#CCCCCC;\"><tr><td valign=\"bottom\" align=\"center\"><img src=\"/images/searching.gif\" /></td></tr><tr><td align=\"center\" valign=\"top\"><br />Loading...</td></tr></table><br /><br /><br /><br />';
        document.getElementById('LeftmenuBook1$dtCheckin$dateInput').value = frm.ctl00_conBody_dtCheckin.value;
        document.getElementById('LeftmenuBook1$dtCheckout$dateInput').value = frm.ctl00_conBody_dtCheckout.value;
        document.getElementById('LeftmenuBook1$cAdults').value = frm.cAdults.value;
        document.getElementById('LeftmenuBook1$cChildren').value = frm.cChildren.value;
        document.getElementById('LeftmenuBook1$cInfants').value = frm.cInfants.value;
        var RoomTypes = "";
        searchResults.buildListings(frm.asCountryID.value, arrLocation[0], frm.ctl00_conBody_dtCheckin.value, frm.ctl00_conBody_dtCheckout.value, frm.cAdults.value, frm.cChildren.value, frm.cInfants.value, frm.cAClass.value, frm.cPrice.value, frm.cPool.checked, frm.cAirCond.checked, frm.cSauna.checked, frm.cRoomService.checked, frm.cGym.checked, frm.cInternet.checked, frm.cRestaurant.checked, frm.cKitchen.checked, frm.cGames.checked, frm.cPaytv.checked, frm.cDisabled.checked, frm.cBalcony.checked, RoomTypes, SucceededCallback, FailedCallback);
    }
}
function CalculateTravellers(RoomType, num, Travelers)
{
    
    if(RoomType.indexOf("+")>-1)
    {
       Travelers = Travelers + (1 * num);
       RoomType = RoomType.replace("+","");
    }
    if(RoomType == "DB" || RoomType == "TB")
    {
        Travelers = Travelers + (2 * num);
    }
    else if (RoomType == "TS" || RoomType == "SB")
    {
           Travelers = Travelers + (1 * num);
    }
    else if (RoomType == "TR")
    {
        Travelers = Travelers + (3 * num);
    }
    else 
    {
        Travelers = Travelers + (4 * num);
    }
      return Travelers;
}
function BuildRoomType(num)
{
   var RoomType = $get("sRoomType" + num).value;
   var Child = ""
   if($get("sRoomType" + num).value.indexOf("+")>-1)
   {
       RoomType = RoomType.replace("+","");
       for(var i = 1;i<=$get("sNoOfRooms" + num).value;i++)
       {
            Child = Child + "&" + $get("sCh" + num + i).value;
       } 
       Child = Child.substring(1);       
   } 
   else
   {
        Child = 0;
   }
   RoomType =  RoomType + "|" + Child + "|" + $get("sNoOfRooms" + num).value;
   return RoomType;
}
// This is the callback function invoked if the Web service succeeded.
// It accepts the result object as a parameter.
function SucceededCallback(result, eventArgs) {
    if (result == 'error') {
        chkElement.checked = false;
        alert('Sorry, you currently have the maximun number of properties in your shortlist, either deselect some or navigate to your shortlist to compare them.');
    }
    else {
        if (RsltElem == 'map') {
            //document.write(result);
            eval(result);
        }
        else {
            //convertProperties.startConversion()
            //alert(result);
            if (RsltElem == document.getElementById("accomBox")) { 
                if (result.indexOf('||') != -1) {
                    var temp = result.split('||');
                    result = temp[0];
                    convertProperties.startConversion(temp[1], temp[2], temp[3]) ;
                }
            }
            RsltElem.innerHTML = result;
        }
    }
}
// This is the callback function invoked if the Web service failed.
// It accepts the error object as a parameter.
function FailedCallback(error) {
    // Display the error.    
    RsltElem.innerHTML = "Service Error: " + error.get_message();
}
// #### END WEB SERVICES FUNCTIONS
//build select boxs live
function generateCountries(element) {
	element.disabled = false;
	element.options[0] = new Option('Select A Country ...','0');
	for (x=0; x<arr_root.length; x++){ 
		element.options[x+1] = new Option(arr_root[x][1],arr_root[x][0]);
	}
}
function generateStateRegions(id, element, valType) {
    //valType: 0=value of normal location url, 1=value of lat and lng coords
	//this is used to display level 2 locs with level 3 under them
	var stateArrID = id
	if (stateArrID == 0) { 
		element.length = 1
		element.disabled = true;
		if (document.getElementById('asLocationID') != null) {
		    document.getElementById('asLocationID').disabled = true;
		}
		if (document.getElementById('asLocationID') != null) {
		    document.getElementById('asLocationID').selectedIndex = 0;
		    document.getElementById('asLocationID').disabled = true;
		}
		else if (document.getElementById('msLocationID') != null) {
		    document.getElementById('msLocationID').selectedIndex = 0;
		    document.getElementById('msLocationID').disabled = true;
		}
	}
	else {
		//firstly we must remove all previous <options>
		if (document.getElementById('asLocationID') != null) {
		    document.getElementById('asLocationID').selectedIndex = 0;
		    document.getElementById('asLocationID').disabled = true;
		}
		else if (document.getElementById('msLocationID') != null) {
		    document.getElementById('msLocationID').selectedIndex = 0;
		    document.getElementById('msLocationID').disabled = true;
		}
		var locList = element;  
		if (locList.length > 0) {
            var i = 0;
            while(locList.hasChildNodes()) {
                locList.removeChild(locList.childNodes[i]);
            }
		}
		else {
			locList.length = 0;	
		}
		if (stateArrID != 0) {
			//then add in new <option> from array
			var cSelect
			var cOption, cOptgroup
			var cThisLevel, cLastLevel
			cThisLevel = 0
			cLastLevel = 0
			cSelect = element;
			cSelect.disabled = false;
			cOption = document.createElement('OPTION');
			cOption.value = '0';
			cOption.appendChild(document.createTextNode('Select A Region/City ...'));
			cSelect.appendChild(cOption)
			//loop level2
			for (x=0; x<arr_states[stateArrID].length; x++){
				
				cOption = document.createElement('OPTION');
				switch (valType) {
					case 1:
					    cOption.value = arr_states[stateArrID][x][5] + '|' +arr_states[stateArrID][x][6] + '|' +arr_states[stateArrID][x][0];
					    break;
					case 0:
					    cOption.value = arr_states[stateArrID][x][0] + '|' +arr_states[stateArrID][x][4];
					    break;
				}
				cOption.appendChild(document.createTextNode(arr_states[stateArrID][x][1]));
				cOption.style.color = '#0066FF';
				cOption.style.fontWeight = 'bold';
				cSelect.appendChild(cOption)
				//loop all cities under level2
				if (arr_regions[arr_states[stateArrID][x][0]] != null) {
					for (y=0; y<arr_regions[arr_states[stateArrID][x][0]].length; y++){
						cThisLevel = arr_regions[arr_states[stateArrID][x][0]][y][3];
						if (cThisLevel == 1) {
							cOption = document.createElement('OPTION');
							cOption.appendChild(document.createTextNode(arr_regions[arr_states[stateArrID][x][0]][y][1]));
							switch (valType) {
							    case 1:
								    cOption.value = arr_regions[arr_states[stateArrID][x][0]][y][5]+'|'+arr_regions[arr_states[stateArrID][x][0]][y][6]+'|10|'+arr_regions[arr_states[stateArrID][x][0]][y][0];
								    break;
							    default:
							        cOption.value = arr_regions[arr_states[stateArrID][x][0]][y][0]+'|'+arr_regions[arr_states[stateArrID][x][0]][y][4];
							        break;
							}
							cOption.style.paddingLeft = '20px';
							cOption.style.color = '#000000';
							cSelect.appendChild(cOption)
						}
					}
				}
			}
		}
	}
}
function generateLocations(id, element, valType) {
    //valType: 0=value of normal location url, 1=value of lat and lng coords
	//this is used to display everything under level 3 (subRegions)
	var temp = id.split("|");
	var regionArrID;
	switch (valType) {
	    case 1:
	        regionArrID = temp[3]
	        break;
	    default:
	        regionArrID = temp[0]
	        break;
	}
	if (regionArrID == 0) {
		element.length = 1
		element.disabled = true;
	}
	else {
		//firstly we must remove all previous <options>
		var locList = element;
		if (locList.length > 0) {
            var i = 0;
            while(locList.hasChildNodes()) {
                locList.removeChild(locList.childNodes[i]);
            }
		}
		else {
			locList.length = 0;	
		}
		if (regionArrID != 0) {
			//then add in new <option> from array
			var cSelect
			var cOption, cOptgroup
			var cThisLevel, cLastLevel
			cThisLevel = 0
			cLastLevel = 0
			cSelect = element;
			cSelect.disabled = false;
			cOption = document.createElement('OPTION');
			cOption.value = '0';
			cOption.appendChild(document.createTextNode('All Sub-Regions'));
			cSelect.appendChild(cOption)
			//loop level2
			if (typeof arr_subRegions[regionArrID] != 'undefined') {
			    for (y=0; y<arr_subRegions[regionArrID].length; y++){
				    cOption = document.createElement('OPTION');
				    cOption.appendChild(document.createTextNode(arr_subRegions[regionArrID][y][1]));
				    switch (valType) {
			            case 1:
				            cOption.value = arr_subRegions[regionArrID][y][5]+'|'+arr_subRegions[regionArrID][y][6]+'|15|'+arr_subRegions[regionArrID][y][0];
				            break;
			            default:
			                cOption.value = arr_subRegions[regionArrID][y][0]+'|'+arr_subRegions[regionArrID][y][4];
			        }
				    cOption.style.color = '#000000';
				    cSelect.appendChild(cOption)
			    }
			}
		}
	}
}
function generateRegions(id, type, element, valType) {
	//valType: 0=value of normal location url, 1=value of lat and lng coords
	var countryArrID = id
	element.length = 1
	if (countryArrID == 0) {
		element.disabled = true;
	}
	else {
		//firstly we must remove all previous <options>
		var locList = element;
		if (locList.length > 0) {
            var i = 0;
            while(locList.hasChildNodes()) {
                locList.removeChild(locList.childNodes[i]);
            }
		}
		else {
			locList.length = 0;	
		}
		if (countryArrID != 0) {
			//then add in new <option> from array
			var cSelect
			var cOption
			var cOptgroup
			var cThisLevel, cLastLevel
			cThisLevel = 0
			cLastLevel = 0
			cSelect = element;
			cSelect.disabled = false;
			cOption = document.createElement('OPTION');
			cOption.value = '0';
			cOption.appendChild(document.createTextNode('Select A Region/City ...'));
			cSelect.appendChild(cOption)
			for (x=0; x<arr_regions[countryArrID].length; x++){
				switch (type) {
					case "optgroup":
						if (x != 0) {
							cSelect.appendChild(cOptgroup);
						}
						cOptgroup = document.createElement('OPTGROUP');
						cOptgroup.label = arr_regions[countryArrID][x][1];
						cOptgroup.style.color = '#0066FF';
						cOptgroup.style.fontWeight = 'bold';
						cOptgroup.style.paddingLeft = '10px';
						break
					default:
						cOption = document.createElement('OPTION');
						switch (valType) {
							case "1":
								cOption.value = arr_regions[countryArrID][x][5]+'|'+arr_regions[countryArrID][x][6]+'|10|'+arr_regions[countryArrID][x][0];
								break;
							default:
								cOption.value = arr_regions[countryArrID][x][0]+'|'+arr_regions[countryArrID][x][4];
								break;
						}
						cOption.appendChild(document.createTextNode(arr_regions[countryArrID][x][1]));
						cOption.style.color = '#0066FF';
						cOption.style.fontWeight = 'bold';
						cSelect.appendChild(cOption);
						break
				}
				for (y=0; y<arr_subRegions[arr_regions[countryArrID][x][0]].length; y++){
				    cOption = document.createElement('OPTION');
				    cOption.appendChild(document.createTextNode(arr_subRegions[arr_regions[countryArrID][x][0]][y][1]));
				    cOption.value = arr_subRegions[arr_regions[countryArrID][x][0]][y][0]+'|'+arr_subRegions[arr_regions[countryArrID][x][0]][y][4];
				    cOption.style.color = '#000000';
				    cOption.style.paddingLeft = '10px';
				    cSelect.appendChild(cOption)
			    }
			}
			if (type == "optgroup") {
				cOptgroup.appendChild(cOption)
			}
			else {
				cSelect.appendChild(cOption)
			}
		}
		else {
			element.disabled = true;
		}
	}
}
function showPage(id, pages) {
	for (i=1; i<=pages; i++) {
		if (parseInt(i) == parseInt(id)) {
			document.getElementById('page'+i).style.display = 'block';
			document.getElementById('link'+i).style.color = '#0054A8';
			document.getElementById('link'+i).style.textDecoration = 'underline';
			if (document.getElementById('link1'+i)) {
			    document.getElementById('link1'+i).style.color = '#0054A8';
			    document.getElementById('link1'+i).style.textDecoration = 'underline';
			}
		}
		else {
			document.getElementById('page'+i).style.display = 'none';
			document.getElementById('link'+i).style.color = '#CC3300';
			document.getElementById('link'+i).style.textDecoration = 'none';
			if (document.getElementById('link1'+i)) {
			    document.getElementById('link1'+i).style.color = '#CC3300';
			    document.getElementById('link1'+i).style.textDecoration = 'none';
			}
		}
	}
	if (id == 1) {
		document.getElementById('linkNext').style.color = '#CC3300';
		document.getElementById('linkNext').onclick = function(){showPage(2, pages);};
		document.getElementById('linkPrev').style.color = '#999999';
		document.getElementById('linkPrev').onclick = '';
		if (document.getElementById('link1Next')) {
		    document.getElementById('link1Next').style.color = '#CC3300';
		    document.getElementById('link1Next').onclick = function(){showPage(2, pages);};
		    document.getElementById('link1Prev').style.color = '#999999';
		    document.getElementById('link1Prev').onclick = '';
		}
	}
	else if (id == pages) {
		document.getElementById('linkNext').style.color = '#999999';
		document.getElementById('linkNext').onclick = '';
		document.getElementById('linkPrev').style.color = '#CC3300';
		document.getElementById('linkPrev').onclick = function(){showPage(pages-1, pages);};
		if (document.getElementById('link1Next')) {
		    document.getElementById('link1Next').style.color = '#999999';
		    document.getElementById('link1Next').onclick = '';
		    document.getElementById('link1Prev').style.color = '#CC3300';
		    document.getElementById('link1Prev').onclick = function(){showPage(pages-1, pages);};
		}
	}
	else {
		document.getElementById('linkNext').style.color = '#CC3300';
		document.getElementById('linkNext').onclick = function(){showPage(id+1, pages);};
		document.getElementById('linkPrev').style.color = '#CC3300';
		document.getElementById('linkPrev').onclick = function(){showPage(id-1, pages);};
		if (document.getElementById('link1Next')) {
		    document.getElementById('link1Next').style.color = '#CC3300';
		    document.getElementById('link1Next').onclick = function(){showPage(id+1, pages);};
		    document.getElementById('link1Prev').style.color = '#CC3300';
		    document.getElementById('link1Prev').onclick = function(){showPage(id-1, pages);};
		}
	}
	document.getElementById('cWhatPage').innerHTML = 'Page '+id+' Of '+pages;
	if (document.getElementById('cWhatPage1')) {
    	document.getElementById('cWhatPage1').innerHTML = 'Page '+id+' Of '+pages;
    }
}
function loadFormForGTAPost(URL, roomCode) {
    //change form action and load hidden field with room type
    document.getElementById('GTARoomCode').value = roomCode;
    document.aspnetForm.action = URL;
    document.aspnetForm.target = "blank";
}

function SetRooms(num)
{
    var RoomType = $get("sRoomType" + num).value;
    var NoOfRooms = parseInt($get("sNoOfRooms" + num).value);
    
    
    if(RoomType.indexOf("+")>-1) //If the room contains a plus child
    {
       var str = "Child Age";
       if (NoOfRooms >1)
       {
            str = str + "s";
       }
        $get("spCh" + num).innerHTML = str + " ";
        SetToVisible($get("dvCh" + num));
        $get("dvCh" + num).style.lineHeight = "23px";
        
        SetToHide($get("sCh" + num + "1"));
        SetToHide($get("sCh" + num + "2"));
        SetToHide($get("sCh" + num + "3"));
        for(var i=1;i<=NoOfRooms;i++)
        {
            CreateChild($get("sCh" + num + i));
        }
    }
    else
    {
        SetToHide($get("dvCh" + num));        
    }
}
function SetToHide(element)
{
    element.style.display = "none";
    element.style.visibility = "hidden";
}
function SetToVisible(element)
{
    element.style.visibility = "visible";
    element.style.display = "inline";
}
function CreateChild(select)
{
    for(var i=2;i<19;i++)
    {
            var cOption = document.createElement('OPTION');
			cOption.value = i;
			cOption.appendChild(document.createTextNode(i));
			select.appendChild(cOption);  
    }
    SetToVisible(select);            
}
function AddRemoveRoomTypes()
{
    var txt = $get("aRoomTypes").innerHTML;
    if(txt=="+ Add more rooms")
    {
        if($get("dvRoom2").style.display == "none")
        {
            SetToVisible($get("dvRoom2"));
        }
        else
        {
            SetToVisible($get("dvRoom3"));
            $get("aRoomTypes").innerHTML = "- Remove Room"
        }
    }
    else
    {
            if($get("dvRoom3").style.display == "none")
            {
                SetToHide($get("dvRoom2"));
                $get("aRoomTypes").innerHTML = "+ Add more rooms"
            }
            else
            {
                SetToHide($get("dvRoom3"));
            }
            

    }
}
function buildChildrenAges(cCount, ChildAgeCount, divChildren, ChildAge,ChildAges) {      
//	var xChildren = document.getElementById(cChildren);
//	var xChildIdx = xChildren.selectedIndex;	
//	var cCount = xChildren[xChildIdx].value;	

	var txt = itxt = "";	
	if (cCount == 0) {	
		  document.getElementById(ChildAgeCount).value = 0;	
		  document.getElementById(divChildren).innerHTML = "<select class=\"fs2\" name=\"" + ChildAge + "0\" id=\"" + ChildAge + "0\" style=\"margin-right: 5px\" disabled=\"disabled\"><option value=\"0\">No Children</option></select>";	
		  document.getElementById(ChildAges).value = "";
	} else {      	
		  document.getElementById(ChildAgeCount).value = cCount;	
		  var y = 0;	
		  itxt = itxt + "<option value=\"0\">&nbsp;</option>";	
		  for (y = 2; y < 19; y++) itxt = itxt + "<option value='" + y + "'>" + y + "</option>";
		  var childString;
		  var childC=0;
		  if(document.getElementById(ChildAges).value != "")
		  {
			  childString = document.getElementById(ChildAges).value.split("-");
			  childC = childString.length;
		  }
		 var ExistingCount=0	

		  for (var x = 0; x < cCount; x++) {	
				 txt = txt + "<select class=\"fs2\" onchange='SetHiddenChildAges(\"" + ChildAges + "\", " + cCount + ", \"" + ChildAge + "\");' name=\"" + ChildAge  + x + "\" id=\"" + ChildAge + x + "\" style=\"margin-right: 5px\">";
				if(childC-ExistingCount>0)
				{
					txt = txt + itxt.replace("value='" + childString[ExistingCount] + "'", "value='" + childString[ExistingCount] + "' selected='selected'") + "</select>";	
					ExistingCount +=1;
					
				}
				else
				{
					txt = txt + itxt + "</select>";	
				}
				if(cCount<childC)//If they are now choosing less rooms. repopulate the hidden ages with correct amount of kids.
				{
					var NewString = "";
					for(i=0;i<cCount;i++)
					{
						if(NewString!="")
						{
							NewString = NewString + "-";
						}
						NewString = NewString+childString[i];
					}
					document.getElementById(ChildAges).value = NewString;					
				}
				document.getElementById(divChildren).innerHTML = txt;					 
		  }  	
	}
}
function SetHiddenChildAges(ChildAges, cCount, ChildAge) {
	var xChild = document.getElementById(ChildAges);
	xChild.value = "";
	for(var i=0;i<cCount;i++) {
		var xCh = document.getElementById(ChildAge + i);
		var xChIdx = xCh.selectedIndex;

		if (xChIdx>0)
		{
			xChild.value += "-" + xCh[xChIdx].value;	
		}
	}
	if(cCount>0) {
		xChild.value = xChild.value.substring(1);		
	}
	else {
		xChild.value = "";
	}
}