


var xm=-100,ym=0,nx=0,ny=0,dy=0,dx=0,x0=0,y0=0;
var N,sled1,sled2,NW,NH,ims,img;
var frame, html_length = 0;
var vert_scroller;

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;


el=function(o){	 
	return document.getElementById(o);  
};


//This one does the vertical scrolling...
function slide(){

	dy-=ym/45;
	
	if(dy>0){ 
	
		dy-=NH; 
		
	}else if( dy<0  &&  dy< (-1)*NH ){
	
		dy+=NH;
		
	}
	//el("output").innerHTML = ym +"px <br/>"+ dy +"px <br/>"+ NH;
	sled1.style.top = Math.round(dy) +"px";
	sled2.style.top = Math.round(dy+NH) +"px";
}


//Get the height of the ul-list from the images it contains
function oResize(obj){
	if(ims = obj.getElementsByTagName("img")){
		N = ims.length;
		//NW = 0;
		NH = 0;
		for(i=0;i<N;i++){
			w = ims[i].offsetHeight;
			//NW += w;
			NH += w;
		}
	}
}

//initialize the values
function resize(){
	nx = document.body.offsetWidth /2;
	ny = document.body.offsetHeight /2;
	
	if(isIE) ny = ny / 2; //This is neccesary because of the CSS used with IE on desertlifestlyes.com...
	
	oResize(sled1);
	oResize(sled2);		
	//NW = Math.round(NW);
	NH = Math.round(NH);
}


//Track mouse
document.onmousemove = function(e) {
	if (window.event) e = window.event;
	xm = (e.x || e.clientX)-nx;
	ym = (e.y || e.clientY)-ny;
}



//Start the scrolling...		start_scroll('ulList0');
function start_scroll(parent_id) {
	
	frame = document.getElementById( parent_id ); 
	html_length = frame.innerHTML.length  //Get the starting length
	
	frame.innerHTML += frame.innerHTML;	//create copy of ul-list and insert as an adjacent node
	
	//Find the scrolling objects...
	e_col = frame.getElementsByTagName("ul");
	sled1 = e_col[0];
	sled2 = e_col[1];
	
	//Init values
	resize();  
	
	//Start scrolling :)
	vert_scroller = setInterval("slide()",8);
	
	//notifyme();
}


function stop_scroll(){
	
	//Stop the animation
	clearInterval(vert_scroller);
	
	if(frame){
		//Remove the duplicate ul-list
		//alert(frame.innerHTML.substring(0, html_length));
		frame.innerHTML = frame.innerHTML.substring(0, html_length + 5);
	}
	
}










//Used to output values...  requires a <div id="output"></div> on the page
function notifyme(){
	el("output").innerHTML = xm +"px <br/>"+ ym +"px <br/>NH: "+ NH +"px <br/>"+parseInt(el("furn").style.height) /2;
	setTimeout("notifyme()",1000);
}



//Experimental function...
function getElementsByClassName(myclass){
	c = new Array();
	var count = 0;
	a = document.getElementsByTagName("div");
	for(x=0;x<a.length;x++){
		if(a[x].className == myclass){
			c[count] = a[x];
			count++;
		}
	}
	
	return c;
}

