home_animation=function(){
	
	new Fx.Style($('menu'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 800, transition:Fx.Transitions.linear}).start(0,1);
	new Fx.Style($('wrapper'), 'border-color',{fps:(document.all) ? 10 : 100,duration: 800, transition:Fx.Transitions.linear}).start("FFFFFF","CCCCCC");	
}

var menu_img_loading=51;
var menu_busy=0;

getmenuimgloading=function(){
	return menu_img_loading-1;
}

show_entry=function(img){

	new Fx.Style(img, 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear}).start(0,1);

}

open_line=function(da){
	new Fx.Style($("submenu"), 'width' ,{duration: 500, fps:(document.all) ? 500 : 100}).start(da,946);
}

close_line=function(){
	new Fx.Style($("submenu"), 'opacity' ,{duration: 500, fps:(document.all) ? 500 : 100, onComplete:function(){
			$("submenu").setStyle('width',0);
			$("submenu").setOpacity(1);
		}
	}).start(0);
}

getFlashMovie=function(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? $(movieName) : $(movieName+'_fx');
}

delFlashMovie=function(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  if (isIE){
  
   	var arr = document.all.tags("object");
   	if (arr && arr.length) {
   		for (var i=arr.length-1; 0<=i; i--) {
   			if(arr[i]["id"]==movieName){
				for (var x in arr[i]) {
					if (typeof arr[i][x] == 'function') {
						arr[i][x] = null;
					}
				}
	   			arr[i].removeNode(true);
   			}
   		}
   	}
  
  }else{
	getFlashMovie(movieName).remove();
  }
}

clearFlashMovie=function(){

		if(getFlashMovie("flash_content")!=undefined && getFlashMovie("flash_content")!=null){
			delFlashMovie("flash_content")
		}

}

if(navigator.appName.indexOf("Microsoft") != -1) window.attachEvent("onbeforeunload",clearFlashMovie);

load_pop_up=function(link_page,pop_target,complete_func){
	$(pop_target).empty().setHTML("<div><img src='00_files/img/loading.gif'></div>");
	$("pop_sfondo").setStyle("visibility","visible");
	$(pop_target).setStyle("visibility","visible");
	if(link_page) loadcontent(link_page,pop_target,complete_func);	
}

close_pop_up=function(pop_target,notremove){

	$(pop_target).setStyle("visibility","hidden");
	if(!notremove) $("pop_sfondo").setStyle("visibility","hidden");
	$(pop_target).empty().setHTML("");
	
}
 
open_page=function(sfondo){
	
	if(getFlashMovie("flash_content")!=undefined && getFlashMovie("flash_content")!=null){
		delFlashMovie("flash_content")
	}

	$('contenuto').empty().setHTML("<div><img src='00_files/img/loading.gif'></div>");
	$('contenuto').setOpacity(1);
	loadcontent($('menu').link_page,'contenuto',function(){
	
		open_voices($('menu').open_menu);
		menu_busy--;
			
	});
	
	if(sfondo) loadcontent(sfondo,'sfondo');

}

open_news=function(link_page,open_menu,sfondo,back_news){

	if(menu_busy>0) return false;
	
	menu_busy=1;

	$('menu').open_menu=open_menu;
	$('menu').link_page=link_page;
	$('menu').sfondo=sfondo;
	close_voices($('menu').open_menu);

	if($('sfondo').getText()!=""){

		if(back_news){
			new Fx.Style($('contenuto'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear, onComplete:function(){
					open_page();					
				}
			}).start(1,0);			
		}else{
			new Fx.Style($('contenuto'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear}).start(1,0);			
			new Fx.Style($('sfondo'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear, onComplete:function(){
	
				$('sfondo').empty().setHTML("");
				$('sfondo').setOpacity(1);		
				open_page($('menu').sfondo);
	
			}}).start(1,0);
		}

	}else{

		if(getFlashMovie("flash_content")!=undefined && getFlashMovie("flash_content")!=null){
			getFlashMovie("flash_content").close_content_news();
			close_line();
		}

		new Fx.Style($('menu'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear}).start(1,0);
		new Fx.Style($('contenuto'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear, onComplete:function(){

			new Fx.Style($('wrapper'), 'background-color',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear, onComplete:function(){
	
				//menu bianco
				var isIE = navigator.appName.indexOf("Microsoft") != -1;
				if($('company').getElement('a').getStyle('filter') && isIE){
					if (style_ie6) style_ie6.remove();
					new Asset.css('00_files/ie2.css', {id: 'style_ie6'});
					style_ie6 = $('style_ie6');
				}else{
					$$("div.vocemenu").each(function(el){
						el.getElement('h3').getElement('a').setStyles({
							'background-color':'transparent',
							'background-image':el.getElement('h3').getElement('a').getStyle('background-image').replace(/(.*)ita_scuro(.*)/,'$1ita_chiaro$2')
						});
					});
				}
				new Fx.Style($('menu'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear}).start(0,1);
				$('sfondo').empty().setHTML("");
				$('sfondomenu').setStyle('visibility','visible');

				open_page($('menu').sfondo);
		
			}}).start('FFFFFF','222222');
	
		}}).start(1,0);
	}
		
}

