/*
 * Copyright 2009 APPIX S.r.l.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//need mootools 1.2
window.addEvent('domready', function() {
	var boxRed = $('boxRed');
	var boxGreen = $('boxGreen');
	var boxYellow = $('boxYellow');
	var boxBlue = $('boxBlue');

	var serviceRed = $('serviceRed');
	var serviceGreen = $('serviceGreen');
	var serviceYellow = $('serviceYellow');
	var serviceBlue = $('serviceBlue');

	var serviceImgRed = $('serviceImgRed');
	var serviceImgGreen = $('serviceImgGreen');
	var serviceImgYellow = $('serviceImgYellow');
	var serviceImgBlue = $('serviceImgBlue');

	serviceRed.onmouseover = function() {
		boxRed.addClass('boxRed');
	}
	serviceRed.onmouseout = function() {
		boxRed.removeClass('boxRed');
	}

	serviceGreen.onmouseover = function() {
		boxGreen.addClass('boxGreen');
	}
	serviceGreen.onmouseout = function() {
		boxGreen.removeClass('boxGreen');
	}

	serviceYellow.onmouseover = function() {
		boxYellow.addClass('boxYellow');
	}
	serviceYellow.onmouseout = function() {
		boxYellow.removeClass('boxYellow');
	}

	serviceBlue.onmouseover = function() {
		boxBlue.addClass('boxBlue');
	}
	serviceBlue.onmouseout = function() {
		boxBlue.removeClass('boxBlue');
	}

	serviceImgRed.onmouseover = function() {
		boxRed.addClass('boxRed');
	}
	serviceImgRed.onmouseout = function() {
		boxRed.removeClass('boxRed');
	}

	serviceImgGreen.onmouseover = function() {
		boxGreen.addClass('boxGreen');
	}
	serviceImgGreen.onmouseout = function() {
		boxGreen.removeClass('boxGreen');
	}

	serviceImgYellow.onmouseover = function() {
		boxYellow.addClass('boxYellow');
	}
	serviceImgYellow.onmouseout = function() {
		boxYellow.removeClass('boxYellow');
	}

	serviceImgBlue.onmouseover = function() {
		boxBlue.addClass('boxBlue');
	}
	serviceImgBlue.onmouseout = function() {
		boxBlue.removeClass('boxBlue');
	}

	if (Cookie.read('startup') != 'Y') {
	  Cookie.write('startup', 'N');
	}

	var boxPrincipale = $('principale');
	var boxHome = $('boxo');
	var boxHomeTxt = $('boxo_text');
	var effScompari = new Fx.Morph(boxHome, {
		duration: 2000,
		transition: Fx.Transitions.Sine.easeOut,
		onComplete: function(element){
			boxHome.removeClass('home');
			boxHomeTxt.removeClass('hide');
			effAppari.start({ 'opacity':1 });

			//myCookie.write('startup', 'Y');
			Cookie.write('startup', 'Y');

		}
	});

	var effAppari = new Fx.Morph(boxHome, {
		duration: 1000,
		transition: Fx.Transitions.Sine.easeOut,
		onComplete: function(element){
		  boxPrincipale.removeEvents('mouseenter');
		}
	});

		boxPrincipale.addEvents({
			'mouseenter': function(e) {
				e.stop();
				if (Cookie.read('startup') == 'N') {
					effScompari.start({ 'opacity':0 });
				}
			},
			'click': function(e) {
				e.stop();
				if (Cookie.read('startup') == 'Y' && boxHomeTxt.hasClass('hide')) {
					effScompari.start({ 'opacity':0 });
				}
			}
		});

});



