// What to do when we have loaded?
 tdco_addEventLoad(handleInit); 
function handleInit()
{
	// should we add any menu items?
	if (typeof(dm2) == "object")
	{
		dm2menu(dm2);
	}

	// should we replace the footpath?
	if (typeof(footpaths) == "object")
	{
		footpath(footpaths);
	}

	// execute any local function
	if (typeof(local_init) == "function")
	{
		local_init()
	}

	if (typeof(moveCustom) == "function")
	{
		moveCustom()
	}

	// update personal topbar but only if we're logged in
	if (ssoLoggedIn())
	{
		var docheck = tdco_mailcheck();
		if (docheck)
		{
			// now do the mailcheck
			var ele = new JSONscriptRequest("http://np.mail.tdconline.dk/portalmailinfo.js");
			ele.buildScriptTag();
			ele.addScriptTag();
		}
	}
}

// Firefox with Console2 can print to the Error Console. See http://forums.mozillazine.org/viewtopic.php?t=318102
function tdco_console(aMsg) {
	if (is.FIREFOX) {
		setTimeout(function() {throw new Error("[debug] " + aMsg)}, 0);
	}
}

function moveCustom() {
	var tomove = "";
	var container = getEle("content");
	if (container) {
		var els = container.getElementsByTagName("DIV");
		for (var i = 0; i < els.length; i++) {
			if (els[i].className == "leftbar custom" || els[i].className == "custom leftbar") {
				tomove += els[i].innerHTML;
				els[i].innerHTML = "";
			}
		}
		if (tomove) {
			getEle("navigationextra").innerHTML += tomove;
		}
	}
}

// adds functions to the onload event
function tdco_addEventLoad(aFunc)
{
	var oldonload = window.onload;
	if (typeof(window.onload) != "function")
	{
		window.onload = aFunc;
	}
	else
	{
		window.onload = function()
		{
			if (oldonload)
			{
				oldonload();
			}
			aFunc();
		}
	}
}

// called from sso.js
function tdco_mailcheck()
{
	var ret = true;
	// do show mail info on webmail
	if (document.location.host.indexOf("mail.tdconline.dk") > -1)
	{
		ret = false;
	}
	var name = getCookie("tdcossomailcheck");
	if (name)
	{
		// parse the cached info
		var mailinfo = name.split(";");
		var now = new Date().getTime();
		if (typeof(mailinfo[0]) != "undefined" && typeof(mailinfo[1]) != "undefined" && now - mailinfo[0] < (5 * 60 * 1000))
		{
			ret = false;
			// update the topbar with cached info
			tdco_mailinfo({"unread":mailinfo[1]}, 1);
		}
	}
	return ret;
}

// function called from np.mail.tdconline.dk
function tdco_mailinfo(aObj, aSkipCookie)
{
	// do show mail info on webmail
	if (document.location.host.indexOf("mail.tdconline.dk") > -1)
	{
		// reset time in the cookie so that when user leaves webmail we check again
		if (typeof(aObj.unread) != "undefined")
		{
			setCookie("tdcossomailcheck", 1 + ";" + aObj.unread, "", "/", "tdconline.dk");
		}
		return;
	}

	var already = getEle("tdcossoinfomail");
	// if the id is already there dont do anything
	if (already)
	{
		return;
	}
	else
	{
		var mailinfoele = getEle("tdcssoinfo");
		if (mailinfoele && typeof(aObj.unread) != "undefined")
		{
			// is the number valid
			if (aObj.unread >= 0)
			{
				var mailinfoele2 = getEle("tdcossoinfoname");
				var ele = document.createElement("div");
				ele.setAttribute("id", "tdcossoinfomail");
				ele.setAttribute("onclick", "Instadia_sendEvent(\"0118m\",\"_klik_topbar_mail\");document.location.href=\"http://mail.tdconline.dk/\"");
				ele.innerHTML = "<a href=\"http://mail.tdconline.dk/\" target=\"_top\">" + (aObj.unread > 0 ? "<strong>" : "") + aObj.unread + (aObj.unread == 1 ? " ny mail" : " nye mails") + (aObj.unread > 0 ? "</strong>" : "") + "</a>";
				mailinfoele.insertBefore(ele, mailinfoele2);
			}
			// update the cookie but only if we did the mailcheck and not when we used the cached info
			if (!aSkipCookie)
			{
				var now = new Date().getTime();
				setCookie("tdcossomailcheck", now + ";" + aObj.unread, "", "/", "tdconline.dk");
			}
		}
	}
}

