/**
 * @fileoverview tdc.tdco
 */

/**
 * tdc.tdco object
 * @constructor
 */
tdc.tdco = function(){
	return {

		/**
		 * Starts the sIFR-replacement procedure
		 * @author kimblim
		 */
		doSifr : function(){
			if(typeof(sIFR) == "function"){
				
			}
		},
		
		/**
		 * Create the correct size popup for rr design.
		 * @param {String} Url to open
		 * @param {String} Window size - optional
		 * @param {String} Window name - optional
		 * @param (Integer) Window height - optional
		 */
		popup : function(aUrl,aSize,aName,aHeight){
			var width = 530;
			var height = 300;

			var size = 'normal';
			if (typeof(aSize) != 'undefined') size = aSize;

			var windowname = '';
			if (typeof(aName) != 'undefined') windowname = aName;

			if (size == 'large'){
				width = 770;
				height = 440;
			}

			if (typeof(aHeight) != 'undefined' && aHeight > 199 && aHeight < 576 ) height = aHeight;

			tdc.popup(aUrl,width,height,windowname);
		},
		
		toggleAllNav: function(){
			tdc.toggleDisplay("t_allnav");
		},
		
		toggleFeedbackComment: function(){
			if (getEle("t_feedback_comment")){
				myElm = getEle("t_feedback_comment");
				if(myElm.style.display == "" || myElm.style.display == "none"){
					myElm.style.display = "block";
				} else{
					myElm.style.display = "none";
				}
			}
		},
				
		drawKontakt : function(){
			var dt = typeof(dogtag) != "undefined" ? dogtag : "unknown";
			var url = "http://tdconline.dk/kontakt/?dogtag=" + dt + "&url=" + location.href;
			document.write("<a href=\""+url+"\" onclick=\"tdc.popup('"+url+"',570,520);return false;\">Kontakt</a>");
		},
		
		/**
		* Draw a link to add the current page as your browser default start page
		* @author Sune (bugfixed by Sunes javascript helt nummer 1)
		*/			
		drawMakeHomepage: function(placement)
		{			
			if ( typeof(placement) == "undefined") placement = "";			
			var linkTxt = "";
			switch (placement){
				case "top":
					linkTxt = "TDC Online som startside";
					break;
				default:
					linkTxt = "Gør til startside";
			}
			if (tdc.browser.isie != 0 && (tdc.browser.getVersion() > 4) && (!tdc.browser.isopera)){
				document.write('<a href="javascript:tdc.tdco.setdefaulthp()" onmouseover="window.status=\'' + linkTxt + '\';return true;" onmouseout="window.status=\'\'">' + linkTxt + '</a><span id=\"ohp\"></span>');
			}
		},
		
		/**
		 * Sets a webpage as the default start page 
		 * Only works in IE!
		 * @author Sune
		 * @param u - the page you want set
		 */
		setdefaulthp : function(u){
			if (tdc.browser.isie != 0 && (tdc.browser.getVersion() > 4)){
				var ohp=getEle("ohp");
				if (ohp){
					ohp.style.behavior="url(#default#homepage)";
					if (u){
						ohp.setHomePage(u);
					}
					else{
						ohp.setHomePage(document.location);
					}
				}
			}
		},
		
		/**
		 * Changes the last breadcrumb entry to NOT have an anchor tag!
		 */
		fixLastBreadcrumb : function() {
			try {
				var children = tdc.element.getId("t_breadcrumb").getElementsByTagName("dd");
				if (children.length > 0) {
					var atag = children[children.length-1].getElementsByTagName("a");
					if (atag.length > 0) {
						var childnodes = atag[0].childNodes;
						children[children.length-1].removeChild(atag[0]); // doesn't work in MSIE...
						for (var k = 0; k < childnodes.length; k++) {
							children[children.length-1].appendChild(childnodes[k]);
						}
					}
				}
			} catch(err) {}
		},
		
		rr : {
			login : {
				drawFrontpageLoginBox : function() {
					
					tdc.login.setLogoutTarget('http://tdconline.dk');
					var templateArguments = tdc.login.loginBoxTemplateArguments();

					var loggedInClass = templateArguments.isLoggedIn ? 't_sso_logged_in' : '';

					document.writeln('<div class="t_login_box t_sso_loginbox t_orange t_login_box_addjs ' + loggedInClass + '" id="t_front_sso_box">');
					document.writeln('	<div class="t_sso_top"></div>');
					document.writeln('	<div class="t_sso_body">');
					document.writeln('		<div class="t_sso_content">');
					document.writeln('			<div class="t_sso_logo"></div>');					
					
					// Are we logged in?
					if (templateArguments.isLoggedIn){
						document.writeln('<form action="' + templateArguments.logoutUrl + '" >');
						document.writeln('<fieldset>');
						document.writeln('<legend>TDC Login</legend>');
						document.writeln('<button class="t_button_white t_login_button" type="submit"><span>Log ud</span></button>');
						
						templateArguments.writeHiddenFieldsFunction();
						if (templateArguments.userName) {
							document.writeln('<p>Du er logget ind som: <strong>' + templateArguments.userName + '</strong></p>');
						} else {
							document.writeln('<p>Du er logget ind</p>');
						}
						
						document.writeln('</fieldset>');
						document.writeln('</form>');
						document.writeln('<ul class="t_sso_links">');
						document.writeln('<li><a href="https://selvbetjening.tdconline.dk/eservice/ditLogin.do" title="Redigér dine indstillinger" target="_' + templateArguments.linkTarget + '">Indstillinger</a></li>');
						document.writeln('<li><a href="http://tdconline.dk/login/" title="L&aelig;s mere om TDC Login" target="_' + templateArguments.linkTarget + '">Om TDC Login</a></li>');
						document.writeln('</ul>');
						templateArguments.writeHiddenSsoImagesFunction();
					}
					// Is SSO down?
					else if (templateArguments.isLoginSystemTemporarilyDisabled){
						document.writeln('<div id="t_front_login" class="t_logintype_0"><fieldset><legend>TDC Login</legend><p>Der er i &oslash;jeblikket drifts- forstyrrelser p&aring; login til TDC. Vi arbejder p&aring; en l&oslash;sning.</p></fieldset></div>');
					}
					// Is SSO disabled?
					else if (templateArguments.isDisabledBecauseOfBrowser){
						document.writeln('<div id="t_front_login" class="t_logintype_0"><fieldset><legend>TDC Login</legend><p>Login er deaktiveret i din browser.</p><p><a href="http://tdconline.dk/testclient.php?case=old" target="_' + templateArguments.linkTarget + '">Hvorfor?</a></p></fieldset></div>');
					}
					// Draw the login box
					else{
						
						document.writeln('			<form action="' + templateArguments.loginUrl + '" method="post">');
						document.writeln('				<fieldset>');
						document.writeln('					<legend>TDC Login</legend>');
						document.writeln('					<div class="t_button t_sso_usrname">');
						document.writeln('						<input tabindex="1" type="text" name="usr_name" title="Dit brugernavn til TDC Login">');
						document.writeln('					</div>');
						document.writeln('					<div class="t_button t_sso_password">');
						document.writeln('						<input tabindex="2" type="text" style="" value="Password" name="usr_password_fake" title="Dit password til TDC Login">');
						document.writeln('						<input type="password" style="display: none;" name="usr_password" class="t_focus" title="Dit password til TDC Login">');
						document.writeln('					</div>');
						document.writeln('					<button class="t_button_white t_login_button" type="submit"><span>Log ind</span></button>');
						document.writeln('					<ul class="t_sso_check">');
						document.writeln('						<li class="t_rememberusername">');
						document.writeln('							<input type="checkbox" name="remember_username" id="t_rememberusername">');
						document.writeln('							<label for="t_rememberusername">Husk brugernavn</label>');
						document.writeln('						</li>');
						document.writeln('					</ul>');
						document.writeln('				</fieldset>');
						templateArguments.writeHiddenFieldsFunction();
						document.writeln('			</form>');
						templateArguments.writeHiddenSsoImagesFunction();						
						document.writeln('			<ul class="t_sso_links">');
						document.writeln('				<li>');
						document.writeln('					<a href="http://tdconline.dk/login/glemt/" target="_top">Glemt password</a>');
						document.writeln('				</li>');
						document.writeln('				<li class="t_newuser">');
						document.writeln('					<a href="' + templateArguments.newUserUrl + '" target="_top">Opret TDC Login</a>');
						document.writeln('				</li>');
						document.writeln('			</ul>');				
						

						


					}
					
					document.writeln('		</div>');
					document.writeln('	</div>');
					document.writeln('	<div class="t_sso_bottom"></div>');
					document.writeln('</div>');	
					
				},
				drawGlobalLoginBox : function() {
					
					tdc.login.setLogoutTarget('http://tdconline.dk');
					var templateArguments = tdc.login.loginBoxTemplateArguments();

					var loggedInClass = templateArguments.isLoggedIn ? 't_sso_logged_in' : '';

					document.writeln('<div class="t_login_box t_sso_loginbox t_orange t_login_box_addjs ' + loggedInClass + '" id="t_login_global">');
					document.writeln('	<div class="t_sso_top"></div>');
					document.writeln('	<div class="t_sso_body">');
					document.writeln('		<div class="t_sso_content">');
					document.writeln('			<div class="t_sso_logo"></div>');					
					
					// Are we logged in?
					if (templateArguments.isLoggedIn){
						document.writeln('<form action="' + templateArguments.logoutUrl + '" >');
						document.writeln('<fieldset>');
						document.writeln('<legend>TDC Login</legend>');
						document.writeln('<button class="t_login_button" type="submit">Log ud</button>');
						
						templateArguments.writeHiddenFieldsFunction();
						if (templateArguments.userName) {
							document.writeln('<p>Du er logget ind som: <strong>' + templateArguments.userName + '</strong></p>');
						} else {
							document.writeln('<p>Du er logget ind</p>');
						}
						
						document.writeln('</fieldset>');
						document.writeln('</form>');
						document.writeln('<ul class="t_sso_links">');
						document.writeln('<li><a href="https://selvbetjening.tdconline.dk/eservice/ditLogin.do" title="Redigér dine indstillinger" target="_' + templateArguments.linkTarget + '">Indstillinger</a></li>');
						document.writeln('<li><a href="http://tdconline.dk/login/" title="L&aelig;s mere om TDC Login" target="_' + templateArguments.linkTarget + '">Om TDC Login</a></li>');
						document.writeln('</ul>');
						templateArguments.writeHiddenSsoImagesFunction();
					}
					// Is SSO down?
					else if (templateArguments.isLoginSystemTemporarilyDisabled){
						document.writeln('<div id="t_front_login" class="t_logintype_0"><fieldset><legend>TDC Login</legend><p>Der er i &oslash;jeblikket drifts- forstyrrelser p&aring; login til TDC. Vi arbejder p&aring; en l&oslash;sning.</p></fieldset></div>');
					}
					// Is SSO disabled?
					else if (templateArguments.isDisabledBecauseOfBrowser){
						document.writeln('<div id="t_front_login" class="t_logintype_0"><fieldset><legend>TDC Login</legend><p>Login er deaktiveret i din browser.</p><p><a href="http://tdconline.dk/testclient.php?case=old" target="_' + templateArguments.linkTarget + '">Hvorfor?</a></p></fieldset></div>');
					}
					// Draw the login box
					else{
						
						document.writeln('			<form action="' + templateArguments.loginUrl + '" method="post">');
						document.writeln('				<fieldset>');
						document.writeln('					<legend>TDC Login</legend>');
						document.writeln('					<div class="t_button t_sso_usrname">');
						document.writeln('						<input type="text" name="usr_name" title="Dit brugernavn til TDC Login">');
						document.writeln('					</div>');
						document.writeln('					<div class="t_button t_sso_password">');
						document.writeln('						<input type="text" style="" value="Password" name="usr_password_fake" title="Dit password til TDC Login">');
						document.writeln('						<input type="password" style="display: none;" name="usr_password" class="t_focus" title="Dit password til TDC Login">');
						document.writeln('					</div>');
						document.writeln('					<button class="t_button_white t_login_button" type="submit"><span>Log ind</span></button>');
						document.writeln('					<ul class="t_sso_check">');
						document.writeln('						<li class="t_rememberusername">');
						document.writeln('							<input type="checkbox" name="remember_username" id="t_rememberusername">');
						document.writeln('							<label for="t_rememberusername">Husk brugernavn</label>');
						document.writeln('						</li>');
						document.writeln('					</ul>');
						document.writeln('				</fieldset>');
						templateArguments.writeHiddenFieldsFunction();
						document.writeln('			</form>');
						templateArguments.writeHiddenSsoImagesFunction();						
						document.writeln('			<ul class="t_sso_links">');
						document.writeln('				<li>');
						document.writeln('					<a href="http://tdconline.dk/login/glemt/" target="_top">Glemt password</a>');
						document.writeln('				</li>');
						document.writeln('				<li class="t_newuser">');
						document.writeln('					<a href="' + templateArguments.newUserUrl + '" target="_top">Opret TDC Login</a>');
						document.writeln('				</li>');
						document.writeln('			</ul>');
					}
					
					document.writeln('		</div>');
					document.writeln('	</div>');
					document.writeln('	<div class="t_sso_bottom"></div>');
					document.writeln('</div>');	
					
				},							
	
				drawLoginToolbar : function(){
					document.writeln('<hr class="t_accessability">');
					
					var templateArguments = tdc.login.loginBoxTemplateArguments();

					if(templateArguments.isLoggedIn){
						document.writeln('<div id="t_sso_info"><p>Du er logget ind som: <strong>'+templateArguments.userName+'</strong> <span id="t_sso_nummails"></span> <a href="'+templateArguments.optionsUrl+'">Login indstillinger</a></p></div>');	
						document.writeln('<form action="' + templateArguments.logoutUrl +'" method="POST" class="t_login_box">');
						document.writeln('<div id="t_sso_button"><p><a href="#" onclick="$j(this).parents(\'form\').get(0).submit(); return false;">Log ud</a></p></div>');
						templateArguments.writeHiddenFieldsFunction();
						document.writeln('</form>');
						templateArguments.writeHiddenSsoImagesFunction();

						
						//dont show number of unread mails on mail.tdconline.dk
						if (document.location.host.indexOf("mail.tdconline.dk") == -1){
							if(tdc.cookie.get("tdcossomailcheck")){
								var now = new Date().getTime();
								var cookieContent = tdc.cookie.get("tdcossomailcheck").split(";");
								if (typeof(cookieContent[0]) != "undefined" && typeof(cookieContent[1]) != "undefined" && now - cookieContent[0] < (5 * 60 * 1000)){
									tdc.tdco.sso.loadNumMails({"unreadcount":cookieContent[1]},1);
								}
							} else {
								// dont load mails when running https
								var pro = (location.protocol == "file:" ? "http:" : location.protocol);
								if (pro == 'http:') {
									var uri = "http://np.mail.tdconline.dk/inboxsummary?callback=tdc.tdco.sso.loadNumMails&TdcSignature="+encodeURIComponent(tdc.cookie.get('TdcSignature'))+"&noCache="+new Date().getTime();
									tdc.include(uri);
								}	
							}
						}
						
					} else {
						document.writeln('<div id="t_sso_button">');
						document.writeln('<p class="t_sso_show"><a href="#t_login_global" onclick="$j(\'#t_login_global\').show();$j(\'.t_sso_show\').hide();$j(\'.t_sso_hide\').show();return false;" title="Log ind">Log ind</a></p>');
						document.writeln('<p class="t_sso_hide"><a href="#t_login_global" onclick="$j(\'#t_login_global\').hide();$j(\'.t_sso_hide\').hide();$j(\'.t_sso_show\').show();return false;" title="Log ind">Luk</a></p>');
						document.writeln('</div>');
						tdc.tdco.rr.login.drawGlobalLoginBox();
					}							
					
					tdc.login.addRedrawCallback(function(links, target, loggedInInfoHtml) {
						var html = '';
						$j.each(links, function(){
							html += '<li><a href="' + this.url + '" target="_' + target + '">'+this.name+'</a></li>';
						});	
						$j('.t_login_links').html(html);				
					});
				}
			}			
		}
	}
}();



