function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {  
    /* HP tabs */
    jQuery('#navigation-carousel li a').featureList({
        output		: '#screen .slide',
        start_item	: 0
    });

    /* Links will not be clickable when carousel is used 
    jQuery('#navigation-carousel li a').attr('href', 'javascript:;');
    */
    
    /* Generates empty span for styling */
    startSpan = jQuery(document.createElement("span")).addClass('link-start');
    endSpan = jQuery(document.createElement("span")).addClass('link-end');
    jQuery('#screen a.link, .bottom-link, #actuality-novyshowpark .bottom .link, .link-history').prepend(startSpan);
    jQuery('.bottom-link, .link-history').append(endSpan);

    /* Repairs Actuality > Actuality in breadcrumbs */
    if(jQuery('body.actuality-sub').size()){
        jQuery('#navigation-breadcrumbs span.active').text(jQuery('h1').text());    
    }  

    /* Search text */
    jQuery('.cs #search-form .text').val('hledej...');
    jQuery('.en #search-form .text').val('search...');
    jQuery('.it #search-form .text').val('cerca...');
    jQuery('.ru #search-form .text').val('Поиск...');
    
    jQuery('.cs #search-form .text').click(function(){
        if(jQuery(this).val() == 'hledej...') {
            jQuery(this).val('');
        }
    });
    jQuery('.en #search-form .text').click(function(){
        if(jQuery(this).val() == 'search...') {
            jQuery(this).val('');
        }
    });
    
    jQuery('.it #search-form .text').click(function(){
        if(jQuery(this).val() == 'cerca...') {
            jQuery(this).val('');
        }
    });
    
    jQuery('.ru #search-form .text').click(function(){
        if(jQuery(this).val() == 'Поиск...') {
            jQuery(this).val('');
        }
    });
    
    jQuery('.cs #search-form .text').blur(function(){
        if(jQuery(this).val() == '') {
            jQuery('.cs #search-form .text').val('hledej...');
        }
    });    
    jQuery('.en #search-form .text').blur(function(){
        if(jQuery(this).val() == '') {
            jQuery('.en #search-form .text').val('search...');
        }
    });
    
    jQuery('.it #search-form .text').blur(function(){
        if(jQuery(this).val() == '') {
            jQuery('.it #search-form .text').val('cerca...');
        }
    });
    
    jQuery('.ru #search-form .text').blur(function(){
        if(jQuery(this).val() == '') {
            jQuery('.ru #search-form .text').val('Поиск...');
        }
    });  
  
    jQuery('html[lang="cs"] .dialog-inside .email input').each(function(){  
        jQuery(this).click(function(){   
            if(jQuery(this).val() == 'emailová adresa kamaráda') {
                jQuery(this).val('');
            }
        });   
    });
    
    jQuery('html[lang="cs"] .dialog-inside .email input').each(function(){
        jQuery(this).blur(function(){
            if(jQuery(this).val() == '') {
                jQuery(this).val('emailová adresa kamaráda');
            }
        });
    
    });
    
    jQuery('html[lang="en"] .dialog-inside .email input').each(function(){
        jQuery(this).click(function(){
            if(jQuery(this).val() == 'e-mail of a friend') {
                jQuery(this).val('');
            }
        });   
    });
    
    jQuery('html[lang="en"] .dialog-inside .email input').each(function(){
        jQuery(this).blur(function(){
            if(jQuery(this).val() == '') {
                jQuery(this).val('e-mail of a friend');
            }
        });
    
    });
    
    jQuery('html[lang="it"] .dialog-inside .email input').each(function(){
        jQuery(this).click(function(){
            if(jQuery(this).val() == 'indirizzo email dell’amico') {
                jQuery(this).val('');
            }
        });   
    });
    
    jQuery('html[lang="it"] .dialog-inside .email input').each(function(){
        jQuery(this).blur(function(){
            if(jQuery(this).val() == '') {
                jQuery(this).val('indirizzo email dell’amico');
            }
        });
    
    });
    
    jQuery('html[lang="ru"] .dialog-inside .email input').each(function(){
        jQuery(this).click(function(){
            if(jQuery(this).val() == 'электронный адрес друга') {
                jQuery(this).val('');
            }
        });   
    });
    
    jQuery('html[lang="ru"] .dialog-inside .email input').each(function(){
        jQuery(this).blur(function(){
            if(jQuery(this).val() == '') {
                jQuery(this).val('электронный адрес друга');
            }
        });  
    });

    
    jQuery('.dialog-inside form').submit(function(){
        jQuery('.dialog-inside .email input').each(function(){
            if(jQuery(this).val() == 'emailová adresa kamaráda') {
                jQuery(this).val('');
            }        
        });
    });
    
    
    /* Carousel - old
    if(jQuery('.gallery li').size()>1){
        jQuery('.gallery').carousel({
            dispItems: 1,
            animSpeed: 1000,
            direction: "horizotal",
            loop: true,
            autoSlide: true,
            autoSlideInterval: 2500
        });
    }
    
   */
   
   /* Carousel */
   jQuery(document).ready(function() {
        jQuery('#mycarousel').jcarousel({
            auto: 3,
            scroll: 1,
            wrap: 'both',
            animation: 'slow',
            initCallback: mycarousel_initCallback
        });
    });      
    
    /* Selects appropriate option of selec box - must be before conversion select box to ul */
    var bodyClass = jQuery('body').attr('class');    
    
    jQuery('#header select option').each(function(){  
        selectedOptionText = ' ' + jQuery(this).text().toLowerCase();  
        if(bodyClass.indexOf(selectedOptionText)>=0) {
            jQuery(this).attr('selected','selected');
        }
    });   
    
    /* Hide submit button */
    jQuery('#header #navigation-lang .submit').css('display','none');
    
    /* Styled select box */
    jQuery('#navigation-lang select').selectbox();
    
    /* Adds class according to its text (to selectbox items) */ 
    currentItem = jQuery('.jquery-selectbox-currentItem');
    currentItem.attr('class', currentItem.attr('class') + ' ' + currentItem.text().toLowerCase());
     
    jQuery('.jquery-selectbox-list span').each(function(){
        jQuery(this).attr('class', jQuery(this).attr('class') + ' ' + jQuery(this).text().toLowerCase());
    });
    
    /* Automatically selects selected value without submitting */
    jQuery('.jquery-selectbox-list span').click(function(){
        selectedLang = jQuery(this).attr('rel');
        if(selectedLang != "") {
            window.location.href = selectedLang; 
        }                 
    });  
    
    /* IE rotation of text not supported by css */
    if(jQuery.browser.msie){
        jQuery('.sticker p').transform({
            rotate: '15deg'
        });
    }    
    
    /* Sets interval for counting price from form */
    if(jQuery('#sale-card').size()){
        setInterval("writeOrderSummary()", 500); 
    }


    jQuery(function() {
        jQuery( "#recommendation_dialog" ).dialog({
            autoOpen: false,
            width: '600',
            height: '600'

        });
    });

    if(jQuery('body.it').size()){
        var linksDiv = jQuery(document.createElement('div')).addClass('forum-links').hide();
        var link1 = jQuery(document.createElement('a')).attr('href', 'http://it.showpark.info/forum/').text('FORUM OFFICIALE su showpark.info').attr('onclick', 'window.open(this.href); return false;');
        var link2 = jQuery(document.createElement('a')).attr('href', 'http://gnoccatravels.com/profile/discussions/271/showpark_official').text('FORUM sul sito dei nostri amici italiani www.gnoccatravels.com').attr('onclick', 'window.open(this.href); return false;');
        linksDiv.append(link1);
        linksDiv.append(link2);
        jQuery('#navigation-main a[title="Forum"]').parent('li').append(linksDiv);

        /* It discussion */
        jQuery('#navigation-main a[title="Forum"]').parent('li').hover(function(){
            linksDiv.show('fade');
        }, function(){
            linksDiv.hide('fade');
        });

        jQuery('#navigation-main a[title="Forum"]').attr('onclick', 'return false;');
    }
});

