 /**
  *  Żeby dodać nowy baner należy rozbudować ponizszą instrukcję switch o kolejny case
  *   - czyli przekopiować przed instrukcją default: następujący kod
  *     case kolejny_numer:
  * 		$("#showBaner>div:first").html('kod html: zwykle <img>');
  *			break;
  *  oraz zmienić wartość countBaner na kolejny_numer.
  */

 var focusBaner = 1;
 var countBaner = 4;

 function akcja() {
     switch(focusBaner) {
	    case 1:
            $("#showBaner>div:first").html('<a href="http://www.prezencik.sklep.pl"><img src="banery/kurier.gif" alt="Przesyłki kurierskie" title="Przesyłki kurierskie" style="border:none;" /></a>');
            break;
        case 2:
            $("#showBaner>div:first").html('<a href="http://www.prezencik.sklep.pl/index.php?k42,upominki-ze-zdjeciem"><img src="banery/maskotki.jpg" alt="Maskotki nie tylko ze zdjęciem" title="Maskotki" style="border:none;" /></a>');
            break;
        case 3:
            $("#showBaner>div:first").html('<a href="http://www.prezencik.sklep.pl/index.php?p657,obraz-na-plotnie-z-twojego-zdjecia-40x60cm"><img src="banery/onpztz.jpg" alt="Baner obrazujący przeniesienie zdjęcia na płótno" title="Obraz z twoim zdjęciem" style="border:none;" /></a>');
            break;
        case 4:
			$("#showBaner>div:first").html('<a href="http://prezencik.sklep.pl/index.php?d=szukaj&szukaj=pokrowiec&x=0&y=0&szukaj_opis=1"><img src="banery/okazjonalne/banner-537x320.gif" alt="Baner zimowy" title="Zimowe gadżety" style="border:none;" /></a>');
			break;			
        default:
    };
 }

 function osmaInitCallback(carousel) {

    focusBaner = Math.floor(Math.random() * countBaner)+1;
    $(".jcarousel-item a:eq("+(focusBaner-1)+")").css("color","orange");
    akcja();

    jQuery('.jcarousel-item a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        $(".jcarousel-item a:eq("+(focusBaner-1)+")").removeAttr("style");
        jQuery(this).css("color","orange");
        focusBaner = jQuery.jcarousel.intval(jQuery(this).text());
        akcja();
        return false;
    });


    jQuery('.jcarousel-prev').bind('click', function() {
        $(".jcarousel-item a:eq("+(focusBaner-1)+")").removeAttr("style");
        focusBaner = --focusBaner < 1 ? 1 : focusBaner;
        $(".jcarousel-item a:eq("+(focusBaner-1)+")").css("color","orange");
        akcja();

        return false;
    });

    jQuery('.jcarousel-next').bind('click', function() {
        $(".jcarousel-item a:eq("+(focusBaner-1)+")").removeAttr("style");
        focusBaner = ++focusBaner > countBaner ? countBaner : focusBaner;
        $(".jcarousel-item a:eq("+(focusBaner-1)+")").css("color","orange");
        akcja();

        return false;
    });

}


$(document).ready(function() {
   // code to execute when the DOM is ready

    $('#navBaner').jcarousel({
        // Configuration goes here
        scroll: 1,
        visible: countBaner,
		width: 537,
		height:320,
        initCallback: osmaInitCallback
    });

    //akcja(wybor);

    $("a[href=#showBaner]").click(function(e){
       // stop normal link click
       e.preventDefault();

       akcja(eval(this.text.valueOf()));
    });

});
