$(document).ready(function()
{
  $('.scrollable').scrollable({
    size: 6,
    item: '.item',
    clickable: false,
    speed: 4500,
    easing: 'linear',
    loop: false,
    keyboard: false
  });//.autoscroll({autoplay: true, interval: 4500});

  $('.fancybox').fancybox();

  $('a#showmsg').fancybox({'hideOnContentClick': false, 'type': 'iframe'}).trigger('click');

  $('.flash').each(function()
  {
    var file = $(this).attr('src');
    var width = $(this).attr('hspace');
    var height = $(this).attr('vspace');
    var id = $(this).attr('id');

    $(this).hide();
    swfobject.embedSWF(file, id+'_holder', width, height, '8.0.0', false, {}, { bgcolor: '#000000', wmode: 'transparent' });
  });

  $('.field_login_clear').focus(function()
  {
    if($(this).attr('value')=='prihlasovacie meno') $(this).attr('value', '');
  });

  $('.field_password_clear').focus(function()
  {
    if($(this).attr('value')=='heslo') $(this).attr('value', '');
  });

  $('.field_login_clear').blur(function()
  {
    if($(this).attr('value')=='') $(this).attr('value', 'prihlasovacie meno');
  });

  $('.field_password_clear').blur(function()
  {
    if($(this).attr('value')=='') $(this).attr('value', 'heslo');
  });

  $('#goto_input').focus(function()
  {
    $(this).select();
  });

  $('#goto_page').submit(function()
  {
    var path = $('#goto_path').val();
    var page = parseInt($('#goto_input').val());

    if(page>0) document.location.href = path.replace('?', page);

    return false;
  });

  $('#anketa').submit(function(e)
  {
    var questions = $('.question');

    questions.each(function()
    {
      var id = ($(this).attr('id')).substr(2);
      var type = $(this).val();

      switch(type)
      {
        case '1':
        case '2':
        case '3':
        case '4':
          var options = $('.answer_' + id + ':checked');
          if(options.length==0) $('#qe_' + id).html('Vyberte aspoň jednu možnosť').show();
          else $('#qe_' + id).hide();
          break;

        case '5':
          var v = $('.answer_' + id).val();
          if(v=='') $('#qe_' + id).html('Chýba odpoveď').show();
          else $('#qe_' + id).hide();
      }
    });

    var errors = $('.error:visible');
    return (errors.length==0);
  });

   $('#Filedata').uploadify({
    'uploader'  : '/flash/uploadify.swf',
    'script'    : '/actions/upload.php',
    'cancelImg' : '/images/cancel.png',
    'buttonImg' : '/images/bt_upload.gif',
	  'height'    : '25',
	  'width'     : '110',
	  'auto'      : true,
    'folder'    : 'upload/',
    'queueSizeLimit'  : '9',
    'multi'     : true,
	//'sizeLimit': '460800',
  	'fileDesc': 'JPG Files',
    'fileExt': '*.jpg',
	   onComplete: function(a, b, c, d)
     {
        $('#partner_registracia').append('<input type="hidden" name="image[]" value="' + d + '" class="img" />');
        $('#uploadet_block').append('<img width="75" height="75" alt="" src="http://www.kofolabiznis.sk/upload/'+ d +'.jpg" />');
        $('#uploadet_block span').css("display", "none");
     }
   });
	
	$(".remove").click(function () {
      $("#uploadet_block img").remove();
      $("#partner_registracia input.img").remove();
    });

  //$().jSnow({flakes:30, flakeMaxSize:30, flakeMinSize:5, flakeCode:['/images/snowflake.gif'], interval:40});
});

