/*** MOVE STRIPEPICS1 ***/


firstleftstart = 272;
rasterleft = 720;
difftomove1 = rasterleft - firstleftstart;
step = 32;
speed = 6;
moved1 = 0;
movedpicsright1 = 0;
marginRight1 = 0;
marginRightAfter1 = 0;
hasChildNodes1 = false;
amountChildNodes1 = 0;

// to prevent parallel calls of moving functions
movingCurrenttly1 = false;


// init functions
initMoveItDone1 = false;
function initMoveIt1() {
	
	if (typeof(beforeleft1)=='undefined') {
		// get init left position of beforepic1 (depending on amount of which pictures)
		beforeleft1 = parseInt(document.getElementById('stripepics1').style.left.replace(/px/, ''));
		//alert(beforeleft1);
  	}
  	
  	if (typeof(beforepic1)=='undefined') {
		beforepic1 = document.getElementById('stripepics1');
		if (beforepic1.hasChildNodes) {
			hasChildNodes1 = true;
			amountChildNodes1 = beforepic1.childNodes.length;
		}
	}
}


function showhidePlus1(child) {
	
	childonclick = child.getAttribute('onclick');
	if (childonclick == null) {
		document.getElementById("navplus1").style.display = "none";
	} else {
		document.getElementById("navplus1").style.display = "block";
	}
	
}
function updateCounter1(minus) {
	//piccounter = amountChildNodes1-minus;
	piccounter = minus+1;
	if (parseInt(piccounter)<10) {
		piccounter = "0"+piccounter;
	}
	document.getElementById("picCounter1").firstChild.nodeValue = piccounter;
}



function moveRightClick1() {
	
	if (initMoveItDone1 == false) {
		initMoveIt1();
		initMoveItDone1 = true;
	}
	
	// prevent multiple calls to moveRight&moveLeft function
	if (movingCurrenttly1==false) {
  		movingCurrenttly1 = true;
  		
  		if (hasChildNodes1 && amountChildNodes1 > (movedpicsright1+1)) {
			childindex = amountChildNodes1 - movedpicsright1 - 2;
			//alert(childindex);
			child = beforepic1.childNodes[childindex];
			childwidth1 = child.getAttribute('width');
			childafter = beforepic1.childNodes[childindex+1];
			if (childwidth1!=null) {
				
				// marginRightAfter1
				marginRightAfter1 = marginRight1;
				marginRight1 = 0;
				
				showhidePlus1(child);
				updateCounter1(childindex);
				moveRight1();
			
			} else {
				movingCurrenttly1 = false;
			}
		} else {
			movingCurrenttly1 = false;
		}
	}
}

function moveLeftClick1() {
	
	if (initMoveItDone1 == false) {
		initMoveIt1();
		initMoveItDone1 = true;
	}
	
	// prevent multiple calls to moveRight&moveLeft function
	if (movingCurrenttly1==false) {
  		movingCurrenttly1 = true;
  		
  		if (hasChildNodes1 && movedpicsright1>0) {
			childindex = amountChildNodes1 - movedpicsright1 - 1;
			child = beforepic1.childNodes[childindex];
			childwidth1 = child.getAttribute('width');
			childafter = beforepic1.childNodes[childindex+1];
			childafterwidth = childafter.getAttribute('width');
			
			if (childafterwidth!=null) {
				
				showhidePlus1(childafter);
				updateCounter1(childindex+1);
				moveLeft1();
			
			} else {
				movingCurrenttly1 = false;
			}
		} else {
			movingCurrenttly1 = false;
		}
	}
}



