function start_index() {
	new Effect.Appear('background')
}

function toggle_collection() {
	x = $('collection_list');
	y = $('collection_menu').firstDescendant();
	xx = $(x).getHeight(); 
	if ( xx == 4) {
	new Effect.Scale(x, 3500, {scaleX: false,  scaleMode:{originalHeight: 4}, scaleContent: false, scaleFrom: 100});
	} else {
	new Effect.Scale(x, 100, {scaleX: false, scaleMode:{originalHeight: 4}, scaleContent: false, scaleFrom: 3500});	
	}
}

function resize() {
	  		
			//Define image ratio & minimum dimensions
			var minwidth = 950;
			var minheight = 694;
			var ratio = minheight/minwidth;
			
			
			//Gather browser and current image size
			var imagewidth = $('img1').getWidth();
			var imageheight = $('img1').getHeight();
			browserwidth = document.viewport.getWidth();;
			browserheight = document.viewport.getHeight();;
			
			//Check for minimum dimensions
			if ((browserheight < minheight) && (browserwidth < minwidth)){
				new Effect.Scale('img1', 100, {scaleMode: {originalHeight: minheight, originalWidth: minwidth}, scaleFrom: 100});
			}
			else{	
				//When browser is taller	
				if (browserheight > browserwidth){
				    imageheight = browserheight;
				    imagewidth = browserheight/ratio;
					new Effect.Scale('img1', 100, {scaleMode: {originalHeight: browserheight, originalWidth: imagewidth}, scaleFrom: 100});

				    if (browserwidth > imagewidth){
				    	imagewidth = browserwidth;
				    	imageheight = browserwidth * ratio;
					new Effect.Scale('img1', 100, {scaleMode: {originalHeight: imageheight, originalWidth: browserwidth}, scaleFrom: 100});
				    }
				
				}
				
				//When browser is wider
				if (browserwidth >= browserheight){
				    imagewidth = browserwidth;
				    imageheight = browserwidth * ratio;
					new Effect.Scale('img1', 100, {scaleMode: {originalHeight: imageheight, originalWidth: browserwidth}, scaleFrom: 100});
				    
				    if (browserheight > imageheight){
				    	imageheight = browserheight;
				    	imagewidth = browserheight/ratio;
					new Effect.Scale('img1', 100, {scaleMode: {originalHeight: browserheight, originalWidth: imagewidth}, scaleFrom: 100});
				    }
				}
			}
			return false;
	};


function sx() {
	var x = $('collection_content_list_ul').getStyle('left');

	var xx = x.substring(0,x.length-2);
	
	if (xx < 0) {
	new Effect.Move('collection_content_list_ul', { x: 640, y: 0, mode: 'relative', queue: 'end' });
	}
}

function dx() {
	x = $('collection_content_list_ul');
	var childCount = x.getElementsByTagName('li').length;
	var gall_width = (childCount * -160) +640;
	var y = $('collection_content_list_ul').getStyle('left');
	
	var xx = y.substring(0,y.length-2);

	if (xx > gall_width) {
	new Effect.Move('collection_content_list_ul', { x: -640, y: 0, mode: 'relative', queue: 'end' });
	}
}

function checkform_info() {
	var sw = 0;
	var msg = '';
	var nome = document.contatto.nome.value;
	var cognome = document.contatto.cognome.value;
	var email = document.contatto.email.value;
	var citta = document.contatto.citta.value;
	var cap = document.contatto.cap.value;
	var messaggio = document.contatto.messaggio.value;

	var the_box1 = document.contatto.checklegge[0].checked;
		
		var x = document.contatto.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		
		msg += "Indirizzo email inesatto.\n" ;
		
		sw = 1 ;	
		} 


		if (!nome) {
		msg += "devi inserire il nome.\n" ;
		sw = 1 ;
		}
		
		if (!cognome) {
		msg += "devi inserire il cognome.\n" ;
		sw = 1 ;
		}
		if (!email) {
		msg += "devi inserire l\' email.\n" ;
		sw = 1 ;
		}
		if (!citta) {
		msg += "devi inserire la citta.\n" ;
		sw = 1 ;
		}
		if (!cap) {
		msg += "devi inserire il cap.\n" ;
		sw = 1 ;
		}
		if (!messaggio) {
		msg += "devi inserire il messaggio.\n" ;
		sw = 1 ;
		}
		
		if (the_box1 == true) {
		msg += "Devi accettare la clausola.\n" ;
		
		sw = 1 ;
		}
		
		
		
		if(sw == 1 ) {
			
			alert(msg);
			return false ;
		
		}
		if(sw == 0 ) {
			
			sendMail_info();
			return false ;
		
		}

}