/**
 * tdc.tdcs.ads object
 * @constructor
 * @author kimblim
 */
tdc.tdco.ads = function() {
	return {
		
		/**
		 * print the ad
		 * @param siteId - unique 7-digit integer from the Helios system
		 * @param adType - 3-digit integer specifying the adtype (225=leaderboard,170=300x250)
		 */
		printAd : function(siteId,adType){
			var width,height,classname,pread;
			var divId = "something"
			switch(adType){
				case 225:
					width = 728;
					height = 90;
					classname = "t_ad_730x90";
					pread = "";
					break;
				case 170:
					width = 300;
					height = 250;
					classname = "t_ad_300x250";
					pread = "<p>Annonce:</p>";
					break;
				default:
					return;
			}
			document.write('<div id='+divId+' class="'+classname+'">');
			document.write(pread);
			document.write('<scr'+'ipt type="text/javascript" src="http://adserver.adtech.de/addyn|3.0|655|'+siteId+'|0|'+adType+'|ADTECH;loc=100;target=_blank;key=key1+key2+key3+key4;grp=[group];misc='+new Date().getTime()+'"></scri'+'pt>');
			document.write('<noscript><a href="http://adserver.adtech.de/adlink|3.0|655|'+siteId+'|0|'+adType+'|ADTECH;loc=300;key=key1+key2+key3+key4;grp=[group]" target="_blank"><img src="http://adserver.adtech.de/adserv|3.0|655|'+siteId+'|0|'+adType+'|ADTECH;loc=300;key=key1+key2+key3+key4;grp=[group]" border="0" width="'+width+'" height="'+height+'" alt=""></a></noscript>');
		},
		
		printAdBottom : function(){
			document.write('</div>');
		}
	}
}();

