// General Helpers for Brisbane/TOI
// Globals 
var tsc_parameter = new Array();
var load = new Date();
var clickcount=[0,0];
// General Helpers
function tsc_urlencode(s) {return (encodeURIComponent) ? encodeURIComponent(s) : escape(s);}
function tsc_urldecode(s) {return (decodeURIComponent) ? decodeURIComponent(s) : unescape(s);}

// fade out
function makeBlass(a) {
	var allHTMLTags = new Array();
	var allHTMLTags=document.getElementsByTagName("td");
	for (i=0; i<allHTMLTags.length; i++) {
		allHTMLTags[i].style.opacity=0.3;
		allHTMLTags[i].style.filter = "Alpha(opacity=100, finishopacity=20, style=2)";
		if (allHTMLTags[i].className==a) {
			allHTMLTags[i].style.opacity=0.5;
		}
	}
}

// Std tsc Helpers
function tsc_submG(g) {
    var f=document.tsc_topsrch;
		makeBlass("tsc_wide");
		if(typeof(xt_click) != "undefined"){
			var obunt=(g.name==f.name)?"top":"bottom"
			return xt_click(this,'C',xtn2,'new_search','S');
		}
    if(document.tsc_topsrch.encQuery)
    {
        if(document.tsc_topsrch.q.value!=document.tsc_topsrch.encQuery.value||f.context!="auto")
        {
            if(f.tax)f.tax.value='';
            if(f.tax_max)f.tax_max.value='';
        }
    }
    if(f.lang && f.lang[2].checked)f.cr.value='all';
    else f.cr.value='';
    if(!tsc_checkq(g)) return false;
    // relocated from tsc_checkq() - we only want to sync on submit
    if(g.q){
		f.q.value = g.q.value;
		tsc_syncG(g.q);
	}

    tsc_checkExt(f);
    tsc__minfrm(f);


    if(g.name==f.name) return true;
	else if(f.sb)f.sb.value='bottom';
    f.submit();
    return false;
}
function tsc_checkExt(f)
{
    var x=f.q.value;
    if((x.indexOf('http://')>-1 || x.indexOf('www.')>-1  || x.indexOf('.de')>-1  || x.indexOf('.com')>-1  || x.indexOf('.net')>-1 ) && f.context.value!='internet-tab'&& f.context.value!='wiki-tab'&& f.context.value!='service-tab')
    {
        f.context.value ='internet-tab';
        f.tpc.value = 'internet';
        f.map.value='1';
        f.map.disabled=false;
        return true;
    }
    return false;
}
function tsc_ocrG() {var f=document.tsc_topsrch; if(f.ocr && tsc_checkq(f)) {f.ocr.value=(f.ocr.value=='yes')?'no':'yes'; tsc_jmpG();}}
function tsc_syncG(e) {if(document.tsc_newsrch) {var f=(e.form.name=='tsc_topsrch')?document.tsc_newsrch:document.tsc_topsrch;
    for(var i=0;i<f.elements.length;i++) {var d=f.elements[i]; if(d.name==e.name && (e.type!='radio'||d.value==e.value)) {if(e.type=='radio')
    d.checked=true; else d.value=e.value; break;}}}}
function tsc_focusq(f,g) {}
function tsc_checkq(g) {var f=document.tsc_topsrch;if(g.q && g.q.value!='' && ',;:._-§$%&/?€'.indexOf(g.q.value)>-1){alert(unescape("ung%FCltige Eingabe"));return false;}
    return true;
}
function tsc_check_input(g){
    if(g.value!='' && ',;:._-§$%&/?€'.indexOf(g.value)>-1){
    	alert(unescape("ung%FCltige Eingabe"));
    	g.value='';
    	g.focus();
    }
}
function tsc__minfrm(f) {for(var i=0;i<f.elements.length;i++) if(f.elements[i].value=='') f.elements[i].disabled=true;}

function getMapsDefaultQuery() {
    return "Unternehmen oder Branche";
}

function getMapsDefaultLocation() {
    return "Adresse oder Ort";
}

function cleanQueryIfFromMaps(tmpQuery, from) {
    if(from!='local') {
        return tmpQuery;
    }
    if(tmpQuery.toLowerCase() == getMapsDefaultQuery().toLowerCase())
        tmpQuery = '';

    if(document.tsc_topsrch.wo) {
        var location = document.tsc_topsrch.wo.value;
        if(location && location.toLowerCase() == getMapsDefaultLocation().toLowerCase())
            location ='';

        tmpQuery += location;
    }
    return tmpQuery;
}

//for start pages
function tsc_suchraum(a,b,c,d,from) {
  q = cleanQueryIfFromMaps(document.tsc_topsrch.q.value, from);

if(q=='')
 {
  switch(a)
  {
   case 'internet-tab':
    open('http://suche.t-online.de/index.php?sr=web','_self').focus();
    break;
   case 'local':
    open('http://suche.t-online.de/index.php?sr=local','_self').focus();
    break;
   case 'themen-tab':
    open('http://suche.t-online.de/index.php?sr=themen','_self').focus();
    break;
   case 'img':
    open('http://suche.t-online.de/index.php?sr=img','_self').focus();
    break;
   case 'wiki-tab':
    open('http://suche.t-online.de/index.php?sr=wiki','_self').focus();
    break;
   case 'profi-search-web':
    open('http://suche.t-online.de/toi/html/de/erw_suche.php','_self').focus();
    break;

   default:
    open('http://suche.t-online.de/toi/html/de/header/hilfe.php','_self').focus();
  }
 }
 else tsc_jmpG(a,b,c);
}
// for tsc result docs only
function tsc_jmpG(c,t,p,cl,s) {
	var f=document.tsc_topsrch;
	if(typeof(xt_click) != "undefined"){
			xt_click(this,'C',xtn2,'Menu','S');
	}
	switch(arguments.length){
		case 0: c=tsc_context;t=tsc_tpc;p=tsc_ptl;break;
	    case 1: t=c;c=c+'-tab';p='std';break;
	    case 2: p=t;t=tsc_tpc;break;
    }
    if (f.context.value == 'local') {
        if (f.q && f.q.value.toLowerCase() == getMapsDefaultQuery().toLowerCase()) {
           f.q.value = '';
        }
        if (f.wo && f.wo.value.toLowerCase() == getMapsDefaultLocation().toLowerCase()) {
                f.wo.value = '';
        }
    }
    f.context.value=c;
    f.tpc.value=t;
    f.ptl.value=p;
    f.classification.value=(arguments.length<4)?(c+'_'+t+'_'+p):cl;
    f.src.value=(arguments.length<5)?'':s;
    tsc_checkExt(f);
    var query=f.q.value;
    query=query.toLowerCase();
    if(f.tax)f.tax.value='';
    if(f.tax_max)f.tax_max.value='';
    if(f.wo && f.wo.value!=getMapsDefaultLocation())
        f.q.value = trim(query+' '+f.wo.value);

    if(c=='local' && f.map && f.map.value=='' && query!='' && woArray){
        for(a=0;a<woArray.length;a++) {
                if(query.indexOf(woArray[a])>=0) {
                    f.q.value = trim(query.replace(woArray[a], ""));
                    f.map.value = trim(woArray[a]);
                }
        }
    }
    tsc__minfrm(f);f.submit();
}

