function changeFR () {
	var currentLocation =  document.location.href;
	var num = currentLocation.lastIndexOf( ".php" );
	if (num==-1) {
		num = currentLocation.lastIndexOf( "/" );
		currentLocation = currentLocation.substring( 0 ,num );
		currentLocation += "/index.php?lang=fr";
	} else {
		currentLocation = currentLocation.substring( 0 ,num );
		currentLocation += ".php?lang=fr";
	}
    document.location = currentLocation;

}

function changeUK () {
	var currentLocation =  document.location.href;
	var num = currentLocation.lastIndexOf( ".php" );
	if (num==-1) {
		num = currentLocation.lastIndexOf( "/" );
		currentLocation = currentLocation.substring( 0 ,num );
		currentLocation += "/index.php?lang=uk";
	} else {
		currentLocation = currentLocation.substring( 0 ,num );
		currentLocation += ".php?lang=uk";
	};
    document.location = currentLocation;

}

function submitForm1 () {	
	var objMenu = document.getElementById("form1");
	objMenu.submit();
}

function submitForm2 () {	
	
	var objText = document.getElementById("email");
	if (bonmail(objText.value)) {
		var objMenu = document.getElementById("form2");
		objMenu.submit();
	} else {
		alert (textWrongEmail);
	}
}


isVisible = false;
function hideShowMenu () {
	var objMenu = document.getElementById("menu");
	if (!isVisible) {
		isVisible = true;
		objMenu.style.visibility = "visible";
	} else {
		isVisible = false;
		objMenu.style.visibility = "hidden";;
	}
}
function selectIdentifiant () {
	var objText = document.getElementById("login");
	if (objText.value==textIdentifiant) {
		objText.value = "";
	} else if (objText.value=="") {
		objText.value = textIdentifiant;
	}
}

function selectPassword () {
	var objText = document.getElementById("password");
	if (objText.value==textPassword) {
		objText.value = "";
	} else if (objText.value=="") {
		objText.value = textPassword;
	}
}

function selectNewsletter () {
	var objText = document.getElementById("email");
	if (objText.value==textEmail) {
		objText.value = "";
	} else if (objText.value=="") {
		objText.value = textEmail;
	}
}

function bonmail(mailteste)
{
	var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i');

	return(reg.test(mailteste));
}
