
/* Merged Plone Javascript file
 * This file is dynamically assembled from separate parts.
 * Some of these parts have 3rd party licenses or copyright information attached
 * Such information is valid for that section,
 * not for the entire composite file
 * originating files are separated by - filename.js -
 */

/* - ++resource++enertourtheme.tis.js/jquery_rotator.js - */
function theRotator() {
	//Set the opacity of all images to 0
	$('div#splash-info ul li').css({opacity: 0.0});

	//Display the list of images, which is hidden by css until now
	$('div#splash-info ul#imagerotator').css('display', 'inline');
	
	//Get the first image and display it (gets set to full opacity)
	$('div#splash-info ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	//Etour modified to call the rotator function twice, the first change occurs after 2s, then cancel the interval and start over with 15s interval
	var timer = setInterval('rotate()',2000);
	setTimeout(function() {clearInterval(timer)}, 3000);
	setInterval('rotate()', 15000);
}

function rotate() {	
	//Get the first image
	var current = ($('div#splash-info ul li.show')?  $('div#splash-info ul li.show') : $('div#splash-info ul li:first'));
	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#splash-info ul li:first') :current.next()) : $('div#splash-info ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 5000);

	//Hide the current image
	current.animate({opacity: 0.0}, 5000)
	.removeClass('show');
};

$(document).ready(function() {		
	curPath = window.location.pathname;
	if ((curPath == '/it') || (curPath == '/de') || (curPath == '/en')) {
	    //Load the slideshow
	    theRotator();
	}
	
	// Track external clicks on expoclima banner
	$(".googleTrackExternal").click(function() { _gaq.push(['_trackEvent', 'googleTrackExternal', this.id]); });
});


/* - ++resource++enertourtheme.tis.js/etour_popupforms.js - */
/*jslint browser: true, white: false */
/*global jQuery */

/******
    Standard popups
******/

var common_content_filter = '#content>*:not(div.configlet),dl.portalMessage.error,dl.portalMessage.info';
var common_jqt_config = {fixed:false,speed:'fast',mask:{color:'#fff',opacity: 0.4,loadSpeed:0,closeSpeed:0}};

jQuery.extend(jQuery.tools.overlay.conf, common_jqt_config);


jQuery(function($){

    if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7) {
        // it's not realistic to think we can deal with all the bugs
        // of IE 6 and lower. Fortunately, all this is just progressive
        // enhancement.
        return;
    }
    
    // method to show error message in a noform
    // situation.
    function noformerrorshow(el, noform) {
        var o = $(el),
            emsg = o.find('dl.portalMessage.error');
        if (emsg.length) {
            o.children().replaceWith(emsg);
            return false;
        } else {
            return noform;
        }
    }

    // After deletes we need to redirect to the target page.
    function redirectbasehref(el, responseText) {
        var mo = responseText.match(/<base href="(\S+?)"/i);
        if (mo.length === 2) {
            return mo[1];
        }
        return location;
    }

    
    // myPopupForm
    $('a#mypopupform').prepOverlay(
	{
	    subtype: 'ajax',
	    filter: common_content_filter,
	    formselector: 'form',
	    noform: function(el) {return noformerrorshow(el, 'close');}
	}
    );

    // myBigPopupForm
    $('a#mybigpopupform').prepOverlay(
        {
            subtype: 'ajax',
            filter: common_content_filter,
            formselector: 'form',
	    width: '960px',
            noform: function(el) {return noformerrorshow(el, 'close');}
        }
    );            

});