function checkform_b2b() {
	var sw = 0;
	var msg = '';
	var nome = document.contatto_b.nome.value;
	var cognome = document.contatto_b.cognome.value;
	var email = document.contatto_b.email.value;
	var citta = document.contatto_b.citta.value;
	var cap = document.contatto_b.cap.value;
	var messaggio = document.contatto_b.messaggio.value;

	var the_box1 = document.contatto_b.checklegge[0].checked;
		
		var x = document.contatto_b.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		
		msg += "Indirizzo email inesatto.\n" ;
		
		sw = 1 ;	
		} 


		if (!nome) {
		msg += "devi inserire il nome.\n" ;
		sw = 1 ;
		}
		
		if (!cognome) {
		msg += "devi inserire il cognome.\n" ;
		sw = 1 ;
		}
		if (!email) {
		msg += "devi inserire l\' email.\n" ;
		sw = 1 ;
		}
		if (!citta) {
		msg += "devi inserire la citta.\n" ;
		sw = 1 ;
		}
		if (!cap) {
		msg += "devi inserire il cap.\n" ;
		sw = 1 ;
		}
		if (!messaggio) {
		msg += "devi inserire il messaggio.\n" ;
		sw = 1 ;
		}
		
		if (the_box1 == true) {
		msg += "Devi accettare la clausola.\n" ;
		
		sw = 1 ;
		}
		
		
		
		if(sw == 1 ) {
			
			alert(msg);
			return false ;
		
		}
		if(sw == 0 ) {
			
			sendMail_b2b();
			return false ;
		
		}

}

function checkform_media() {
	var sw = 0;
	var msg = '';
	var nome = document.contatto_media.nome.value;
	var cognome = document.contatto_media.cognome.value;
	var email = document.contatto_media.email.value;
	var citta = document.contatto_media.citta.value;
	var cap = document.contatto_media.cap.value;
	var messaggio = document.contatto_media.messaggio.value;

	var the_box1 = document.contatto_media.checklegge[0].checked;
		
		var x = document.contatto_media.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		
		msg += "Indirizzo email inesatto.\n" ;
		
		sw = 1 ;	
		} 


		if (!nome) {
		msg += "devi inserire il nome.\n" ;
		sw = 1 ;
		}
		
		if (!cognome) {
		msg += "devi inserire il cognome.\n" ;
		sw = 1 ;
		}
		if (!email) {
		msg += "devi inserire l\' email.\n" ;
		sw = 1 ;
		}
		if (!citta) {
		msg += "devi inserire la citta.\n" ;
		sw = 1 ;
		}
		if (!cap) {
		msg += "devi inserire il cap.\n" ;
		sw = 1 ;
		}
		if (!messaggio) {
		msg += "devi inserire il messaggio.\n" ;
		sw = 1 ;
		}
		
		if (the_box1 == true) {
		msg += "Devi accettare la clausola.\n" ;
		
		sw = 1 ;
		}
		
		
		
		if(sw == 1 ) {
			
			alert(msg);
			return false ;
		
		}
		if(sw == 0 ) {
			
			sendMail_media();
			return false ;
		
		}

}

function checkform_job() {
	var sw = 0;
	var msg = '';
	var nome = document.contatto_c.nome.value;
	var cognome = document.contatto_c.cognome.value;
	var email = document.contatto_c.email.value;
	var citta = document.contatto_c.citta.value;
	var cap = document.contatto_c.cap.value;
	var messaggio = document.contatto_c.messaggio.value;

	var the_box1 = document.contatto_c.checklegge[0].checked;
		
		var x = document.contatto_c.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		
		msg += "Indirizzo email inesatto.\n" ;
		
		sw = 1 ;	
		} 


		if (!nome) {
		msg += "devi inserire il nome.\n" ;
		sw = 1 ;
		}
		
		if (!cognome) {
		msg += "devi inserire il cognome.\n" ;
		sw = 1 ;
		}
		if (!email) {
		msg += "devi inserire l\' email.\n" ;
		sw = 1 ;
		}
		if (!citta) {
		msg += "devi inserire la citta.\n" ;
		sw = 1 ;
		}
		if (!cap) {
		msg += "devi inserire il cap.\n" ;
		sw = 1 ;
		}
		if (!messaggio) {
		msg += "devi inserire il messaggio.\n" ;
		sw = 1 ;
		}
		
		if (the_box1 == true) {
		msg += "Devi accettare la clausola.\n" ;
		
		sw = 1 ;
		}
		
		
		
		if(sw == 1 ) {
			
			alert(msg);
			return false ;
		
		}
		if(sw == 0 ) {
			
			sendMail_job();
			return false ;
		
		}

}

