samarudge 16 Posting Whiz

Hi,
I have written the following code that makes the DIV fall down from the top of the page to a certain point E.G. 200 pixels from the top of the page however, I want the DIV to appear 200 pixles from the top of the page wherever the user is on the page E.G. if they had scroled half way down the page and clicked a link to load the DIV then it would appear from the top of their screen and stop 200 pixles from the top;
This is my JS:

function show_diag(elm_id, display, step) {
	
if ( display == 'show' ) {
	if ( step == 1 ) {
		document.getElementById(elm_id).style.top = '-100px';
		setTimeout("show_diag('"+elm_id+"', '"+display+"', 2);", 50);
	}
	if ( step <= 15 && step != 1 ) {
		top = -100 + (20*step);
		document.getElementById(elm_id).style.top = top+"px";
		
		elm_step = step + 1;
		setTimeout("show_diag('"+elm_id+"', '"+display+"', "+elm_step+");", 20);
	}
	
	} else if (display == 'hide') {
	
	if ( step <= 15 ) {
		top = 200 - (20*step);
		width = 400 - (20*step)
		document.getElementById(elm_id).style.top = top+"px";
		
		elm_step = step + 1;
		setTimeout("show_diag('"+elm_id+"', '"+display+"', "+elm_step+");", 20);
	}
	if ( step == 15 ) {
		document.getElementById(elm_id).style.top = '-1000px';
	}
	
	}
	return false; //Stop the link going anywhere
}

And my CSS:

.Layout_Login{
	width:400px;
	height:200px;
	background-color:#CCC;
	border:#000;
	border:double;
	position:absolute;
	left:50%;
	top:-1000px;
	margin-left:-200px;
	margin-top:-100px;
	vertical-align:middle;
	overflow:hidden;
}

Thanx
Sam R

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.