
function modifyQuickSearchAction(rentSectionImg, form) {
	//rentSectionImg = ;
	// a hack. For the active section _over is appended to the image src
	// for the rent offers section, this suffix is also used as
	// avlue of the class attribute, just to make determining whether
	// the rent section is active easier
	if (rentSectionImg)
	if (rentSectionImg.className == '_over') {
		//document.quickSearch.action = '/properties/rent-offers?clear=1';
		form.action = '/properties/rent-offers?clear=1';
	}
}


// this function is relevant only in the new offer screen in the user area
function toggleNewVillageInput(flag) {
	// this code is relevant only for the create offer screen in the user area
	villageName = document.getElementById('VillageName');
	villageIsPublic = document.getElementById('VillageIsPublic');
	if(flag && villageName && villageIsPublic) {
		villageName.disabled = false;
		villageIsPublic.disabled = false;
	} else if(villageName && villageIsPublic) {
		villageName.disabled = true;
		villageIsPublic.disabled = true;
	}
}

function populateVillages(regionId, villageSelectId, choiceAllNotPresent ) {
	return;
	villageChoiceBox = document.getElementById(villageSelectId);
	var regionMatched = false;
	var found = false;
	for(i in villagesToRegions) {
		if(i == regionId) {
				setVillageOptions(villageChoiceBox, villagesToRegions[i], choiceAllNotPresent);
				found = true;
				break;		
		}
	}
	
	if(!found) {
		setVillageOptions(villageChoiceBox, new Array(), choiceAllNotPresent);
	}
	
	toggleNewVillageInput(true);	
	
	// this code is relevant only for the search screen
	villageSelectedBox = document.getElementById('SelectedVillageID');
	
	if(villageSelectedBox) {
		villageSelectedBox.options.length = 0;
		villageSelectedBox.options[0]  = null;
	
	}
	
}
// Angel Naydenov 02.07.2007 ///////////////////////////////////////////////////////////////////////
var newPopulateVillages = function(t)
{
	//alert(t.responseText);
	var aData = t.responseText.split('<LEVEL1>');
	aData[0] = aData[0].split('<LEVEL2>');
	aData[1] = aData[1].split('<LEVEL2>');
	
	var villageSelectId = aData[0][1];
	var villageChoiceBox = document.getElementById(villageSelectId);
	var choiceAllNotPresent = aData[0][2];
	var SelectedVillageID = aData[0][3];
	
	if (SelectedVillageID)
	{
		var villageSelectedBox = document.getElementById(SelectedVillageID);
		villageSelectedBox.options.length = 0;
	}
	
	//var sTest = '';
	villageChoiceBox.options.length = 0;
	villageChoiceBox.options[0]  = null;
	for (var i = 1; i < aData[1].length; i++)
	{
		aData[1][i] = aData[1][i].split('<LEVEL3>');
		//sTest += aData[1][i][0] + ' => ' + aData[1][i][1] + '\n';
		villageChoiceBox.options[villageChoiceBox.options.length] = new Option(aData[1][i][1],aData[1][i][0]);
	}
	
	//alert(sTest);
}

function populateVillagesAjax(regionId, villageSelectId, choiceAllNotPresent, SelectedVillageID)
{
	sParams = 'regionId=' + regionId + '&villageSelectId=' + villageSelectId +
	          '&choiceAllNotPresent=' + choiceAllNotPresent +
	          '&SelectedVillageID=' + SelectedVillageID;
	
	new Ajax.Request('/populateVillages.php', {parameters:sParams, onSuccess:newPopulateVillages});
}
////////////////////////////////////////////////////////////////////////////////////////////////////	
function setVillageOptions(villageChoiceBox, optionArray, choiceAllNotPresent) {
		villageChoiceBox.options.length = 0;
		if(optionArray.length == 0) {
			villageChoiceBox.options[0] = new Option('--Select area--',0);
			return;
		}
		
		if(!choiceAllNotPresent && !villageChoiceBox.multiple) {
			villageChoiceBox.options[villageChoiceBox.options.length] = new Option('All','');
		}
		
		for(i in optionArray) {
			villageChoiceBox.options[villageChoiceBox.options.length] = new Option(optionArray[i],i);
		}
	}
	
function validateQuickSearchCriteria(propertyType, regionId, villageId, propertyPriceTo) {
	if(!propertyType && regionId && villageId && propertyPriceTo) {
	 return false;
	} 
	
	
	if(propertyPriceTo.length > 0 && parseInt(propertyPriceTo) != propertyPriceTo) {
	 return false;
	}

	return true;
}
	
