var objSettlement;
function RegionChanged(objRegion,restTypeID,settlementID)
{
	objSettlement = document.getElementById(settlementID);
	WeekendRestType.UserControls.SearchEngine.GetRegionSettlements(parseInt(restTypeID),parseInt(objRegion.value),FillSettlements_Callback);
}

function FillSettlements_Callback(settlements)
{
	//first,clear the items in destination
	for(var k=objSettlement.options.length - 1 ; k > -1 ; --k)
	{
		objSettlement.options[k] = null;
	}
	if (settlements.value != null && settlements.value.Rows != null && settlements.value.Rows != 'undefined')
	{
		for(var k = 0 ; k < settlements.value.Rows.length ; ++k)
		{
			var row = settlements.value.Rows[k];
			var ListItem = new Option();
			ListItem.value = row.settlementID;
			ListItem.text = row.settlementName;	
			objSettlement.options[objSettlement.options.length] = ListItem;
		}
	}
	else if(settlements.value != null)
	{
		for(var k = 0 ; k < settlements.value.length ; ++k)
		{
			var row = settlements.value[k];
			var ListItem = new Option();
			ListItem.value = row[0];
			ListItem.text = row[1];	
			objSettlement.options[objSettlement.options.length] = ListItem;
		}	
	}
	//select the first item
	try
	{
	objSettlement.options[0].selected = true;
	}
	catch{}
}

function RoomVacancy(customerID)
{
	window.open("http://www.weekend.co.il/CustomerRoomVacancy.aspx?CustomerID="+customerID+"&lang=HE",'RoomVacancy','width=540, height=410, resizable=no, scrollbars=yes, top=50, left=50');
}

function openMapWindow(settlement, address, house, comment){
	window.open("http://www.emap.co.il/?client=weekend&action=match_address&city=" + settlement + "&street=" + address + "&house=" + house + "&comment0=" + comment, "mapPage", "left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=750,height=600",true)
}

var favObj;
function addToFavouriteList(favBtn,customerID)
{
	favObj = favBtn;
	WeekendRestType.UserControls.CustomersList.AddToFavouriteList(customerID,addToFavouriteList_Callback);		
	return false;
}
function addToFavouriteList_Callback(response)
{
	favObj.src = './images/addToFavourite_click.gif';
	favObj.onmouseover = null;
	favObj.onmouseout  = null;	
	favObj.disabled = true;
}
function openVideoWindow(customerID)
 {
	openWin1 = window.open("http://www.weekend.co.il/Video/customerVideo.aspx?customerID="+ customerID +"&lang=HE", 'openCustVideo', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,top=100,left=100,width=340 height=548');
	openWin1.focus();
}
function RefreshGif(imgID,imgURL)
{
	var imgObj = document.getElementById(imgID);
	imgObj.src = imgURL;	
}
