$(document).ready(function(){


  if (jQuery.browser.safari && document.readyState != "complete"){
    //console.info('ready...');
    setTimeout( arguments.callee, 100 );
    return;
  } 


// Scroller
// Setup Gross
var jump_width = 970;
var animation_speed = 500;

var breite_scroller_content = $("#scroller_content").width();

var i = 0;

// Next-Button
$('.next').click(function() {
								  $('#scroller_content').stop().animate({
																		marginLeft: i-jump_width
																		}, animation_speed, function() {
																			
																			// Animation complete.
																			i = i-jump_width;
																			});
								  });

// Prev-Button
$('.prev').click(function() {
								  $('#scroller_content').stop().animate({
																		marginLeft: i+jump_width
																		}, animation_speed, function() {
																			
																			// Animation complete.
																			i = i+jump_width;
																				});
								  });




// Scroller
// Setup Subnav

var jump_width_subnav = 804;
var animation_speed_subnav = 500;

var breite_scroller_content_subnav = $("#subnav_scroller_content").width();
var i_subnav = 0;


if (breite_scroller_content_subnav == jump_width_subnav)
	  {
		  $('#subnav_prev, #subnav_next').addClass("hide");
	  }

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

var ref_par = gup( 'ref' );
var firstref_par = gup( 'firstref' );

var pos_par = (ref_par-firstref_par+1);

var tot_par = (60-firstref_par+1);

if (pos_par >= 1 && pos_par <= 6) {myjump = 0}
if (pos_par >= 7 && pos_par <= 12) {myjump = 1}
if (pos_par >= 13 && pos_par <= 18) {myjump = 2}
if (pos_par >= 19 && pos_par <= 24) {myjump = 3}
if (pos_par >= 25 && pos_par <= 30) {myjump = 4}
if (pos_par >= 31 && pos_par <= 36) {myjump = 5}
if (pos_par >= 37 && pos_par <= 42) {myjump = 6}
if (pos_par >= 43 && pos_par <= 48) {myjump = 7}
if (pos_par >= 49 && pos_par <= 54) {myjump = 8}
if (pos_par >= 55 && pos_par <= 60) {myjump = 9}

if (pos_par >= 1 && pos_par <= 6 && tot_par <= 6) {$('#subnav_next').addClass("hide");}
if (pos_par >= 7 && pos_par <= 12 && tot_par <= 12) {$('#subnav_next').addClass("hide");}
if (pos_par >= 13 && pos_par <= 18 && tot_par <= 18) {$('#subnav_next').addClass("hide");}
if (pos_par >= 19 && pos_par <= 24 && tot_par <= 24) {$('#subnav_next').addClass("hide");}
if (pos_par >= 25 && pos_par <= 30 && tot_par <= 30) {$('#subnav_next').addClass("hide");}
if (pos_par >= 31 && pos_par <= 36 && tot_par <= 36) {$('#subnav_next').addClass("hide");}
if (pos_par >= 37 && pos_par <= 42 && tot_par <= 42) {$('#subnav_next').addClass("hide");}
if (pos_par >= 43 && pos_par <= 48 && tot_par <= 48) {$('#subnav_next').addClass("hide");}
if (pos_par >= 49 && pos_par <= 54 && tot_par <= 54) {$('#subnav_next').addClass("hide");}
if (pos_par >= 55 && pos_par <= 60 && tot_par <= 60) {$('#subnav_next').addClass("hide");}


$('#subnav_scroller_content').stop().animate({marginLeft: (myjump*jump_width_subnav)*-1}, 0, function() {
																									  // Animation complete.
																									  i_subnav = (myjump*jump_width_subnav)*-1;
																									  });

if (i_subnav != 0) {
	$('#subnav_prev').removeClass("hide");
	}

if (i_subnav * -1 > breite_scroller_content_subnav - jump_width_subnav) {
	$('#subnav_next').addClass("hide");
	}

//alert (pos_par);
//alert (ref_par);
//alert (tot_par);


$("#subnav_next").click(function(){
								 $("#subnav_scroller_content").stop().animate({"marginLeft": "-=804px"}, animation_speed_subnav, function() {
																																   //     Animation complete.
																																   $('#subnav_prev').removeClass("hide");
																																   
																																   i_subnav = i_subnav -= 804;
																																   
																																   if (i_subnav != 0) {
																																	   $('#subnav_prev').removeClass("hide");
																																	   }
																																	   
																																   if (i_subnav * -1 >= breite_scroller_content_subnav - jump_width_subnav) {
																																	   $('#subnav_next').addClass("hide");
																																	   }
																																	   
																																	   });
								 });


$("#subnav_prev").click(function(){
								 $("#subnav_scroller_content").stop().animate({"marginLeft": "+=804px"}, animation_speed_subnav, function() {
																																   // Animation complete.
																																   $('#subnav_next').removeClass("hide");
																																   
																																   i_subnav = i_subnav += 804;
																																   
																																   if (i_subnav == 0) {
																																	   $('#subnav_prev').addClass("hide");
																																	   }
																																	   
																																	   });
								 });




});//Document ready ende



