var w = window;
var d = window.document;

function by (id) {
	return window.document.getElementById (id);
}

function check () {
	var args = check.arguments;
	for (var i = 0 ; i < args.length; i++) {
		if (args[i].value == "") {
			return false;
		}
	}
	return true;
}

function convertirPrix (idtxt) {
	var prix = by (idtxt).value;
	
	try {
		prix = Number (prix);
		return true;
	} catch (err) {
		return false;
	}

}

function verifierNaN (id) {
	var txt = by (id);
	if (isNaN (txt.value)) {
		alert ("Nombre incorrect");
	} 
}

//xxxx-xxxx-xxxx-x
function verifierISBN (id) {
	var txt = by (id);
	
	//retirer les tirets
	txt = txt.value;
	while (txt.indexOf ('-') != -1) {
		txt = txt.replace ("-", "");
	}
	
	if (isNaN(txt) || ( txt.length != 13 && txt.length != 10)) {
		// alert ("ISBN incorrect");
		return false;
	} 
	return true;
}

function afficherPhoto (idfile, idimg)  {
	var file = by (idfile);
	var img = by (idimg);
	
	if (file.value != "") {
		img.src = "file://" + file.value;
	}
}