// JavaScript Document

	function home_slide(mainID,dir,totalPR) {
		var currentScroll_1 = document.getElementById(mainID+1).scrollLeft;
		var currentScroll_2 = document.getElementById(mainID+2).scrollLeft;
		var prsize = 150;
		var currentPos1 = currentScroll_1/prsize;
		var currentPos2 = currentScroll_2/prsize;
		var speed = 0.4;
		var p1check = currentPos1.toString();
		var p2check = currentPos2.toString();
		
		
		//if(p1check.length == 1 && p2check.length == 1) { //// ensure there is no decimal number
			//
			//console.log('pos 1 = ' + currentPos1 +' / pos 2 = '+ currentPos2);
		
			if(dir == 'next') {
				
				if(currentPos1 == totalPR) {
					document.getElementById(mainID+1).scrollLeft = 0;
					new Effect.Scroll((mainID+1), {x:prsize, mode:'relative', duration: speed } );
					
				///////////////////////////////////////
				////// if we are nearing the end, loop
				} else if(currentPos1 == (totalPR-1)) {
					new Effect.Scroll((mainID+1), {x:prsize, mode:'relative', duration: speed, 
														afterFinish:function(){ document.getElementById(mainID+1).scrollLeft = 0; }
												   } );
				
				///////////////////////////////////////
				////// else, show the next project
				} else new Effect.Scroll((mainID+1), {x:prsize, mode:'relative', duration: speed } );
				
				
				if(currentPos2 == totalPR) {
					document.getElementById(mainID+2).scrollLeft = 0;
					new Effect.Scroll((mainID+2), {x:prsize, mode:'relative', duration: speed } );
					
				///////////////////////////////////////
				////// if we are nearing the end, loop
				} else if(currentPos2 == (totalPR-1)) {
					new Effect.Scroll((mainID+2), {x:prsize, mode:'relative', duration: speed, 
														afterFinish:function(){ document.getElementById(mainID+2).scrollLeft = 0; }
												   } );
				
				///////////////////////////////////////
				////// else, show the next project
				} else {
					new Effect.Scroll((mainID+2), {x:prsize, mode:'relative', duration: speed } );
				}
				
				
			/////////////////////////////////////////////////////////////////////////////////////////////////////////
			/////////////////////////////////////////////////////////////////////////////////////////////////////////
			/////////////////////////////////////////////////////////////////////////////////////////////////////////
				
			} else if(dir == 'prev') {
				
				if(currentPos1 == 0) {
					document.getElementById(mainID+1).scrollLeft = totalPR*prsize;
					new Effect.Scroll((mainID+1), {x:(-prsize), mode:'relative', duration: speed } );
					
				///////////////////////////////////////
				////// if we are nearing the start, loop
				} else if(currentPos1 == 1) {
					new Effect.Scroll((mainID+1), {x:(-prsize), mode:'relative', duration: speed, 
														afterFinish:function(){ document.getElementById(mainID+1).scrollLeft = totalPR*prsize; }
												   } );
				
				///////////////////////////////////////
				////// else, show the next project
				} else new Effect.Scroll((mainID+1), {x:(-prsize), mode:'relative', duration: speed } );
				
				
				
				if(currentPos2 == 0) {
					document.getElementById(mainID+2).scrollLeft = totalPR*prsize;
					new Effect.Scroll((mainID+2), {x:(-prsize), mode:'relative', duration: speed } );
					
				///////////////////////////////////////
				////// if we are nearing the start, loop
				} else if(currentPos2 == 1) {
					new Effect.Scroll((mainID+2), {x:(-prsize), mode:'relative', duration: speed, 
														afterFinish:function(){ document.getElementById(mainID+2).scrollLeft = totalPR*prsize; }
												   } );
				
				///////////////////////////////////////
				////// else, show the next project
				} else {
					new Effect.Scroll((mainID+2), {x:(-prsize), mode:'relative', duration: speed } );
				}
			}
		//} else console.log('fail ' + p1check + ' / ' + p2check);
		
		
		
	}
	
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	function news_scroll(id,distance,amount) {
		var speed = 0.5;
		//console.log('pos 1 = ' + distance +' / pos 2 = '+ document.getElementById(id).scrollTop);
		if(document.getElementById(id).scrollTop == distance*2) {
			
			new Effect.Scroll(id, { y:(-distance), mode:'relative', duration: speed,
							  		afterFinish:function(){ document.getElementById(id).scrollTop = distance*(amount+1); } 
								   } );
		} else {
			new Effect.Scroll(id, { y:(-distance), mode:'relative', duration: speed } );
		}
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function initplacement() {
		// show featured projects
		document.getElementById("featured_block1").scrollLeft = 231;
		document.getElementById("featured_block2").scrollLeft = 462;
		document.getElementById("featured-pr-container").style.visibility = "visible";
		
		// show public projects
		document.getElementById("public_block1").scrollLeft = 231;
		document.getElementById("public_block2").scrollLeft = 462;
		document.getElementById("public-pr-container").style.visibility = "visible";
		
		// show chapters
		document.getElementById("chapter_block1").scrollLeft = 231;
		document.getElementById("chapter_block2").scrollLeft = 693;
		document.getElementById("chapter-container").style.visibility = "visible";
		
		// show rambles
		document.getElementById("ramble_block1").scrollLeft = 231;
		document.getElementById("ramble_block2").scrollLeft = 693;
		document.getElementById("ramble-container").style.visibility = "visible";
		
		/* show news ticker
		var distance = 35;
		var amount = 5;
		var id = "newsinfo";
		document.getElementById(id).scrollTop = distance*(amount-1);
		*/
		
		
		// fix safari arrows
		if(BrowserDetect.browser == 'Safari' && BrowserDetect.OS == 'Mac') {
			function fix_safari_arrow() {
				var dw = document.width;
				var cw = 904;
				var diff = (dw - cw)/2;
				var pa = document.getElementById('safari_fix_p');
				var ca = document.getElementById('safari_fix_c');
				var ra = document.getElementById('safari_fix_r');
				pa.style.width = (diff-15) + 'px';
				ca.style.width = (diff-15) + 'px';
				ra.style.width = (diff-15) + 'px';
				//
				pa.style.height = '171px';
				ca.style.height = '171px';
				ra.style.height = '171px';
			}
			fix_safari_arrow();
			window.onresize = fix_safari_arrow;
		}
		
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		function initplacement2() {
				document.getElementById("chapter_block1").scrollLeft = 231;
				document.getElementById("chapter_block2").scrollLeft = 693;
				document.getElementById("chapter-container").style.visibility = "visible";
				
				//console.log(document.getElementById("chapter_block1").scrollLeft);
				//console.log(document.getElementById("chapter_block1"));
				document.getElementById("chapter-container").style.visibility = "visible";
				
				if(BrowserDetect.browser == 'Safari' && BrowserDetect.OS == 'Mac') {
					function fix_safari_arrow() {
						var dw = document.width;
						var cw = 904;
						var diff = (dw - cw)/2;
						var pa = document.getElementById('safari_fix_p');
						var ca = document.getElementById('safari_fix_c');
						var ra = document.getElementById('safari_fix_r');
						pa.style.width = (diff-15) + 'px';
						ca.style.width = (diff-15) + 'px';
						ra.style.width = (diff-15) + 'px';
					}
					fix_safari_arrow();
					window.onresize = fix_safari_arrow;
				}
					//safari_fix_reload
		}
			
			


/////////////////////////////////////////////////////////////////////////////////////////////////







