var is
is=new browserHandling()
function browserHandling(){
	this.IE=0
	this.NS=0
	this.element=(document.getElementById) ? 1 : 0
	this.NSapp=(navigator.appName=="Netscape") ? 1 : 0
	this.IEapp=(navigator.appName=="Microsoft Internet Explorer") ? 1 : 0
	var ual=navigator.userAgent.toLowerCase()
	this.OPERAapp=(ual.indexOf("opera") != -1)
	this.MAC=(ual.indexOf("mac") != -1)
	this.WIN=(ual.indexOf("windows") != -1)
	this.appver=navigator.appVersion
	if(this.IEapp)
		this.IE=(document.all) ? 1 : 0
	else if(this.NSapp && !this.element)
		this.NS=(document.layers) ? 1 : 0
	if(this.NSapp)
		this.version=parseFloat(this.appver)
	else if(this.OPERAapp)
		this.version=parseFloat(ual.substr(ual.indexOf("opera") + 5, 4))
	else
		this.version=parseFloat(this.appver.substr(this.appver.indexOf("MSIE") + 5, 4))
	this.IE5=(this.WIN && this.IE && this.version=='5' && !document.compatMode)
	this.GECKO=(ual.indexOf("gecko") != -1)
	this.FIREFOX=(ual.indexOf("firebird") != -1||ual.indexOf("firefox") != -1)
	this.NS6=(ual.indexOf("netscape6/6") != -1)
	this.MEDIAPLAYER=(this.GECKO && ual.indexOf("(ax") != -1) || (this.IE && this.version >= 5 && !this.OPERAapp)
}
function getEle(id){
	if(is.NS)
		return document.layers[id]
	else if(is.element)
		return document.getElementById(id)
	else if(is.IE)
		return document.all[id]
	else
		return -1
}
function getI(f){
	var pro=(location.protocol=="file:"?"http:":location.protocol)
	if(pro=="https:"||f)
		return pro + "//i.tdconline.dk"
	else
		return pro + "//i.c.dk"
}
function popup(file, width, height){
	var windowname=""
	if(arguments.length==3)
		windowname=arguments[3]
	window.open(file,windowname,"width="+width+",height="+height+",left=150,top=100,resizable=1,scrollbars=1")
}

// Fix for IE5 rendering bug when using float in a complex layout.
function IE5RenderFix(){
	var _containerElm=getEle("t-c")
	var _measureElm=getEle("t-ie5fix")
	var _limit=10
	if(_containerElm && _measureElm){
		if(getOffsetY(_measureElm) > getOffsetY(_containerElm) + _limit){
			var _temp=_containerElm.innerHTML
			_containerElm.innerHTML=_temp
		}
	}
}

function setTDCRef(obj,csref) {
	if (obj.href.indexOf('?')==-1)
		dest=obj.href+'?csref='+csref
	else
		dest=obj.href+'&csref='+csref
	if (obj.target=='_blank')
		window.open(dest)
	else if (obj.target=="_top")
		top.location=dest
	else
		document.location=dest
	return false
}

function setPopupTitle(str) {
document.title = str
}

window.onload=handleInit
function handleInit(){
	if(typeof(IE5RenderFix)=="function")
		IE5RenderFix()
	if(typeof(tableRows)=="function")
		tableRows()
	if(typeof(local_init)=="function")
		local_init()
	if (typeof(dm)!="undefined" && dm.length!=0)
		dm_make()
	if(typeof(banner_init)=="function") banner_init()
}

function dw(s){
	document.write(s)
}

function getOffsetY(obj){
	var currentY=0
	while(obj.offsetParent){
		currentY += obj.offsetTop
		obj=obj.offsetParent
	}
	return currentY
}

// search stuff
function doSubmit(){
	if (getEle('t-ts-inp').value != "")
		if (isKeyword(getEle('t-ts-inp').value)){
			Instadia_sendEvent('0118m','_klik_tdco_ks_ql_tdco_' + getEle('t-ts-inp').value); // bz1234
			location.href='http://kundeservice.tdconline.dk/keyword.php?kid='+getEle('t-ts-inp').value
			return false
		}else{
		getEle('t-ts-form').action='http://find.tdconline.dk/google.php'
		return true
	}
	return false
}

function isKeyword(sstr){
	var i=0
	var ch=''
	var returnSpecial=false
	if (sstr.length==4 || sstr.length==5){
		returnSpecial=true
		for (i=0; i < sstr.length; i++){
			ch=sstr.substring(i,i + 1)
			if (ch < "0" || "9" < ch)
				returnSpecial=false
		}
	}
	return returnSpecial
}

