// JavaScript Document
function bpToolTip(attach, content){
	new Tip(attach,
					$(content).innerHTML,
					{className: 'dannas-tooltip',
						closeButton: false,
						showOn: 'mousemove',
						fixed: true,
						hideOn: 'mouseout',
						hideOthers: true,
						offset: {x:-206, y:10}} );
}

function ulDropdowns() {
	var ulList = document.getElementsByClassName('ppl');
	for (var i = 0; i < ulList.length; i ++) {
		var liList = ulList[i].getElementsByTagName('li');
		for (var n = 0; i < liList.length; i++) {
			liList[i].onclick = function() {
				var subList = this.getElementsByTagName('ul')[0];
				if (subList.style.display != "block") {
					this.getElementsByTagName('ul')[0].style.display = "block";
				} else {
					this.getElementsByTagName('ul')[0].style.display = "none";
				}
			}
		}
	}
}

function ulDropdowns2(thelist) {
	var ulList = document.getElementsByClassName(thelist);
	for (var i = 0; i < ulList.length; i ++) {
		var liList = ulList[i].getElementsByTagName('li');
		for (var n = 0; n < liList.length; n++) {
		
		//alert(liList.length);
		
			if (liList[n].getElementsByTagName('ul').length > 0) {
			    liList[n].getElementsByTagName('ul')[0].style.display = "none";
			}
		
			liList[n].onclick = function() {
			
				/*Find and Hide Image*/
				if($('hideimage')){
				    if($('hideimage').style.display == 'block'){
					new Effect.BlindUp('hideimage');
				    }				
				}			
			
				var subList = this.getElementsByTagName('ul')[0];
				var subsid = subList.id;
				//alert(subsid);
				
				for (var i = 0; i < ulList.length; i ++) {
				    var liList = ulList[i].getElementsByTagName('li');
				    for (var n = 0; n < liList.length; n++) {
					var subList1 = liList[n].getElementsByTagName('ul');
					var subListLen1 = subList1.length;
					if(subListLen1>0){
					    var subsid1 = subList1[0].id;
					    //alert('go ' + subsid1);
					    if(subsid==subsid1){
						new Effect.BlindDown(subsid);
					    }else{
						new Effect.BlindUp(subsid1);
					    }
					}
				    }
				}
				
				//new Effect.toggle(subsid,'blind');
				//$(subsid).style.display = 'block';
			}
		}
	}
}

var biog=null;

function doslide(element,id,runget){
	//$$('.biogwindow').invoke('hide');
	if (biog) {
		new Effect.BlindUp(biog);
	}
	if (element !=biog) {
		new Effect.BlindDown(element, {delay:1} );
		biog = element;
	}
	else {biog=null;}
 //new Ajax.Updater('display_info', 'people.php?id=' + id, {onComplete:function(){ new Effect.toggle('display_info','blind');},asynchronous:true, evalScripts:true});
}

function ulDropdownsAjax(thelist,id) {
	var ulList = document.getElementsByClassName(thelist);
	for (var i = 0; i < ulList.length; i ++) {
		var liList = ulList[i].getElementsByTagName('li');
		for (var n = 0; i < liList.length; i++) {
			liList[i].onclick = function() {
				var id = this.id;
				var thisdisplay = document.getElementById('display_info').style.display;
				//alert(thisdisplay);
				if(thisdisplay=='none'){
				    new Ajax.Updater('display_info', 'people.php?id=' + id, {
					asynchronous:true,
					evalScripts:true,
					onComplete: function(){ 
					    new Effect.toggle('display_info','blind', {
						afterFinish: function() {
						 //alert('done');    
						}
					    });
					}
				    });
				}else{
				    new Effect.toggle('display_info','blind', {
					afterFinish: function() {
					    //alert('done');
					    new Ajax.Updater('display_info', 'people.php?id=' + id, {
						asynchronous:true,
						evalScripts:true,
						onComplete: function() {
						    new Effect.toggle('display_info','blind'); 
						}
					    });


					}
				    });
				}
			}
		}
	}
}


function changepage(pageto){

 if($('items')){
  var pages = $('items').getElementsByTagName('li');
  var nextbit = pages.length-1;
  var totalpages = pages.length;
  var lastpage = 'item' + totalpages;
  
  /*Find and Hide Image*/
    if($('hideimage')){
	if($('hideimage').style.display == 'block'){
	    new Effect.Fade('hideimage');
	}				
    }	
  
  /*Find Current Page*/
  var pageto = pageto;
  //alert(pageto);
  if(pageto=='next'){
    for(a=1;a<=totalpages-1;a++){
	var item1 = 'item' + a;
	//alert(item1);
	var thepage1 = $(item1);
	if(thepage1.style.display!='none'){
	    var newpage = (a+1)*1;
	    var pageto = 'item' + newpage;
	    alert(pageto + ' 1');
	}
    }
  }
  
  var newheight = $(pageto).style.height;
  
  var pagenum = pageto.replace("item",""); 
  //alert(pagenum);
  if(pagenum<=totalpages){
      for(i=1;i<=totalpages;i++){
	var item = 'item' + i;
	var thepage = $(item);
	new Effect.Fade(item, {
	    afterFinish: function() {
		//alert('done - ' + pageto + ' - ' + newheight);
		//$('pagescontent').morph({height:newheight})
		new Effect.Appear(pageto);				
	    }
	}); 
      
      }
   }
 }
}


function init(){
    var theurl = window.location.href;
    //alert(theurl);
    var thequery = theurl.split('#');
    if(thequery[1]){
    	changepage('item'+thequery[1]);
    }
}