/* Price counting from form */
function writeOrderSummary(){ 
       
    var entry_5 = entry_20 = entry_5Text = entry_20Text = orderPriceText = '';
    var entry_5Count = entry_20Count = entry_Count = postCount = 0;
    var bothEntries = false;
            
    /* Value selection */        
    if((selectedValue = jQuery('select[name=5_entry] option:selected').attr('value')) >= 1){
        entry_5 = selectedValue;
        if(jQuery('body.cs').size()){
            entry_5Text = selectedValue + ' x Kč 500,- vč. DPH';
        } else if (jQuery('body.en').size()){
            entry_5Text = selectedValue + ' x CZK 500, VAT incl.';
        } else if (jQuery('body.it').size()){
            entry_5Text = selectedValue + ' x CZK 500, IVA inclusa';
        } else if (jQuery('body.ru').size()){
            entry_5Text = selectedValue + 'x 500 CZK с учетом НДС';
        }
        
        entry_5Count = selectedValue * 500;
    }
    
    if((selectedValue = jQuery('select[name=20_entry] option:selected').attr('value')) >= 1){
        entry_20 = selectedValue;
        if(jQuery('body.cs').size()){
            entry_20Text = selectedValue + ' x Kč 1000,- vč. DPH';
        } else if (jQuery('body.en').size()){
            entry_20Text = selectedValue + ' x CZK 1000, VAT incl.';
        } else if (jQuery('body.it').size()){
            entry_20Text = selectedValue + ' x CZK 1000, IVA inclusa';
        } else if (jQuery('body.ru').size()){
            entry_20Text = selectedValue + 'x 1000 CZK с учетом НДС';
        }
        
        entry_20Count = selectedValue * 1000;
    }
    
    if((selectedState = jQuery('select[name=state] option:selected').attr('value')) == '') {
        postCount = 0;
    } else if (selectedState != 'cz' ) {
        postCount = 150;
    } else {
        postCount = 50;
    }
    
    if(entry_5 >= 1 && entry_20 >= 1) bothEntries = true;
    
    orderPriceText = entry_5Text + ((bothEntries)? ', ' : '') + entry_20Text;
    entryCount = postCount + entry_5Count + entry_20Count;
            
    /* Write contents */
    jQuery('.order-info .order-price').text(orderPriceText);    
    if(jQuery('body.cs').size()){
        jQuery('.order-info .order-post').text((entry_5Count + entry_20Count != 0 && selectedState != '')?'Kč ' + postCount + ',- vč. DPH': '');
        jQuery('.order-info .order-sum').text((entry_5Count + entry_20Count != 0)?'Kč ' + entryCount + ',- vč. DPH': '');
    } else if (jQuery('body.en').size()){
        jQuery('.order-info .order-post').text((entry_5Count + entry_20Count != 0 && selectedState != '')?'CZK ' + postCount + ', VAT incl.': '');
        jQuery('.order-info .order-sum').text((entry_5Count + entry_20Count != 0)?'CZK ' + entryCount + ', VAT incl.': '');
    } else if (jQuery('body.it').size()){
        jQuery('.order-info .order-post').text((entry_5Count + entry_20Count != 0 && selectedState != '')?'CZK ' + postCount + ', IVA inclusa': '');
        jQuery('.order-info .order-sum').text((entry_5Count + entry_20Count != 0)?'CZK ' + entryCount + ', IVA inclusa': '');
    } else if (jQuery('body.ru').size()){
        jQuery('.order-info .order-post').text((entry_5Count + entry_20Count != 0 && selectedState != '')? postCount + ' CZK с учетом НДС': '');
        jQuery('.order-info .order-sum').text((entry_5Count + entry_20Count != 0)? entryCount + ' CZK с учетом НДС': '');
    }
}

function bookmarksite(title,url){
    if (document.all)
    {
        window.external.AddFavorite(url, title);
    }
    else if (window.sidebar)
    {
        window.sidebar.addPanel(title, url, "");
    } else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
        alert('Unfortunately, this browser does not support the requested action,'
            + ' please bookmark this page manually.');
    }
}






