/* check if frameset is loaded */
function checkFrames(){

	if (parent.frames.length == 0){

		var poslastslash = (location.href.lastIndexOf("/")+1);
		var poslast_p = (location.href.lastIndexOf("p")+1);
		var length_contentpage = poslast_p - poslastslash;
		var contentpage = location.href.substr(poslastslash, length_contentpage);
		
		// redirect to adequate frameset
		if(contentpage != "" && contentpage != "topmenue.php" && contentpage != "mainmenue.php"){
		 	parent.location = "index.php?contentpage=" + contentpage;
		 }
		 else{
		 	parent.location = "index.php";
		 }
	}
}


/* highlight the selected mainmenue, when clicked, fuction is started when contentsite is loade */
function machAn(welches){

	/* reset all */
	for (var i = 0; i < document.links.length; ++i){

		document.links[i].style.color = "#AB3C49";
	 	
	 }
	
	 /* highlight selected */
	 obj = document.getElementById(welches);
	
	 if(welches){
	 	obj.style.color = "#5094CC";
	 }
}


/* get the position of the Main-Link in left navigation bar - is needed to display submenue at the correct top position in the content frame 
   http://blog.firetree.net/2005/07/04/javascript-find-position/
*/

function findPosY(obj){

	var curtop = 0;
	
	obj = document.getElementById(obj);
	
	if(obj.offsetParent){
		while(1){
		
			curtop += obj.offsetTop;
			
			if(!obj.offsetParent){
				break;
			}
			
		obj = obj.offsetParent;
		
		}

	}else if(obj.y){
		curtop += obj.y;
	}
  return(curtop);
}