function checkPicture() {
	var obj = document.FRM_Picture;
	if(obj.image == "") alert(ErrPhoto);
	else if((obj.image.value.lastIndexOf(".jpeg") == -1)
		&& (obj.image.value.lastIndexOf(".jpg") == -1)
		&& (obj.image.value.lastIndexOf(".JPG") == -1)
		&& (obj.image.value.lastIndexOf(".JPEG") == -1)
		&& (obj.image.value.lastIndexOf(".gif") == -1)
		&& (obj.image.value.lastIndexOf(".GIF") == -1)
		&& (obj.image.value.lastIndexOf(".png") == -1)
		&& (obj.image.value.lastIndexOf(".bmp") == -1)
		&& (obj.image.value.lastIndexOf(".bmp") == -1)
		&& (obj.image.value.lastIndexOf(".BMP") == -1)) 
	alert(ErrPhoto);
	else obj.submit();
}

function checkPictureJPG() {
	var obj = document.FRM_Picture;
	if(obj.image == "") alert(ErrPhoto);
	else if((obj.image.value.lastIndexOf(".jpeg") == -1)
		&& (obj.image.value.lastIndexOf(".jpg") == -1)
		&& (obj.image.value.lastIndexOf(".JPG") == -1)
		&& (obj.image.value.lastIndexOf(".JPEG") == -1))
	alert(ErrPhoto);
	else obj.submit();
}

function checkNews(oblig) {
	var obj = document.FRM_News;
		if (oblig == true) {
			var checkEmpty = checkTextEmpty(obj.titre, obj.nom, obj.prenom, obj.mail);
			if (checkEmpty != -1) alert(ErrMessage);
			else if (!isEmail(obj.mail.value))  alert(ErrEmail);
			else obj.submit();
		} else if (oblig == false) {
			var checkEmpty = checkTextEmpty(obj.titre, obj.prenom);
			if (checkEmpty != -1) alert(ErrMessage);
			else obj.submit();
		} 
}

function checkPromotions() {
	var obj = document.FRM_Promotions;
	var checkEmpty = checkTextEmpty(obj.titre);
	if (checkEmpty != -1) alert(ErrMessage);
	else obj.submit();
}

function checkBackground() {
	var obj = document.FRM_Picture;
	if(obj.image == "") alert(ErrPhoto);
	else if((obj.image.value.lastIndexOf(".jpeg") == -1)
		&& (obj.image.value.lastIndexOf(".jpg") == -1)
		&& (obj.image.value.lastIndexOf(".JPG") == -1)
		&& (obj.image.value.lastIndexOf(".JPEG") == -1)) 
	alert(ErrPhoto);
	else obj.submit();
}

function checkLogos() {
	var obj = document.FRM_Logos;
	var checkEmpty = checkTextEmpty(obj.marque, obj.url);
	if (checkEmpty != -1) alert(ErrMessage);
	else obj.submit();
}

function checkOccasions() {
	var obj = document.FRM_Occasions;
	var checkEmpty = checkTextEmpty(obj.a, obj.b, obj.marque, obj.modele, obj.annee, obj.prix);
	if (checkEmpty != -1) alert(ErrMessage);
	else obj.submit();
}

function checkLinks() {
	var obj = document.FRM_Links;
	var checkEmpty = checkTextEmpty(obj.titre, obj.url);
	if (checkEmpty != -1) alert(ErrMessage);
	else obj.submit();
}

function checkSpots() {
	var obj = document.FRM_Spots;
	var checkEmpty = checkTextEmpty(obj.nom, obj.gauche, obj.haut);
	if (checkEmpty != -1) alert(ErrMessage);
	else obj.submit();
}

function checkCustomer() {
	var obj = document.FRM_Customer;
	if (isEmpty(obj.email.value)) goAlert(obj.email, errMsg);
	else if (isEmpty(obj.password.value)) goAlert(obj.password, errMsg);
	else if (checkSelectEmpty("", obj.gender) != -1) goAlert(obj.gender, errMsg);
	else if (checkSelectEmpty("", obj.language) != -1) goAlert(obj.language, errMsg);
	else if (isEmpty(obj.lname.value)) goAlert(obj.lname, errMsg);
	else if (isEmpty(obj.fname.value)) goAlert(obj.fname, errMsg);
	else if (isEmpty(obj.address.value)) goAlert(obj.address, errMsg);
	else if (isEmpty(obj.city.value)) goAlert(obj.city, errMsg);
	else if (isEmpty(obj.zip.value)) goAlert(obj.zip, errMsg);
	else if (isEmpty(obj.country.value)) goAlert(obj.country, errMsg);
	else obj.submit();
}

function checkTransaction() {
	var obj = document.FRM_Transaction;
	if (checkSelectEmpty("", obj.email) != -1) goAlert(obj.email, errMsg);
	else if (isEmpty(obj.amount.value)) goAlert(obj.amount, errMsg);
	else if (isEmpty(obj.fees.value)) goAlert(obj.fees, errMsg);
	else if (isEmpty(obj.description.value)) goAlert(obj.description, errMsg);
	else if (!isEmpty(obj.refobject.value) && !isNumeric(obj.refobject.value)) goAlert(obj.refobject, "La référence doit être un nombre!");
	else {
		if (isEmpty(obj.refobject.value)) obj.refobject.value = 0; 
		obj.submit();
	}
}

