var defaultDelay=30;var steps=3;var boxContainers=new Array();var boxes=new Array();function slide(e){var targ;if(!e)var e=window.event;if(e.target)targ=e.target;else if(e.srcElement)targ=e.srcElement;slideBlock(targ,defaultDelay);}
function slideBlock(block,delay){var callerObj=block;var containerID=block.getAttribute('slidebox');var boxContainer=document.getElementById(containerID);var box=document.getElementById(containerID+"_box");boxContainer.callerObj=callerObj;boxContainers[containerID]=boxContainer;boxes[containerID]=box;if(boxContainer.callerObj.direction==undefined){boxContainer.callerObj.direction=true;}
else{boxContainer.callerObj.direction=!boxContainer.callerObj.direction;}
if(!boxContainer.callerObj.direction){var swapStyles=boxContainer.callerObj.swapstyles;for(var i=0;i<swapStyles.length;i++){swapStyles[i].element.className=swapStyles[i].open;}}
box.style.height=box.offsetHeight+"px";if(box.offsetTop<-5000){box.style.top=-box.offsetHeight+"px";boxContainer.style.height="1px";}
else{box.style.top=box.offsetTop+"px";if(!boxContainer.callerObj.direction){boxContainer.style.height="1px";}}
boxContainer.style.height=boxContainer.offsetHeight+"px";if(box.offsetHeight!=0){boxContainer.slideSpeed=Math.round(box.offsetHeight/steps);}
else{boxContainer.slideSpeed=Math.round(boxContainer.offsetHeight/steps);}
boxContainer.slideDelay=delay;if(boxContainer.slideInterval!=undefined){clearInterval(boxContainer.slideInterval);}
if(boxContainer.callerObj.direction){boxContainer.slideInterval=setInterval("slideUp('"+ containerID+"')",boxContainer.slideDelay)}
else{boxContainer.slideInterval=setInterval("slideDown('"+ containerID+"')",boxContainer.slideDelay)}}
function slideUp(containerID){var boxContainer=boxContainers[containerID];var box=boxes[containerID];var boxHeight=parseInt(box.style.height);var boxTop=parseInt(box.style.top);var boxContainerHeight=parseInt(boxContainer.style.height);var slideSpeed=boxContainer.slideSpeed;if(boxTop>=(boxHeight*(-1))){box.style.top=boxTop- slideSpeed+"px"
if((boxContainerHeight- slideSpeed)>0){boxContainer.style.height=boxContainerHeight- slideSpeed+"px"}}
else{clearInterval(boxContainer.slideInterval)
box.style.top=boxHeight*(-1)+"px";var swapStyles=boxContainer.callerObj.swapstyles;for(var i=0;i<swapStyles.length;i++){swapStyles[i].element.className=swapStyles[i].closed;}}}
function slideDown(containerID){var boxContainer=boxContainers[containerID];var box=boxes[containerID];var boxHeight=parseInt(box.style.height);var boxTop=parseInt(box.style.top);var boxContainerHeight=parseInt(boxContainer.style.height);var slideSpeed=boxContainer.slideSpeed;if((boxTop+ slideSpeed)<0){box.style.top=boxTop+ slideSpeed+"px"
boxContainer.style.height=boxContainerHeight+ slideSpeed+"px"}
else{clearInterval(boxContainer.slideInterval)
box.style.top=0;box.style.height="100%";boxContainer.style.height="100%";}}
function initvSliders(){var allDIVs=document.getElementsByTagName('div');for(var i=0;i<allDIVs.length;i++){if(allDIVs[i].getAttribute("vslider")){addEvent(allDIVs[i],"click",slide);if(allDIVs[i].getAttribute("styleswitchcode")){var swapstyles=eval(allDIVs[i].getAttribute("styleswitchcode"));}
else{var swapstyles=new Array();}
allDIVs[i].swapstyles=swapstyles;if(allDIVs[i].getAttribute("startclosed")){allDIVs[i].direction=true;}}}}
function addEvent(obj,evType,fn){if(obj.addEventListener){obj.addEventListener(evType,fn,false);return true;}else if(obj.attachEvent){var r=obj.attachEvent('on'+evType,fn);return r;}else{return false;}}
addEvent(window,"load",initvSliders);
