
/* Banner image change */
	var img = new Array("images/1.jpg", "images/2.jpg", "images/3.jpg","images/4.jpg", "images/5.jpg")		
	var rand_pic = new Array('images/rand/bio_pic1.jpg', 'images/rand/bio_pic2.jpg', 'images/rand/bio_pic3.jpg');
	
	function imageRotate (){
	if (!document.images) return
	ranImage = Math.floor(Math.random()*img.length);	
	bioRanImage = Math.floor(Math.random()*rand_pic.length);	
		
	imgHolder = document.getElementById("imgChange")	
	bioImgHolder = document.getElementById("rand_pic")		

	if(bioImgHolder == null){	
		imgHolder.src = img[ranImage]		
		
	} else {
		imgHolder.src = img[ranImage]
		bioImgHolder.src = rand_pic[bioRanImage]	
	}
		
	}
	setInterval("imageRotate()",10000)
/*End Banner image change */

/* Pagination Javascript */
	var divs;
	var items = new Array();
	var itemsPerPage = 6;
	var currentPage = 0;
	var pageNum = 0;
	var pageNos, numberOfPages;	
	var prevLink = '<a href="javascript:showPage(currentPage-itemsPerPage);">< Previous</a>';
	var nextLink = '<a href="javascript:showPage(currentPage+itemsPerPage);">Next ></a>';
	

function allPage(){

		topControls.innerHTML = "<a href='javascript:showPage(0)'>Return to previous view ></a>";	
			
		for(i=0;i<items.length;i++){
			items[i].style.display = "inline";
		}
				

}
	
	function showPage(cPage){
	
		currentPage = cPage;
		 
		if(currentPage<0) currentPage =0;
		if(currentPage>=items.length) currentPage = items.length - itemsPerPage;
		
	
		for(ai=0;ai<items.length;ai++){

			items[ai].style.display = "none";
		}

		for(i=currentPage;i<items.length;i++){
			if(i<(currentPage+itemsPerPage) ){
				items[i].style.display = "inline";
			}
		}
		
	
		
	
		if(items.length > itemsPerPage){			
				topControls.innerHTML = "<a href='javascript:allPage();' class='pagshow'>< Show all</a>";	
				
				if(currentPage!=0 && numberOfPages>1){
					topControls.innerHTML += prevLink;
				}
				
					
				for(n=0;n<numberOfPages;n++){
					  if((n*itemsPerPage)==currentPage){
						topControls.innerHTML += "<a href='javascript:showPage("+n*itemsPerPage+")' class='on' style='color:#878B78;'>"+(n+1)+"</a> ";
						
					  }else{
						topControls.innerHTML += "<a href='javascript:showPage("+n*itemsPerPage+")' class='off'>"+(n+1)+"</a> ";
				
					  }
				}
				
				if((currentPage+itemsPerPage)<items.length){
					topControls.innerHTML += nextLink;
				}
		}else{
			topControls.innerHTML="";
		}

	}
	
	
	window.onload = function countPages(){
		divs = document.getElementsByTagName("div");	
		for(p=0;p<divs.length;p++){

			if(divs[p].className == "port_img"){
			 items.push(divs[p]);				
			}			
		}
		

		topControls = document.getElementById("pagination");
	  	numberOfPages = Math.ceil(items.length / itemsPerPage);	
		
		showPage(currentPage);	
	
	}
/* End Pagination Javascript */