//special handling for Categories, added ocontext=redir to url, LT
function tsc_jmpK(c,t,p,cl,s) {var f=document.tsc_topsrch; switch(arguments.length){case 0: c=tsc_context;t=tsc_tpc;p=tsc_ptl;break;
    case 1: t=c;c=c+'-tab';p='std';break; case 2: p=t;t=tsc_tpc;break;}
    f.context.value=c;
    f.tpc.value=t;
    f.ptl.value=p;
    f.ocontext.value='redir';
    f.classification.value=(arguments.length<4)?(c+'_'+t+'_'+p):cl;
    f.src.value=(arguments.length<5)?'':s;
    tsc__minfrm(f);f.submit();}


function tsc_goto_misc(from, to) {
    var tmpQuery = cleanQueryIfFromMaps(document.tsc_topsrch.q.value, from);
    self.location.href=to + "&q=" +tmpQuery;
    return false;
}


function tsc__pobj(k,v) {this.name=k || ''; this.value=v || '';}
function tsc__mkparms()
{
    var a=window.location.search.substring(1).split('&');
    for(var i=0;i<a.length;i++)
    {
        var p=a[i].split('=');
        var v='';
        if (decodeURIComponent != null)
        {
            try {
                v=decodeURIComponent(p[1].replace(/\+/g,'%20'))
            } catch (tEx)
            {
                if(p[1]) v=unescape(p[1].replace(/\+/g,'%20'));
            }
        } else {
            v = (unescape != null) ? (unescape(p[1].replace(/\+/g,'%20'))) : p[1];
        }
        tsc_parameter[i]=new tsc__pobj(p[0],v);
        tsc_parameter[p[0]]=v;
    }
}

function tsc__setsel(e,v) {for(var i=0;i<e.options.length;i++) {var o=e.options[i]; if(o.value==v) {o.selected=true; return true;}} return false;}
function tsc__setcrbtn(e,v) {for(var i=0;i<e.length;i++) {var o=e[i]; if(o.value==v) {o.checked=true;   return true;}} return false;}

function tsc_gnu (d,t,u)
{
    u=unescape(decodeURI(u))
    Fenster1 = window.open("", "CC", "width=450,height=160,left=100,top=200");
    Fenster1.document.writeln('<html>');
    Fenster1.document.writeln('<head>');
    Fenster1.document.writeln('<title>Lizenz-Verweis</title>');
    Fenster1.document.writeln('<link href="/toi/html/de/css/v2d_neu.css" type="text/css" rel="stylesheet">');
    Fenster1.document.writeln('<head>');
    Fenster1.document.writeln('<body bgcolor="EFEFF7">');
    Fenster1.document.writeln('<DIV style="PADDING-left: 5px;PADDING-TOP: 9px;PADDING-BOTTOM: 24px; FONT-WEIGHT: bold;   FONT-SIZE: 13px; COLOR: #000000; FONT-FAMILY: Arial, Helvetica, sans-serif">Hinweis zum Dokument von Wikipedia</DIV>');
    Fenster1.document.writeln('<TABLE border="0" width="100%" cellspacing="0" cellpadding="0" >');
    Fenster1.document.writeln('<TR>');
    Fenster1.document.writeln('<TD width="110" valign="top">');
    Fenster1.document.writeln('<DIV style="PADDING-left: 5px;PADDING-BOTTOM:  0px; FONT-WEIGHT: normal; FONT-SIZE: 13px; COLOR: #000000; FONT-FAMILY: Arial, Helvetica, sans-serif">Titel:</DIV>');
    Fenster1.document.writeln('</TD>');
    Fenster1.document.writeln('<TD>');
    Fenster1.document.writeln('<DIV style="PADDING-BOTTOM:  0px; FONT-WEIGHT: normal; FONT-SIZE: 13px; COLOR: #000000; FONT-FAMILY: Arial, Helvetica, sans-serif"><a target="_blank" class="text_kat" href="'+u+'">'+t+'</a></DIV>');
    Fenster1.document.writeln('</TD>');
    Fenster1.document.writeln('</TR>');
    Fenster1.document.writeln('<TR>');
    Fenster1.document.writeln('<TD width="110" valign="top">');
    Fenster1.document.writeln('<DIV style="PADDING-left: 5px;PADDING-BOTTOM: 10px; FONT-WEIGHT: normal; FONT-SIZE: 13px; COLOR: #000000; FONT-FAMILY: Arial, Helvetica, sans-serif">Letzte Änderung:</DIV>');
    Fenster1.document.writeln('</TD>');
    Fenster1.document.writeln('<TD>');
    Fenster1.document.writeln('<DIV style="PADDING-BOTTOM: 22px; FONT-WEIGHT: normal; FONT-SIZE: 13px; COLOR: #000000; FONT-FAMILY: Arial, Helvetica, sans-serif">'+d+'</DIV>');
    Fenster1.document.writeln('</TD>');
    Fenster1.document.writeln('</TR>');
    Fenster1.document.writeln('</TABLE>');
    Fenster1.document.writeln('<DIV style="PADDING-left: 5px;PADDING-BOTTOM:  0px; FONT-WEIGHT: normal; FONT-SIZE: 13px; COLOR: #000000; FONT-FAMILY: Arial, Helvetica, sans-serif">Der Inhalt steht unter der&nbsp;&nbsp;&nbsp;<a target="_blank" class="text_kat" href="http://de.wikipedia.org/wiki/Wikipedia:Lizenzbestimmungen_Commons_Attribution-ShareAlike_3.0_Unported">Creative-Commons-Lizenz (CC-by-sa-3.0)</a></DIV>');
    Fenster1.document.writeln('</body>');
    Fenster1.document.writeln('</html>');
    Fenster1.document.close();
    Fenster1.focus();

}


