jQuery.noConflict();

// TopSlider

function initListSlider() {

  var LI = jQuery("DIV#topslider:last LI");

  var maxWidth = 420;

  var int = 1;

  var activeIndex = 0;

  var width = new Array();

  var userEvent = 0;

  jQuery("#topslider").mouseenter(function(){ userEvent = 1; }).mouseleave(function(){ userEvent = 0; });

  var setWidth = function() {
    var restCheck = 0;
    for(var i=0;i<width.length;i++){
      if ( i <= activeIndex && i != 0 ) {
        width[i] += 30;
        if ( width[i] > maxWidth ) width[i] = maxWidth;
      } else {
        width[i] -= 10;
        if ( width[i] < 0 ) width[i] = 0;
        restCheck += width[i];
      }
      var x = Math.round((width[i]/maxWidth)*100)/100;
      var y = Math.sin(Math.PI/-2+Math.PI*x);
      var outputWidth = Math.round((y+1)/2*maxWidth);
      if(i==0){
      } else {
        LI.eq(i).css("margin-right",-420+outputWidth).css("margin-left",outputWidth*(-1));
      }
    }
    if ( width[activeIndex] >= maxWidth && restCheck == 0 ) {
      window.clearInterval(int);
      int = 1;
    }
  }

 

  var startInterval = function() {
    if ( int != 1 ) {
      window.clearInterval(int);
      int = 1;
    }
    setWidth();
    int = setInterval(function(){
      setWidth();
    },15);
  }

 

  LI.each(function(){
    var index = LI.index(jQuery(this));
    if ( jQuery(this).hasClass("active") ) {
      width.push(420);
    } else {
      width.push(0);
    }
    jQuery(this).mouseover(function(){ 
      activeIndex = index;
      startInterval();
    });
  });

  setInterval(function(){
    if ( userEvent == 0 ) {
      LI.removeClass();
      activeIndex++;
      if ( activeIndex >= LI.length ) activeIndex = 0;
      LI.eq(activeIndex).addClass("active");
      startInterval();
    }
  },7500);

}


// Multimedia-Box

function fotostrecke() {



    jQuery("#fotostrecke #right").click(function(){

      if(parseInt(jQuery("#bilderinhalt").css("margin-left")) > -3618){
           jQuery('div#left').css('display','block');
	   jQuery("#bilderinhalt").animate({
		  "marginLeft": "-=402px",
		}, 500);
}
     });



    jQuery("#left").click(function(){

     
      if(parseInt(jQuery("#bilderinhalt").css("margin-left")) < 0){



	   jQuery("#bilderinhalt").animate({
		  "marginLeft": "+=402px",
		}, 500);
}




     });






}



// Mein Verein

function meinVerein() {
	
	jQuery('#hernes').hover(
		function() {
			jQuery('div#laden').css('display','block');
			jQuery('#laden').load('test.html');		
		}
	);
	jQuery('#windecks').hover(
		function() {
			jQuery('div#laden').css('display','block');
			jQuery('#laden').load('test2.html');		
		}
	);

	jQuery('#ausblenden').hover(
		function() {
			jQuery(this).css('cursor', 'pointer');
		},
		function() {
			jQuery(this).css('cursor', 'default');
		}
	);
	
	
	jQuery('LI.meinverein').hover(
		function() {
			jQuery(this).css('cursor', 'pointer');
		},
		function() {
			jQuery(this).css('cursor', 'default');
		}
	);

	jQuery("LI.meinverein").click(function(){
	   jQuery("#content").animate({
		  "marginTop": 425,
		}, 200);
		jQuery('#MeinVerein').css('display','block');
	});
	
	jQuery("#ausblenden").click(function(){
	   jQuery("#content").animate({
		  "marginTop": 0,
		}, 220);
		jQuery('#MeinVerein').css('display','none');
	});
};


function abschneiden() {
	while ( jQuery("#nachrichtenInhalt").find("LI").length > 5 ) {
	jQuery("#nachrichtenInhalt").find("LI:last").remove();
	}
}


