/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h<k.length;h++){var c=jQuery.trim(k[h]);if(c.substring(0,b.length+1)==(b+"=")){d=decodeURIComponent(c.substring(b.length+1));break}}}return d}}; 


$(document).ready(function () {

        var ie6 = false;
        var ie7 = false;
        var ie8 = false;

        if((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)){

            ie6 = true;
        
        }

        if((document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1)||(navigator.appVersion.indexOf("MSIE 8.")!=-1)){

            ie7 = true;
            ie8 = true;

        }

/*        if(typeof sIFR == "function"){
            sIFR.bHideBrowserText = false;
            sIFR.bFixFragIdBug = false; // not recommended!
            sIFR.setup();

            sIFR.replaceElement("p.fontMyriad", named({sFlashSrc: "lib/fonts/myriad.swf", sColor: "#7F7F7F", sWmode: 'transparent' }));
            sIFR.replaceElement("p.fontMyriadSmall", named({sFlashSrc: "lib/fonts/myriad.swf", sColor: "#4D4D4D", sWmode: 'transparent' }));

        }*/
        
        //Cufon.replace('.fontFlare', { fontFamily: 'Flareserif821 Lt BT'});
        Cufon.replace('.fontFlare', { fontFamily: 'Museo Sans 500'});
        //Cufon.replace('p.enter', { fontFamily: 'Myriad Web'});

	$('#bannerSlide #preloader').remove();

        $('#bannerSlide #slideIt').show().cycle({
            fx:     'fade',
            speed:   900,
            timeout: 5200,
            next:   '#slideArrRight',
	    prev:   '#slideArrLeft',
	    pager:  '#slideNav',
	    pause: 1,
	    slideResize: 0
        });

        $('#mainGalSlide #galSlideIt').cycle({
            fx:    'fade',
            speed:    1500,
            timeout:  4200
        });

        $('#videoSlide').cycle({
            fx:    'fade',
            speed:    600,
            timeout:  5000
        });

        var navBar = $('#navBar ul li a');

        $.each(navBar, function() {

            $(this).bind("mouseover focus", function() {

                $(this).parent().find('.eff').animate({ top: "0px", opacity: "0.5" }, 600, "swing");
                $(this).parent().find('.sh').animate({ bottom: "-10px", opacity: "1.0" }, 550, "swing");

            });

            $(this).bind("mouseout blur", function() {

                $(this).parent().find('.eff').animate({ top: "-60px", opacity: "0.0" }, 280, "swing");
                $(this).parent().find('.sh').animate({ bottom: "-30px", opacity: "0.0" }, 250, "swing");

            });

        });
        
      /* carousel on homepage */
      jQuery('#carouselMini').jcarousel({
          auto: 2,
	  wrap: 'circular',
	  scroll: 1,
	  animation: 'slow',
	  easing: 'swing'
      });
                                  

      if($('#langChooser')) {

          $('#LanguageID').change(function(e) {

              var oldLocation = document.location.toString();

              switch($('#LanguageID').val()) {
                case 'cestina':
                var newLocation = "http://www.sypien.pl/cestina/";
                document.location = newLocation;
                break;

                case 'slovensky':
                var newLocation = "http://www.sypien.pl/slovensky/";
                document.location = newLocation;
                break;
                
                case 'deutsch':
                var newLocation = "http://www.sypien.pl/deutsch/";
                document.location = newLocation;
                break;

                case 'english':
                var newLocation = "http://www.sypien.pl/english/";
                document.location = newLocation;
                break;

              }

          });

      }

   Shadowbox.init();
   
   
   $('#asideNewsletter form, #newsletter-dialog form').each(function () {
		$(this).validate({

			rules: {
				freshmail_email: {
					email: true
				}
			},
			
			messages: {
				freshmail_email: 'Prosimy podać prawidłowy adres e-mail'
			},
			 
			onkeyup: false,
			onfocusout: false
	   })
   })

});

