﻿window.addEvent('domready', function() {

	$$('div.icona').addEvent('mouseover', function(e){
		e.stop();
		
		//otherEl.tween('border', '10px dashed #C6D880');
		this.getChildren().setProperty('class', 'icona_over');
	});
	
	$$('div.icona').addEvent('mouseout', function(e){
		e.stop();
		
		this.getChildren().setProperty('class', 'icona_out');
	});

});

var isExtended = new Array();
isExtended[1] = 0;

var height = 210;
var width = 200;

var slideDuration = new Array();
slideDuration[1] = 400;

var opacityDuration = 800;
var myClone;
	
function extendContract(target1, target2, num, gap){

	if(isExtended[num] == 0){
		//$('abiti_sottomenu').setStyle('height', 3 ); 
		//myClone = $('abiti_sottomenu').clone(1,1); //clones the element and its events
		
		sideBarSlide(target1, gap, height, 0, width, slideDuration[num]);
		
		isExtended[num] = 1;
		
		// make expand tab arrow image face left (inwards)
		//$('tasto_menu_sup').setStyle('margin-top', '-25'); 
		}
	else{
		sideBarSlide(target1, height, gap, width, 0, slideDuration[num]);
		
		isExtended[num] = 0;

		// make expand tab arrow image face right (outwards)
		//$('tasto_menu_sup').setStyle('margin-top', '0'); 
		}

	}


function sideBarSlide(target1, fromHeight, toHeight, fromWidth, toWidth, slideDuration){
	var myEffects = new Fx.Styles(target1, {duration: slideDuration, transition: Fx.Transitions.linear});
	myEffects.custom({
		 'height': [fromHeight, toHeight]
		 
		 //,'width': [fromWidth, toWidth]
	});
}


function init(){
	//myClone = $('abiti_sottomenu').clone(1,1); //clones the element
	//$('abiti_sottomenu').setStyle('height', '0');//imposta l'altezza a 0
	//myClone.setStyle('height', height[2]); //imposta l'altezza del clone memorizzato a height[2]

	$('v_toggle').addEvent('click', function(){extendContract('vertical_slide', 'menu_sup_elenco', '1', '0')});
	//$('abiti').addEvent('click', function(){extendContract('abiti_sottomenu', 'abiti_sottomenu', '2', '0')});
}

window.addEvent('load', function(){init()});