// Tracking
function tsc_track(obj,ch,typ,ivwtopic){
	var jetzt = new Date();
	var timediff=jetzt.getTime() - load.getTime();
	var fn;
	var buf = new Image();
	var now = new Date();
	var src = location.pathname;
	var q = tsc_urldecode(location.search); if (q != '') q='&' + q.substring(1);
	if (q == '' && location.hostname.indexOf('themen')>-1 && src.indexOf('news')>-1) q='q='+src.substring(6);
	var splitx = q.split("&");
	var t = (arguments.length > 2) ? typ : 'c'; // actual class of the call; 'c[lick]' as default, opposed to 'i[nfo]'
	var loc = '', rang = '', rank = '', csmodul="", q_encode="";
	var c = ch.split("_");
	
	for(var i=0;i<splitx.length;i++){
		if(splitx[i].substring(0,2)=="q=")splitx[i]="q="+escape(splitx[i].substring(2));
		if(splitx[i].substring(0,9)=="encQuery=")splitx[i]="encQuery="+escape(splitx[i].substring(9));
		q_encode+="&"+splitx[i];
	}
	q=q_encode;
    ch = c[0];
	if(ch=="p4pviewonly"){
		ch="p4pview";
		q += '&scope=noresults';
	}
	if(ch=="p4ponly"){
		ch="p4p";
		q += '&scope=noresults';
	}
	if(t=='c')q += '&timediff='+timediff;
	if(c.length>1) {
		// alert("channel: "+c[0]+" rang: "+c[1]);
		if(t=='c')rang='&rang='+c[1];
		if(ch=="p4p"||ch=="p4p-adprom"||ch=="p4p-narrow"){
			rank=c[1];
			// special Test p4p-narrow
			if(rank>10&&ch=="p4p-narrow")rank-=10;
			var target=(obj.title);
			if(target!="" && ch.indexOf('p4p')<0)q += '&target='+target; // not allowed for p4p
		}
		else {
			loc = '_'+c[1];
		}
		if(ch=="p4pview" && c[1]!="")csmodul='&csmodul='+c[1];
	}
	if (arguments.length > 3 && ivwtopic!='') ivw(ivwtopic);        // special extra call
	if (q.indexOf('&mandant=')==-1) q += '&mandant=toi';
	var qx=q;
	if(q.indexOf('&context=')==-1){  // short-URL? -> check param sr
		if(q.indexOf('&sr=tportal')>-1||q.indexOf('&sr=ptoweb')>-1||q.indexOf('&sr=searchbar')>-1||q.indexOf('&sr=scrs-web')>-1||q.indexOf('&sr=suggest')>-1||q.indexOf('&sr=acc')>-1||q.indexOf('&sr=chrome')>-1||q.indexOf('&sr=tweb')>-1||q.indexOf('&sr=to-software')>-1||q.indexOf('&sr=hpad')>-1||q.indexOf('&sr=msie8-intern')>-1||q.indexOf('&sr=msie8-sugg-intern')>-1||q.indexOf('&sr=set-variante-')>-1) q += '&context=internet-tab'; // web
		else if(q.indexOf('&sr=tlocal')>-1||q.indexOf('&sr=icc-local')>-1||q.indexOf('&sr=icc-route')>-1) q += '&context=local'; // local
		else if(q.indexOf('&sr=ttonline')>-1) q += '&context=themen-tab'; // tonline.de
		else if(q.indexOf('&sr=twiki')>-1) q += '&context=wiki-tab'; // wiki
		else if(q.indexOf('&sr=icc-sl')>-1) q += '&context=sl'; // swl
		else if(q.indexOf('&sr=timg')>-1) q += '&context=img'; // img
		else if(ch=='tpc') q += '&context=hub'; // special short url hub
		else q += '&context=static'; // no original context => build one named 'static'
	}
	// alert(qx+"\n"+q);
	
	if (location.hostname=='themen.fussball.de') q += '&ptl=fussball'; // special fussball-hub
	
	switch (t) {
		case 'i':
			switch (ch) {
				// special case
				case 'noresult':
					fn = 'noresult.js';
					break;
				// standard cases
				default:
					fn = 'stats.js';
			}
			break;
		default:
			q = q.replace(/&context=/, '&xcontext=');   // mod. query for these
			if (q.indexOf('&url=')==-1 && (typeof obj.href != 'undefined') && ch.indexOf('p4p')<0) q += '&url=' + tsc_urlencode(obj.href);    // click but no target-url given => get from href (if caller got it) not allowed for p4p
			// build source dep. on caller; NOTE: no loc yet for nonresults!
			if (src.indexOf('/startseite_de')>-1)
				q += '&source=startseite';
			else if (src.indexOf('/hilfe')>-1)
				q += '&source=hilfeseite';
			else
				q += '&source=ergebnisseite' + loc;
			switch (ch) {
				// special promotion click cases, not treated as redirs
				case 'tbdl':
				case 'pwd':
					q += '&context=promotion';
					fn = 'stats.js';
					break;
				// ls case
				case 'ls':
					q += '&context=ls_feed';
					fn = 'stats.js';
					break;
				// standard cases
				default:
					q += '&context=redir';
					fn = 'redir.js';
			}
	}
	//if cs cookie add param cs
	if(ch.substring(0,3)=="s-v")ch="c"+ch;
	// special handling for bbs mod variante
	if(typeof param_csv=="string"){
		cs_variante=param_csv;
	}
	var cs=(cs_variante != 999)?'&cs=variante'+cs_variante+'&more=variante'+cs_variante:'';
	//if(cs_variante == 'x')cs='&cv=variante'+cs_variante;
	// alert('Channel: '+ch+'\nTrack: '+t+'\nq: '+q);
	//if sid cookie add param sid
	var sid=(sid_cookie != '')?'&sid='+sid_cookie:'';
	var bidcs="";
	if(ch=='sid') q=str_replace ('mandant=toi', 'mandant=toi_sid', q);
	if(ch=='cs-v0c-translate-res') ch='www'; //temp. fix for statistics
	if(cs_variante!='2e'&&cs_variante!='3a')bidcs='&bidcs=on';
	// count clicks
	var counter=(t=='c'&&ch=='www')?"&count="+(++clickcount[0]):"";
	if(t=='c'&&(ch=='p4p'||ch=='p4p-adprom'))counter="&count="+(++clickcount[1]);
	// Esemos-Tracking:
	buf.src = (rank=='') ? '/toi/html/de/css/'+fn +'?track='+t +'&tstamp='+ now.valueOf() +'&src='+src +'&channel='+ch+bidcs +q+cs+sid+rang+csmodul+counter : '/toi/html/de/css/'+fn +'?track='+t +'&tstamp='+ now.valueOf() +'&src='+src +'&channel='+ch +q+"&rank="+rank+cs+sid+rang+csmodul+counter;
    
	// document.getElementById("csg_debug").innerHTML = "tsc_track: ch="+ch+".";
	if(typeof(xt_click) != "undefined"){
		if(ch=='hub'){
			var linkname=obj.href;
			linkname=linkname.substring(linkname.indexOf('t-online.de/')+12);
			linkname=linkname.substring(0,linkname.indexOf('/'));
			// return xt_click(this,'F','','content::'+klickinfo[0]+'::'+linkname);
			xt_click(this,'F','','content::'+klickinfo[0]+'::'+linkname);
			return true;
		}
		else if(ch=='tpc'){
			if(location.hostname.indexOf('themen')>-1) return xt_click(this,'C',xtn2,'Netzwerk::'+klickinfo[0]+'::TPC_links::position_'+c[1],'N');
			else return xt_click(this,'C',xtn2,'TPC_links::position_'+c[1],'N');
		}
		else if(ch=='browser'){
			return xt_click(this,'C',xtn2,'Browser_links','S'); 
		}
		else if(ch=='p4p'||ch=='p4p-adprom'){
			return xt_click(this,'C',xtn2,'Sponsored_links::position_'+c[1],'N');
		}
		else if(ch=='www'){
			return xt_click(this,'C',xtn2,'&mc='+klickinfo[1]+'&np='+aktseite+'&mcrg='+c[1],'IS');
		}
		else if(t=='c' && ch.indexOf('s-v')==1){
			var modk=ch.substring(7);
			modk=(modk.indexOf('-')>0)?modk.substring(0,modk.indexOf('-')):modk;
			var modpos=parseInt(c[1]);
			if(isNaN(modpos))modpos=0;
			return xt_click(this,'C',xtn2,'Modul_'+modk+'::position_'+modpos,'N');
		}
		
		
		
	}
} // End of "function tsc_track(..)".

