function Validate(){
	
	checkboxSedi = document.forms[2].checkbox_sede;
	checkboxAree = document.forms[2].checkbox_area;
	
	numCheckedSedi = 0;
	for (i = 0; i <= checkboxSedi.length-1; i++){
		if (!checkboxSedi[i].checked) numCheckedSedi += 1;
	}
	
	if (numCheckedSedi == checkboxSedi.length) {
		alert("E' necessario selezionare almeno una sede");
		return false;
	}
	
	numCheckedAree = 0;
	for (i = 0; i <= checkboxAree.length-1; i++){
		if (!checkboxAree[i].checked) numCheckedAree += 1;
	}
	
	if (numCheckedAree == checkboxAree.length) {
		alert("E' necessario selezionare almeno un'area");
		return false;
	}
}

function ValidateMail(){
	if (document.forms[0].nome.value  == ""){
		alert("Il campo \"Nome\" non può essere vuoto");
		document.forms[0].nome.focus();
		return false;
	}
	
	if (document.forms[0].cognome.value  == ""){
		alert("Il campo \"Cognome\" non può essere vuoto");
		document.forms[0].cognome.focus();
		return false;
	}
	
	if (document.forms[0].eta.value  == ""){
		alert("Il campo \"Età\" non può essere vuoto");
		document.forms[0].eta.focus();
		return false;
	}
	
	if (document.forms[0].occupazione.value  == ""){
		alert("Il campo \"Occupazione\" non può essere vuoto");
		document.forms[0].occupazione.focus();
		return false;
	}
	
	if (document.forms[0].telefono.value  == ""){
		alert("Il campo \"Telefono\" non può essere vuoto");
		document.forms[0].telefono.focus();
		return false;
	}
	
	if (document.forms[0].email.value == ""){
		alert("Il campo \"E-mail\" non può essere vuoto");
		document.forms[0].email.focus();
		return false;
	}
	
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.forms[0].email.value)){
		alert("L\'indirizzo e-mail inserito non è in un formato corretto");
		return false;
	}
}

function ValidateFranchising(){
	if (document.forms[0].nome.value  == ""){
		alert("Il campo \"Nome\" non può essere vuoto");
		document.forms[0].nome.focus();
		return false;
	}
	
	if (document.forms[0].cognome.value  == ""){
		alert("Il campo \"Cognome\" non può essere vuoto");
		document.forms[0].cognome.focus();
		return false;
	}
	
	if (document.forms[0].ditta.value  == ""){
		alert("Il campo \"Ditta\" non può essere vuoto");
		document.forms[0].ditta.focus();
		return false;
	}
	
	if (document.forms[0].telefono.value  == ""){
		alert("Il campo \"Telefono\" non può essere vuoto");
		document.forms[0].telefono.focus();
		return false;
	}
	
	if (document.forms[0].email.value == ""){
		alert("Il campo \"E-mail\" non può essere vuoto");
		document.forms[0].email.focus();
		return false;
	}
	
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.forms[0].email.value)){
		alert("L\'indirizzo e-mail inserito non è in un formato corretto");
		return false;
	}
}

function ValidateOfferta(){
	/*
	if (document.forms[0].nome.value  == ""){
		alert("Il campo \"Nome\" non può essere vuoto");
		document.forms[0].nome.focus();
		return false;
	}
	
	if (document.forms[0].cognome.value  == ""){
		alert("Il campo \"Cognome\" non può essere vuoto");
		document.forms[0].cognome.focus();
		return false;
	}
	*/
	if (document.forms[0].pers_rif.value  == ""){
		alert("Il campo \"Persona di riferimento\" non può essere vuoto");
		document.forms[0].pers_rif.focus();
		return false;
	}
	
	if (document.forms[0].azienda.value  == ""){
		alert("Il campo \"Azienda\" non può essere vuoto");
		document.forms[0].azienda.focus();
		return false;
	}
	
	if (document.forms[0].citta.value  == ""){
		alert("Il campo \"Città\" non può essere vuoto");
		document.forms[0].citta.focus();
		return false;
	}
	
	if (document.forms[0].telefono.value  == ""){
		alert("Il campo \"Telefono\" non può essere vuoto");
		document.forms[0].telefono.focus();
		return false;
	}
	
	if (document.forms[0].email.value == ""){
		alert("Il campo \"E-mail\" non può essere vuoto");
		document.forms[0].email.focus();
		return false;
	}
	
	if (document.forms[0].offerta.value == ""){
		alert("Il campo \"Offerta\" non può essere vuoto");
		document.forms[0].offerta.focus();
		return false;
	}
	
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.forms[0].email.value)){
		alert("L\'indirizzo e-mail inserito non è in un formato corretto");
		return false;
	}
}

