function checkLogin(usernameField, usernameDefaultText, passwordField, passwordDefaultText, errorMessage)
{
	if (document.getElementById(usernameField).value==usernameDefaultText)
	{
		alert(errorMessage);
		document.getElementById(usernameField).focus();
		return false;
	}
	if (document.getElementById(passwordField).value==passwordDefaultText)
	{
		alert(errorMessage);
		document.getElementById(passwordField).focus();
		return false;
	}
	return true;
}

function deleteImage(realestateLocation, erasedFile, actualURL, record_id, message)
{
	if (confirm(message+"?"))
		document.location = realestateLocation+'inc/erase_file.php?file='+erasedFile+'&actualURL='+actualURL+"&record_id="+record_id;
}

function loadBigImage(my_image)
{
	document.getElementById("image_place").innerHTML = '<img src="'+my_image+'" style="border:1px solid #30438F;" />';
}

function changeTab(nr, page)
{
	//, containerToShow
	// , "ffedd7"
//	alert(nr+"~"+page)
	var tabColors = ["", "C6EFC4", "d7eefe", "daffd8"];
	for (i=1;i<tabColors.length;i++)
	{
		if (nr==i)
		{
			document.getElementById("tab"+i).className = "tabActive"+page;
			document.getElementById("box"+i).className = "boxActive"+page;
			document.getElementById("box"+i).style.display = '';
			document.getElementById("tab"+i).style.backgroundColor = "#"+tabColors[i];
			document.getElementById("box"+i).style.backgroundColor = "#"+tabColors[i];
		}
		else
		{
			document.getElementById("tab"+i).className = "tabInactive"+page;
			document.getElementById("box"+i).className = "boxInactive"+page;
			document.getElementById("box"+i).style.display = 'none';
			document.getElementById("tab"+i).style.backgroundColor = "#C6EFC4";
			document.getElementById("box"+i).style.backgroundColor = "#C6EFC4";
		}
	}
}

function changeTabSite(nr, page, containerToShow)
{
	// , "ffedd7"
	var tabColors = ["", "d7eefe", "daffd8"];
	for (i=1;i<tabColors.length;i++)
	{
		if (nr==i)
		{
			document.getElementById("tab"+i).className = "tabActive"+page;
			document.getElementById("box"+i).className = "boxActive"+page;
			document.getElementById("box"+i).style.display = '';
			document.getElementById("tab"+i).style.backgroundColor = "#"+tabColors[i];
			document.getElementById("box"+i).style.backgroundColor = "#"+tabColors[i];
		}
		else
		{
			document.getElementById("tab"+i).className = "tabInactive"+page;
			document.getElementById("box"+i).className = "boxInactive"+page;
			document.getElementById("box"+i).style.display = 'none';
			document.getElementById("tab"+i).style.backgroundColor = "#C6EFC4";
			document.getElementById("box"+i).style.backgroundColor = "#C6EFC4";
		}
	}
	document.getElementById("resultList_sale").style.display = 'none';
	document.getElementById("resultList_rent").style.display = 'none';
	document.getElementById("resultList_"+containerToShow).style.display = '';
}

function verificaForm(component, reWriteContent, mod)
{
	actualContent = document.getElementById(component).value;

	if (mod == "focus")
	{
		if (actualContent == reWriteContent)
			document.getElementById(component).value = "";
	}
	if (mod == "blur")
	{
		if (actualContent == "")
			document.getElementById(component).value = reWriteContent;
	}
}

function changeHorizTab(actualTab)
{
	var colors = ["", "D7EEFE", "DAFFD8", "FFEDD7"];
	for (i=1;i<4;i++)
	{
		if (i==actualTab)
		{
			document.getElementById("hor_tab"+i).className = "horizontalTabs"+i+"Active";
			document.getElementById("containerTabs").style.backgroundColor = "#"+colors[i];
			document.getElementById("cont"+i).style.display = "";
		}
		else
		{
			document.getElementById("hor_tab"+i).className = "horizontalTabs"+i;
			document.getElementById("cont"+i).style.display = "none";
		}
	}
}




var responseSuccessLocalitiesAdmin = function(o)
{
	lang = document.getElementById("language").value;
	if (lang=="ro")
	{
		__other = "altul";
		__any	= "orice";
	}
	if (lang=="en")
	{
		__other = "other";
		__any	= "any";
	}
	document.getElementById("cartiere_container").innerHTML = '<select name="cartier" onchange="getCartier(this.value)" class="form"><option value="0">----'+__any+'----</option><option value="-1">----'+__other+'----</option></select>\n<input type="text" class="form" style="display:none;" name="cartier_other" id="cartier_other" onfocus="this.className=\'form_hover\'" onblur="this.className=\'form\'" />';
	document.getElementById("localities_container").innerHTML = o.responseText;
};

var responseFailureLocalitiesAdmin = function(o)
{ }
var callbackLocalitiesAdmin =
{
	success:responseSuccessLocalitiesAdmin,
	failure:responseFailureLocalitiesAdmin
};

function getLocalitiesAdmin(frm)
{
	current_frm = frm;
	var country = document.getElementById("country").value;
	var cObj = YAHOO.util.Connect.asyncRequest('GET', '/ajax/get_localities_admin.php?frm='+frm+'&country='+country, callbackLocalitiesAdmin);
}


function getCartier(myValue)
{
	if (myValue==-1)
		document.getElementById("cartier_other").style.display='';
	else
		document.getElementById("cartier_other").style.display='none';
}




var responseSuccessCartiereAdmin = function(o)
{
	document.getElementById("cartiere_container").innerHTML = o.responseText;
};

var responseFailureCartiereAdmin = function(o)
{ }
var callbackCartiereAdmin =
{
	success:responseSuccessCartiereAdmin,
	failure:responseFailureCartiereAdmin
};

function getCartiereAdmin()
{
	current_frm = 'frm_register';
	var locality = document.getElementById("locality").value;
	var cObj = YAHOO.util.Connect.asyncRequest('GET', '/ajax/get_cartiere_admin.php?frm='+current_frm+'&locality='+locality, callbackCartiereAdmin);
}


function getCartiere(myValue)
{
	if (myValue!=-1)
	{
		document.getElementById("locality_other").style.display='none';
		getCartiereAdmin()
	}
	else
	{
		document.getElementById("locality_other").style.display='';
	}	
}