  ///////////////////////////////////////////////////
///     SCRIPT PER PAGINA GENERALE DEI PRODOTTI     ///
  ///////////////////////////////////////////////////
  
// http://dean.edwards.name/packer/
// per rimpicciolire le dimensioni
  
function setDiv(){
var cont_community_h = document.getElementById("cont_community");
var cont_wait_h = document.getElementById("cont_wait");
var cont_office_h = document.getElementById("cont_office");
var ah = cont_community_h.offsetHeight;
var bh = cont_wait_h.offsetHeight;
var ch = cont_office_h.offsetHeight;
if (ah>bh){
	if (ah>ch){
		//document.getElementById("content_categorie").style.height = ah+80 + 'px';
		Cambia_h_sfondo(ah+80);
	}
	else{
		//document.getElementById("content_categorie").style.height = ch+80 + 'px';
		Cambia_h_sfondo(ch+80);
	}
}
else{
	if (bh>ch){
		//document.getElementById("content_categorie").style.height = bh+80 + 'px';
		Cambia_h_sfondo(bh+80);
	}
	else{
		//document.getElementById("content_categorie").style.height = ch+80 + 'px';
		Cambia_h_sfondo(ch+80);
	}
}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_changeProp(objId,x,theProp,theValue) { //v9.0
  var obj = null; with (document){ if (getElementById)
  obj = getElementById(objId); }
  if (obj){
    if (theValue == true || theValue == false)
      eval("obj.style."+theProp+"="+theValue);
    else eval("obj.style."+theProp+"='"+theValue+"'");
  }
}

function changecss(theClass,element,value) {
//documentation for this script at http://www.shawnolson.net/a/503/
var cssRules;
if (document.all) {
cssRules = 'rules';
}
else if (document.getElementById) {
cssRules = 'cssRules';
}
for (var S = 0; S < document.styleSheets.length; S++){
for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
document.styleSheets[S][cssRules][R].style[element] = value;
}
}
}
}

function Cambia_h_sfondo(altezza) {
	$('content_categorie').tween('height', altezza);
	return false; // alternative syntax to stop the event
}

function Nascondi(div_da_nascondere) {
		var mySlider = new Fx.Slide(div_da_nascondere, {
			duration: 500,
			//transition: Fx.Transitions.Cubic.easeInOut,
			//wait:false,
			onComplete: function(){
				var lista = $$('.foto_small');
    			lista.each(function(elemento) {
					elemento.addClass('x');
					//elemento.removeClass('x');
				 });
				//setDiv();	
			}
		});
		mySlider.slideOut();
}

function Mostra(div_da_mostrare) {
		//$(div_da_mostrare).fade(1);
		var mySlider = new Fx.Slide(div_da_mostrare, {
			duration: 500,
			//transition: Fx.Transitions.Cubic.easeInOut,
			//wait:false,
			onComplete: function(){
				var lista = $$('.foto_small');
    			lista.each(function(elemento) {
				//elemento.addClass('x');
				elemento.removeClass('x');
				 });
				//setDiv();	
			}
		});
		mySlider.slideIn();
}

function nascondi_tutti(quello1, quello2, quale) {
	//quello1 e quello2 = div da mostrare del menu nell'header
	//quale sezione da mostrare della pagina prodotti
	changecss ('#menu_cat', 'left', '-5000px');
	changecss ('#menu_cat2', 'left', '-5000px');
	changecss ('#menu_cat3', 'left', '-5000px');
	changecss ('#menu_cat4', 'left', '-5000px');
	changecss ('#menu_sottocat', 'left', '-5000px');
	changecss ('#menu_sottocat_2', 'left', '-5000px');
	changecss ('#menu_sottocat_3', 'left', '-5000px');
	changecss ('#menu_sottocat_4', 'left', '-5000px');
	changecss ('#menu_sottocat2', 'left', '-5000px');
	changecss ('#menu_sottocat2_2', 'left', '-5000px');
	changecss ('#menu_sottocat2_3', 'left', '-5000px');
	changecss ('#menu_sottocat2_4', 'left', '-5000px');
	changecss ('#menu_sottocat2_5', 'left', '-5000px');
	changecss ('#menu_sottocat3', 'left', '-5000px');
	changecss ('#menu_sottocat3_2', 'left', '-5000px');
	changecss (quello1, 'left', '50%');
	changecss (quello2, 'left', '50%');


//////////////////////////////////////////// CASI SPECIFICI PER LE MACRO-CATEGORIE
	if (quale == 'cont_office') {
		Mostra('cont_office1'); 
		Mostra('cont_office2'); 
		Mostra('cont_office3'); 

		Nascondi('cont_community1'); 		
		Nascondi('cont_community2'); 
		Nascondi('cont_community3'); 	
		Nascondi('cont_community4'); 
		
		Nascondi('cont_wait1');
	}
	else if (quale == 'cont_community') {
		Nascondi('cont_office1'); 
		Nascondi('cont_office2'); 
		Nascondi('cont_office3'); 
		
		Mostra('cont_community1'); 
		Mostra('cont_community2'); 
		Mostra('cont_community3'); 	
		Mostra('cont_community4'); 	
		
		Nascondi('cont_wait1'); 	
	}
	else if (quale == 'cont_wait') {
		Nascondi('cont_office1'); 
		Nascondi('cont_office2'); 
		Nascondi('cont_office3'); 
		
		Nascondi('cont_community1'); 
		Nascondi('cont_community2'); 
		Nascondi('cont_community3'); 	
		Nascondi('cont_community4'); 	
		
		Mostra('cont_wait1'); 	
	}
//////////////////////////////////////////// SE NON E' UNA MACRO > CASO SINGOLE SOTTO-CATEGORIE
//////////////////////////////////////////// NASCONDO TUTTE E POI MOSTRO QUELLA GIUSTA
	else{
		if (quale != 'cont_office1') {
			Nascondi('cont_office1');
		}
		if (quale != 'cont_office2') {
			Nascondi('cont_office2');
		}
		if (quale != 'cont_office3') {
			Nascondi('cont_office3');
		}
		if (quale != 'cont_community1') {
			Nascondi('cont_community1'); 
		}
		if (quale != 'cont_community2') {
			Nascondi('cont_community2'); 
		}
		if (quale != 'cont_community3') {
			Nascondi('cont_community3'); 
		}
		if (quale != 'cont_community4') {
			Nascondi('cont_community4'); 
		}
		if (quale != 'cont_wait1') {
			Nascondi('cont_wait1'); 
		}
		// se passo da macro a sotto-categoria il fade e' da 1 a 1 e non si nota
		Mostra(quale);
	}

}//nascondi_tutti

