function poll(url,blength) {		
        if (jQuery("body *", window.opener.document).length == 0 || jQuery("body *", window.opener.document).length == blength) {
            setTimeout("poll('"+url+"', '"+blength+"')", 10);
        }
        else {			
            window.opener.document.body.innerHTML = "<style type='text/css'>html {height:100%;} body{margin:0;padding:0;height:100%;}</style><iframe src='"+url+"' width='100%' height='100%' scrolling='no' frameborder='0' marginwidth='0' marginheight='0'></iframe>";
        }
    } 
function gotoPage(url) {	
	
	window.opener.location=url;//"http://new.typo3.redesign.kabeldeutschland.de:11580";	
	/*var bodyLength = jQuery("body *", window.opener.document).length;	
	setTimeout("poll('"+url+"', '"+bodyLength+"')", 10);	*/
  }


function dynamicSitemap(normal, current, tipp, visited)
{
	var dScookie = new HashCookie('kdg_visited', 0);
	this.cNormal;
	this.cCurrent;
	this.cTipp;
	this.cVisited;
	
	this.aNormal;
	this.aCurrent;
	this.aTipp;
	this.aVisited;
	
	this.sTipp;
	this.sVisited;
	this.dScookie; 
	

	this.init = function (normal, current, tipp, visited)
	{
		
		this.cNormal = normal;
		this.cCurrent = current;
		this.cTipp = tipp;
		this.cVisited = visited;
		
		this.refresh();
		this.sTipp = this.aTipp;
		
		this.setVisited();		
		
		this.validateHref();
	}
	
	this.validateHref = function ()
	{	
		var self = this;
		$("li").each(function() {	
			
			$(this).children("a").removeAttr("target");
			$(this).children("a").attr("onclick", "dSobject.setCurrent($(this).parent(), true);gotoPage('"+$(this).children('a').attr('href')+"');");
			
			if($.browser.msie)
			{
				$(this).children("a").click(function() {
					self.setCurrent($(this).parent(), true);
					var attrOncl = $(this).attr("onclick");
					attrOncl = attrOncl.toString();
					
					gotoPage(attrOncl.substring(attrOncl.indexOf("gotoPage('")+10, attrOncl.lastIndexOf("');")));				
				});
			}
			$(this).children("a").attr("href", "#");
		});			
	}
	
	this.refresh = function ()
	{
		$("."+this.cNormal+"0").removeClass().addClass(this.cNormal);
		this.aNormal = $("."+this.cNormal);	
		this.aCurrent = $("."+this.cNormal+this.cCurrent);
		this.aTipp = $("."+this.cNormal+this.cTipp);
		this.aVisited = $("."+this.cNormal+this.cVisited);
	}
	
	this.setVisited = function ()
	{	
		dScookie.refresh();	
		var self = this;
		this.aNormal.each(function() {
			
			if(dScookie.get($(this).children("a").attr("rel"))==1)
			{				
				$(this).removeClass().addClass(self.cNormal+self.cVisited);
				
				return true;			}
		});
		this.refresh();	
		this.sVisited = this.aVisited;	
	
		this.aCurrent = this.getCurrent();
		this.setCurrent(this.aCurrent, true);	
	}
	
	this.getCurrent = function()
	{		
		var obj;
		var objChk=false;
		$("li a:first-child").each(function() {
			if($(this).attr("href") == "#")
			{
				var attrChk = $(this).attr("onclick");
				attrChk = attrChk.toString();
			  	if(window.opener.location.href.indexOf(attrChk.substring(attrChk.indexOf("gotoPage(")+10, attrChk.lastIndexOf(");")-1)) != -1)
				{
					obj = $(this);
					objChk=true;
					return true;
				}
			}
			else
			{
				if(window.opener.location.href.indexOf($(this).attr("href")) != -1)
				{					
					obj = $(this);
					objChk=true;
					return true;
				}	
			}
		});	
		if(objChk == true)
		{	
			return obj.parent();
		}
		else
		{			
			return $("li:first");
		}
	}
	
	this.setCurrent = function (obj, kill)
	{		
		if(kill != false)
		{			
			if(!this.relInList($("."+this.cNormal+this.cCurrent), this.sTipp))
			{
				$("."+this.cNormal+this.cCurrent).removeClass().addClass(this.cNormal+this.cVisited);
			}
			else
			{
				$("."+this.cNormal+this.cCurrent).removeClass().addClass(this.cNormal+this.cTipp);
			}
		}
		obj.removeClass().addClass(this.cNormal+this.cCurrent);	
		this.refresh();
	}
	
	this.relInList = function (obj, arr)
	{
		var objChk = false;
		arr.each(function() {
			if(obj.children("a").attr("rel") == $(this).children("a").attr("rel"))
			{
				objChk = true;
				return true;
			}
		});
		return objChk;
	}

	this.init(normal, current, tipp, visited);
}