open_news_esp=function(link_page,open_menu,news,dettaglio){

	$('menu').link_page=link_page + "?id_contenuti=" + news + "&priorita_dettaglio=" + dettaglio;
	$('menu').open_menu=open_menu;

	new Fx.Style($('contenuto'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear,onComplete:function(){
	
		open_page();		
	
	}}).start(1,0);			
			
}

open_content=function(link_page,open_menu){

	if(menu_busy>0) return false;
	
	menu_busy=1;

	$('menu').open_menu=open_menu;
	$('menu').link_page=link_page;
	close_voices($('menu').open_menu);

	if($('sfondo').getText()!=""){
	
		if($('menucucina').getText()!="") close_kitchen();
		
		new Fx.Style($('contenuto'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear}).start(1,0);			
		new Fx.Style($('sfondo'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear, onComplete:function(){
	
			$('sfondomenu').setStyle('visibility','hidden');
			//$$("div.vocemenu").getElement('h3').getElement('a').setStyle('background-color','222222');
			new Fx.Style($('menu'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear}).start(1,0);
			new Fx.Style($('wrapper'), 'background-color',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear, onComplete:function(){
	
				//menu nero
				var isIE = navigator.appName.indexOf("Microsoft") != -1;
				if($('company').getElement('a').getStyle('filter') && isIE){
					if (style_ie6) style_ie6.remove();
					new Asset.css('00_files/ie.css', {id: 'style_ie6'});
					style_ie6 = $('style_ie6');
				}else{
					$$("div.vocemenu").each(function(el){
						el.getElement('h3').getElement('a').setStyles({
							'background-color':'ffffff',
							'background-image':el.getElement('h3').getElement('a').getStyle('background-image').replace(/(.*)ita_chiaro(.*)/,'$1ita_scuro$2')
						});
					});
				}
				new Fx.Style($('menu'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear}).start(0,1);
				$('sfondo').empty().setHTML("");
				$('sfondo').setOpacity(1);		

				open_page();
	
			}}).start('222222','FFFFFF');
	
	
		}}).start(1,0);

				
	}else{
	
		$('sfondomenu').setStyle('visibility','hidden');
		
		if(getFlashMovie("flash_content")!=undefined && getFlashMovie("flash_content")!=null){
		
			getFlashMovie("flash_content").close_content();
			close_line();
		
		}else{

			new Fx.Style($('contenuto'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear, onComplete:function(){open_page();}}).start(1,0);			
	
		}
	}
	
}

var pic_loaded=0;

load_picture=function(img){

	if(img.id=="pic_"+sel){
	
		$(img).setStyle('display','block')
		show_entry(img);
	
	}
	
	window.setTimeout("check_picture_menu("+img.id.substr(4)+")", 500)
	
}

check_picture_menu=function(id){

	if($('LI'+id)){
		$('LI'+id).getElement('a').setStyle('visibility','visible');
		if($('txt')) {
			$('txt').empty().setHTML(desc_value[titles[sel]]);
			$('txt').setStyle("visibility","visible");
		}
		pic_loaded++;
		if(pic_loaded==titles.length) loadcontent('html/pop_zoom.asp?content='+$('menu').kitchen,'pop_gallery')
	}else{
		window.setTimeout("check_picture_menu("+id+")", 500);
	}
	
}

check_picture_zoom=function(id){

	if($('LI'+id)){
		zoom_load++;
		zooms_loaded[id]=true;
		if (id==sel) {
			$('zoom').setStyle("visibility","visible");
			$('zc_'+sel).setStyle("display","block");
		}
	}else{
		window.setTimeout("check_picture_zoom("+id+")", 1000);
	}
	
}