// Used in element from KTV
function tdco_toggleDisplay(id){
	state = document.getElementById(id).style.display;
   	if (state == 'block'){
   		document.getElementById(id).style.display = 'none';
   	} else {
   		document.getElementById(id).style.display = 'block';
   	}
}

function toggleFeedbackComment()
{
	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";
		}
	}
}

// Dynamic Menu
function dm2menu(aObj)
{
	if (typeof(aObj) == "object" && aObj.length > 0)
	{
		var nav = getEle("navigation");
		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 elem;
			var indent = false;
			// insert the links
			for (var i = 0; i < aObj.length; i++)
			{
				// make sure we have a object
				if (typeof(aObj[i]) == "undefined")
				{
					break;
				}

				// create the li with the link
				ele = document.createElement("li");

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

				// do we have to indent it? indent can't happen on the first item
				if (i != 0 && typeof(aObj[i][4]) == "boolean" && aObj[i][4])
				{
					// are we already indented?
					if (!indent)
					{
						var eleul = document.createElement("ul");
						navul[0].lastChild.appendChild(eleul);
					}
					elem = navul[0].lastChild.childNodes[1];
					indent = !indent;
					elem.appendChild(ele);
				}
				else
				{
					navul[0].appendChild(ele);
				}
			}
		}
	}
}


// create a DOM link from an object
function createLink(aObj)
{
	var ele;
	if (typeof(aObj[1]) != "undefined" && aObj[1] != "")
	{
		ele = document.createElement("a");
		ele.setAttribute("href", aObj[1]);
		if (typeof(aObj[2]) != "undefined" && aObj[2] != "")
		{
			ele.setAttribute("title", aObj[2]);
		}
		if (typeof(aObj[3]) != "undefined")
		{
			if (aObj[3] != "")
			{
				ele.setAttribute("target", aObj[3]);
			}
		}
		else
		{
			ele.setAttribute("target", "_top");
		}
		ele.appendChild(document.createTextNode(aObj[0]));
	}
	else
	{
		ele = document.createTextNode(aObj[0]);
	}
	return ele;
}

// footpath aka breadcrumb
function footpath(aPaths)
{
	var footpath = getEle("footpath");
	if (footpath && typeof(aPaths) == "object" && aPaths.length > 1)
	{
		// we always replace the last li in footpath with the first in aPaths
		var footpathEles = footpath.getElementsByTagName("li");
		var footpathLast = footpathEles[footpathEles.length-1];
		footpathLast.removeChild(footpathLast.childNodes[0])
		footpathLast.appendChild(createLink(aPaths[0]))

		// add the rest of the li's
		for (var i = 1; i < aPaths.length; i++)
		{
			var ele = document.createElement("li");
			ele.appendChild(createLink(aPaths[i]));
			footpath.appendChild(ele)
		}
	}
}

function drawKontakt()
{
	document.write('<a href="" onclick="popup(\'http://tdconline.dk/kontakt/?dogtag=' + (typeof(t_dogtag) != "undefined" ? t_dogtag : "unknown") +'&url=' + location.href +'\',570,520);return false;">Kontakt</a>');
}

function randomNo(mp)
{
	return Math.random() * mp;
}

function sethp(u)
{
	var ohp=getEle("ohp");
	if (ohp){
		ohp.style.behavior="url(#default#homepage)";
		if (u)
		{
			ohp.setHomePage(u);
		}
		else
		{
			ohp.setHomePage(document.location);
		}
	}
}

function drawMakeHomepage()
{
	if (is.IEapp && (is.version > 4) && !is.OPERAapp)
	{
		document.write('<a href="javascript:sethp()" onmouseover="window.status=\'G&oslash;r til startside\';return true;" onmouseout="window.status=\'\'">G&oslash;r til startside</a><span id=\"ohp\"></span>');
	}
}

