/*

used to roll or move a div or html element content vertical up
example:
oroll1=new rolling_div('oroll1',['div_id_1','div_id_2','div_id_3'],'delay=1,delay_section=5000');
oname : the name of the object
div_ids : an array of div ids that intend  to be roll up, you need at least 2 divs to make the rolling, if one is define then no rolling will happen, put an empty div to ensure the rolling action
options : may contain any of these value :
- delay : the timer speed
- delay_section : the time wait in each of the div border
note that all the div_ids should be placed in a container that have a style of position:relative and overflow:hidden
and all the div should have the same width as the container
created by bear_form and copyrighted
*/
function rolling_div(oname,div_ids,options){
var p=parseProp(options);
if(p['delay']==null || p['delay']=="") p['delay']=10;
if(p['delay_section']==null || p['delay_section']=="") p['delay_section']=2000;
if(p['direction']==null || p['direction']=="") p['direction']='north';
var t;
this.last_div=null;
this.rolling_div_roll=rolling_div_roll;
this.halt=false;
if(!div_ids) return;
for(var i=0;i<div_ids.length;i++){
t=document.getElementById(div_ids[i]);
if(!t.onmouseover){
t.onmouseover=function(){eval(oname+".halt=true;");}
t.onmouseout=function(){eval(oname+".halt=false;");}
}
t.style.position='absolute';
switch(p['direction']){
case 'north':
t.style.left='0px';
if(this.last_div==null) t.style.top='0px';
else t.style.top=parseInt(this.last_div.style.top)+parseInt(this.last_div.offsetHeight)+'px';
break;
case 'west':
t.style.top='0px';
if(this.last_div==null) t.style.left='0px';
else t.style.left=parseInt(this.last_div.style.left)+parseInt(this.last_div.offsetWidth)+'px';
break;
}
this.last_div=t;
}
if(div_ids.length>1) this.rolling_div_roll();
function rolling_div_roll(){
if(this.halt==false){
var delay=p['delay'];
var t,top,height,left,width;
for(var i=0;i<div_ids.length;i++){
t=document.getElementById(div_ids[i]);
switch(p['direction']){
case 'north':
top=parseInt(t.style.top);
height=parseInt(t.offsetHeight);
if(top==0) delay=p['delay_section'];
t.style.top=(top-1)+'px';
if(top+height==0){
t.style.top=parseInt(this.last_div.offsetTop)+parseInt(this.last_div.offsetHeight)+'px';
this.last_div=t;
}
break;
case 'west':
left=parseInt(t.style.left);
width=parseInt(t.offsetWidth);
if(left==0) delay=p['delay_section'];
t.style.left=(left-1)+'px';
if(left+width==0){
t.style.left=parseInt(this.last_div.offsetLeft)+parseInt(this.last_div.offsetWidth)+'px';
this.last_div=t;
}
break;
}
}
}
setTimeout(oname+".rolling_div_roll();",delay);
}
}
function parseProp(str){
var arrProp,ret=new Array();
if(str==null || str=="") return ret;
var ret=new Array();
var arrStr=str.split(",");
for(var i=0;i<arrStr.length;i++){
arrProp=arrStr[i].split("=");
ret[arrProp[0]]=arrProp[1];
}
return ret;
}