open_zoom_cucina=function(){
	$('pop_gallery').setStyle("visibility","visible");	
}

change_img=function(id){

	if($('pic_'+sel) && $('LI'+sel)){

		$('sfondo').load_id=id

		new Fx.Style($('pic_'+sel), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear, onComplete:function(){

			for(var i=0;i<15;i++){
				if($('LI'+i)) $('LI'+i).getElement('a').removeClass('selected')
			}
			
			$('pic_'+sel).setStyle('display','none')
			if($('zc_'+sel)) $('zc_'+sel).setStyle("display","none")

			sel=$('sfondo').load_id;

			if(zooms_loaded[sel]){
				$('zoom').setStyle("visibility","visible");	
			}else{
				$('zoom').setStyle("visibility","hidden");
			}
			
			if($('txt')) $('txt').empty().setHTML(desc_value[titles[$('sfondo').load_id]]);
			$('pic_'+sel).setStyle('display','block')
			if($('zc_'+sel)) $('zc_'+sel).setStyle("display","block")
			show_entry($('pic_'+sel));
			$('LI'+sel).getElement('a').addClass('selected')

		}}).start(1,0);
	}

}

close_kitchen=function(){

	$('pop_gallery').empty().setHTML("");

	new Fx.Style($("menucucina"), 'height' ,{duration: 500, fps:(document.all) ? 10 : 100, onComplete:function(){$('menucucina').empty().setHTML("");$('menucucina').setStyle('visibility','hidden');$('sfondomenucucina').setStyle('visibility','hidden');}}).start(90,0);
	new Fx.Style($("sfondomenucucina"), 'height' ,{duration: 500, fps:(document.all) ? 10 : 100}).start(90,0);

}

open_kitchen=function(){

	sel=$('menu').version;
	pic_loaded=0;
	if($('txt')) $('txt').setStyle("visibility","hidden")

	open_page('html/cucina.asp?content='+$('menu').kitchen+'&version='+$('menu').version+'&menu='+$('menu').open_menu);
	//open_page();
	
	loadcontent('html/menucucina.asp?content='+$('menu').kitchen+'&version='+$('menu').version+'&menu='+$('menu').open_menu,'menucucina',function(){

		$('menucucina').setStyle('visibility','visible');
		$('sfondomenucucina').setStyle('visibility','visible');
		
		new Fx.Style($("menucucina"), 'height' ,{duration: 500, fps:(document.all) ? 10 : 100,onComplete:function(){menu_busy--;}}).start(0,90);
		new Fx.Style($("sfondomenucucina"), 'height' ,{duration: 500, fps:(document.all) ? 10 : 100}).start(0,90);
		
	});

}

open_kitchens=function(kitchen,version,open_menu){

	if(menu_busy>0) return false;
	
	menu_busy=2;
	
	$('menu').open_menu=open_menu;
	$('menu').link_page='html/blank.asp';
	$('menu').kitchen=kitchen;
	$('menu').version=version;
	
	close_voices($('menu').open_menu);

	if($('menucucina').getText()!=""){
	
		close_kitchen()
		new Fx.Style($('sfondo'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear, onComplete:function(){
	
			$('sfondo').empty().setHTML("");
			$('sfondo').setOpacity(1);
			
			open_kitchen();
	
		}}).start(1,0);
		
	}else{

		close_line();

		new Fx.Style($('menu'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear}).start(1,0);
		new Fx.Style($('contenuto'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear, onComplete:function(){
	
			//$('contenuto').empty().setHTML("");
			new Fx.Style($('wrapper'), 'background-color',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear, onComplete:function(){
	
				//menu bianco
				var isIE = navigator.appName.indexOf("Microsoft") != -1;
				if($('company').getElement('a').getStyle('filter') && isIE){
					if (style_ie6) style_ie6.remove();
					new Asset.css('00_files/ie2.css', {id: 'style_ie6'});
					style_ie6 = $('style_ie6');
				}else{
					$$("div.vocemenu").each(function(el){
						el.getElement('h3').getElement('a').setStyles({
							'background-color':'transparent',
							'background-image':el.getElement('h3').getElement('a').getStyle('background-image').replace(/(.*)ita_scuro(.*)/,'$1ita_chiaro$2')
						});
					});
				}
				$('sfondo').empty().setHTML("");
				$('sfondomenu').setStyle('visibility','visible');
				new Fx.Style($('menu'), 'opacity',{fps:(document.all) ? 10 : 100,duration: 500, transition:Fx.Transitions.linear}).start(0,1)

				open_kitchen();	
		
			}}).start('FFFFFF','222222');
	
		}}).start(1,0);
	}
	
}

