// ======================= http://meddle.dzygn.com =======================
// LatScro v.0.10: (Lat)eral (Scro)ller. Modified from 13thparallel.org
// Free to use for personal projects. Contact meddle for commercial use
// Requires Dan and Michael's columns.js, api.js, and animation.js files
// see 13thparallel.org/?title=about for more specific Copyright
// ======================= Copyright (c) 2002-2003 =======================                   


// Scoping Navigation methods:
LatScro  = {
	// properties for da navigation:
	slidin 			: 0, 
	active 			: 0, 
	startX 			: 0, 
	colW 			: 215, 
	colH 			: 225, 
	colD 			: 30, 
	moveDist 		: 0,
	colsNum			: 0,

	init 			: function(){
		// setting value of scrolling distance for one column:
		LatScro.moveDist = parseInt( LatScro.colW + LatScro.colD);
		
		// styling links layer:
		if (lang=="cat"){
		document.getElementById( 'canviPopUp' ).innerHTML = '<div class="icon" id="iconGran">B</div>'; 
		document.getElementById( 'canviPopUp' ).innerHTML += '<div class="icon" id="iconPetitA"><a href="/'+lang+'/'+seccio+'/popupfoto/1/" title="Anar a popups de fotografia">F</a></div>'; 
		document.getElementById( 'canviPopUp' ).innerHTML += '<div class="icon" id="iconPetitB"><a href="/'+lang+'/'+seccio+'/popupcit/1/" title="Anar a popups de cites">C</a></div>'; 
		}
		if (lang=="esp"){
		document.getElementById( 'canviPopUp' ).innerHTML = '<div class="icon" id="iconGran">B</div>'; 
		document.getElementById( 'canviPopUp' ).innerHTML += '<div class="icon" id="iconPetitA"><a href="/'+lang+'/'+seccio+'/popupfoto/1/" title="Ir a popups de fotografía">F</a></div>'; 
		document.getElementById( 'canviPopUp' ).innerHTML += '<div class="icon" id="iconPetitB"><a href="/'+lang+'/'+seccio+'/popupcit/1/" title="Ir a popups de citas">C</a></div>'; 
		}
		if (lang=="eng"){
		document.getElementById( 'canviPopUp' ).innerHTML = '<div class="icon" id="iconGran">B</div>'; 
		document.getElementById( 'canviPopUp' ).innerHTML += '<div class="icon" id="iconPetitA"><a href="/'+lang+'/'+seccio+'/popupfoto/1/" title="Go to photography popups">P</a></div>'; 
		document.getElementById( 'canviPopUp' ).innerHTML += '<div class="icon" id="iconPetitB"><a href="/'+lang+'/'+seccio+'/popupcit/1/" title="Go to quote popups">Q</a></div>'; 
		}
		
		// creating layer to compute sizes/columns:
		var daSizerDiv = document.createElement("div");
			daSizerDiv.id = "divSizer";
		document.getElementsByTagName( 'body' ).item( 0 ).appendChild( daSizerDiv );	
		
		// creating scroll containing layer via DOM+innerHTML:
		var daDiv = document.createElement("div");
			daDiv.id = "cajaGrandeDiv";
		document.getElementsByTagName( 'body' ).item( 0 ).appendChild( daDiv );	
		document.getElementById( 'cajaGrandeDiv' ).innerHTML = '<div id="cajaDiv"></div>';
		capaObj = new make("cajaDiv");
		
		// creating lateral navigation layer via DOM+innerHTML:
		var butDiv = document.createElement("div");
			butDiv.id = "navLatDiv";
		document.getElementsByTagName( 'body' ).item( 0 ).appendChild( butDiv );
		
		// computing columns:
		var donde = "container";
		var exampleColumns = Columns.splitText(document.getElementById( donde ).innerHTML, LatScro.colW, LatScro.colH);
		
		// resetting values for scroller: 
		var pos = LatScro.startX;
		capaObj.timeSlide(0,0,550,-1);
		LatScro.colsNum = exampleColumns.length;
		
		// Recomputing info values inside infoScrDiv:
		LatScro.showInfo();
		
		// Writting the text for each column:
		for (var i = 0; i < exampleColumns.length; i ++)
		{
			if (i!=0) pos = LatScro.startX+(i*(LatScro.colW+LatScro.colD)); 
			document.getElementById( 'cajaDiv' ).innerHTML += "<div id='col"+i+"' class='columna'>" +exampleColumns[i]+"</div>";
			document.getElementById( 'col'+i ).style.left = pos + "px";
		}
		
		// Printing hack for dhtml version:
		//addPrinter();
	},

	goThere 		: function(w){
		if (LatScro.slidin==0){
			LatScro.slidin=1;  
			if(!w)	w=0;
			w=parseInt(w);
			capaObj.timeSlide(-LatScro.moveDist*w,0,750,-1,null,'LatScro.resetSlide()');
			LatScro.active=w;
			LatScro.showInfo();
		}
	},

	resetSlide 		: function(){
		LatScro.slidin=0;
	},

	showInfo 		: function(){
		document.getElementById( 'navLatDiv' ).innerHTML = "";
		for (var i = 0; i < LatScro.colsNum; i ++) {
			if (i == LatScro.active) document.getElementById( 'navLatDiv' ).innerHTML +=  parseInt(i+1) + "&nbsp;";
			else document.getElementById( 'navLatDiv' ).innerHTML += "<a href='#' onclick='LatScro.goThere(" +i+ ")'>"+ parseInt(i+1) + "</a>&nbsp;";
		}
	}
}

//===============================================================================================
// If browser supports enough DOM/CSS we change CSS on the fly and start javascript functions.
//===============================================================================================
if (document.getElementById && document.getElementsByTagName && document.createElement 
&& !brw.konq && typeof document.getElementsByTagName("head")[0].innerHTML != "undefined" ) {

addStyleSheet("/css/biografia.css", "screen");
	onload=LatScro.init;
}
