/* Jquery Carousel */

jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
};

function mycarousel_initCallback(carousel)
  {
      carousel.buttonNext.bind('click', function() {
          carousel.startAuto(0);
      });
      carousel.buttonPrev.bind('click', function() {
          carousel.startAuto(0);
      });
      carousel.clip.hover(function() {
          carousel.stopAuto();
      }, function() {
          carousel.startAuto();
      });
  };
  
  jQuery(document).ready(function() {
  
    /* jQuery - function: Ajax Send Form
    ============================================================================*/
    jQuery('.left form').attr({action: window.location.href});
    jQuery('.left form').attr({method: 'get'});
    jQuery('.left form').submit(function() {

      var form_values = new Array(
        'jmeno', 'e-mail', 'predmet', 'text'
      );
      
      form_data = '';
      for (i in form_values) form_data += form_values[i] + '=' + encodeURIComponent(jQuery('.left #' + form_values[i]).val()) + '&';
      form_data += 'phpmailer';
      var return_value = jQuery.ajax({ type: "GET", url: window.location.href + "?" + form_data, async: false }).responseText;
      if (return_value != 'ok') {
        alert(return_value);
      } else {
        jQuery('.left #msg').empty();
        jQuery('.left #predmet').val('');
        jQuery('.left #text').val('');
        jQuery('.left #msg').append('Vaše zpráva byla úspěšně odeslána Budeme se snažit Vám v co nejbližší době odpovědět.');
      }
      
      return false;
    });

  jQuery('.fancy_iframe').fancybox({
    'width'          : 444,
    'height'         : 333,
    'overlayOpacity' : 0.7,
    'transitionIn'   : 'elastic',
    'transitionOut'  : 'elastic',
    'padding'        : 0,
    'autoScale'      : false,
    'type'           : 'iframe'
  });
      
  });