// ajax helper
function tdco_ajax()
{
	var xmlhttp = false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions and security blocked creation of the objects.
	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e)
		{
			xmlhttp = false;
		}
	}
	@end @*/
	if (!xmlhttp && typeof(XMLHttpRequest) != "undefined")
	{
		try
		{
			xmlhttp = new XMLHttpRequest();
		}
		catch(e)
		{
			xmlhttp = false;
		}
	}
	if (!xmlhttp && window.createRequest)
	{
		try
		{
			xmlhttp = window.createRequest();
		}
		catch(e)
		{
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

// JSON class from http://www.xml.com/pub/a/2005/12/21/json-dynamic-script-tag.html
function JSONscriptRequest(aURL)
{
	this.fullUrl = aURL;
	this.nocache = (aURL.indexOf("?") > 0 ? "&" : "?") + new Date().getTime();
	this.headLoc = document.getElementsByTagName("head").item(0);
	this.scriptId = "JscriptId" + JSONscriptRequest.scriptCounter++;
}
JSONscriptRequest.scriptCounter = 1;
JSONscriptRequest.prototype.buildScriptTag = function ()
{
	this.scriptObj = document.createElement("script");
	this.scriptObj.setAttribute("type", "text/javascript");
	this.scriptObj.setAttribute("charset", "utf-8");
	this.scriptObj.setAttribute("src", this.fullUrl + this.nocache);
	this.scriptObj.setAttribute("id", this.scriptId);
}
JSONscriptRequest.prototype.removeScriptTag = function ()
{
	this.headLoc.removeChild(this.scriptObj);
}
JSONscriptRequest.prototype.addScriptTag = function ()
{
	this.headLoc.appendChild(this.scriptObj);
}


function feedback_toggleComment() {

	if (getEle('opinion_ja').checked == true) {
		Instadia_sendEvent('0118n', 'FB3#' + yes_id + '#' + CScontext + '_ja');
	} else {
		Instadia_sendEvent('0118n', 'FB3#' + no_id + '#' + CScontext + '_nej');
	}
	//disable so that the user cannot toggle back and forth to keep generating sendevents
	getEle('opinion_ja').disabled = true;
	getEle('opinion_nej').disabled = true;
	getEle('furtherCommentsLink').style.display = 'block';
}


function feedback_moreComments(templateId){
	getEle('holdsInstadiaTemplate').style.display = 'block';
	Instadia_launchSurvey(templateId, 'holdsInstadiaTemplate', function() { feedback_afterSurveySubmit(); });
	return true;
}

function feedback_afterSurveySubmit(){
	getEle('holdsInstadiaTemplate').style.display = 'none';
	getEle('furtherCommentsLink').style.display = 'none';
	//say thank you if the user filled out the Instadia form
	getEle('second').style.display = 'block';
}

var csColor = "";

function forceCsColor(aColor){
	csColor = aColor;
}

function getColor(){	
	csColor = "orange";
}

function printCsStylesheet(aMedia){

	if(csColor == "") getColor();
	document.body.className = "t_cs_" + csColor;
	var stylesheet = document.createElement('link');
	stylesheet.rel = "stylesheet";
	stylesheet.media = aMedia ? aMedia : "screen";
	stylesheet.href = getI()+"/ngto/css/cs.css";
	document.getElementsByTagName("head")[0].appendChild(stylesheet);
}

function printLogo(pUrl){
	if(csColor == "") getColor();
	if(!pUrl) pUrl = "http://tdconline.dk/";

	if(is.flash >= 8){
		document.writeln("<div id=\"t_globallogo_anim\">");
		document.writeln("<object type=\"application/x-shockwave-flash\" data=\""+getI()+"/swf/rr/cs/"+csColor+"/logo/tdcologo_anim.swf?pUrl="+pUrl+"\" width=\"162\" height=\"56\">");
		document.writeln("<param name=\"movie\" value=\""+getI()+"/swf/rr/cs/"+csColor+"/logo/tdcologo_anim.swf?pUrl="+pUrl+"\" \/>");
		document.writeln("<param name=\"AllowScriptAccess\" value=\"always\" \/>");
		document.writeln("<param name=\"wmode\" value=\"transparent\" \/>");
		document.writeln("</object>");
		document.writeln("</div>");
	} else {
		document.writeln("<a href=\""+pUrl+"\" title=\"Til forsiden af TDC Online\"><img src=\""+getI()+"/gfx/rr/cs/"+csColor+"/logo/tdcologo.png\" id=\"t_globallogo\" /></a>");
	}
}

function printAd(siteId){
	document.write('<scr'+'ipt type="text/javascript" src="http://adserver.adtech.de/addyn|3.0|655|'+siteId+'|0|225|ADTECH;loc=100;target=_blank;key=key1+key2+key3+key4;grp=[group];misc='+new Date().getTime()+'"></scri'+'pt>');
}

function toggleAllNav(){
	if(getEle("allnav")){
		var allnav = getEle("allnav");
		if(allnav.style.display == "" || allnav.style.display == "none"){
			allnav.style.display = "block";
		} else {
			allnav.style.display = "none";
		}
	}
}

function clickRedir(obj,data) {
	var dest='http://click.tdc.dk/go/?u='+escape(obj.href)+"&s="+escape(data).replace(/\+/g, '%2B');
	if (obj.target=='_blank') {
		window.open(dest);
	} else if (obj.target=="_top") {
		top.location=dest;
	} else {
		document.location=dest;
	}
	return false;
}

/**
* Initializerer topnav på subsites på tdconline.dk, og tilføjer mouseover og click events til show/hide af 2nd menu
*/
function topnavInit(){
	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
}


var googleSearch = "Søg på nettet";
var onlineSearch = "Søg på tdconline.dk";

/**
* Initialiserer søgeboksen på subsites
*/
function searchBoxInit(){							
	
	// Set blur and focus events on input
	readyInput("#t_search .t_s_input", googleSearch, true);
	$j("#t_s_a_google").parent().addClass("t_active");
	
	$j("#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;
				}
				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;
				}
				readyInput("#t_search .t_s_input", onlineSearch, doClear);
				break;
		}	
	});
}