/**
 * tdc.tdco.colorscheme object
 * @constructor
 */
tdc.tdco.colorscheme = function(){
	/**
	 * Determines the colorscheme
	 * @author kimblim
	 */
	
	var color;
	var present = new Date().getTime();
	var logoHtml = "";
	
	function getColor(){
		color = "orange";		
	}
	
	return {		
		/**
		 * Makes it possible to force a colorscheme
		 * @author kimblim
		 */
		forceColor : function(aColor){
			color = aColor;
		},
		
		/**
		 * Prints the stylesheet in the right color
		 * @author kimblim
		 */
		printStylesheet : function(){
			if(typeof(color) == "undefined"){
				getColor();
			}
			document.body.className = "t_cs_" + color;
			tdc.addStylesheet(tdc.getI()+"/css/rr/cs/"+color+".css","screen","t_css");
		},
		
		/**
		 * changes the stylesheet on the fly
		 * @param aColor : change to this color
		 * @author kimblim
		 */
		changeStyles : function(aColor){
			color = aColor;
			//remove old styles
			var currentStyleSheet = document.getElementById("t_css");
			document.getElementsByTagName("HEAD")[0].removeChild(currentStyleSheet);
			//add new styles
			tdc.cookie.set("tdcoColorScheme",aColor,(new Date(present+(1000*60*60*24*365))),"/",".tdconline.dk");			
			tdc.addStylesheet(tdc.getI()+"/css/rr/cs/"+aColor+".css","screen","t_css");
			document.body.className = "t_cs_"+aColor;
			if(getEle('tdco_selvbetjening_frame')) {
				var iframeElem = getEle('tdco_selvbetjening_frame'); 
				var iframeDoc = iframeElem.contentDocument ||(iframeElem.contentWindow && iframeElem.contentWindow.document);				
				iframeDoc.body.className = "t_cs_"+aColor;
				iframeDoc.reload();							
			}			
			this.printLogo();
			return false;
		},
		
		/**
		 * Prints the logo in the right color
		 * @author kimblim
		 * @param pUrl  destination url if logo is clicked
		 */
		printLogo : function(pUrl){
			if(typeof(color) == "undefined"){
				getColor();
			}
			if(!pUrl) pUrl = "http://tdconline.dk/";
			if(tdc.browser.hasFlash() >= 8){
				logoHtml = ("<div id=\"t_globallogo_anim\">");
				logoHtml += ("<object type=\"application/x-shockwave-flash\" data=\""+tdc.getI()+"/swf/rr/cs/"+color+"/logo/tdcologo_anim.swf?pUrl="+pUrl+"\" width=\"162\" height=\"56\">");
				logoHtml += ("<param name=\"movie\" value=\""+tdc.getI()+"/swf/rr/cs/"+color+"/logo/tdcologo_anim.swf?pUrl="+pUrl+"\" \/>");
				logoHtml += ("<param name=\"AllowScriptAccess\" value=\"always\" \/>");
				logoHtml += ("<param name=\"wmode\" value=\"transparent\" \/>");
				logoHtml += ("</object>");
				logoHtml += ("</div>");
			} else {
				logoHtml += ("<a href=\""+pUrl+"\" title=\"Til forsiden af TDC Online\"><img src=\""+tdc.getI()+"/gfx/rr/cs/"+color+"/logo/tdcologo.png\" id=\"t_globallogo\" /></a>");
			}
			tdc.element.getId("t_logo").innerHTML = logoHtml;
		}
		
	}
}();

