new Asset.css('./css/services.css',  {id: 'servicesStyle', title: 'servicesStyle'});
// Estendo la classe Element aggiungendo il metodo cleanWhitespace
Element.extend({
    cleanWhitespace: function(){
        $A(this.childNodes).each(function(node){
            if ($type(node) == 'textnode') 
                this.removeChild(node);
        }, this);
        
        return this;
    }
});

Element.cleanWhitespace('conteiner');

function processHTMLRequest(page, divID) {
    new Ajax(page + '.html', {
        method: 'get',
        update: divID,
        evalScripts: true,
        onComplete: function(){}
    }).request();
}



function getServiceDescription(page, divID, effect) {
    var firstFx = new Fx.Style(divID, effect, {
        duration: 400,
        transition: Fx.Transitions.quartInOut,
        wait: true,
        onComplete: function() { 
            processHTMLRequest(page, divID);               
        }
    });
    
    var secondFx = new Fx.Style(divID, effect, {
        duration: 600,
        transition: Fx.Transitions.quartInOut,
        wait: true
    });
    
    firstFx.start(1,0).chain( secondFx.start.pass([0,1], secondFx) );  
}



function getServiceGallery(page, divID) {
    processHTMLRequest(page,divID); 
}


function load_gallery(gallery_file, divID) {
    
    var firstFx = new Fx.Style(divID, 'opacity', {
        duration: 400,
        transition: Fx.Transitions.quartInOut,
        wait: true,
        onComplete: function() { 
            getServiceGallery(gallery_file, divID);
        }
    });
    
    var secondFx = new Fx.Style(divID, 'opacity', {
        duration: 600,
        transition: Fx.Transitions.quartInOut,
        wait: true
    });
    
    firstFx.start(1,0).chain( secondFx.start.pass([0,1], secondFx) );  
    
}


function reset_gallery(gallery_file, divID) {
    
    var firstFx = new Fx.Style(divID, 'opacity', {
        duration: 400,
        transition: Fx.Transitions.quartInOut
        
    });
    
        
    firstFx.start(1,0);  
    
}



window.addEvent('domready', function() {         
    var vkwick = new Kwick.Menu($$("#allsections .mainsections"), {
        large:35,
        normal:20,
        small:15,
        mode: 'vertical',
        wait:false,
        duration:300,
        transition: Fx.Transitions.Back.easeOut
    });        
});