function moveRight1() {  
  
  if (moved1 >= difftomove1) {
	
	// one move finished!
	
	//alert(moved1);
	//child.style.marginRight = '0px';
	//alert(marginRight1);
	
	moved1 = 0;
	
	
	// moved one more pic of beforepic1 to the right
	movedpicsright1++;
	//alert(movedpicsright1);
	
	movingCurrenttly1 = false;
	
  } else {
  
	// still moving...		
	
	// move 'stripepics1'
	//alert(moved1+step);
	if (moved1+step <= childwidth1) {
		
		//alert('a');
		
		// move all pictures...
		
		// if current pictures has right margin, reduce it to 0 step by step
		if (marginRightAfter1 > 0) {
			if (marginRightAfter1 < step) {
				//alert('kleiner '+marginRightAfter1);
				marginDiff = marginRightAfter1;
				marginRightAfter1 = 0;
				
				// and move
				beforeleft1 = beforeleft1 + marginDiff;
				beforepic1.style.left = beforeleft1 + 'px';
				// inc position counter
				moved1 = moved1 + marginDiff;
				
			} else {
				marginRightAfter1 = marginRightAfter1 - step;
				
				// and move
				beforeleft1 = beforeleft1 + step;
				beforepic1.style.left = beforeleft1 + 'px';
				// inc position counter
				moved1 = moved1 + step;
			}
			childafter.style.marginRight = marginRightAfter1 + 'px';
			//alert(marginRight1);
			//marginRightAfter1 = marginRight1;
			
		} else {
			
			// just move
			beforeleft1 = beforeleft1 + step;
			beforepic1.style.left = beforeleft1 + 'px';
			// inc position counter
			moved1 = moved1 + step;
		}
	
	} else if (moved1+step > childwidth1 && moved1 < childwidth1) {
		
		//alert('b');
		
		// close gap left
		beforeleft1 = beforeleft1 + (childwidth1-moved1);
		beforepic1.style.left = beforeleft1 + 'px';
		
		// inc position counter
		moved1 = moved1 + (childwidth1-moved1);
	
	} else if (moved1+step > childwidth1) {
	
		/*alert('c');
		alert('mr'+marginRight1);
		alert('mra'+marginRightAfter1);*/
		
		
		// close the gap right with childafter
		//alert(marginRightAfter1);
		if (marginRightAfter1>0) {
			//alert(marginRightAfter1);
			if (marginRightAfter1 < step) {
				marginDiffAfter = marginRightAfter1;
				marginRightAfter1 = 0;
				childafter.style.marginRight = marginRightAfter1 + 'px';
				//moved1 = moved1 + marginDiffAfter;
			} else {
				marginRightAfter1 = marginRightAfter1 - step;
				childafter.style.marginRight = marginRightAfter1 + 'px';
				//moved1 = moved1 + step;
			}
		}
		
		
		// current picture needs right margin...
		//alert(marginRight1);
		marginRight1 = marginRight1 + step;
		child.style.marginRight = marginRight1 + 'px';
		
		// inc position counter
		moved1 = moved1 + step;
		
		
		// close the gap right
		if (moved1+step > difftomove1) {
			
			// gap is to big, close it again
			marginRight1 = marginRight1 + (difftomove1-moved1);
			child.style.marginRight = marginRight1 + 'px';
			
			// also have to move?
			if (moved1 < difftomove1) {
				//alert('c1');
				moved1 = moved1 + (difftomove1-moved1);
			}
		} 
	}
	
	
	// inc position counter
	//moved1 = moved1 + step;
	
	// loop
	window.setTimeout("moveRight1()", speed);
  }
}



function moveLeft1() {  
  
  if (moved1 >= difftomove1) {
	
	// one move finished!
	
	moved1 = 0;
	
	// marginRightAfter1
	marginRight1 = marginRightAfter1;
	marginRightAfter1 = 0;
	
	// moved one more pic of beforepic1 to the right
	movedpicsright1--;
	//alert(movedpicsright1);
	
	movingCurrenttly1 = false;
	
  } else {
  
	// still moving...		
	
	if (marginRight1 > 0) {
		
		//alert('la');
		
		// if current pictures has right margin, reduce it to 0 step by step
		
		if (marginRight1 < step) {
			// inc position counter
			moved1 = moved1 + marginRight1;
			diffstep = marginRight1;
			
			marginRight1 = 0;
		} else {
			// inc position counter
			moved1 = moved1 + step;
			diffstep = step;
			
			marginRight1 = marginRight1 - step;
		}
		child.style.marginRight = marginRight1 + 'px';
		
		
		// picture after needs right margin?
		
		if ((parseInt(childwidth1)+parseInt(childafterwidth)+parseInt(marginRight1)+parseInt(marginRightAfter1)) < difftomove1) {
			//alert('lb');
			//alert((parseInt(childwidth1)+parseInt(childafterwidth)+parseInt(marginRight1)+parseInt(marginRightAfter1)));
			marginRightAfter1 = marginRightAfter1 + diffstep;
			childafter.style.marginRight = marginRightAfter1 + 'px';
		}
		
		
	} else {
		
		
		if (moved1+step > childafterwidth) {
	
			// after picture needs right margin...
			
			marginRightAfter1 = marginRightAfter1 + step;
			childafter.style.marginRight = marginRightAfter1 + 'px';
		}
		
		// move all pictures...
		
		beforeleft1 = beforeleft1 - step;
		beforepic1.style.left = beforeleft1 + 'px';
		
		// inc position counter
		moved1 = moved1 + step;
		
		
		// close gap
		if (moved1+step > difftomove1) {
			
			// right
			if (moved1+step > childafterwidth) {
				marginRightAfter1 = (difftomove1-childafterwidth);
				childafter.style.marginRight = marginRightAfter1 + 'px';
			}

			// left
			beforeleft1 = beforeleft1 - (difftomove1-moved1);
			beforepic1.style.left = beforeleft1 + 'px';
			// inc position counter
			moved1 = moved1 + (difftomove1-moved1);
		}
	}
		
	
	// inc position counter
	//moved1 = moved1 + step;	
	
			
	// loop
	window.setTimeout("moveLeft1()", speed);
  }
}



function openCurrentPicWindow1() {
	if (initMoveItDone1 == false) {
		initMoveIt1();
		initMoveItDone1 = true;
	}
	n = amountChildNodes1-movedpicsright1-1;
	child = beforepic1.childNodes[n];
	childonclick = child.getAttribute('onclick');
	//alert(childonclick);
	if (childonclick != null) {
		eval(childonclick);
	}
	/*
	src = child.getAttribute('src');
	newsrc = src.replace(/thumbnails/, "popup");
	openPicWindow(newsrc);
	*/
}