tdc.tdco.dynmenu = function(){

        /**
         * Holds the current dynmenu menu
         * @type Object
         */
        var menu = false;

        /**
         * What CSS class to add to a current item
         * @type String
         */
        var classon = "t_current";

        /**
         * What default class the dynmenu is added to
         * @type String
         */
        var div = "t_leftnav";

        /**
         * Fourth level of navigation must be on the content area!
         * Defaults to empty!
         */
        var level4;

        /**
         * Returns the correct node for a level
         * @param {Boolean} aUL The top UL root
         * @param {Boolean} aLevel What level should we insert at
         * @param {Boolean} aIndent What indent are we current add
         * @returns A node
         * @author Henrik Gemal
         */
        function getNode(aUL, aLevel, aIndent){
			var d;
            if (aLevel > aIndent){
				// find the last li
				var lis = aUL.getElementsByTagName("li");
				d = lis[lis.length-1];
			} else {
                // find the last ul with level == indent
                var uls = aUL.getElementsByTagName("ul");
                for (var i = uls.length-1; i >= 0; i--) {
                    if (uls[i].className == "t_dm_level" + aLevel){
                        d = uls[i];
                        break;
                    }
                }
            }
			return d;
        }

        return {
        /**
         * Initializes the dynmenu object
         * @param {Object} aObj A dynmenu object
         * @author Henrik Gemal
         */
        init : function(aObj){
			menu = aObj;
        },

        /**
         * Change the default placeholder for the menu
         * @param (String) aString The id of the placeholder
         */
        placeholder : function(aDiv){
			div = aDiv;
        },

        /**
         * Builds the dynmenu
         * @author Henrik Gemal
         */
        build : function(){
            // make sure we have an dynmenu object
            if (typeof(menu) == "object" && menu && menu.length > 0){
                var nav = tdc.element.getId(div);
                if (nav) {
                    var ele;
                    var navul = nav.getElementsByTagName("ul");
                    // if the UL isn't there we have to create it first
                    if (!navul || !navul.length) {
                        ele = document.createElement("ul");
                        nav.appendChild(ele);
                        navul = nav.getElementsByTagName("ul");
                    }

                    var indent = 1;
                    var firstIndent = indent;
                    // insert the links
                    for (var i = 0; i < menu.length; i++){

                        // make sure we have a object
                        if (typeof(menu[i]) != "object"){
							break;
                        }

                        // Set first indent value
                        if (i == 0 && typeof(menu[i][4]) != "undefined"){
							firstIndent = menu[i][4];
                        }

                        // create the li with the link
                        ele = document.createElement("li");
                        if (typeof(menu[i][1]) != "undefined" && menu[i][1] == ""){
							ele.className = "t_leftnav_subheader";
                        }

                        // should the the menuitem be active
                        if (typeof(menu[i][5]) == "boolean" && menu[i][5]){
                            // need to set both since IE doesn't support class
                            ele.className = classon;
                        }
                        ele.appendChild(tdc.dynmenu.createLink(menu[i]));

                        // do we have to indent it?
                        if (typeof(menu[i][4]) == "number" && menu[i][4] > firstIndent && menu[i][4] < 5) {
                            // where should we add the item
                            var cul = getNode(navul[0], menu[i][4], indent);
                            // if we have to indent add the ul
                            if (menu[i][4] > indent) {
                                var eleul = document.createElement("ul");
                                eleul.className = "t_dm_level" + menu[i][4];
                                eleul.style.display = "none";
                                cul = cul.appendChild(eleul);
                            }
                            cul.appendChild(ele);
                        } else{
							navul[0].appendChild(ele);
                        }
                        // set the indent level
                        if (typeof(menu[i][4]) != "undefined"){
							indent = menu[i][4];
                        } else {
							indent = 1;
                        }
                    }

                    var activeLine = new Array();
                    var tree = navul[0].getElementsByTagName("li");
                    var staticMenuPresent = false;

                    for (var j = 0; j < tree.length; j++){
                        if (tree[j].id){
							staticMenuPresent = true;
                        }
                        if (tree[j].className == classon){
                            activeLine[activeLine.length] = tree[j];
                            var childNode = tree[j].getElementsByTagName("ul");
                            if (typeof(childNode[0]) == "object"){
								childNode[0].style.display = "block";
                            }
							var parent = tree[j].parentNode;
                            while (parent.id != div) {
                                if (parent.tagName == "ul" || parent.tagName == "UL"){
									parent.style.display = "block";
                                }
                                if (parent.tagName == "li" || parent.tagName == "LI"){
									activeLine[activeLine.length] = parent;
                                }
								parent = parent.parentNode;
                            }
                        }
                    }
                    var atag;
					var dd;
					var ittModifier = (staticMenuPresent) ? activeLine.length-6 : 1;
					for (i = (activeLine.length-1); i >= (firstIndent - ittModifier); i--) {
						atag = activeLine[i].getElementsByTagName("a");
						if (typeof(atag[0]) == "object") {
							dd = document.createElement("dd");
							dd.appendChild(atag[0].cloneNode(true));
							tdc.element.getId("t_breadcrumb").appendChild(dd);
						}
					}
					tdc.tdco.fixLastBreadcrumb();
                }
            }
        }
    }
}();

