window.onload = function(e) {

    try
    {
        document.execCommand("BackgroundImageCache", false, true);
    }
    catch(err){}

};

var gallery = null;

jQuery(document).ready(function($) {
    
    try
    {
        $("a.lightbox").lightBox('', $('#baseUrl').text());
        
        gallery = $('#thumbs').galleriffic({
            delay:                     1000, // in milliseconds
            numThumbs:                 20, // The number of thumbnails to show page
            preloadAhead:              40, // Set to -1 to preload all images
            enableTopPager:            false,
            enableBottomPager:         false,
            maxPagesToShow:            7,  // The maximum number of pages to display in either the top or bottom pager
            imageContainerSel:         '#slideshow',
            controlsContainerSel:      '',
            captionContainerSel:       '',
            loadingContainerSel:       '',
            renderSSControls:          false, // Specifies whether the slideshow's Play and Pause links should be rendered
            renderNavControls:         false, // Specifies whether the slideshow's Next and Previous links should be rendered
            playLinkText:              'Play',
            pauseLinkText:             'Pause',
            prevLinkText:              'Previous',
            nextLinkText:              'Next',
            nextPageLinkText:          'Next &rsaquo;',
            prevPageLinkText:          '&lsaquo; Prev',
            enableHistory:             false, // Specifies whether the url's hash and the browser's history cache should update when the current slideshow image changes
            enableKeyboardNavigation:  false, // Specifies whether keyboard navigation is enabled
            autoStart:                 false, // Specifies whether the slideshow should be playing or paused when the page first loads
            syncTransitions:           false, // Specifies whether the out and in transitions occur simultaneously or distinctly
            defaultTransitionDuration: 1000 // If using the default transitions, specifies the duration of the transitions
            
        });
    }
    catch(err){}
});

function switchProduct(product,catid,name, popis, aside, bside, cside, dside)
{             
    $('.bigitem').show();
    
    $('#slideshow').text('');
    $('#big_name').text(name);
    $('#big_popis').text(popis);
              // alert('#exp_'+product);
      //alert("#exp_"+catid+"_"+product);        
    //alert($("#exp_"+catid+"_"+product).text());
    
    $('#explanation_box').text($("#exp_"+catid+"_"+product).text());
    if($("#exp_"+catid+"_"+product).text() != '')
    {
        $('#explanation_box_name').show();
    }
    else
    {
        $('#explanation_box_name').hide();
    }    
        
    $('#description_box').text($("#description_"+catid+"_"+product).text());
    $('#remark_box').text($("#remark_"+catid+"_"+product).text());
    
    $('#stock_box').text($("#stock_"+catid+"_"+product).text());
    if($("#stock_"+catid+"_"+product).text() != '')
    {
        $('#stock_box').show();
    }
    else
    {
        $('#stock_box').hide();
    }
    
    $('#code_box').text($("#code_"+catid+"_"+product).text());
    
    $('.category').hide();
    $('#'+catid).show();
    $('#showall').show();
    
    $('#switchbuttonA').attr("title", aside);
    $('#switchbuttonB').attr("title", bside);
    $('#switchbuttonC').attr("title", cside);
    $('#switchbuttonD').attr("title", dside);

    if(bside != -1)
        $('#switchbuttonB').show();
    else
        $('#switchbuttonB').hide();
    

    $('#switchbuttonA').hide();
    $('#switchbuttonC').hide();
    $('#switchbuttonD').hide();

    animation = $("#animation_"+catid+"_"+product).val();
    
    if(animation != '')
    {
        $('.lightbox').attr("href", animation);
        $('.lightbox').show();
    }    
    else
    {
     $('.lightbox').hide();
    }
    //alert($('#switchbutton').attr("title"));
}

function bside()
{
    $('#slideshow').text('');
    gallery.gotoIndex(parseInt($('#switchbuttonB').attr("title")));

    if(parseInt($('#switchbuttonC').attr("title")) >=0 )
    {
       $('#switchbuttonA').hide();
       $('#switchbuttonB').hide();
       $('#switchbuttonC').show();
       $('#switchbuttonD').hide();
    }
    else
    {
        $('#switchbuttonA').show();
        $('#switchbuttonB').hide();
        $('#switchbuttonC').hide();
        $('#switchbuttonD').hide();   
    }
}

function aside()
{
    $('#slideshow').text('');
    gallery.gotoIndex(parseInt($('#switchbuttonA').attr("title")));
    
    if(parseInt($('#switchbuttonB').attr("title")) >=0 )
    {
        $('#switchbuttonA').hide();
        $('#switchbuttonB').show();
        $('#switchbuttonC').hide();
        $('#switchbuttonD').hide();
    }
    else
    {
        $('#switchbuttonA').show();
        $('#switchbuttonB').hide();
        $('#switchbuttonC').hide();
        $('#switchbuttonD').hide();   
    }
        
}

function cside()
{
    $('#slideshow').text('');
    gallery.gotoIndex(parseInt($('#switchbuttonC').attr("title")));

    if(parseInt($('#switchbuttonD').attr("title")) >=0 )
    {
        $('#switchbuttonA').hide();
        $('#switchbuttonB').hide();
        $('#switchbuttonC').hide();
        $('#switchbuttonD').show();
    }
    else
    {
        $('#switchbuttonA').show();
        $('#switchbuttonB').hide();
        $('#switchbuttonC').hide();
        $('#switchbuttonD').hide();   
    }
}

function dside()
{
    $('#slideshow').text('');
    gallery.gotoIndex(parseInt($('#switchbuttonD').attr("title")));

    if(parseInt($('#switchbuttonA').attr("title")) >=0 )
    {
        $('#switchbuttonA').show();
        $('#switchbuttonB').hide();
        $('#switchbuttonC').hide();
        $('#switchbuttonD').hide();
    }
}


   

