//*******************************
// site by Margherita spa
// code by chocLABS inc
//*******************************

// global variables
var myDoc=document

// purpose: To navigate to the URL contained in the value of the option
// usage: doesUrl(this) 
function doesUrl(obj) {
		if (obj.selectedIndex != 0) 
		location.href=obj.options[obj.selectedIndex].value;
}


// write the date in Italian
function doesDate() {
	var now = new Date();
	var year= now.getYear();if (year < 1000) year += 1900;
	nameDay = new Array('zondag','maandag','dinsdag','woensdag','donderdag','vrijdag','zaterdag');
	nameMth = new Array('januari','februari','maart','april','mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november','december');
	myDoc.write('<span class="green"><b>'+ now.getDate() + " " + nameMth[now.getMonth()] + " " + year+'</b></span>');
}	


//backward compatibility
function controleerFormulier (email) {
  return doesMail(email);
}

// purpose: validate & submit emailaddress
// usage: doesMail(this) 
// AND
// a tag like <input type="text" name="inpAdr" etc etc> in current form
function doesMail(obj) {
	var a = null;
	var f = obj.form.elements;

	//Looking for a text element in current form called "inpAdr"
	for(var i = 0; i < f.length && a == null; i++) {
		if (f[i].type == 'text' && f[i].name == 'inpAdr') {a=f[i].value;}
	}

	if (a.length == 0) {alert('Inserisci il tuo indirizzo di e-mail!');	return false;}
	else 
		if ((a.indexOf ('@') == -1) || (a.indexOf ('.') == -1) || (a.indexOf (' ') >= 0) || (a.length < 6)){
			alert ('\''+ a + '\'' +' non è un indirizzo valido!');return false;	}  
		else {obj.form.submit();return true;}
			
}


