zeit                                                                = 3000;
i_slide                                                             = 2;
anz_slide                                                           = 0;
akt_download                                                        = 0;
i_download                                                          = 0;

$(document).ready(function()
  {
  /* buttons
  ----------------------------------------------------------------*/
  $('a.cx-button').wrapInner('<span></span>');


  /* contentflow
  ----------------------------------------------------------------*/
  if($('#contentFlow').hasClass('ContentFlow'))
    {
	cf																= new ContentFlow('contentFlow',
      {
	  //reflectionType : 'none'
	  startItem: parseInt($('.ContentFlow .item[autostart=1]').attr('pos')),
	  scaleFactor: 1.1,
	  flowSpeedFactor: 0.3,
	  onclickActiveItem : function(item)
		{
		}
	  });

	anz_slide                                                       = $('.ContentFlow .item').length;
    setTimeout('slideme()',zeit);
	}


  $('.cx-fancybox-download').click(function(data)
	{
	akt_download                                                    = $(this);
	});


  $('.cx-fancybox-download').fancybox(
    {
    'autoDimensions'  												: true,
    'autoScale'       												: true,
    'transitionIn'	  												: 'none',
	'transitionOut'	  												: 'none',
	'titleShow'       												: false,
	'onStart'         												: function()
	  {
	  $('body').addClass('cx-no-scrolling');
	  cx_download_init();
	  },
	'onClosed'        : function()
	  {
	  $('body').removeClass('cx-no-scrolling');
	  $('#cx_dialog_download').html();
	  },
	'onComplete'      : function()
	  {
	  }
	});

  });


function slideme()
  {
  i_slide++;
  if(i_slide == anz_slide)
	{
	i_slide                                                         = 0;
	}
  cf.moveTo(i_slide);

  setTimeout('slideme()',zeit);
  }


function cx_download_init()
  {
  $('#cx_dialog_download').addClass('cx-loading');
  str_rel															= ($(akt_download).attr('alt'));

  $.get($('#cx_header p a').attr('href'),'download_form='+str_rel,function(data)
    {
	$('#cx_dialog_download').html(data);
	$('#cx_dialog_download').removeClass('cx-loading');

	$('#cx_dialog_download .cx-formular-submit').click(function()
	  {
	  if(cx_formular_fehler_pruefen('#cx_dialog_download form') == 0)
		{
	  $('.cx-dialog-inner').hide();
	  $('#cx_dialog_download').addClass('cx-loading');
	  $.post($('#cx_dialog_download form').attr('action'),$('#cx_dialog_download form').serialize(),function(data)
	    {
		$('#cx_dialog_download').removeClass('cx-loading');
		$('#fancybox-close').trigger('click');

		if(str_rel.indexOf('PF') > 0)
		  {
		  $(akt_download).remove();
		  $('[alt][alt=\''+str_rel+'\']').show().trigger('click');
		  }
		else
		  {
		  document.location.href                                      = data;
		  $(akt_download).removeClass('cx-fancybox-download').attr('href',data);
		  a_neu                                                       = '<a href="'+data+'" class="'+$(akt_download).attr('class')+'">'+$(akt_download).html()+'</a>';
		  obj_parent_td												= $(akt_download).parents('td');
		  $(akt_download).wrap('<span id="hallo'+i_download+'"></span>');
		  $('#hallo'+i_download).html(a_neu);
		  $(akt_download).remove();
		  i_download++;
		  }
		});
		}
	  });
	});
  }
