 //
 // Cityguide Lineup Scroller
 // © eymedia.ch
 // sbe
 //

 	var forcexmove = 1000; // just any random number
 	var forcewmove = 1000; // just any random number
	var ds_shown = 1; 				// Visible Datasets (Fix Valiue for this Project)
	var ds_width = 350; 			// Width for the  Dataset  (Fix Valiue for this Project)
	var arrow_l;					// Name for the Left Arrow
	var arrow_r;					// Name for the Right Arrow
	var ds_count; 					// Amount  of the Datasets(Should be posted from PHP)
	var direction; 					// possible directions 'back' and 'forward'
	var layer;  					// id of the Moving Div Layer
	var xmove;						// X Valiue for the Movement
	var img_name;					// Image Name for the Changing Image
	var img_source;					// Image Path for the Changing Image
	var sliderpos;
	var slidesteps_big;
	var slidestep_last;
	var clicktimeout = "false";		//this makes the arrows clickable
	
	//Change arrow Image
	function change_img(img_name,img_src) {
		
		//document.images[img_name].src=img_src;
		$(img_name).src=img_src;
	}
	
	//function should detect wich arrow should be swichtched (but it dont get the variabels propper frome the muve_lineup() function
  function arrow_finder(sliderpos, arrow_l, arrow_r, slidesteps_big, slidestep_last){
  if(sliderpos == 0)
   {
		change_img(arrow_l,'fileadmin/template/main/images/arrow_l_0.gif');		   
   }
   if(sliderpos < 0)
   {
		change_img(arrow_l,'fileadmin/template/main/images/arrow_l_1.gif');		   
   }
   if(sliderpos <= -(((slidesteps_big - 1) * (ds_width * ds_shown )) + (slidestep_last * ds_width)))
   {
	  change_img(arrow_r,'fileadmin/template/main/images/arrow_r_0.gif');	 
   }
   if(sliderpos > -(((slidesteps_big - 1) * (ds_width * ds_shown )) + (slidestep_last * ds_width)))
   {
	  change_img(arrow_r,'fileadmin/template/main/images/arrow_r_1.gif');	 
   }
   

 }
 
 
 //widerklicken
 function makeclickable(){
		   clicktimeout="false";
 
 }
	
 
	
	//Move Function
   function move_lineup(direction, layer, ds_count, arrow_l, arrow_r){
	   clicktimeout="true";																								// Disable the onClick event
	   setTimeout('makeclickable()', 1500);																				// Enable the onClick event after 1.5 sec gain
	   

 
 
 
 	var slidesteps = ds_count / ds_shown; 																				// Caalculates the Amount for the Big Steps
	 slidesteps_big = Math.floor(slidesteps);																			// Amount for the Big Steps
	slidestep_last = ds_count - (ds_shown * slidesteps_big);														// Caalculates the last small Step
	 sliderpos =  $(layer).offsetLeft;																					// Checks the actual Position of the Slide div Layer  
   
   
   
	
   
    //Move Back
	if(direction == 'back')
   {
		if(sliderpos <= -(ds_shown * ds_width))																		// Calculate the Big 'xmove' xvaliue
		{
		xmove = ds_shown * ds_width;
		change_img(arrow_r,'fileadmin/template/main/images/arrow_r_1.gif');																					// Enable the Right Arrow Image
		}else if(sliderpos > -(ds_shown * ds_width) && sliderpos < 0){												// Calculate the small 'xmove' xvaliue for the last Moving
		xmove = slidestep_last * ds_width;
		change_img(arrow_l,'fileadmin/template/main/images/arrow_l_0.gif');																	// Disable the Left Arrow Image
		}else if(sliderpos == 0){																						// Calculate the the end of the slider and set the 'xmove' xvaliue to 0
		xmove = 0;
		}
	}
	
	//Move Forward
	if(direction == 'forward')
   {
 		if(sliderpos > -((slidesteps_big - 1) * (ds_width * ds_shown )))												// Calculate the Big 'xmove' xvaliue
		{
		xmove = -(ds_shown * ds_width);
		change_img(arrow_l,'fileadmin/template/main/images/arrow_l_1.gif');																	// Enable the Left Arrow Image
		}else if(sliderpos == -((slidesteps_big - 1) * (ds_width * ds_shown ))){										// Calculate the small 'xmove' xvaliue for the last Moving
		xmove = -(slidestep_last * ds_width);
		change_img(arrow_r,'fileadmin/template/main/images/arrow_r_0.gif');																	// Disable the Right Arrow Image
		}
		
		if(sliderpos <= -(((slidesteps_big - 1) * (ds_width * ds_shown )) + (slidestep_last * ds_width))){		// Calculate the the end of the slider and set the 'xmove' xvaliue to 0
		xmove =0;
		}		
	
	}
	
 

   	
	var t = 0;  
   
  //setTimeout("t = 0;", 2000);							//this should call the arrow_finder() function, but it dont gifs the variables proper
//arrow_finder(sliderpos, arrow_l, arrow_r, slidesteps_big, slidestep_last);
 

   
   new Effect.Move(layer, { x: xmove, mode: 'relative' }); 														// Movemend Command with preseted valiues
   
   
   if($(layer).offsetLeft>0)
 	change_img(arrow_l,'fileadmin/template/main/images/arrow_l_0.gif');
   
 
 
 //  return false;
    } 
      