function submitSearch(tipo) {

    var selID = "SearchText";
    var obj = (document.getElementById) ? document.getElementById(selID) : eval("document.all['" + selID + "']");

    var inviaSearch = false;

    if (tipo == '0') {
        if (window.event) // solo se IE
        {
            if (window.event.keyCode == 13) {
                window.event.keyCode = 0;
                inviaSearch = true;
            }
        }
    }
    else if (tipo == '1') {
        inviaSearch = true;
    }

    if (inviaSearch == true) {
        document.location.href = '/search.athx?SearchText=' + encodeURI(obj.value) + '&searchword=false&searchmode=2';
    }
}



function createCarousel(data) {

    var strLi = "";

    for (i = 0; i < data.Items.length; i++) {
        strLi = strLi + '<li>' +
								'<a class="thumb" name="leaf" href="'+ data.Items[i].Foto + '.jpg" title="' + data.Items[i].Titolo + '">' +
									'<img src="' + data.Items[i].Foto + '.jpg" alt="' + data.Items[i].Titolo + '" />' +
								'</a>' +
								'<div class="caption">' +
									'<div class="image-title">' + data.Items[i].Titolo + '</div>' +
									'<div class="image-desc">' + data.Items[i].Sottotitolo + '</div>' +
									'<span class="boxHeaderHpLink">Per saperne di pi&ugrave;  <a target="_blank" href="' + data.Items[i].Url + '">clicca qui</a>' +
									'</span>' +
								'</div>' +
							'</li>';
    }
    $('.thumbs.script').html(strLi);

    // Initialize Advanced Galleriffic Gallery
    var gallery = $('#thumbs').galleriffic({
        delay: 6000,
        numThumbs: 3,
        preloadAhead: 10,
        enableTopPager: false,
        enableBottomPager: false,
        imageContainerSel: '#slideshow',
        controlsContainerSel: '#controls',
        captionContainerSel: '#caption',
        loadingContainerSel: '#loading',
        renderSSControls: true,
        renderNavControls: true,
        playLinkText: '',
        pauseLinkText: '',
        prevLinkText: '',
        nextLinkText: '',
        nextPageLinkText: '',
        prevPageLinkText: '',
        enableHistory: true,
        autoStart: true,
        syncTransitions: true,
        defaultTransitionDuration: 1000,
        onSlideChange: undefined
    });

    /**************** Event handlers for custom next / prev page links **********************/

    

    /****************************************************************************************/

    /**** Functions to support integration of galleriffic with the jquery.history plugin ****/

    // PageLoad function
    // This function is called when:
    // 1. after calling $.historyInit();
    // 2. after calling $.historyLoad();
    // 3. after pushing "Go Back" button of a browser
    function pageload(hash) {
        // alert("pageload: " + hash);
        // hash doesn't contain the first # character.
        if (hash) {
            $.galleriffic.gotoImage(hash);
        } else {
            gallery.gotoIndex(0);
        }
    }

    $('.navigation-container').append($('#controls'));

   gallery.find('a.prev').click(function(e) {
       gallery.previousPage();
       e.preventDefault();
   });

   gallery.find('a.next').click(function(e) {
       gallery.nextPage();
       e.preventDefault();
   });

   if ($.browser.msie) {
       userAgent = $.browser.version;
       userAgent = userAgent.substring(0, userAgent.indexOf('.'));
       version = userAgent;
       if (version == '8') {
           $('div.slideshow img').css('margin', '0px 0 0 -3px');
       }
   }
    

}





$(document).ready(function() {

if ($("#contBoxColums a").length == 0) {
    $("#contBoxColums").remove();
}

if ($('.mapSearchContainer').length > 0) {
    $('#TestoBlocco').css('margin-right', '0px');
    $('#TestoBlocco').css('margin-left', '0px');
}

function ajaxHeader(id) {
    if ($('#' + id).length > 0) {
        function callbackOK(data) {


            createCarousel(data);




        } function callbackKO() {

        }
        Xtend.CGT.UI.Internet.WebServices.ws.GetCarouselItemsJson("IT", callbackOK, callbackKO);
    }
}
    ajaxHeader('headerHp');
    // We only want these styles applied when javascript is enabled
    $('div.content').css('display', 'block');

    // Initially set opacity on thumbs and add
    // additional styling for hover effect on thumbs
   

    //attivo slideheader
    if ($('#HeaderImages').length > 0) {
        $('#HeaderImages').cycle({
            fx: 'fade',
            speed: 2000,
            timeout: 4000
        });
    }




});