function apri_chiudi(ma_cosa) {
		var mySlider = new Fx.Slide(ma_cosa, {duration: 500});
		mySlider.toggle();		
}

function apri_chiudi_tasto_grande(toggle_cosa) {
// solo per 3 tasti grandi	
	if (toggle_cosa == 'office') {
		var isopenA = $('cont_office1').getStyles('margin-top');
		var isopenA1 = isopenA['margin-top'];
		if (isopenA1 == "0px"){ // aperto
			Nascondi('cont_office1'); 
			Nascondi('cont_office2'); 
			Nascondi('cont_office3');
			Nascondi('cont_wait1');
		}
		else { // chiuso
			Mostra('cont_office1'); 
			Mostra('cont_office2'); 
			Mostra('cont_office3'); 	
			Mostra('cont_wait1');
		}
	}
	else if (toggle_cosa == 'community') {
		var isopenB = $('cont_community1').getStyles('margin-top');
		var isopenB1 = isopenB['margin-top'];
		if (isopenB1 == "0px"){ // aperto
			Nascondi('cont_community1'); 
			Nascondi('cont_community2'); 
			Nascondi('cont_community3'); 	
			Nascondi('cont_community4'); 
		}
		else { // chiuso
			Mostra('cont_community1'); 
			Mostra('cont_community2'); 
			Mostra('cont_community3'); 	
			Mostra('cont_community4'); 	
		}
	}
	else if (toggle_cosa == 'waiting') {
		var isopenC = $('cont_wait1').getStyles('margin-top');
		var isopenC1 = isopenC['margin-top'];
		if (isopenC1 == "0px"){ // aperto 	
			Nascondi('cont_wait1');
		}
		else { // chiuso
			Mostra('cont_wait1');			
		}
	}
}


// al mouseover mette tutti i div vicini semi trasparenti
// e lascia quello del mouseover con alpha 100%
window.addEvent('domready', function() {

		Mostra('cont_office1'); 
		Mostra('cont_office2'); 
		Mostra('cont_office3'); 
		Mostra('cont_community1'); 		
		Mostra('cont_community2'); 
		Mostra('cont_community3'); 	
		Mostra('cont_community4'); 
		Mostra('cont_wait1');
	//differentfadein --> true  =  non fratelli fade diverso da fratelli
	//					false =  tutti non mouseover stesso fade
	//gradualfadein ---->	true  =  fade graduale
	//					false =  cambia opacità senza tween
	var gradualfadein = true;
	var differentfadein = false;
	if (gradualfadein == false){differentfadein = false;} //per prestazioni

	var list = $$('.foto_small');
    list.each(function(element) {
	element.get('tween').options.duration=200; 
	element.addEvent('mouseenter', function(){
		$$('.foto_small').addClass('altri');
		if (differentfadein == true && gradualfadein == true){
			var stessa_cat = this.parentNode.getChildren();
			stessa_cat.removeClass('altri');
			stessa_cat.addClass('stessa_cat');
			element.removeClass('stessa_cat');
			var whofademore = $$('.altri');
			whofademore.fade(0.05);//non fratelli
			var whofade = $$('.stessa_cat');
			whofade.fade(0.25);//solo fratelli
		}
		else if (differentfadein == false && gradualfadein == true){
			element.removeClass('altri');
			var whofade = $$('.altri');
			whofade.fade(0.2);//solo fratelli
			element.fade(1);				
		}
		else { // entrambi false
			$$('.foto_small').setStyle('opacity','0.2');
			element.setStyle('opacity','1');
		}
		//element.fade(1);
	});
	element.addEvent('mouseleave', function(){
		if (differentfadein == true && gradualfadein == true){
			$$('.stessa_cat').removeClass('stessa_cat');
			list.fade(1);// in tutta la pagina
		}
		else if (differentfadein == false && gradualfadein == true){
			list.fade(1);// in tutta la pagina
		}
		else { // entrambi false
			$$('.foto_small').setStyle('opacity','1');
			element.setStyle('opacity','1');
		}
	});
});
//setDiv();
});
