
interval=30;
scrollSpeed=7;


function activate_zone()	{


//subtract first 5, add five more
for(x=0;x<size;x++)	{
if($('#lens_'+x))	{
if(x>=5*current_zone && x<=(5*current_zone)+9) 	{

$('#lens_'+x).css("display","block");
}else	{
$('#lens_'+x).css("display","none");
}
}

}
if(current_zone<zones)	{
current_zone++;

}
}


function activate_zone_north()	{

for(x=0;x<size;x++)	{
//subtract last 5, add first missing 5
if(x<(5*(current_zone))  && x>=(5*current_zone)-9) 	{

$('#lens_'+x).css("display","block");
}else	{
$('#lens_'+x).css("display","none");
}


}
if(current_zone>1)	{
current_zone--;



}
}



function activate_zone_scroll()	{


//subtract first 5, add five more
for(x=0;x<size;x++)	{
if($('#lens_'+x))	{
if(x>=5*current_zone && x<=(5*current_zone)+9) 	{

$('#lens_'+x).css("display","block");
}
}

}
if(current_zone<zones)	{
current_zone++;


}
}




function scroll(direction, mouseDown)	{


if(direction=='north')	{
document.getElementById('north').style.background='#ffffff';
scrolling=setInterval('north(' + mouseDown + ')', interval);
}
if(direction=='south')	{
document.getElementById('south').style.background='#ffffff';
scrolling=setInterval('south(' + mouseDown + ')', interval);
}
if(direction=='east')	{
document.getElementById('east').style.background='#ffffff';
scrolling=setInterval('east(' + mouseDown + ')', interval);
}
if(direction=='west')	{
document.getElementById('west').style.background='#ffffff';
scrolling=setInterval('west(' + mouseDown + ')', interval);
}
if(direction=='stop')	{
document.getElementById('north').style.background='#333333';
document.getElementById('south').style.background='#333333';
document.getElementById('east').style.background='#333333';
document.getElementById('west').style.background='#333333';
clearInterval(scrolling);
}
}

function north(mouseDown)	{

var dome =document.getElementById('dome');
pos=dome.style.top;

if(pos.indexOf('px') !=-1)	{
pos=parseInt(pos.substring(0, pos.indexOf('px')));
} else	{
pos=parseInt(pos.substring(0, pos.indexOf('pt')));
}
if(mouseDown)	{
pos+=scrollSpeed*2;
} else	{
pos+=scrollSpeed;
}
dome.style.top = pos + 'px';

//$('#stat').html("<br/><br/><br/>"+$('#dome').css('top')+"<br/>z:"+current_zone);

t=parseInt($('#dome').css('top').substring(0, $('#dome').css('top').indexOf('px')));
if(t>(threshold*(current_zone-1))*-1 ){

if($('#lens_'+(9*(current_zone))).css('display')!='block'){
//current_zone++;
activate_zone_north();
}
}


}

//previously marginTop, marginLeft, etc.

function south(mouseDown)	{
var dome =document.getElementById('dome');
pos=dome.style.top;
if(pos.indexOf('px') !=-1)	{
pos=parseInt(pos.substring(0, pos.indexOf('px')));
} else	{
pos=parseInt(pos.substring(0, pos.indexOf('pt')));
}

if(mouseDown)	{
pos-=scrollSpeed*2;
} else	{
pos-=scrollSpeed;
}
dome.style.top = pos + 'px';

//$('#stat').html("<br/><br/><br/>"+$('#dome').css('top')+"<br/>z:"+current_zone);

t=parseInt($('#dome').css('top').substring(0, $('#dome').css('top').indexOf('px')));
if(t<(threshold*current_zone)*-1 ){

if(current_zone<zones && $('#lens_'+((5*current_zone)+9)).css('display')!='block'){
//current_zone++;

activate_zone();
}
}


}

function west(mouseDown)	{
var dome =document.getElementById('dome');
pos=dome.style.left;
pos=parseInt(pos.substring(0, pos.indexOf('px')));
if(mouseDown)	{
pos+=scrollSpeed*2;
} else	{
pos+=scrollSpeed;
}
dome.style.left = pos + 'px';

}

function east(mouseDown)	{
var dome =document.getElementById('dome');
pos=dome.style.left;
pos=parseInt(pos.substring(0, pos.indexOf('px')));
if(mouseDown)	{
pos-=scrollSpeed*2;
} else	{
pos-=scrollSpeed;
}
dome.style.left = pos + 'px';

}
