//=============================================================================
// Slide and hide/show the content
//
// @author      Anja Pluijlaar
// @since       2006-01-02
//=============================================================================

//declare de variables for the top-value
var top1a = 330;
var top1b = 360;
var top2a = 150;
var top2b = 180;
var MenuArray = new Array();
var j = 0;
var DocTitle = document.title;

//call Init() after 10 milliseconds (to make sure all the elements are created, maybe a while-loop would work to?)
setTimeout('Init()', 10);

//reset the top and id values when this is the home page			
function Init() {
    if(document.title == "Marina Aarts - Home") {
    	document.getElementById("name").style.top = "330px";
    	document.getElementById("menu").style.top = "360px";
    	document.getElementById("content").setAttribute("id","filler");
    }
	for(var i=0; i<7; i++) {
		if(document.getElementById("mainmenu-0-"+i)) {
			var Temp = document.getElementById("mainmenu-0-"+i)
			MenuArray[j] = Temp.firstChild;
			j++;
		}
	}
	
	for(var i=0; i<j; i++) {
		if(DocTitle.search(/home/i) == -1 && i == 0) {
			MenuArray[i].onclick = function() {
			var temp = String(this.href);
			GoToUrl2(temp);
			return false;
			}
		}else {
			MenuArray[i].onclick = function() {
			var temp = String(this.href);
			GoToUrl(temp);
			return false;
			}
		}
	}
}

//check whether the content is showing or not
function swap(){
	if (document.all) {
        if(document.all["filler"]) {
    		//call RunSlide every 20 milliseconds with variable 1
        	TIMER_SLIDE = setInterval('RunSlide(1)', 20);
        } else {
    		//set the id attribute
        	var temp = document.all["content"];
        	temp.setAttribute("id","filler");
    		//call RunSlide every 20 milliseconds with variable 0
        	TIMER_SLIDE = setInterval('RunSlide(0)', 20);
		}
    } else {
        if(document.getElementById("filler")) {
    		//call RunSlide every 20 milliseconds with variable 1
        	TIMER_SLIDE = setInterval('RunSlide(1)', 20);
        } else {
    		//set the id attribute
        	var temp = document.getElementById("content");
        	temp.setAttribute("id","filler");
    		//call RunSlide every 20 milliseconds with variable 0
        	TIMER_SLIDE = setInterval('RunSlide(0)', 20);
        }
	}
}

//slide the content
function RunSlide(direction) {
    if(direction == 0) {
		//save the references to the objects that need to slide in variables
    	var bar1 = document.getElementById("name").style;
    	var bar2 = document.getElementById("menu").style;
		//check whether the objects are in position yet
    	if(top2a < 330) {
			//increment the top-value variables by 10
    		top2a += 10;
    		top2b += 10;
			//set the top-value variables
    		bar1.top = String(top2a+"px");
    		bar2.top = String(top2b+"px");
    	} else {
			//stop RunSlide from being called again
    		clearInterval(TIMER_SLIDE)
			//reset the top-value variables
    		top2a = 150;
    		top2b = 180;
    	}
    } else {
		//save the references to the objects that need to slide in variables
    	var bar1 = document.getElementById("name").style;
    	var bar2 = document.getElementById("menu").style;
		//check whether the objects are in position yet
    	if(top1a > 150) {
			//decrement the top-value variables by 10
    		top1a -= 10;
    		top1b -= 10;
			//set the top-value variables
    		bar1.top = String(top1a+"px");
    		bar2.top = String(top1b+"px");
    	} else {
			//stop RunSlide from being called again
    		clearInterval(TIMER_SLIDE)
			//set the id attribute
    		var temp = document.getElementById("filler");
    		temp.setAttribute("id","content");
			//reset the top-value variables
    		top1a = 330;
    		top1b = 360;
    	}
    }
}

function GoToUrl(url1) {
	if(url1.search(/home/i) != -1) {
		swap();
	} else {
    	if (document.all) {
    		//set the id attribute
    		if(document.all["content"]) {
    			window.location=url1;
    		} else {
    			//call RunSlide2 every 20 milliseconds with variable 0
        		TIMER_SLIDE = setInterval('RunSlide2("'+String(url1)+'")', 20);
    		}
    	} else {
    		//set the id attribute
        	if(document.getElementById("content")) {
    			window.location=url1;
    		} else {
    			//call RunSlide2 every 20 milliseconds with variable 0
        		TIMER_SLIDE = setInterval('RunSlide2("'+String(url1)+'")', 20);
			}
		}
	}
}

function RunSlide2(url2) {
	//save the references to the objects that need to slide in variables
    var bar1 = document.getElementById("name").style;
    var bar2 = document.getElementById("menu").style;
	//check whether the objects are in position yet
	if(top1a > 150) {
	//decrement the top-value variables by 10
		top1a -= 10;
		top1b -= 10;
	//set the top-value variables
		bar1.top = String(top1a+"px");
		bar2.top = String(top1b+"px");
	} else {
	//stop RunSlide from being called again
		clearInterval(TIMER_SLIDE)
	//reset the top-value variables
		top1a = 330;
		top1b = 360;
	//open the new url
		window.location=url2;
	}
}

function GoToUrl2(url1) {
	if (document.all) {
		//set the id attribute
		if(document.all["filler"]) {
			window.location=url1;
		} else {
			var temp = document.all["content"];
    		temp.setAttribute("id","filler");
			//call RunSlide2 every 20 milliseconds with variable 0
    		TIMER_SLIDE = setInterval('RunSlide3("'+String(url1)+'")', 20);
		}
	} else {
		//set the id attribute
    	if(document.getElementById("filler")) {
			window.location=url1;
		} else {
			var temp = document.getElementById("content");
    		temp.setAttribute("id","filler");
			//call RunSlide2 every 20 milliseconds with variable 0
    		TIMER_SLIDE = setInterval('RunSlide3("'+String(url1)+'")', 20);
		}
	}
}

function RunSlide3(url2) {
	//save the references to the objects that need to slide in variables
    var bar1 = document.getElementById("name").style;
    var bar2 = document.getElementById("menu").style;
	//check whether the objects are in position yet
	if(top2a < 330) {
	//increment the top-value variables by 10
		top2a += 10;
		top2b += 10;
	//set the top-value variables
		bar1.top = String(top2a+"px");
		bar2.top = String(top2b+"px");
	} else {
	//stop RunSlide from being called again
		clearInterval(TIMER_SLIDE)
	//reset the top-value variables
		top2a = 150;
		top2b = 180;
	window.location=url2;
	}
}