// Add to Searches
function tsc_chkSSI() {
  var checkIE8acc = ""+self.location.href;
  if(checkIE8acc.indexOf('dia=msie8-acc')==-1 && checkIE8acc.indexOf('ptl=ad')==-1)
  {
     return ((navigator.appName=='Netscape' || navigator.appName=='Microsoft Internet Explorer') &&
        ((window.external && ('AddSearchProvider' in window.external)) || (window.sidebar && ('addSearchEngine' in window.sidebar)))
        );
  }
  else {return false;}
}
function tsc_addSSI() {
    if (window.external && ('AddSearchProvider' in window.external)) {  // OpenSearch
        switch (navigator.appName) {
            case 'Netscape':
                window.external.AddSearchProvider('http://suche.t-online.de/plugin/t-online.ff.xml');
                break;
            case 'Microsoft Internet Explorer':
                window.external.AddSearchProvider('http://suche.t-online.de/plugin/t-online.ie.xml');
                break;
        }
    }
    else if (navigator.appName=='Netscape' && window.sidebar && ('addSearchEngine' in window.sidebar))  // FF<2 Sherlock
        window.sidebar.addSearchEngine('http://suche.t-online.de/plugin/t-online.src', 'http://suche.t-online.de/plugin/t-online.png', 'T-Online', '');
}
function tsc_SSI() {
    if (tsc_chkSSI()) {
    document.write('<img src="/toi/html/de/img/lupe.gif" style="position: relative; top: 4px;">');
    document.write('<a class="LinkGrey" href="#" onClick="tsc_addSSI();">T-Online Suche zur Suchleiste hinzuf&uuml;gen</a>');
    }
}
function tsc_rand(range)
{
	return Math.ceil(Math.random() * 1000) % range +1;
}
var keywordlist=new Array();
  keywordlist["internet-tab"]=new Array("http://suche.t-online.de/fast-cgi/tsc?mandant=toi&device=html&dia=ad_einstieg_web&context=internet-tab&tpc=internet&ptl=ad&classification=internet-tab_internet_ad&start=0&num=10&lang=any&q=","Antivirus","Auto","Autokauf","Automarkt","Autoteile","Baufinanzierung","Bekanntschaften","Bildschirmschoner","Dessous","Download","Druckerpatronen","D&uuml;sseldorfer Tabelle","flirten kostenlos","Freeware","freeware Spiele","F&uuml;hrerschein","Gebrauchtwagen","Heiz&ouml;lpreise","Hintergrundbilder","Internet TV","Jahreswagen","Jobsuche","Kapitalanlage","Kfz-Versicherung","kostenlos","Krankenkassen","Kurzurlaub","Last Minute Reisen","Navigationssoftware","Notebooks","Partnersuche","Patientenverf&uuml;gung","PC-Spiele","Pin-Up-Girl","Reifen","Reifenwechsel","Restposten","Routenplaner","Single Treff","Stellenmarkt","Stromtarife","Tagesgeld","Tintenpatronen","Urlaub Flugreisen","Versandapotheke","Versicherungsvergleich","Visitenkarten","Zwangsversteigerung");
  keywordlist["shop-tab"]=new Array("http://suche.t-online.de/fast-cgi/tsc?mandant=toi&device=html&dia=ad_einstieg_shopping&context=shop-tab&tpc=shop&ptl=std&classification=shop-tab_shop_std&start=0&num=10&ocr=yes&mm=m&tax_max=3059&lang=any&q=","Digitalkamera","Schuhe","Handy","Notebook","Camcorder","Dessous","Drucker","Kinderwagen","Spiele","Gardinen","M&ouml;bel","Gartenm&ouml;bel","B&uuml;cher","Laptop","Fahrr&auml;der","Waschtisch","Sonnenbrillen","Fernseher","Kleidung","Uhren","Schmuck","Telefone","Bettw&auml;sche","Staubsauger","Tischlampe","Beamer","Sportschuhe","Handtaschen","Wasserkocher","Schulranzen","Splitter","Parf&uuml;m","DVD","Jeans","Aquarium","Roller","Webcam","Bademode","Sonnenschirme");
  keywordlist["wiki-tab"]=new Array("http://suche.t-online.de/fast-cgi/tsc?mandant=toi&device=html&dia=ad_einstieg_wiki&context=wiki-tab&tpc=internet&ptl=std&classification=wiki-tab_internet_std&start=0&num=10&ocr=yes&mm=m&tax_max=6&lang=any&q=","Amateurfunk","Antiblockiersystem","Antike","Archaikum","Architektur","Bauhaus","Biomasse","Dinosaurier","Donaukanal","Elefanten","Erdgeschichte","Genfer Abkommen","Gezeiten","Hilfsorganisationen","Hybridantrieb","Klassische Musik","Kraftwerk","Landschaftsmaler","Lichttechnik","M&auml;rchen","Marketing","Mittelalter","Mythen","Nachrichtentechnik","Portugal","Raketen","Raumfahrt","Religion","Rom","Sonne","Sonnensystem","Thailand","Vatikan","Vererbungslehre","Werbung","Wetter","Italien","Vatikan","Namibia","Flugzeug","Religion","M&auml;rchen","Vogelgrippe","Amazonas","Bali","Leonardo da Vinci","Japan","Colorado","Irland","Jemen","Buchpreis","Chicago","Belgien","griechische G&ouml;tter","Papaya","Ballett","Aktienindex","Pferd","Musik","Area 51","Aphorismen","Mozart","Mittelalter","Brot","Puma","Hundertwasser","Hornissen","Hooligans","Zahnmedizin","Zentralabitur","New York","Medizin","Erd&ouml;lwirtschaft","Pyramide","Rakete","Medici","Bundeskanzler","Patrizier","Sternzeichen","Kakteen","Elefant","Regenwald","Zinsen","Atommodell","Delfin","Nemesis");
  keywordlist["multimedia"]=new Array("http://suche.t-online.de/fast-cgi/tsc?mandant=toi&device=html&dia=ad_einstieg_musik&context=multimedia&tpc=internet&ptl=std&classification=all&start=0&num=10&ocr=yes&mm=m&tax_max=6&lang=any&q=","50 Cent","ABBA","Alaska","Anastacia","Andrea Berg","Because of You","Beep","Sportfreunde Stiller","Blink 182","Bushido","Die &Auml;rzte","Eros Ramazzotti","Fettes Brot","Green Day","Him","James Last","Katie Melua","Kelly Clarkson","Madonna","Neil Young","Pink","Placebo","Pussycat Dolls","Rammstein","Rosenstolz","Santana","Sasha","Seeed","Silbermond","Slowly","Sorry","Texas Lightning","Tobias Regner","Tokio Hotel","Us5","Wir sind Helden","200 Sachen","Bosse");
  keywordlist["themen-tab"]=new Array("http://suche.t-online.de/fast-cgi/tsc?mandant=toi&device=html&dia=ad_einstieg_portal&context=themen-tab&tpc=themen&ptl=std&classification=portal&start=0&num=10&ocr=yes&mm=m&tax_max=6&lang=any&q=","Adressbuch","Aktien","analog","Bildschirmschoner","Billigflieger","Brettspiele","Browser","Chat","Download","Downloads","DSL","DSL Tarife","DSL Telefonie","DSL Treiber","DSL Verf&uuml;gbarkeit","Email","Fussball","Geb&uuml;hren","Handball","Handy","Handy Logos","Handy Tarife","Hilfe","Horoskop","Internetzugang","ISDN","Kachelmann Wetter","King Kong","Kinotickets","Klingelt&ouml;ne","Kundencenter","Mitbenutzer","MMS","Moorhuhn","Musik","Nachrichten","News","Online-Banking","Pop 3 Zugang","Pop3 Server","Preisvergleich","Reisen","Routenplaner","Schlagzeilen","Sicherheit","Simlock","SMS","SMS verschicken","Software","Software 6.0","Spiele","Stauinfos","Steuererkl&auml;rung","Tetris","T-Mobile","T-Online Outlook","T-Online Server","T-Online Service","T-Online Software","T-Online Update","T-Online Vision","T-Online Webmail","Trojaner","Unwetter","Verliebt In Berlin","Video","Virenschutz","Webhosting","Wetter");
      keywordlist["service-tab"]=new Array("http://suche.t-online.de/fast-cgi/tsc?classification=service-tab_service_bhp&context=service-tab&tpc=service&ptl=bhp&device=html&dia=suche&mandant=toi&more=inline&num=10&ocr=yes&q=","H&ouml;rbuch","Ahnenforschung","Anwalt","Arbeitsrecht","Catering","Design","Elektronik","Existenzgr&uuml;ndung","Ferienwohnungen","Fotograf","Galerien","Immobilien","Kochrezepte","Konzerte","Modellflug","Multimedia","Schnellrestaurant","Steuerberater","Telekommunikation","&Uuml;bersetzer","Veranstaltungen","Versicherungen");
	  keywordlist["img"]=new Array("http://suche.t-online.de/fast-cgi/tsc?mandant=toi&device=html&dia=ad_einstieg_bild&context=img&tpc=internet&ptl=std&classification=all&start=0&num=10&ocr=yes&mm=m&type=all&q=","50 Cent","Alyssa Milano","Angelina Jolie","Blumen","Brad Pitt","Bruce Lee","Carmen Electra","Claudia Schiffer","Diddl","Drachen","Frosch","Heidi Klum","Hintergrundbilder","Hummer","Indianer","Irland","Jennifer Lopez","Justin Timberlake","Katie Holmes","Lara Croft","Mallorca","Malvorlagen","Pamela Anderson","Paris Hilton","Penelope Cruz","Pferde","Ritter","Romy Schneider","Samurai","Schiffe","Serena Williams","Shakira","Sommerlandschaft","Sonne","Sonnenfinsternis","Tokio Hotel","Tom Cruise","Uma Thurman","unterwasser","Wallpaper","Xavier Naidoo","Fische","farbenfroh");
	  keywordlist["auto"]=new Array("http://suche.t-online.de/fast-cgi/tsc?mandant=toi&device=html&dia=suche&context=auto&tpc=internet&ptl=std&classification=auto_internet_std&start=0&num=10&ocr=yes&type=all&more=inline&q=","VW","Audi","BMW","Opel","Mercedes","Ford","Wohnwagen","Motorrad","Volkswagen","Oldtimer","Honda","Corvette","Suzuki","Skoda","Volvo","Quad","Toyota","Porsche","Renault");
	  keywordlist["local"]=new Array("http://suche.t-online.de/fast-cgi/tsc?mandant=toi&device=html&dia=ad_einstieg_lokales&context=local&tpc=std&ptl=std&classification=local_std_std&start=0&num=10&ocr=yes&type=all&more=none&lang=any&q=","Hotel","Restaurant","Zahnarzt","Rechtsanwalt","Arzt","Gastst&auml;tten","Autohaus","Hautarzt","Friseur","Bank","B&auml;ckerei","Reiseb&uuml;ro","Rechtsanw&auml;lte","Bau","Buchhandlung","Apotheke","Gastst&auml;tte","Steuerberater","Restaurants","Physiotherapie","Heilpraktiker","Autoverwertung","Taxi","Einzelhandel","Verlag","Anwalt","Baumarkt","Pension","Maler","Allgemeinmedizin","Kino","&Auml;rzte","Gartenbau","Schneider","Druckerei","Spedition","Hotels","Fleischerei","Partyservice","&Auml;rzte","Schreiner","Augenarzt","Pizzeria","Autowerkstatt","G&auml;rtnerei","Copyshop","Unternehmensberatung","Gastronomie","Transporte","Pflegeheim","Altenheim","Fach&auml;rzte","Werbeagentur","Videothek","Architekt","Tischlerei","Tanzschule","Metzgerei","B&auml;cker","Tierarzt","Banken","Autohandel","Kinderarzt","Tankstelle","Krankenkasse","Geb&auml;udereinigung","Fahrschule","Bar","Orthop&auml;de","Autoh&auml;user","Notar","Elektriker","Fliesenleger");
	keywordlist["auto-used"]=new Array("http://suche.t-online.de//toi/html/de/gebrauchtwagen/?q=", "Audi A4","Alfa Romeo","Bmw x3","Bmw x6","Ford Fiesta","Ford Focus","Jaguar","Mercedes Glk","Mini","Opel Corsa","Piaggio","Renault Kangoo","Renault Twingo","Saab","Seat Ibiza","Smart MX 04","VW Golf","VW Polo");