function checkform_unsubscribe() {
	var sw = 0;
	var msg = '';
	var nome = document.unsubscribe.nome.value;
	var cognome = document.unsubscribe.cognome.value;
	var email = document.unsubscribe.email.value;
		
		var x = document.unsubscribe.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		
		msg += "Indirizzo email inesatto.\n" ;
		
		sw = 1 ;	
		} 


		if (!nome) {
		msg += "devi inserire il nome.\n" ;
		sw = 1 ;
		}
		
		if (!cognome) {
		msg += "devi inserire il cognome.\n" ;
		sw = 1 ;
		}
		if (!email) {
		msg += "devi inserire l\' email.\n" ;
		sw = 1 ;
		}
		
		if(sw == 1 ) {
			
			alert(msg);
			return false ;
		
		}
		if(sw == 0 ) {
			
			sendMail_unsubscribe();
			return false ;
		
		}

}

function sendMail_info() {

	var url = "" ;
	
	nome = document.contatto.nome.value ;
	cognome = document.contatto.cognome.value ;
	email = document.contatto.email.value ;
	citta = document.contatto.citta.value;
	cap = document.contatto.cap.value;
	country = document.contatto.country.value;
	messaggio = document.contatto.messaggio.value ;
	
	url  = "./php/contatto.php?action=sendmail_info"  ;
	url += "&nome="+nome ;
	url += "&cognome="+cognome ;
	url += "&email="+email ;
	url += "&citta="+citta ;
	url += "&cap="+cap ;
	url += "&country="+country ;
	url += "&messaggio="+messaggio ;

 
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {
		
			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = eval("document.getElementById('contact') ;") ;
				 
				//alert(html);
				
				elem.innerHTML=html ;

			}

		} else {
			
		}
	}
	,1) ; 
}

function sendMail_b2b() {

	var url = "" ;
	
	nome = document.contatto_b.nome.value ;
	cognome = document.contatto_b.cognome.value ;
	email = document.contatto_b.email.value ;
	citta = document.contatto_b.citta.value;
	cap = document.contatto_b.cap.value;
	country = document.contatto_b.country.value;
	messaggio = document.contatto_b.messaggio.value ;
	
	url  = "./php/contatto.php?action=sendmail_b2b"  ;
	url += "&nome="+nome ;
	url += "&cognome="+cognome ;
	url += "&email="+email ;
	url += "&citta="+citta ;
	url += "&cap="+cap ;
	url += "&country="+country ;
	url += "&messaggio="+messaggio ;

 
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {
		
			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = eval("document.getElementById('contact') ;") ;
				 
				//alert(html);
				
				elem.innerHTML=html ;

			}

		} else {
			
		}
	}
	,1) ; 
}

function sendMail_media() {

	var url = "" ;
	
	nome = document.contatto_media.nome.value ;
	cognome = document.contatto_media.cognome.value ;
	email = document.contatto_media.email.value ;
	citta = document.contatto_media.citta.value;
	cap = document.contatto_media.cap.value;
	country = document.contatto_media.country.value;
	messaggio = document.contatto_media.messaggio.value ;
	
	url  = "./php/contatto.php?action=sendmail_media"  ;
	url += "&nome="+nome ;
	url += "&cognome="+cognome ;
	url += "&email="+email ;
	url += "&citta="+citta ;
	url += "&cap="+cap ;
	url += "&country="+country ;
	url += "&messaggio="+messaggio ;

 
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {
		
			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = eval("document.getElementById('contact') ;") ;
				 
				//alert(html);
				
				elem.innerHTML=html ;

			}

		} else {
			
		}
	}
	,1) ; 
}