function ligenWechseln(){
	jQuery('.amateurkickBTN').hover(
		function() {
			jQuery(this).css('cursor', 'pointer');
			jQuery(this).removeClass('amateurkickBTN').addClass('amateurkickactiveBTN');
			jQuery(".nrwligaactiveBTN").removeClass('nrwligaactiveBTN').addClass('nrwligaBTN');
			jQuery(".niederrheinligaactiveBTN").removeClass('niederrheinligaactiveBTN').addClass('niederrheinligaBTN');
			jQuery(".westfalenliga2activeBTN").removeClass('westfalenliga2activeBTN').addClass('westfalenliga2BTN');
			jQuery(".regionalligaactiveBTN").removeClass('regionalligaactiveBTN').addClass('regionalligaBTN');
			jQuery('div#alle').css('display','block');
			jQuery('div#nrwliga_liste').css('display','none');
			jQuery('div#niederrheinliga_liste').css('display','none');
			jQuery('div#westfalenliga_liste').css('display','none');
			jQuery('div#regionalliga_liste').css('display','none');			
		},
		function() {
			jQuery(this).css('cursor', 'default');
		}
	);
	jQuery('.amateurkickactiveBTN').hover(
		function() {
			jQuery(this).css('cursor', 'pointer');
			jQuery(this).removeClass('amateurkickBTN').addClass('amateurkickactiveBTN');
			jQuery(".nrwligaactiveBTN").removeClass('nrwligaactiveBTN').addClass('nrwligaBTN');
			jQuery(".niederrheinligaactiveBTN").removeClass('niederrheinligaactiveBTN').addClass('niederrheinligaBTN');
			jQuery(".westfalenliga2activeBTN").removeClass('westfalenliga2activeBTN').addClass('westfalenliga2BTN');
			jQuery(".regionalligaactiveBTN").removeClass('regionalligaactiveBTN').addClass('regionalligaBTN');
			jQuery('div#alle').css('display','block');
			jQuery('div#nrwliga_liste').css('display','none');
			jQuery('div#niederrheinliga_liste').css('display','none');
			jQuery('div#westfalenliga_liste').css('display','none');
			jQuery('div#regionalliga_liste').css('display','none');			
		},
		function() {
			jQuery(this).css('cursor', 'default');
		}
	);
	jQuery('.nrwligaBTN').hover(
		function() {
			jQuery(this).css('cursor', 'pointer');
			jQuery(this).removeClass('nrwligaBTN').addClass('nrwligaactiveBTN');
			jQuery(".amateurkickactiveBTN").removeClass('amateurkickactiveBTN').addClass('amateurkickBTN');
			jQuery(".niederrheinligaactiveBTN").removeClass('niederrheinligaactiveBTN').addClass('niederrheinligaBTN');
			jQuery(".westfalenliga2activeBTN").removeClass('westfalenliga2activeBTN').addClass('westfalenliga2BTN');
			jQuery(".regionalligaactiveBTN").removeClass('regionalligaactiveBTN').addClass('regionalligaBTN');
			jQuery('div#alle').css('display','none');
			jQuery('div#nrwliga_liste').css('display','block');
			jQuery('div#niederrheinliga_liste').css('display','none');
			jQuery('div#westfalenliga_liste').css('display','none');
			jQuery('div#regionalliga_liste').css('display','none');			
		},
		function() {
			jQuery(this).css('cursor', 'default');
		}
	);
	jQuery('.niederrheinligaBTN').hover(
		function() {
			jQuery(this).css('cursor', 'pointer');
			jQuery(this).removeClass('niederrheinligaBTN').addClass('niederrheinligaactiveBTN');
			jQuery(".amateurkickactiveBTN").removeClass('amateurkickactiveBTN').addClass('amateurkickBTN');
			jQuery(".nrwligaactiveBTN").removeClass('nrwligaactiveBTN').addClass('nrwligaBTN');
			jQuery(".westfalenliga2activeBTN").removeClass('westfalenliga2activeBTN').addClass('westfalenliga2BTN');
			jQuery(".regionalligaactiveBTN").removeClass('regionalligaactiveBTN').addClass('regionalligaBTN');
			jQuery('div#alle').css('display','none');
			jQuery('div#nrwliga_liste').css('display','none');
			jQuery('div#niederrheinliga_liste').css('display','block');
			jQuery('div#westfalenliga_liste').css('display','none');
			jQuery('div#regionalliga_liste').css('display','none');			
		},
		function() {
			jQuery(this).css('cursor', 'default');
		}
	);
	jQuery('.westfalenliga2BTN').hover(
		function() {
			jQuery(this).css('cursor', 'pointer');
			jQuery(this).removeClass('westfalenliga2BTN').addClass('westfalenliga2activeBTN');
			jQuery(".amateurkickactiveBTN").removeClass('amateurkickactiveBTN').addClass('amateurkickBTN');
			jQuery(".niederrheinligaactiveBTN").removeClass('niederrheinligaactiveBTN').addClass('niederrheinligaBTN');
			jQuery(".nrwligaactiveBTN").removeClass('nrwligaactiveBTN').addClass('nrwligaBTN');
			jQuery(".regionalligaactiveBTN").removeClass('regionalligaactiveBTN').addClass('regionalligaBTN');
			jQuery('div#alle').css('display','none');
			jQuery('div#nrwliga_liste').css('display','none');
			jQuery('div#niederrheinliga_liste').css('display','none');
			jQuery('div#westfalenliga_liste').css('display','block');
			jQuery('div#regionalliga_liste').css('display','none');			
		},
		function() {
			jQuery(this).css('cursor', 'default');
		}
	);
	
	jQuery('.regionalligaBTN').hover(
		function() {
			jQuery(this).css('cursor', 'pointer');
			jQuery(this).removeClass('regionaligaBTN').addClass('regionalligaactiveBTN');
			jQuery(".amateurkickactiveBTN").removeClass('amateurkickactiveBTN').addClass('amateurkickBTN');
			jQuery(".niederrheinligaactiveBTN").removeClass('niederrheinligaactiveBTN').addClass('niederrheinligaBTN');
			jQuery(".westfalenliga2activeBTN").removeClass('westfalenliga2activeBTN').addClass('westfalenliga2BTN');
			jQuery(".nrwligaactiveBTN").removeClass('nrwligaactiveBTN').addClass('nrwligaBTN');
			jQuery('div#alle').css('display','none');
			jQuery('div#nrwliga_liste').css('display','none');
			jQuery('div#niederrheinliga_liste').css('display','none');
			jQuery('div#westfalenliga_liste').css('display','none');
			jQuery('div#regionalliga_liste').css('display','block');			
		},
		function() {
			jQuery(this).css('cursor', 'default');
		}
	);
}