function tsc_topsearch(context) {
	var keywordarray=keywordlist[context];
	var anzahl=keywordarray.length-1;
	document.write('<div><img alt="" src="/toi/html/de/contextual/img/csm_frame_top.gif"><div style="width:235px;padding:5px;margin:0;background-image: url(/toi/html/de/contextual/img/csm_frame_middle.gif);"><div class="tsc_topsuchen_hl">Top Suchen</div>');
	for(var i=0; i<10;i++) {
		var keyword=keywordarray.splice(tsc_rand(anzahl),1);
		// document.write("<a href=\""+keywordarray[0]+keyword[0]+"\" target=\"_self\" class=\"tsc_topsuche_link\" style=\"width:"+(225-5*i)+"px;\">"+keyword[0]+"</a>");
		document.write("<a href=\""+keywordarray[0]+keyword[0]+"\" target=\"_self\" class=\"tsc_modul_nd\" style=\"font-size:"+(16-i/2)+"px;\">"+keyword[0]+"</a>,&nbsp; ");
		anzahl=anzahl-1;
	}
	document.write('</div><img style="margin: 0 0 5px 0;border:0;" alt="" src="/toi/html/de/contextual/img/csm_frame_bottom.gif"></div>');
}

function tsc_ps_start(context,row,name) {
	document.write("<table style='margin:auto;width:180px;padding:1px;'>");
	document.write("<tr><td style=\"font-size: 13px;font-weight: bold;\">Top Suchen "+name+":</td></tr>");

	var keywordarray=keywordlist[context];
	var anzahl=keywordarray.length-1;

	for(i=0; i<row;i++) {
		document.write("<tr><td style='margin:0;padding:0;text-align:left;background-color: #efeff7;'>");
		keyword=keywordarray.splice(tsc_rand(anzahl),1);
		document.write("<a class=\"tsc_topsuche_link\" href=\""+keywordarray[0]+keyword[0]+"\" target=\"_self\">"+keyword[0]+"</a></span>");
		anzahl=anzahl-1;
		document.write("</td></tr>");
	}
	document.write("</table>")
}


