$(document).ready(function () {

  $(function() {
  
    $('#content a:has(img)').lightBox({
    	overlayBgColor: '#000',
    	overlayOpacity: 0.8,
    	imageLoading:  'http://www.countrylife.cz/bioskoly/gfx/lightbox/loading.gif',
    	imageBtnClose: 'http://www.countrylife.cz/bioskoly/gfx/lightbox/close.gif',
    	imageBtnPrev:  'http://www.countrylife.cz/bioskoly/gfx/lightbox/prev.gif',
    	imageBtnNext:  'http://www.countrylife.cz/bioskoly/gfx/lightbox/next.gif',
    	containerResizeSpeed: 100,
    	txtImage: 'obrázek',
    	txtOf: 'z'
     })
  });
  
  $(function() {
      NumberOfElements = $(".figure").size();

      for(var i = 0; i < NumberOfElements; i++){
        odstavec = $(".figure:eq("+ i +") p").text();
        $(".figure:eq("+ i +") a").attr("title",odstavec);
      };
  
  });
  
  $('blockquote p').append("<span class='end'>“</span>");
  $('blockquote p').prepend("<span class='hide'>„</span>");
  
  $(function () {
  if($.browser.msie && $.browser.version<7){
      $('#menu ul a').hover(function(){
             $(this).addClass('ie-over');
      }, function() {
             $(this).removeClass('ie-over');
      });
    };
  });
  
	$("a[href$='.pdf']").addClass("pdf");
  $("a[href$='.txt']").addClass("txt");
  $("a[href$='.doc']").addClass("doc");
  $("a[href$='.xls']").addClass("xls");  
  $("a[href$='.zip'], a[href$='.rar']").addClass("zip");
	
});

/* -------------------------------------------------------------------------- */
/* ------------------------------ validace registrace ----------------------- */
/* -------------------------------------------------------------------------- */

var validateRegistration = {

    init: function()
    {
        $(document).ready(function () {
            validateRegistration.start();
        });
    },

    start: function() {

        $("#registration-form").validate({
           onkeyup: false,
           rules: {
              name: {
                required: true
              },
              email: {
                required: true,
                email: true
              },
              password: {
                required: true
              },
              password2: {
                required: true,
                equalTo: "#usr_password"
              }              
           }
        });
    }
};

/* -------------------------------------------------------------------------- */
/* ------------------------------ validace přihlášení ----------------------- */
/* -------------------------------------------------------------------------- */

var validateLogin = {

    init: function()
    {
        $(document).ready(function () {
            validateLogin.start();
        });
    },

    start: function() {

        $("#login-form").validate({
           onkeyup: false,
           rules: {
              login: {
                required: true,
                email: true
              },
              password: {
                required: true
              }              
           }
        });
    }
};


/* -------------------------------------------------------------------------- */
/* ------------------------------ kontaktní formulář ------------------------ */
/* -------------------------------------------------------------------------- */

var actionContact = {

    init: function()
    {
        $(document).ready(function () {
            actionContact.start();
        });
    },

    start: function() {
    
        $('#ctc_e-mail').attr("disabled", true).empty().hide();

        $("#contact-form").validate({
           onkeyup: false,
           rules: {
              email: {
                required: true,
                email: true
              },
              name: {
                required: true
              },
              text: {
                required: true
              }              
           }
        });
    }
};


/* -------------------------------------------------------------------------- */
/* ------------------------------ změna údajů ------------------------------- */
/* -------------------------------------------------------------------------- */

var validateEdit = {

    init: function()
    {
        $(document).ready(function () {
            validateEdit.start();
        });
    },

    start: function() {

        $("#editlogin-form").validate({
           onkeyup: false,
           rules: {
              email: {
                required: true,
                email: true
              },
              name: {
                required: true
              },
              password2: {
                equalTo: "#usr_password"
              }              
           }
        });
    }
};


