function changecity(cityvalue)
{ 
	catmenu[0].selectedIndex = -1;
	catmenu[1].selectedIndex = -1;
	document.ListItemForSale.cityename.value="";
	if (document.ListItemForSale.cityname.value!="")
	  {
	    document.ListItemForSale.cityname.value="";
	  }
	
}
function zxw(thm)
{
    
	catmenu[0].selectedIndex=-1;
	catmenu[1].selectedIndex=-1;
	document.ListItemForSale.cityename.value="";
	for (i=0;i<document.ListItemForSale.hotelcity.length;i++)
	{
			
		if (document.ListItemForSale.hotelcity[i].checked) 
			{
			    document.ListItemForSale.hotelcity[i].checked=false;
				break;
			}
	
	}
}
function changemenu(cm)
{
	var chosencategory;
	var numChildren;
	var CatId;
	var CatName;
	var i;
	if (cm!=-1)
	   {
	     for (i=0;i<document.ListItemForSale.hotelcity.length;i++)
	           {
			   if (document.ListItemForSale.hotelcity[i].checked) 
			        {
			        document.ListItemForSale.hotelcity[i].checked=false;
				    break;
			        }
	            document.ListItemForSale.cityename.value="";
		       }
		 if (document.ListItemForSale.cityname.value!="")
	           {
	               document.ListItemForSale.cityname.value="";
	            }
	     
		 
		}
	// make sure user didn't click on an empty box
	if ((cm != -1) && (catmenu[cm].length < 1))
		return;
	// get the chosen category from this catmenu
	if (cm == -1)
		chosencategory = 0;
	else
	{
		if (catmenu[cm].selectedIndex == -1)
			return;
			chosencategory = catmenu[cm].options[catmenu[cm].selectedIndex].value;
	}
		
	// if no children, then user is done;
	if (c[chosencategory] == null)
	{
		document.ListItemForSale.category1.value = chosencategory;
		numChildren = 0;
	}
	else
	{
		if (cm != -1)
		{
			if (document.ListItemForSale.name != "ChangePreferencesShow")
				document.ListItemForSale.category1.value = "";
			else
				document.ListItemForSale.category1.value = chosencategory;
		}
		numChildren = c[chosencategory].length;
	}
	// fill up the next based on the chosencategory
	if ((cm+1) < catmenu.length)
	{
		for (i = 0; i < numChildren; i++)
		{
			CatId = c[chosencategory][i];
			CatName = (c[CatId]==null) ? n[CatId] : n[CatId];
			catmenu[cm+1].options[i] = new Option(CatName, CatId);
//			if (i == numChildren-1 && cm+1 == catmenu.length-1)
			if (i == 0 && cm+1 == catmenu.length-1)
			{
				catmenu[cm+1].options[i].selected = true;
				document.ListItemForSale.category1.value=catmenu[cm+1].options[i].value;
			}
		}
		catmenu[cm+1].length = numChildren;
	}
	// clear out all menus to the right of this menu
	for (i = cm+2; i < catmenu.length; i++)
	{
		catmenu[i].length = 0;
	}
	a=document.ListItemForSale.category1.value;
	document.ListItemForSale.cityename.value=n[a];
}
function show(strtype)
{
document.all.item(strtype).style.display = "block";
}
function hide(strtype)
{
document.all.item(strtype).style.display = "none";
}
function isDate(sDate) {
	var iYear, iMonth, iDay, iIndex

	var	reg
	reg = new RegExp('[^0-9-]','')
	if (sDate.search(reg) >= 0)
		return false;
	
	iIndex = sDate.indexOf('-');
	if ( iIndex == -1 )
		return false;
	else {
		iYear = parseFloat(sDate.substr(0, iIndex));
		if ( isNaN(iYear) || iYear < 1900 || iYear > 2099 )
			return false;
		else
			sDate = sDate.substring(iIndex + 1, sDate.length);
	}
	
	iIndex = sDate.indexOf('-');
	if ( iIndex == -1 )
		return false;
	else {
		iMonth = parseFloat(sDate.substr(0, iIndex));
		if ( isNaN(iMonth) || iMonth < 1 || iMonth > 12 )
			return false;
		else
			sDate = sDate.substring(iIndex + 1, sDate.length);
	}
	
	iIndex = sDate.indexOf('-');
	if ( iIndex >= 0 )
		return false;
	else {
		iDay = parseFloat(sDate);
		if ( isNaN(iDay) || iDay < 1 || iDay > 31 )
			return false;
	}
	
	
	switch(iMonth) {
		case 4:
		case 6:
		case 9:
		case 11:
			if ( iDay > 30 )
				return false;
			else
				break;
		case 2:
			if ( ( ( iYear % 4 == 0 && iYear % 100 != 0 ) || iYear % 400 == 0 ) && iDay > 29 )
				return false;
			else if ( (iYear % 4 != 0 || (iYear % 100 == 0 && iYear % 400 != 0)) && iDay > 28 )
				return false;
			else
				break;
		default:
	}
	return true;
}
function stringToDate(sDate, bIgnore)
{	var bValidDate, year, month, day
	var iaDate = new Array(3)
	
	if (bIgnore) bValidDate = true
	else bValidDate = isDateString(sDate)
	
	if (bValidDate)
	{  iaDate = sDate.toString().split("-")
		year = parseFloat(iaDate[0])
		month = parseFloat(iaDate[1]) - 1
		day=parseFloat(iaDate[2])
		return (new Date(year,month,day))
	}
	else return (new Date(1900,1,1))
}
function isnumber(str)
{
var number_chars = "1234567890";
var i;
for (i=0;i<str.length;i++)
{
if (number_chars.indexOf(str.charAt(i))==-1) return false;
}
return true;
}
