function favoritControl(action,object,objectId) {
	if(action.checked  == true) {
		return dataUpdater.updateObject('FavoritesComponent', 'favorites-list', false, '/?FavoritesComponent[action]=add&FavoritesComponent[favorite]['+object+'][id]='+objectId , 'favoritesList', false, false)
	} else {
		return dataUpdater.updateObject('FavoritesComponent', 'favorites-list', false, '/?FavoritesComponent[action]=remove&FavoritesComponent[favorite]['+object+'][id]='+objectId , 'favoritesList', false, false)
	}
}

var locations = new Array();
locations[0] = "http://posrednik.com.ua";
locations[1] = "http://odessa.posrednik.com.ua";
locations[2] = "http://ilyichevsk.posrednik.com.ua";
locations[3] = "http://yuzhny.posrednik.com.ua";
locations[4] = "http://nikolaev.posrednik.com.ua";
locations[5] = "http://dnepropetrovsk.posrednik.com.ua";
locations[6] = "http://kiev.posrednik.com.ua";
locations[7] = "http://donetsk.posrednik.com.ua";
locations[1001] = "http://odessa-region.posrednik.com.ua";
locations[1002] = "http://kiev-region.posrednik.com.ua";

function setLocationFilter(locationId) {
	var location = "";
	if(locationId && locations[locationId]){
		location += locations[locationId];
	}else{
		location += locations[0];
	}
	
	var params = window.location.search;
	params = params.replace("CommonPageController[filter][locationId]=", "");
	
	location += window.location.pathname + params;
	
	if(locationId == "" || locationId == 0){
		location += (window.location.search == "")?"?":"&";
		location += "CommonPageController[filter][locationId]=";
	}
	
	window.location.href = location;
	//dataUpdater.updateObject('CommonPageController', false, false, '/?CommonPageController[filter][locationId]='+locationId , false, false, new Function('window.location.href=window.location.href;'));
}

function setBgColor(object, color){
	object.style.backgroundColor=color;
}

function switchVillageRegion(locationId) {
	if(locationId > 1000) {
		document.getElementById("village").disabled = false;
		document.getElementById("regionSelector").disabled=true;
	} else {
		document.getElementById("village").disabled = true;
		document.getElementById("regionSelector").disabled=false
	}
}

function getElementsByName_iefix(tag, name) {

 var elem = document.getElementsByTagName(tag);
 var arr = new Array();
 for(i = 0,iarr = 0; i < elem.length; i++) {
	  att = elem[i].getAttribute("name");
	  if(att == name) {
		   arr[iarr] = elem[i];
		   iarr++;
	  }
 }
	 return arr;
}

function getTimestamp() {
	return new Date();
}