function checkSuperg() {
	var obj = document.FRM_Superg;
	if (isEmpty(obj.lname.value)) goAlert(obj.lname, "Veuillez indiquer votre nom");
	else if (isEmpty(obj.fname.value)) goAlert(obj.fname, "Veuillez indiquer votre prénom");
	else if (isEmpty(obj.address1.value)) goAlert(obj.address1, "Veuillez indiquer votre adresse");
	else if (isEmpty(obj.zip.value)) goAlert(obj.zip, "Veuillez indiquer votre code postal");
	else if (isEmpty(obj.city.value)) goAlert(obj.city, "Veuillez indiquer votre ville");
	else if (checkSelectEmpty("", obj.day) != -1 || checkSelectEmpty("", obj.month) != -1 || checkSelectEmpty("", obj.year) != -1) goAlert(obj.day, "La date de naissance n'est pas correcte");
	else if (!isDate(getSelect(obj.year), getSelect(obj.month), getSelect(obj.day))) goAlert(obj.day, "La date de naissance n'est pas correcte");
	else if (isEmpty(obj.email.value)) goAlert(obj.email, "Veuillez indiquer votre email");
	else if (!isEmail(obj.email.value)) goAlert(obj.email, "Votre email n'est pas correct");
	else if (obj.email.value != obj.email2.value) goAlert(obj.email2, "La confirmation de l'email n'est pas correcte");
	else if (checkSelectEmpty("", obj.club) != -1) goAlert(obj.club, "Veuillez choisir un club");
	else obj.submit();
}


function checkRange(typeSave) {
	var obj = document.FRM_Catalogue;
	if (isEmpty(obj.t_brand.value) && checkSelectEmpty("", obj.s_brand) != -1) goAlert(obj.s_brand, "Veuillez choisir une marque");
	else if (isEmpty(obj.t_brand.value) && checkSelectEmpty("", obj.s_brand) != -1) goAlert(obj.s_brand, "Veuillez choisir une marque");
	else if (isEmpty(obj.t_model.value) && checkSelectEmpty("", obj.s_model) != -1) goAlert(obj.s_model, "Veuillez choisir un modèle");
	else if (isEmpty(obj.t_typefr.value) && checkSelectEmpty("", obj.s_typefr) != -1) goAlert(obj.s_typefr, "Veuillez choisir un type FR");
	else if (isEmpty(obj.t_typeen.value) && checkSelectEmpty("", obj.s_typeen) != -1) goAlert(obj.s_typeen, "Veuillez choisir un type EN");
	else {
		obj.action.value = typeSave;
		obj.submit();
	}
}

function checkProduct(typeSave) {
	var obj = document.FRM_Catalogue;
	if (isEmpty(obj.size.value)) goAlert(obj.size, "Veuillez indiquer une taille");
	else if (isEmpty(obj.price.value)) goAlert(obj.price, "Veuillez indiquer un prix (pas cher)");
	else {
		obj.action.value = typeSave;
		obj.submit();
	}
}

function goAlert (champ, msg) {
	champ.focus();
	alert (msg);
}

function checkEmail() {
	var obj = document.FRM_Email;
	if (isEmpty(obj.email.value) || !isEmail(obj.email.value)) alert(errEmail);
	else document.FRM_Email.submit();
}

function checkVpc(from) {
	var obj = document.FRM_Vpc;
	if (from == 'standalone') {
		type = getCheckBox(obj.typecheck, '@@');
		if (isEmpty(obj.product.value)) goAlert(obj.product, errProduct);
		else if (type == '-@@-') goAlert(obj.typecheck[0], errType);
		else if (isEmpty(obj.email.value) || !isEmail(obj.email.value)) goAlert(obj.email, errEmail);
		else if (obj.email.value != obj.email2.value) goAlert(obj.email2, errEmail2);
		else if (isEmpty(obj.lname.value)) goAlert(obj.lname, errLname);
		else if (isEmpty(obj.fname.value)) goAlert(obj.fname, errFname);
		//else if (isEmpty(obj.comment.value)) goAlert(obj.comment, errComment);
		else {
			obj.type.value = type;
			obj.submit();
		}
	} else if (from == 'winterdeals') {
		if (isEmpty(obj.email.value) || !isEmail(obj.email.value)) goAlert(obj.email, errEmail);
		else if (obj.email.value != obj.email2.value) goAlert(obj.email2, errEmail2);
		else if (isEmpty(obj.lname.value)) goAlert(obj.lname, errLname);
		else if (isEmpty(obj.fname.value)) goAlert(obj.fname, errFname);
		else if (isEmpty(obj.comment.value)) goAlert(obj.comment, errComment);
		else obj.submit();
	} else {
		if (isEmpty(obj.email.value) || !isEmail(obj.email.value)) goAlert(obj.email, errEmail);
		else if (obj.email.value != obj.email2.value) goAlert(obj.email2, errEmail2);
		else if (isEmpty(obj.lname.value)) goAlert(obj.lname, errLname);
		else if (isEmpty(obj.fname.value)) goAlert(obj.fname, errFname);
		else obj.submit();
	}
}