// JavaScript Document
var arrDefaultValues = new Array("nome azienda", "nome e cognome referente", "indirizzo e-mail", "descrizione richiesta");


function getForm(productName) {
		
		var form = "<form id=\"form_ordine\" name=\"form_ordine\" method=\"post\" action=\"../inviarichiesta.php\" onsubmit=\"return validateFormOrdine();\"> \
			<div class=\"cornice\"> \
			  <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> \
				<tr>\
				  <td><input type=\"hidden\" name=\"hiddenProduct\" value=\"" + productName + "\" /><input name=\"azienda\" type=\"text\" value=\"" + arrDefaultValues[0] + "\" style=\"width:142px; margin-right:12px;\" /></td> \
				  <td><input name=\"referente\" type=\"text\" value=\"" + arrDefaultValues[1] + "\" style=\"width:150px;\" /></td> \
				</tr> \
			  </table> \
			  <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> \
				<tr> \
				  <td><input name=\"email\" type=\"text\" style=\"width:310px;\" value=\"" + arrDefaultValues[2] + "\"  /></td> \
				</tr> \
			  </table> \
			  <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> \
				<tr>\
				  <td><textarea name=\"descrizione\" rows=\"2\" style=\"width:230px; margin-right:12px; height:30px;\">" + arrDefaultValues[3] + "</textarea></td> \
				  <td><input type=\"submit\" name=\"Submit\" value=\"invia\" style=\"color:#333;\"/></td> \
				</tr> \
			  </table> \
			 </div> \
			</form>";
		
	
		document.write(form);
	
	}


function validateFormOrdine() {
		
		
		var objForm = document.form_ordine;
		
		if (objForm.azienda.value == '' || objForm.azienda.value == arrDefaultValues[0]) {
				alert('Digita il nome della tua azienda!');
				return false;
		}
		
		if (objForm.referente.value == '' || objForm.referente.value == arrDefaultValues[1]) {
				alert('Digita il tuo nome e cognome!');
				return false;
		}	

		if (objForm.email.value == '' || objForm.email.value == arrDefaultValues[2]) {
				alert('Digita il tuo indirizzo e-mail!');
				return false;
		}	
		
		if (objForm.descrizione.value == '' || objForm.descrizione.value == arrDefaultValues[3]) {
				alert('Descrivi il tuo ordine!');
				return false;
		}
	
	}