function readyInput(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 = "";
		});
}

/* Overwrites to make the search element work in both designs */
tdc.tdco = function(){}
tdc.tdco.search = function(){
	return{	
		/**
        * 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 = getEle("t_googlequery");				
				if(sEl.value == "" || sEl.value == googleSearch || sEl.value == onlineSearch){
					redir($j("#t_s_online form").attr("action"));
					return false;
				} else {
					if(tdc.tdco.search.isKeyword(sEl.value)){
						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;
				}
			}
		},
		isKeyword : function(aStr) {
			if (aStr.search("^[1-9][0-9]{3,3}$") != -1) {
				return true;
			} else {
				return false;
			}
		}
	}
}();

/**
 * Redirect function
 * @param {String} aUrl URL to redirect to
 * @param {String} aCsref csref to attach on url 
 * @author kimblim
 */
function redir(aUrl, aCsref) {
	if (typeof(aCsref) != 'undefined' && aCsref != '' && aUrl.indexOf('csref') == -1) {
		delimiter = (aUrl.indexOf("?") > -1) ? "&" : "?";
		aUrl += delimiter + "csref=" + aCsref;
	}	
	top.location.href = aUrl;
}  


tdc.tdco.ngto = {
	login : {
		drawLoginToolbar : function() {
			var templateArguments = tdc.login.loginBoxTemplateArguments();

			if(templateArguments.isLoggedIn){
				document.write("<div id=\"sso_funcs\"><a href=\"" + templateArguments.optionsUrl + "\" title=\"Redig\xE9r dine indstillinger\">Login indstillinger</a>&nbsp;&nbsp;&nbsp;");
				document.writeln('<form action="' + templateArguments.logoutUrl +'" method="POST" style="display:inline" class="t_login_box">');
				document.writeln('<a href="#" onclick="$j(this).parents(\'form\').get(0).submit(); return false;" title=\"Log ud af TDC Login\" id=\"tdcossobutton\">Log ud</a>');
				templateArguments.writeHiddenFieldsFunction();
				document.writeln('</form>');
				templateArguments.writeHiddenSsoImagesFunction();						
				document.write("</div>");
				document.write("<div id=\"tdcssoinfo\"><div id=\"tdcossoinfoname\">Velkommen <strong><span title=\"" + templateArguments.userName + "\">" + templateArguments.userName + "</span></strong></div></div>");
				if (typeof tdco_mailcheck == "function") {
					tdco_mailcheck();
				}					
				
				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.ngto.login.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.ngto.login.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.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>');	
				
					templateArguments.writeHiddenSsoImagesFunction();	
				
					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);				
					});
			}				
		},

		loadNumMails : function (obj,cookieskip){  // cloned from /js/rr/tdco.js
			var msg = "";
			var unreadcount;
			if(obj.unreadcount){
				unreadcount = obj.unreadcount
				msg = "<a href=\"http://mail.tdconline.dk/\"><strong>" + unreadcount + " nye mails</strong></a>";
				tdc.element.getId("tdcossoinfomail").innerHTML = msg;
				if(cookieskip!=1){
					var now = new Date().getTime();
					tdc.cookie.set("tdcossomailcheck",now+";"+unreadcount,"", "/", "tdconline.dk");
				}
			}
		}					
		
			
	}
};