function tsc_ps(context,row,name)
{
	if(keywordlist[context]){
		document.write("<table width=\"100%\">");
		document.write("<colgroup><col width=\"199px\"><col width=\"2px\"><col width=\"199px\"></colgroup>");
		document.write("<tr height=\"25px\"><td colspan=\"3\" class=\"tsc_error_hl\">Top Suchen "+name+":</td></tr>");
		var keywordarray=keywordlist[context];
		var anzahl=keywordarray.length-1;

		for(i=0; i<row;i++)
		{
			document.write("<tr height=\"20px\"><td style=\"background-color: #efeff7;\">");
			keyword=keywordarray.splice(tsc_rand(anzahl),1);
			document.write("<span style=\"padding-left: 8px; font-size: 12px;\"> - &nbsp;<a href=\""+keywordarray[0]+keyword[0]+"\" target=\"_self\" class=\"tsc_ps_link\">"+keyword[0]+"</a></span>");
			anzahl=anzahl-1;
			document.write("</td><td></td><td style=\"background-color: #efeff7;\">");
			keyword=keywordarray.splice(tsc_rand(anzahl),1);
			document.write("<span style=\"padding-left: 8px; font-size: 12px;\"> - &nbsp;<a href=\""+keywordarray[0]+keyword[0]+"\" target=\"_self\" class=\"tsc_ps_link\">"+keyword[0]+"</a></span>");
			anzahl=anzahl-1;
			document.write("</td></tr>");
		}
		document.write("</table>")
	}
}