function sendMail_job() {

	var url = "" ;
	
	nome = document.contatto_c.nome.value ;
	cognome = document.contatto_c.cognome.value ;
	email = document.contatto_c.email.value ;
	citta = document.contatto_c.citta.value;
	cap = document.contatto_c.cap.value;
	country = document.contatto_c.country.value;
	messaggio = document.contatto_c.messaggio.value ;
	
	url  = "./php/contatto.php?action=sendmail_job"  ;
	url += "&nome="+nome ;
	url += "&cognome="+cognome ;
	url += "&email="+email ;
	url += "&citta="+citta ;
	url += "&cap="+cap ;
	url += "&country="+country ;
	url += "&messaggio="+messaggio ;

 
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {
		
			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = eval("document.getElementById('contact') ;") ;
				 
				//alert(html);
				
				elem.innerHTML=html ;

			}

		} else {
			
		}
	}
	,1) ; 
}

function sendMail_unsubscribe() {

	var url = "" ;
	
	nome = document.unsubscribe.nome.value ;
	cognome = document.unsubscribe.cognome.value ;
	email = document.unsubscribe.email.value ;
	
	url  = "./php/unsubscribe.php?action=sendmail_unsubscribe"  ;
	url += "&nome="+nome ;
	url += "&cognome="+cognome ;
	url += "&email="+email ;

 
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {
		
			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = eval("document.getElementById('news') ;") ;
				 
				//alert(html);
				
				elem.innerHTML=html ;

			}

		} else {
			
		}
	}
	,1) ; 
}

function checkform_jobopp() {
	var sw = 0;
	var msg = '';
	
	var settore = document.job_opp.settore.value;
	var nome = document.job_opp.nome.value;
	var cognome = document.job_opp.cognome.value;
	var indirizzo = document.job_opp.indirizzo.value;
	var citta = document.job_opp.citta.value;
	var cap = document.job_opp.cap.value;
	var provincia = document.job_opp.provincia.value;
	var tel = document.job_opp.tel.value;
	var email = document.job_opp.email.value;
//	var login = document.job_opp.login.value;
//	var passwd = document.job_opp.passwd.value;
	
	var the_box1 = document.job_opp.checklegge[0].checked;
		
		var x = document.job_opp.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		
		msg += "Indirizzo email inesatto.\n" ;
		
		sw = 1 ;	
		} 


		if (!settore) {
		msg += "devi indicare il settore.\n" ;
		sw = 1 ;
		}

		if (!nome) {
		msg += "devi inserire il nome.\n" ;
		sw = 1 ;
		}
		
		if (!cognome) {
		msg += "devi inserire il cognome.\n" ;
		sw = 1 ;
		}
		if (!indirizzo) {
		msg += "devi inserire l\' indirizzo.\n" ;
		sw = 1 ;
		}
		if (!cap) {
		msg += "devi inserire il cap.\n" ;
		sw = 1 ;
		}
		if (!citta) {
		msg += "devi inserire la citta.\n" ;
		sw = 1 ;
		}
		if (!provincia) {
		msg += "devi inserire la provincia.\n" ;
		sw = 1 ;
		}
		if (!tel) {
		msg += "devi inserire il telefono.\n" ;
		sw = 1 ;
		}
		if (!email) {
		msg += "devi inserire l\' email.\n" ;
		sw = 1 ;
		}
//		if (!login) {
//		msg += "devi inserire il nome utente.\n" ;
//		sw = 1 ;
//		}		
//		if (!passwd) {
//		msg += "devi inserire la password.\n" ;
//		sw = 1 ;
//		}		


		
		
		if (the_box1 == true) {
		msg += "Devi accettare la clausola.\n" ;
		
		sw = 1 ;
		}
		
		
		
		if(sw == 1 ) {
			
			alert(msg);
			return false ;
		
		}


}

function send_job() {

	data = document.job_opp.data.value ;
	cognome = document.job_opp.cognome.value ;
	nome = document.job_opp.nome.value ;
	indirizzo = document.job_opp.indirizzo.value ;
	citta = document.job_opp.citta.value ;
	cap = document.job_opp.cap.value ;
	provincia = document.job_opp.provincia.value ;
	tel = document.job_opp.tel.value ;
	settore = document.job_opp.settore.value ;
	email = document.job_opp.email.value ;
	
	url  = "./php/job.php?action=doJobIn"  ;
	url += "&data="+data ;
	url += "&cognome="+cognome ;
	url += "&nome="+nome ;
	url += "&indirizzo="+indirizzo ;
	url += "&citta="+citta ;
	url += "&cap="+cap ;
	url += "&provincia="+provincia ;
	url += "&tel="+tel ;
	url += "&settore="+settore ;
	url += "&email="+email ;
	
	new Ajax.Updater('contact', url)
}