function Popup(sPicURL) {
	window.open("/popup.html?"+sPicURL, "", "height=200, width=200, scrollbars=no, menubar=no");
}

function PopupInfo(intCorso) {
	window.open("/info.asp?CorsoID="+intCorso, "", "left=0,top=0,height=430, width=547, scrollbars=no, menubar=no");
}

function PopupAnnuncio() {
	window.open("/annuncio.asp", "", "left=0,top=0,height=510, width=570, scrollbars=yes, menubar=no");
}

function PopupFranchising() {
	window.open("/info_franchising.asp", "", "left=0,top=0,height=500, width=547, scrollbars=no, menubar=no");
}

// Preload delle immagini
function Preload(){	
	imgs = new Array(3);
	var imgnames = ['/en/img/italiano.gif', '/en/img/italiano1.gif', '/img/english.gif', '/img/english1.gif'];
	for (i=0; i<=3; i++) {
		imgs[i] = new Image();
		imgs[i].src = imgnames[i]; 
	}
}

function PreloadSub(){
	subimgs = new Array(9);
	var subimgnames = ['/img/storia.gif', '/img/storia1.gif', '/img/organizzazione.gif', '/img/organizzazione1.gif', '/img/referenze.gif', '/img/referenze1.gif', '/img/convenzioni.gif', '/img/convenzioni1.gif', '/img/contatti.gif', '/img/contatti1.gif'];
	for (i=0; i<=9; i++) {
		subimgs[i] = new Image();
		subimgs[i].src = subimgnames[i]; 
	}
}
	
// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 
// Coded by Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
// If want to use this code, feel free to do so, but please leave this message intact.
// If you do remove this, I will hunt you down :)
//
// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

// Detect Constructor

Detect = function() {
	var agent = navigator.userAgent.toLowerCase(); 
	this._mac = agent.indexOf('mac') != -1;
	this._win = !this._mac;
	this._w3c = document.getElementById;
	this._iex = document.all;
	this._ns4 = document.layers;
}
Detect.prototype.getObj = function(name) {
	if(this._w3c){
		return document.getElementById(name);
	}else if(this._iex){
		return document.all[name];
	}else if(this._ns4){
		return this.getObjNS4(document,name);
	}
}
Detect.prototype.getObjNS4 = function(obj, name) {
	var d = obj.layers;
	var result,temp;
	for(var i=0; i<d.length; i++){
		if(d[i].id == name){
		 	result = d[i];
		}else if(d[i].layers.length){
			var temp = this.getObjNS4(d[i],name);
		}
		if(temp){
			result = temp;
		}
	}
	return result;
}
Detect.prototype.getStyle = function(obj) {
	return (this._ns4) ? obj : obj.style;
}
Detect.prototype.getScrollTop = function(){
	return this._iex ? document.body.scrollTop : window.pageYOffset;
}

// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// MenuDiv Constructor

MenuDiv = function(name){
	if(name){
		this._inherit = Detect; this._inherit(name);
		this._id  = name;
		this._el  = this.getObj(this._id);
		this._css = this.getStyle(this._el);
		this._by  = this.getTop();
		return this;
	}
}
MenuDiv.prototype = new Detect();

MenuDiv.prototype.getTop = function(){
	return parseInt(this._css.top || 0);
}

var init = false;

function setInit(){
	if (init) init = false;
	if (!init) init = true;
}

function isInit(){
	return init;
}

MenuDiv.prototype.scrollMenu = function(){
	
	if (!isInit()) {
		
		if (this.getScrollTop() > 340) {
		
			var ty = this._by + this.getScrollTop()-300;
			var my = this.getTop();
			
			this._css.visibility = 'hidden'; // fixes redraw problem for nested divs
			this._css.top = (my + (ty-my)/4);
			this._css.visibility = 'visible'; // fixes redraw problem for nested divs
			
			if (this.getTop() <= 340) this._css.top = 340;
			
			setInit();
			
		}
		
	} else {
		
		var ty = this._by + this.getScrollTop()-300;
		var my = this.getTop();
		
		this._css.visibility = 'hidden'; // fixes redraw problem for nested divs
		this._css.top = (my + (ty-my)/4);
		this._css.visibility = 'visible'; // fixes redraw problem for nested divs
		
		if (this.getTop() <= 340) this._css.top = 340;
		
		setInit();
		
	}
	
}

// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

API = new Detect();

function createObjects(){
	API.menu = new MenuDiv('ricerca');
	menuInterval = setInterval('API.menu.scrollMenu()', 50);
}

//onload = createObjects;

// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