tdc.tdco.topnav = function(){
	return {
		/**
         * Initializes the top navigation on subsites
         * @author Sune Radich Christensen
         */
		init: function(){			

			var isHover = false;
			var isActive = false;
			
			$j("li.t_tn_more a")
				.bind('click', function(event){
					$j('#t_topnav_sub').hide();
				})
				.bind('mouseover', function(event){
					isActive = true;
					$j('#t_topnav_sub').show();
				});
		
			$j(".t_topnav").hover(
				function(event){
					if (isActive == true){
						$j('#t_topnav_sub').show();
						isHover = true;
					}
				}, 
				function(event){
					isHover = false;
					setTimeout(function(){
						if (isHover == false)
						{
							$j('#t_topnav_sub').hide();
							isActive = false;
						}
					}, 600);
				}
			);
			$j("#t_topnav_sub ul li:last").addClass("t_tn_last");//add class with hover-effect to last element
		}
	}	
}();

tdc.tdco.search = function(){
	
	var googleSearch = "Søg på nettet";
	var onlineSearch = "Søg på tdconline.dk";	
			
	return {		
		
		/**
        * Initializes the search box on subsites
        * @author Sune Radich Christensen
        */                
		init: function(){

			// Set blur and focus events on input
			tdc.tdco.search.readyInput("#t_search .t_s_input", googleSearch, true);
			$j("#t_s_a_google").parent().addClass("t_active");
			
			$("#t_search dd a").bind("click", function(){
				//remove class from all
				$j(this).parent().parent().each(function(n){
					$j(this).children().removeClass("t_active");
				});
				//set class on clicked
				$j(this).parent().addClass("t_active");				
				$j("#t_search fieldset fieldset").hide();	//Hide search divs
								
				switch(this.id){
					case "t_s_a_google":
						$j("#t_searcharea").attr("value", "world");	// Google
						$j("#t_s_online form").attr("action", "http://find.tdconline.dk/google.php");
						$j("#t_s_online").addClass("t_s_google").show();					
						
						var tmpInputValue = $j("#t_search .t_s_input").attr("value");
						var doClear = false;						
						if (tmpInputValue != ""){
							if (tmpInputValue == onlineSearch)
								doClear = true;
						}
						tdc.tdco.search.readyInput("#t_search .t_s_input", googleSearch, doClear);						
						break;
					case "t_s_a_online":
						$j("#t_searcharea").attr("value", "tdc");	// TDC
						$j("#t_s_online form").attr("action", "http://search3.tdconline.dk/");
						$j("#t_s_online").removeClass("t_s_google").show();

						var tmpInputValue = $j("#t_search .t_s_input").attr("value");
						var doClear = false;
						if (tmpInputValue != ""){
							if (tmpInputValue == googleSearch)
								doClear = true;
						}
						tdc.tdco.search.readyInput("#t_search .t_s_input", onlineSearch, doClear);
						break;
				}	
			});
		},
		/*
         * Sets blur and focus for an input element
         * @param {String} css selector  to find the element
         * @param {String} Message to set
         * @param {Bool} Clear current value?
         * @author Sune Radich Christensen
         */
		readyInput: function(inputSelector, textMsg, clearBool){
        	if (clearBool == true)
        		$j(inputSelector).attr("value", textMsg);        		
        	$j(inputSelector)
        		.unbind()
        		.bind('blur', function(){
					if (this.value == "")
						this.value = textMsg;
				})
				.bind('focus', function(){
					if (this.value == textMsg)
						this.value = "";
				});
        },
        
        /**
        * Validate input to check if it is a 4-digit keyword
        * @param aForm - which searchform to use (1=google,tdc - 2=dgs)
        */
        validate: function(aForm){        
        	if(aForm == 1){
				sEl = tdc.element.getId("t_googlequery");
							
				if(sEl.value == "" || sEl.value == googleSearch || sEl.value == onlineSearch){
					tdc.redir($j("#t_s_online form").attr("action"));
					return false;					
				} else {
					if(tdc.isKeyword(sEl.value)){						
						tdc.redir("http://kundeservice.tdc.dk/keyword.php?stdcdk&kid=" + sEl.value);
						return false;
					} else {
						return true;
					}
				}
			}
			if(aForm == 2){				
				var sEl = tdc.element.getId("t_dgsquery1");
				if(sEl.value == "Indtast navn/nummer"){
					sEl.focus();
					return false;
				} else {
					return true;
				}
			}
		}
	}
}();
