function goThere1(form){
	var linkList=form.qlink.selectedIndex
	var img=form.qlink.options[linkList].value
	if(img!=""){quadro.src=img; document.qform.submit.disabled=false} else {quadro.src="/qapp/blank.jpg"; document.qform.submit.disabled=true}
}

function goThere2(form){
	var linkList=form.sdlink.selectedIndex
	var img=form.sdlink.options[linkList].value
	if(img!=""){sfondo.src="/qapp/sfondi/"+img; document.sdform.submit.disabled=false} else {sfondo.src="/qapp/blank.jpg"; document.sdform.submit.disabled=true}
}

function checkAll(form){
	var ls = form.ls;
	var as = form.as;
	var slink = form.slink;
	if(notEmpty(ls, "Compilare tutti i campi")){
		if(notEmpty(as, "Compilare tutti i campi")){
			if(notEmpty(slink, "Compilare tutti i campi")){
				if(isNumeric(ls, "Compilare correttamente i campi numerici")){
					if(isNumeric(as, "Compilare correttamente i campi numerici")){
						return true;
					}
				}
			}
		}
	} return false;
}

function checkFile(elem){
	helperMsg="Le estensioni ammesse sono: jpg, jpeg, gif, png, bmp";
	pos = elem.lastIndexOf(".");
	len = elem.length;
	ext = elem.substring(pos+1,len);
	ext = ext.toLowerCase();
	if(ext!="jpg" && ext!="jpeg" && ext!="gif" && ext!="png" && ext!="bmp"){
		document.upload.submit.disabled=true;
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		document.upload.submit.disabled=false;
		return true;
	}
}

function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	} else {
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function notEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus();
		return false;
	}
	return true;
}