open_rivenditori=function(continente,nazione,regione,provincia,lista){

	$('scrollRivenditori').empty().setHTML("<p style='margin-bottom:8px; padding-bottom:0;'>wait...</p>");
	loadcontent('html/elencorivenditori.asp?continente='+continente+'&nazione='+nazione+'&regione='+regione+'&provincia='+provincia+'&priorita_lista='+lista,'scrollRivenditori',function(){news_scroller1.refresh();});

}


loadcontent=function(link_page,layer_page,complete_func){

	new Ajax(link_page, {
		method: 'get',
		evalScripts: true,
		update: $(layer_page),
		onComplete: (complete_func==undefined) ? function(){} : complete_func
	}).request();

}

close_voices=function(open_menu){

	var menus=open_menu.split(",");
	
	$$("div.vocemenu").each(function(el){

	 	if(!menus.contains(el.getProperty("class").substr(el.getProperty("class").indexOf(" ")+1))){

	 		menu_fxslide[el.id].slideOut();
			menu_fxalpha[el.id].start(1,0);	 		
		}	 			
	
	})

}

open_voices=function(open_menu){

	var menus=open_menu.split(",");
	
	menus.each(function(item, index){
		
		$$('div.'+item).each(function(el){
			
			menu_fxslide[el.id].slideIn();
	 		if(el.getStyle('opacity').toInt()!=1){
	 			menu_fxalpha[el.id].start(0,1);
	 		}
		})

	});
	

}

select_menu=function(menu,voce){

	for(var k=0;k<eval('menu_'+menu).length;k++){
		$$('div.'+eval('menu_'+menu)[k]).getElement('h3').getElement('a').removeClass('selected');
	}
	
	$(voce).getElement('a').addClass('selected');

}

var thumb_busy=false;
var thumb_sel='0';
var thumb_col=0

thumb_back=function(){

	if(thumb_col>0 && !thumb_busy) {
		
		thumb_busy=true;
		var myFx = new Fx.Style('thumbs_cont', 'left',{duration: 850, transition:Fx.Transitions.Bounce.easeOut, onComplete:function(){thumb_col--;thumb_busy=false}}).start($('thumbs_cont').getStyle('left').toInt()+102);
		
	}

}

thumb_next=function(){

	if(thumb_col<$$('img.thumbnail').length-9 && !thumb_busy) {

		thumb_busy=true;
		var myFx = new Fx.Style('thumbs_cont', 'left',{duration: 850, transition:Fx.Transitions.Bounce.easeOut, onComplete:function(){thumb_col++;thumb_busy=false}}).start($('thumbs_cont').getStyle('left').toInt()-102);
		
	}

}





function emailCheck (emailStr, lingua) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	switch (lingua)
	{
		case "it": alert("Il formato dell'indirizzo Email non è valido.\n(controllare @ e dominio)"); break;
		case "es": alert("El formato de la dirección Email no es válido.\n(controlar @ y dominio)"); break;
		default  : alert("Email address seems incorrect (check @ and .'s)"); break;
	}
 
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
	switch (lingua)
	{
		case "it": alert("Il formato del nome non è valido.\n(controllare i caratteri prima la @)"); break;
		case "es": alert("El formato del nombre no es válido.\n(controlar los caracteres antes de la @)"); break;
		default  : alert("The domain name doesn't seem to be valid."); break;
	}
    
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	switch (lingua)
	{
		case "it": alert("Il formato del dominio non è valido.\n(controllare i caratteri dopo la '@')"); break;
		case "es": alert("El formato del dominio no es válido.\n(controlar los caracteres después de la @)"); break;
		default  : alert("The domain name doesn't seem to be valid."); break;
	}

    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
	switch (lingua)
	{
		case "it": alert("Un indirizzo Email deve finire con 3 lettere\ndi dominio o due lettere di nazione."); break;
		case "es": alert("Una dirección Email debe finalizar con 3 letras.\n de dominio o dos letras de nación"); break;
		default  : alert("The address must end in a three-letter domain, or two letter country."); break;
	}
   
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}