/* ---------- MouseOver-Effekt für ListSlider ---------- */

function initHwsSlider() {

  var LI = jQuery("DIV.listSlider:last LI");
  var maxHeight = 70;
  var int = 1;
  var activeIndex = 0;
  var height = new Array();

  var setHeight = function() {
    var restCheck = 0;
    for(var i=0;i<height.length;i++){
      if ( i <= activeIndex && i != 0 ) {
        height[i] += 5;
        if ( height[i] > maxHeight ) height[i] = maxHeight;
      } else {
        height[i] -= 5;
        if ( height[i] < 0 ) height[i] = 0;
        restCheck += height[i];
      }
      var x = Math.round((height[i]/maxHeight)*100)/100;
      var y = Math.sin(Math.PI/-2+Math.PI*x);
      var outputHeight = Math.round((y+1)/2*maxHeight);
      if(i==0){
      } else {
        LI.eq(i).css("margin-bottom",-70+outputHeight).css("margin-top",outputHeight*(-1));
      }
    }
    if ( height[activeIndex] >= maxHeight && restCheck == 0 ) {
      window.clearInterval(int);
      int = 1;
    }
  }

  var startInterval = function() {
    if ( int != 1 ) {
      window.clearInterval(int);
      int = 1;
    }
    setHeight();
    int = setInterval(function(){
      setHeight();
    },15);
  }

  LI.each(function(){
    var index = LI.index(jQuery(this));
    if ( jQuery(this).hasClass("active") ) {
      height.push(70);
    } else {
      height.push(0);
    }
    jQuery(this).mouseover(function(){ 
      activeIndex = index;
      startInterval();
    });
  });

}
