

var isScrolling;
function scrollWin(num,dir){
	isScrolling=true;
	keepScrolling(num,dir);
}

function keepScrolling(num,dir){
	if(isScrolling){
		if((contentsDiv.y-dir*3<=0)&&(contentsDiv.y+contentsDiv.getContentHeight()-dir*3>=clipperDiv.h)){
			contentsDiv.moveTo(null,contentsDiv.y-dir*3);
			setTimeout('keepScrolling('+num+','+dir+')',25);
		}
	}
}

function stopScrolling(){
	isScrolling=false ;
}


//function for sector projects
function stepThru(num,dir){
	if((contentsDiv.y-dir*18<=0)&&(contentsDiv.y+contentsDiv.getContentHeight()-dir*18>=clipperDiv.h)){
		contentsDiv.moveTo(null,contentsDiv.y-18*dir);
	}
}

//function for relief projects
function stepThruRelief(num,dir){
	if(((contentsReliefDiv.y-dir*126<=0)&&((contentsReliefDiv.y+contentsReliefDiv.getContentHeight()-dir*126)+126)>=clipperReliefDiv.h)){
		
		if(((contentsReliefDiv.y+contentsReliefDiv.getContentHeight()-dir*126)<clipperReliefDiv.h) && (((contentsReliefDiv.y+contentsReliefDiv.getContentHeight()-dir*126)+126)>clipperReliefDiv.h)){
			contentsReliefDiv.moveTo(null,contentsReliefDiv.y-126*dir);
			writeRecords(0);
		}
		else{
			contentsReliefDiv.moveTo(null,contentsReliefDiv.y-126*dir);
			writeRecords(1);
			}
	}
}

//function to show number of records and current records in relief projects

function getRecords(){
var total=((contentsReliefDiv.getContentHeight() - 1)/18)
return Math.round(total);
}


function writeRecords(mode){
var mode
str1='<table border="0" cellspacing="0" cellpadding="0"  width="200">'
str2='<tr>'
str3='<td align="right">'
str4='</td>'
str5='</tr>'
str6='</table>'

if ((mode==null)||(mode==1)){
	recordCounterDiv.write(str1+str2+str3+'records ' + getCurrentRecords() +' to ' + (getCurrentRecords()+6) +' of ' + getRecords()+str4+str5+str6)
	}
else{
	recordCounterDiv.write(str1+str2+str3+'records ' + getCurrentRecords() +' to ' + (getCurrentRecords()+getLastRecord()-1) +' of ' + getRecords()+str4+str5+str6)
}
}

function getCurrentRecords(){
var currentFirstRecord = ((contentsReliefDiv.y*-1)*7/126)+1
return currentFirstRecord;
}

function getLastRecord(){
var temp = contentsReliefDiv.getContentHeight()
var temp2 = temp % 126;
return Math.round((temp2-1)/18);
}

//function to hightlight current project in ADPs according to query string passed
function makeOnState(myproj){

	if(!ns){
		var elm=document.all["pr" + myproj];
		elm.className='rollAt';
		var ch = elm.getElementsByTagName ? elm.getElementsByTagName("a") : elm.children.tags("a");
		ch[0].style.color='#FFFFFF';
		ch[1].style.color='#FFFFFF';
		ch[2].style.color='#FFFFFF';
	
			var temp = nextNearest(myproj/7,1)
			for(i=1;i<temp;i++){
			stepThruRelief(0,1)	;
			}
	}
}

//function to hightlight current project in sector projects according to query string passed
function makeOnStateS(myproj){

	var elm=document.all["pr" + myproj];
	elm.className='rollAt';
	var ch = elm.getElementsByTagName ? elm.getElementsByTagName("a") : elm.children.tags("a");
	ch[0].style.color='#FFFFFF';
	ch[1].style.color='#FFFFFF';

		for(i=1;i<myproj;i++){
		stepThru(0,1);
		}
}



function nextNearest(value, number) {
  var ceil = Math.ceil(value);
  var remainder = value % number;
  if (remainder > 0)
    value = value - remainder + number;
  return value;
}
