function ucfirst (str) {
    str += '';
    var f = str.charAt(0).toUpperCase();
    return f + str.substr(1);
}

function changeEDIT(field, value) {
	document.getElementById(field).innerHTML = ucfirst(value);
}

function changeMAP() {
	street = document.getElementById('street').value;
	zip = document.getElementById('zip').value;
	city = document.getElementById('city').value;
	google = street + ' ' + zip + ' ' + city;
	document.getElementById('MAP').href = 'http://maps.google.be/maps?f=q&source=s_q&hl=fr&geocode=&q=' + google + '&keepThis=true&TB_iframe=true&height=500&width=800';
}

function hideContent(type, name)
{
	if(document.getElementById(type).value == name) {
	document.getElementById(type).value = '';
	}
}
			
function showContent(type, name)
{
	if(document.getElementById(type).value == '') {
	document.getElementById(type).value = name;
	}
}

function checkPass()
{
	pass1 = document.getElementById('newPass').value;
	pass2 = document.getElementById('newPass2').value;
	if(pass1 !== pass2) {
	alert('Les mots de passe diffèrent, veuillez corriger!');
	return false;
	}
}

function show(rid)
{
    document.getElementById(rid).style.display = "";
}

function hide(rid)
{
    document.getElementById(rid).style.display = "none";
}

function file(file) {
	if(window.XMLHttpRequest) // FIREFOX
				xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
				xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
				return(false);
	xhr_object.open("GET", file, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4) return(xhr_object.responseText);
	else return(false);
}

function deletePhoto(good, photo) {
	verif = file('/admin/scripts/deletePhoto.php?bien='+good+'&photo='+photo);
	document.getElementById('existingPhoto'+photo).style.display = "none";
	document.getElementById('newPhoto'+photo).innerHTML = '<input type="file" name="photo' + photo + '" id="photo' + photo + '" />';
}