// Event Stuff
function tsc_addEv(obj,et,f) {
  if (obj.addEventListener)
    obj.addEventListener(et,f,false);
  else if (obj.attachEvent) {
    obj['eH'+et+f] = f;
    obj[et+f] = function(){obj['eH'+et+f](event);}
    obj.attachEvent('on'+et,obj[et+f]);
    delete obj;
  }
}
function tsc_remEv(obj,et,f) {
  if (obj.removeEventListener)
    obj.removeEventListener(et,f,false);
  else if (obj.detachEvent) {
    obj.detachEvent('on'+et,obj[et+f]);
    obj[et+f] = null;
    obj['eH'+et+f] = null;
  }
} 
// click events
function tsc_clickH(e) {
  e = (e) ? e : ((event) ? event : null);
  if (e) {
    var el = (e.target) ? e.target : ((e.srcElement) ? e.srcElement : null);
		if(document.tsc_topsrch){if(document.tsc_topsrch.wh)wh=getWH();}
    if (el && el.className.indexOf("noclick")<0) {
      if (el.tagName!='A' && el.tagName!='AREA')
        el = el.parentNode;
	  if (el.tagName!='A' && el.tagName!='AREA')
        el = el.parentNode;
      if (el && el.id && el.href) {
        var c = el.id.split('.'); // split into parts, acc. to schema 'tscc.<classname>.[...]'
        if (c.length > 2 && c[0]=='tscc') {
			if(c[1]=='') c[1]='generic';	// give empty ones a name...
			if(c[2]!='') c[1]=c[1]+"_"+c[2];	// add rank...
			if(c.length > 3 && c[3]!='') c[1]=c[1]+"_"+c[3];	// add place...
			if(c.length > 4 && c[4]!='') c[1]=c[1]+"_"+c[4];	// add 2ndplace...
			// alert("ClickEvent\nc[1]: "+c[1]);
			tsc_track(el, c[1]);    // simple direct call for now, using <classname> as channel
        }
      }
	  if(document.getElementById('tsc_dd1i'))tsc_header_dd_hide(); //hide dropdown
    }
    
	// Note: Functions related to "Bildersuche" may / should be inside file "bilder.js".
	//
	if(typeof(hide_filters)=='function')hide_filters();
  }
} 

// get window height
function getWH() {
	var whn = 0;
	if(window.innerHeight!=undefined)whn=window.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight) { 
		//IE gte 6
		whn = document.documentElement.clientHeight; 
	} 
	else if (document.body && document.body.clientHeight) { 
		//IE 4 compatible 
		whn = document.body.clientHeight; 
	}
	if(document.tsc_topsrch.wh)document.tsc_topsrch.wh.value=whn;
	return whn;
}

// MAIN

// register click handler with document
tsc_addEv(document,'click',tsc_clickH);

// fixme: cs_mod declaration p4pview error
var cs_mod="";

var cs_cookie=document.cookie;
var cs_variante=(cs_cookie.indexOf("cs=variante") >-1 && document.location.href.indexOf("context=internet-tab") > -1)?cs_cookie.substr(cs_cookie.indexOf("cs=variante")+11,2):999;
if(cs_cookie.indexOf("cs=variante") ==-1 && document.location.href.indexOf("context=internet-tab") > -1)cs_variante='x';
// cs_variante='0x';
self.focus();
//alert(document.cookie);


// COOKIEtest for sessionid
var sid_cookie=(cs_cookie.indexOf("sid=")>-1)?cs_cookie.substr(cs_cookie.indexOf("sid=")+4,26):'';
if(sid_cookie=='') {
	var expJ = new Date();
	var einJahr = expJ.getTime() + (365 * 24 * 60 * 60 * 1000);
	expJ.setTime(einJahr);
	document.cookie="sid="+gen_id()+";expires="+expJ.toGMTString()+";path=/;";
	tsc_track(this,'sid','i');
}
else tsc_track(this,'sid','i');

// Zufallszahl
function gen_id() {
	var gen = Math.random() * 100000000000000000 * Math.random() / Math.random();
	var gen2 = parseInt(Math.random() * 100000000000000000 * Math.random());
	var gen3 = parseInt(Math.random() * 100000000000000000 * Math.random());
	var sid=Number(gen).toString(16)+""+Number(gen2).toString(16)+""+Number(gen3).toString(16);
	return sid.substring(0,26);
}


// microtime
function microtime () {
    var now = new Date().getTime() / 1000;
    var s = parseInt(now, 10);
    return (get_as_float) ? now : (Math.round((now - s) * 1000) / 1000) + ' ' + s;
}

function iframeResize_newsModul_narrow(h,n) {
	if(!n)n="list_iframe_news";
	if(document.getElementById(n))document.getElementById(n).style.height=h+"px";
}
	
