var flowCFmax = 0;
var flowUTmax = 0;
var flowmax = 0;


$(document).ready(function() {

  $("#mittebox_innen").swipe({
      swipeLeft: function() { beRightUT(); },
      swipeRight: function() { beLeftUT(); },
  });
    
  if (flowUTmax == 0) $("#leftUT").css( "background-image", "url(typo3conf/ext/flow_ut/img/schalter_coverflow_links_ki.jpg)");
  if ((flowUTend+4) < 5) $("#rightUT").css( "background-image", "url(typo3conf/ext/flow_ut/img/schalter_coverflow_rechts_ki.jpg)");

    
  $("#leftUT").hover(function (){
		    if (flowUTmax > 0) $(this).css( "background-image", "url(typo3conf/ext/flow_ut/img/schalter_coverflow_links_aktiv.jpg)"); 
    }, function(){ 
        if (flowUTmax > 0) $(this).css( "background-image", "url(typo3conf/ext/flow_ut/img/schalter_coverflow_links_inaktiv.jpg)"); 
    });

    
	$("#rightUT").hover(function (){
		    if (flowUTmax < flowUTend) $(this).css( "background-image", "url(typo3conf/ext/flow_ut/img/schalter_coverflow_rechts_aktiv.jpg)"); 
    }, function(){ 
        if (flowUTmax < flowUTend) $(this).css( "background-image", "url(typo3conf/ext/flow_ut/img/schalter_coverflow_rechts_inaktiv.jpg)"); 
    });


});

function beLeftUT(was){


  link_status = 1;
  if (flowUTmax <= 0) {
  
  } else {
    $("#rightUT").css({ "backgroundImage": "url(typo3conf/ext/flow_ut/img/schalter_coverflow_rechts_inaktiv.jpg)" });
    $("#flowUT").animate({left: "+=324px"}, 500 );
    flowUTmax--;
    if (flowUTmax == 0) {
      $("#leftUT").css({ "backgroundImage": "url(typo3conf/ext/flow_ut/img/schalter_coverflow_links_ki.jpg)" });
    }
  }
  setTimeout(function(){ resetLink() }, 1000 );
}

function beRightUT(was){

  link_status = 1;
  // $("#check").html(flowUTend+"-"+flowUTmax);
  if (flowUTmax >= flowUTend) {
  
  } else {
    $("#flowUT").animate({left: "-=324px"}, 500 );
    $("#leftUT").css({ "backgroundImage": "url(typo3conf/ext/flow_ut/img/schalter_coverflow_links_inaktiv.jpg)" });
    flowUTmax++;
    if (flowUTmax >= flowUTend) {
      $("#rightUT").css({ "backgroundImage": "url(typo3conf/ext/flow_ut/img/schalter_coverflow_rechts_ki.jpg)" });
    }
  }
  setTimeout(function(){ resetLink() }, 1000 );
  
}

function switchPage(link){

    document.location.href = link;
    
}


function resetLink() {
  link_status=0;
}
