// Script Parameters
var default_delay=0;
var default_max=20;
var default_mode=1; // 0 - top of the page / 1 - bottom of the page
var height=0;
var default_height=0;
var min_top=200;
var i=0;

// Main function
function Move_Tag(input_height) {
	for (i=0;i<2;i++) height[i]= input_height[i];
	setTimeout("Start1()",default_delay);
	setTimeout("Start2()",default_delay);
}

function Start1() {
	default_height=height[1];
	min_top=380;
	MoveLayer("bottom",GetTop("bottom"));
	setTimeout("Start1()",default_delay);
}
function Start2() {
	default_height=height[2];
	min_top=200;
	MoveLayer("nav_bar",GetTop("nav_bar"));
	setTimeout("Start2()",default_delay);
}
function Debug() {
	var bod=document.body
	var Z="";
	for (var i in bod) {
		Z+=i+"="+obj[i]+"\n";
	}
	alert(Z);
}
function MoveLayer(name,top) {
	if (document.getElementById) { //IE5 et NS6
		document.getElementById(name).style.top=top;
	}
	if ((document.all)&&(!document.getElementById)) { //IE4 seul
		document.all[name].style.top=top;
	}
	if (document.layers) { //NS4.X seul
		document.layers[name].top=top;
	}
}
function GetTop(name) {
	if (document.getElementById) { //IE5 
		var pos=parseInt(document.getElementById(name).style.top);
		var wintop=parseInt(document.body.scrollTop);
		var avail=document.body.clientHeight;
	}
	if ((document.getElementById)&&(!document.all)) { //NS6
		var pos=parseInt(document.getElementById(name).style.top);
		var wintop=parseInt(window.pageYOffset);
		var avail=window.innerHeight;
	}
	if ((document.all)&&(!document.getElementById)) { //IE4 seul
		var pos=parseInt(document.all[name].style.top);
		var wintop=parseInt(document.body.scrollTop);
		var avail=document.body.clientHeight;
	}
	if (document.layers) { //NS4.X seul
		var pos=parseInt(document.layers[name].top);
		var wintop=parseInt(window.pageYOffset);
		var avail=window.innerHeight;
	}

	if (default_mode==0) {
		var delta=Math.ceil((pos-wintop)/3);
		if (delta>default_max) {delta=default_max;}
		if (delta<-1*default_max) {delta=-1*default_max;}
		var top=pos-delta;
	}
	if (default_mode==1) {
		//if (name=="bottom") var default_height=default_height1;
		//if (name=="nav_bar") var default_height=default_height2;
		var delta=Math.ceil((pos-(wintop+avail-default_height)));
		if (delta>default_max) {delta=default_max;}
		if (delta<-1*default_max) {delta=-1*default_max;}
		var top=pos-delta;
		
	}
// the minimum distance from the top (top is the distance from the begining of the page (and not the browser) to the tag
	if (top < min_top)
		top = min_top;
//if (name=="bottom") && (top < 200) top = 200;
//if (name=="nav_bar") && (top < 360) top = 360;
	return top;
}


function open_tag(name){
window.open(name,"", "width=254,height=320,scrollbars=1" );
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);