function tsc_header_dd(x){
	var sw=(document.getElementById('tsc_dd'+x+'i').style.display!='block')?"block":"none";
	if(sw=="block"){
		var y=(x==1)?2:1;
		document.getElementById('tsc_dd'+y+'i').style.display="none";
		document.getElementById('tsc_dd'+y+'a').style.display="none";
		if(x==1){
			var leftpos=671;
			if(document.getElementById('tsc_pfu'+x))leftpos=document.getElementById('tsc_pfu'+x).offsetLeft;
			var leftposhs=0;
			if(document.getElementById('tsc_headerspace_left'))leftposhs=document.getElementById('tsc_headerspace_left').offsetWidth;
			if (leftposhs != 0) {
				leftposhs = leftposhs
			}
			leftpos = leftpos+leftposhs;
			if(leftpos>500){
				document.getElementById('tsc_dd'+x+'a').style.left=eval(leftpos-131)+"px";
				document.getElementById('tsc_dd'+x+'i').style.left=eval(leftpos-131)+"px";
			}
			else if(leftpos<120){
				document.getElementById('tsc_dd'+x+'a').style.left=eval(leftpos+493-131)+"px";
				document.getElementById('tsc_dd'+x+'i').style.left=eval(leftpos+493-131)+"px";
			}
			//document.getElementById('tsc_headerdd'+y+'a').style.left=leftpos+"px";
		} else 
		if(x==2){
			if(document.getElementById('tsc_option_menu_image')) {
				var optionpos=0;
				optionpos=document.getElementById('tsc_option_menu_image').offsetLeft;
				var leftposhs=0;
				if(document.getElementById('tsc_headerspace_left'))leftposhs=document.getElementById('tsc_headerspace_left').offsetWidth;
				if (leftposhs != 0) {
					leftposhs = leftposhs
				}
				optionpos= optionpos+leftposhs; 
				if ((document.getElementById('tsc_dd2a')) && (document.getElementById('tsc_dd2i')) ){
					document.getElementById('tsc_dd2a').style.left=eval(optionpos-131)+"px";
					document.getElementById('tsc_dd2i').style.left=eval(optionpos-131)+"px";
				}
			}
		}
	}
	// only IE: hide & view select field
	if(navigator.userAgent.indexOf('MSIE 6')>0)
	{
		if(document.all && document.all.autosort)document.getElementById('autosort').style.display=(sw=="block")?"none":"inline";
		if(x==2 && document.all && document.getElementById('mapFrame') && document.mapFrame.document.all.UmkreisOption)document.mapFrame.document.all.UmkreisOption.style.display=(sw=="block")?"none":"inline";
		if(x==2 && document.all && document.getElementById('mapFrame') && document.mapFrame.document.all.UmkreisRadius)document.mapFrame.document.all.UmkreisRadius.style.display=(sw=="block")?"none":"inline";
	}
	document.getElementById('tsc_dd'+x+'i').style.display=sw; 
	document.getElementById('tsc_dd'+x+'a').style.display=sw;
}
function tsc_header_ddphp(x){
	var sw=(document.getElementById('tsc_dd'+x+'i').style.display!='block')?"block":"none";
	if(sw=="block"){
		var y=(x==1)?2:1;
		document.getElementById('tsc_dd'+y+'i').style.display="none";
		document.getElementById('tsc_dd'+y+'a').style.display="none";
		if(x==1){
			var leftpos=601;
			if(document.getElementById('tsc_pfu'+x))leftpos=document.getElementById('tsc_pfu'+x).offsetLeft;
			if(leftpos>500){
				document.getElementById('tsc_dd'+x+'a').style.left=eval(leftpos-131)+"px";
				document.getElementById('tsc_dd'+x+'i').style.left=eval(leftpos-131)+"px";
			}
			else if(leftpos<120){
				document.getElementById('tsc_dd'+x+'a').style.left=eval(leftpos+493-131)+"px";
				document.getElementById('tsc_dd'+x+'i').style.left=eval(leftpos+493-131)+"px";
			}
		}
		
	}
	document.getElementById('tsc_dd'+x+'i').style.display=sw; 
	document.getElementById('tsc_dd'+x+'a').style.display=sw;
}
function tsc_header_dd_hide(){
	var sw="none";
	// only IE: hide select field
	if(document.all && document.all.autosort)document.getElementById('autosort').style.display="inline";
	document.getElementById('tsc_dd1i').style.display=sw;
	document.getElementById('tsc_dd1a').style.display=sw;
	document.getElementById('tsc_dd2i').style.display=sw;
	document.getElementById('tsc_dd2a').style.display=sw;
}
function tsc_ul(o,act){
	var n=(o.childNodes[0].tagName=='A')?0:1;
	o.childNodes[n].style.textDecoration=(act==1)?"underline":"none";
	o.style.cursor="pointer";
}
function str_replace (search, replace, subject)
{
  var result = "";
  var  oldi = 0;
	if(search!=""){
		for (i = subject.indexOf (search); i > -1; i = subject.indexOf (search, i))
		{
			result += subject.substring (oldi, i);
			result += replace;
			i += search.length;
			oldi = i;
		}
		return result + subject.substring (oldi, subject.length);
	}
	else return subject;
}

/* ++++++++++++++++++ XHR CS Modules ++++++++++++++++++++++++ */
function getCsModules(uri,divid){
	var req;
	try{req = new XMLHttpRequest();}
	catch (ms){
		try{req = new ActiveXObject("Msxml2.XMLHTTP");} 
		catch (nonms){
			try{req = new ActiveXObject("Microsoft.XMLHTTP");} 
			catch (failed){req = null;}
		}
	}
	if (req == null) alert("Error creating request object!");
	req.open("GET", uri, true);
	req.onreadystatechange = function(){
		switch(req.readyState) {
			case 4:
				if(req.status!=200) {
					// alert("Fehler:"+req.status); 
				}else{
					// alert("uri: "+uri+"\nNr. Modul: "+divid+"\nResponse: "+req.responseText );
					var el = document.getElementById(divid);
 					if(el) {
						el.innerHTML = ""+req.responseText;
						// 'endsWith empty <div />'
						var emptyDiv = '<div />';
						if(req.responseText.indexOf(emptyDiv, req.responseText.length - emptyDiv.length) > 0) {
							el.parentNode.removeChild(el);
							//el.style.display='none';
						} 
						else if(el.parentNode.className.indexOf('tsc_display_modules') < 0) {
							if (el.parentNode.className.indexOf('tsc_wide') < 0) {
								el.parentNode.className += " tsc_display_modules";
							}
						}
					}
				}
				break;
			default:
				return false;
				break;     
		}
	}
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	req.send(null);
}