function resetValues(f1, v1, f2, v2) {
	if (f1.value == v1)
		f1.value="";
	if (f2.value == v2)
		f2.value="";
	return true;
}
function resetValue(f, v) {
	if (f.value == v)
		f.value="";
}


function slide(src,href,imgbar,heading,teaser,csref) {
	this.src = src
	this.href = href
	this.imgbar = imgbar
	this.heading = heading
	this.teaser = teaser
	this.csref = csref
	if (document.images)
		this.image = new Image()
	this.loaded = false
	this.load = function() {
		if (!document.images)
			return
		if (!this.loaded) {
			this.image.src = this.src
			this.loaded = true
		}
	}
}
function slideshow( slideshowname ) {
	this.name = slideshowname
	this.repeat = true
	this.prefetch = 1
	this.timeout = 6000
	this.slides = new Array()
	this.current = 0
	this.timeoutid = 0
	this.add_slide = function(slide) {
	this.nip = 1;
		var i = this.slides.length
		if (this.prefetch == -1)
			slide.load()
		this.slides[i] = slide
	}
	this.play = function(timeout) {
		this.pause()
		if (timeout)
			this.timeout = timeout

		if (typeof this.slides[ this.current ].timeout != 'undefined')
			timeout = this.slides[ this.current ].timeout
		else
			timeout = this.timeout
		this.timeoutid = setTimeout( this.name + ".loop()", timeout)
	}
	this.pause = function() {
		if (this.timeoutid != 0) {
			clearTimeout(this.timeoutid)
			this.timeoutid = 0
		}
	}
	this.update = function() {
		if (!this.valid_image())
			return
		var slide = this.slides[ this.current ]
		var dofilter = false
		if (i_directx && this.image && typeof this.image.filters != 'undefined' && typeof this.image.filters[0] != 'undefined')
			dofilter = true
		slide.load()
  		if (dofilter) {
			if (slide.filter && this.image.style && this.image.style.filter)
				this.image.style.filter = slide.filter
			this.image.filters[0].Apply()
		}
		this.image.src = slide.image.src
		if (dofilter)
			this.image.filters[0].Play()
		this.updateClass()
		if (typeof this.post_update_hook == 'function')
			this.post_update_hook()
		if (this.prefetch > 0) {
			var next, prev, count
			next = this.current
			prev = this.current
			count = 0
			do {
				if (++next >= this.slides.length)
					next = 0
				if (--prev < 0)
					prev = this.slides.length - 1
				this.slides[next].load()
				this.slides[prev].load()
			} while (++count < this.prefetch)
		}
	}
	this.next = function() {
		if (this.current < this.slides.length - 1)
			this.current++
		else if (this.repeat)
			this.current = 0
		this.update()
	}
	this.previous = function() {
		if (this.current > 0)
			this.current--
		else if (this.repeat)
			this.current = this.slides.length - 1
		this.update()
	}
	this.loop = function() {
		if (this.current < this.slides.length - 1) {
			this.next_slide = this.slides[this.current + 1]
			if (this.next_slide.image.complete == null || this.next_slide.image.complete)
				this.next()
		} else {
			this.next()
		}
		this.play( )
	}
	this.updateClass = function() {
		getEle('t-slide-imghref').href = this.slides[this.current].href
		getEle('t-slide-href').href = this.slides[this.current].href
		getEle('t-slide-imgbar').innerHTML = this.slides[this.current].imgbar
		getEle('t-slide-href').innerHTML = this.slides[this.current].heading
		getEle('t-slide-teaser').innerHTML = this.slides[this.current].teaser
		return false
	}
	this.valid_image = function() {
		if (!this.image)
			return false
		else
			return true
	}
	this.setCurrent = function(id) {
		this.current = id
		this.update()
		this.pause()
	}
	this.gotoLink = function() {
		location.href = this.slides[this.current].href
	}
	this.csRef = function(refType) {
		return this.slides[this.current].csref + refType + '_felt' + this.current
	}
	this.nav = function(ac) {
		if (this.nip == 1) {
			this.pause()
			getEle('t-slide-nav').src = 'http://i.c.dk/tdco/gfx/slidenav2.gif'
			this.nip = 2
		} else if (ac == true) {
			this.play()
			getEle('t-slide-nav').src = 'http://i.c.dk/tdco/gfx/slidenav1.gif'
			this.nip = 1
		}
	}
}
