/* Toyota v8 core javascript - 2007-11-07  */

if(!Array.prototype.push){Array.prototype.push=function(a){this[this.length]=a};window.noScript=true}

/* global namespace: Tme */
var Tme={
gecko:navigator.product=='Gecko',
ie6:(!!document.all && !(typeof window.XMLHttpRequest=='object')),
init:function(){var o=this,n;for(n in o)if(o[n].init)o[n].init()},
get:function(a,b){return(b||document).getElementById(a)},
tags:function(a,b){return(b||document).getElementsByTagName(a)},
set:function(a,b){for(var o in b)a[o]=b[o];return a},
create:function(a,b,c,d){var g=Tme,o=(d||document).createElement(a);g.set(o,b);g.set(o.style,c);return o},
append:function(a,b,c,d){var o=b.tagName?b:Tme.create(b,c,d);a.appendChild(o);return o},
remove:function(a){var o=a.tagName?a:Tme.get(a);o.parentNode.removeChild(o)},
time:function(){return new Date().getTime()},
fn:function(a){return(0.5-Math.cos(a*Math.PI)/2)},
absTop:function(a){var y=0;if(a.y)return a.y;while(a!=null){y+=a.offsetTop;a=a.offsetParent};return y},
absLeft:function(a){var x=0;if(a.x)return a.x;while(a!=null){x+=a.offsetLeft;a=a.offsetParent};return x},
opacity:function(a,b){Tme.set(a.style,{'filter':'alpha(opacity='+b+')',opacity:b/100})},
expand:function(a){a.style.display='block'},
collapse:function(a){a.style.display='none'},
inspect:function(a){var n,v=[];for(n in a)v.push(n+': '+a[n]);return v.join('\n')}
}

Tme.viamichelin={
createNamedElement:function(a,b,c,d,n){var g=Tme;var o=null;try{o=(d||document).createElement('<'+a+' name="'+n+'">');}catch(err){}if (!o || o.nodeName != a.toUpperCase()){o=(d||document).createElement(a);o.name= n;}g.set(o,b);g.set(o.style,c);return o}
}

Tme.request={
_r:function(){return window.XMLHttpRequest?new XMLHttpRequest():window.ActiveXObject?new ActiveXObject('Microsoft.XMLHTTP'):null},
get:function(a){var o=this._r();o.open('GET',a,false);o.send(null);return o}
}

Tme.set(String.prototype,{middle:function(a,b){var o=this.split(a);return(o.length<2)?'':o[1].split(b)[0]}})
try{document.execCommand('BackgroundImageCache', false, true)}catch(err){}

window.onload=function(){Tme.init()}

/* process links */
Tme.links={init:function(){
var g=Tme,o=g.tags('a'),i,p
for(i=0;i<o.length;i++){
	p=o[i]
	if(p.className=='external'){p.title='New window: '+(p.title||p.href);p.target='_blank'}
	if(p.className=='promo-ovl-link'){g.promo.add(p)}
}
}}



/* top navigation */
/* top navigation */
Tme.nav={pos:[],size:160,
init:function(){
	if(window.noScript)return
	var o=this,qn=Tme.get('nav'),q,i,p,pp
	if(!qn || !window.JsTopMenu)return
	q=Tme.tags('a',qn)
	o.sub=Tme.create('iframe',{frameBorder:0})
	qn.appendChild(o.sub)
	o.doc=(o.sub.contentWindow||o.sub).document
/* Safari issue : o.doc is undefined and stops all script executions */
	if (!o.doc)return
	pp=Tme.get('logo').src.middle('//','/')
	o.doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><style>html,body{margin:0;padding:0;overflow:hidden;font-family:verdana,sans serif;font-size:11px;line-height:12px}body{border:solid 1px #6d6d6d;border-top:0;border-left:solid 1px #6d6d6d;padding:3px 0 10px 0; background:#fafafa}a{display:block;color:#666;padding:3px 6px;text-decoration:none}a:hover{color:#0db604; text-decoration:underline}</style></head><body></body></html>')
	o.doc.close()
	o.body=Tme.tags('body',o.doc)[0]
	o.body.onmouseover=o.subover;o.body.onmouseout=o.out
	for(i=0;i<q.length;i++){
		p=q[i];p.index=i
		switch(i){
			case 0:o.shift=1-p.parentNode.offsetLeft;o.pos[i]=0;break
			case q.length-1:o.pos[i]=o.shift+p.parentNode.offsetLeft+p.offsetWidth-o.size;break
			default:o.pos[i]=o.shift+p.parentNode.offsetLeft
		}
		p.onmouseover=o.over;p.onmouseout=o.out
	}
},
over:function(){
try{
	var o=Tme.nav,q=window.event?event.srcElement:this,nn=JsTopMenu[q.index].children,i,sb=o.body,qq
	if(o.timer)o.stop()
	o.xx=q
	o.origid=q.parentNode.id
	q.parentNode.id='nav-on'
	o.body.innerHTML=''
	for(i=0;i<nn.length;i++)sb.appendChild(o.item(nn[i]))
	qq=JsTopMenu[q.index].description
	if(qq)sb.appendChild(Tme.create('span',{innerHTML:qq},null,o.doc))
	Tme.set(o.sub.style,{left:o.pos[q.index]+'px',width:((q.index=='0')?194:160)+'px',display:'block'})
	o.sub.style.height=o.doc.body.clientHeight+1+'px'
	o.drop()
}catch(e){}
},
subover:function(){var o=Tme.nav;if(o.timer)clearTimeout(o.timer)},
out:function(){
try{
var o=Tme.nav;if(o.xx)o.timer=setTimeout(o.stop,250)
}catch(e){}
},
stop:function(){
	var o=Tme.nav
	o.xx.parentNode.id=o.origid
	clearTimeout(o.timer);o.timer=null
	o.sub.style.display='none'
},
item:function(a){
	var o=Tme.nav.doc,n=null
	if(a.label=='--SEPARATOR--')return Tme.create('div',n,n,o)
	return Tme.create('a',{href:a.url,target:'_parent',innerHTML:a.label},n,o)
},
drop:function(){
	var o=Tme.nav,s=o.sub
	Tme.set(s.style,{height:0,display:'block'})
	Tme.set(s,{h2:o.doc.body.clientHeight+1,start:Tme.time(),end:350})
	s.step=function(){
		var t=Tme.time()-s.start,q,g,g2
		if(t>s.end){s.style.height=s.h2+'px';clearInterval(s.timer);s.timer=null}
		else{q=Tme.fn(t/s.end);s.style.height=parseInt(q*s.h2)+'px'}
	}
	s.timer=setInterval(s.step,10)
}
}



/* highlights zoom function */
Tme.keyinfo={
init:function(){
	var g=Tme,o=g.get('key-info');if(!o)return
	try{var o=g.tags('a',o),i;for(i=0;i<o.length;i++){if(o[i].className=='zoom')o[i].onclick=g.keyinfo.zoomIn}}
	catch(e){}
},
zoomIn:function(){
	var g=Tme,o=g.keyinfo,q,u='px',d=document.body,p=this
	q=g.create('div',{id:'key-detail',onclick:o.close},{top:g.absTop(p)+u,left:g.absLeft(p)+u})
	g.append(q,'img',{src:p.href})
	g.append(q,'div',{innerHTML:g.tags('span',p)[0].innerHTML})
	g.append(d,q)
	p.blur()
	return false
},
close:function(){Tme.remove('key-detail')}
}

/* section homepages */
Tme.secnav={
init:function(){
	var g=Tme,t=this,o=t.js=window.JsLevel2Menu,i;if(!o)return
	t.sub=g.create('div',{id:'section-sub'})
	g.append(g.get('mainfocus'),t.sub)
	t.menu=g.tags('a',g.get('carnav'))
	t.min=g.get('carnav').offsetLeft
	for(i=0;i<o.length;i++)g.set(t.menu[i],{id:i,onmouseover:t.over,onmouseout:t.out})
},
over:function(){
	var g=Tme,t=g.secnav,q=window.event?event.srcElement:this,x=q.parentNode.offsetLeft-t.min+'px',v='ERROR: Image and Summary required!',p
	p=t.js[q.id]
	if(p.image && p.summary){
		v='<img src="' + p.image + '" /><div>'+p.summary+'</div>'
		t.sub.innerHTML=v
		g.set(t.sub.style,{left:x,display:'block'})
	}
},
out:function(){Tme.secnav.sub.style.display='none'}
}

/* webtrends */
Tme.dcs={init:function(){
	var w=window,o
	if(w.DcsL&&w.dcsT){
		w.DcsV={'dcssip':w.location.hostname}
		new Image().src=dcsT()
	}
}}

/* touchclarity */
Tme.Tcl={init:function(){
	var w=window,o=this
	if(w.TcId){
		if (typeof tc_logging_active == 'undefined') tc_logging_active = true;
		tc_site_id=TcId
		tc_server_url='toyota.touchclarity.com'
		tc_log_path = '/applications/touchclarity'
		Tme.append(Tme.tags('body',o.doc)[0],'script',{type:'text/javascript',src:tc_log_path+'/logging-code.js'})
	}
}}

/* newsticker */
Tme.ticker={speed:50,delay:2000,lines:[],num:0,chars:0,
init:function(){
	var g=Tme,o=this,os=o.source=g.get('newsticker'),v,i,ph,pn;if(!os)return
	v=g.tags('a',os);for(i=0;i<v.length;i++)o.lines.push({href:v[i].href,label:v[i].innerHTML})
	o.target=g.tags('div',os)[0];o.render()
},
render:function(){
	var o=Tme.ticker,p=o.lines[o.num],d=o.speed
	if(o.chars>p.label.length){o.chars=0;o.num++;if(o.num>=o.lines.length)o.num=0;d=o.delay}
	else o.target.innerHTML='<a href="'+p.href+'">'+p.label.substring(0,o.chars++)+'</a>'
	setTimeout(o.render,d)
}
}

/* smooth scroll to read more */
Tme.more={to:300,end:800,
init:function(){
	var g=Tme,m=g.more,o=g.get('read-more')
	if(!o || !document.documentElement)return
	o=g.tags('a',o)[0]
	o.onclick=m.click
},
click:function(){
	var g=Tme,m=g.more,v=document.documentElement.scrollTop
	if(v>=m.end)return false
	m.from=v
	m.start=g.time()
	m.step=function(){
		var t=Tme.time()-m.start,q,g,g2,de=document.documentElement
		if(t>m.end){de.scrollTop=m.to;clearInterval(m.timer);m.timer=null}
		else{q=Tme.fn(t/m.end);de.scrollTop=m.from+q*(m.to-m.from)}
	}
	m.timer=setInterval(m.step,10)
	return false
}
}

/* old functions */
var N=null,W=window
function $escape(a){return encodeURIComponent(a)}
function $tags(a,b){return a.getElementsByTagName(b)}
function $get(a){return document.getElementById(a)}
function $tag(a,b,c){var v=['<'+a],q;if(c){for(q in c)v.push(S+q+'="'+c[q]+'"')};v.push((b!=N)?'>'+b+'</'+a+'>':' />');return v.join(E)}
function pop_glos(a){W.open(a,'popup_window','width=410,height=300,resizable=yes,scrollbars=yes')}
function pop(sLink){openpopup(sLink,750,500)}
function openpopup(sLink,iWidth,iHeight,left,name){
	if(left==N)left=0
	G_day=new Date()
	G_seed=G_day.getTime()
	iRand=parseInt(((G_seed-(parseInt(G_seed/1000,10)*1000))/10)/100*100000+1,10)
	if(name!=N)iRand=name
	winleft=((screen.width-iWidth)/2)-left
	winUp=(screen.height-iHeight)/2
	W.open(sLink,iRand,'resizable=yes,scrollbars=yes,width='+iWidth+',height='+iHeight+',left='+winleft+',top='+winUp)
}


var AjxRemote={_reg:[],
_request:function(){
	var o=this
	return W.XMLHttpRequest?new XMLHttpRequest():W.ActiveXObject?new ActiveXObject('Microsoft.XMLHTTP'):N
},
get:function(a){
	var o=this,r=o._request(),oo
	r.open('GET',a,F)
	r.send(N)
	return r
},
post:function(a,b){
	var o=this,r=o._request(),oo
	r.open('POST',a,F)
	r.setRequestHeader('Content-Type','application/x-www-form-urlencoded')
	r.send(b)
	return r
}
}

/* Ajax poll */
var AjxPoll={
prepare:function(a){
	var o=this,oo=a.parentNode.parentNode,v,oa
	a.onsubmit=function(){
		v=AjxRemote.post(a.action+'&ajaxid='+o.getAjxId(a),o.getFields(a))
		oo.innerHTML=v.responseText
		return F
	}
	oa=$tags(a,'a')
	if(oa.length>0){
		oa=oa[oa.length-1]
		oa.onclick=function(){
			v=AjxRemote.get(oa.href+'&ajaxid='+o.getAjxId(a))
			oo.innerHTML=v.responseText
			return F
		}
	}
},
getAjxId:function(a){
	var o=$tags(a,'input'),i
	for(i=Z;i<o.length;i++){if(o[i].name=="ajaxid"){return o[i].value}}
	return ""
},
getFields:function(a){
	var o=$tags(a,'input'),i,v=[]
	for(i=Z;i<o.length;i++){
		switch(o[i].type){
			case 'radio':if(o[i].checked)v.push($escape(o[i].name)+'='+$escape(o[i].value));break
			case 'hidden':v.push($escape(o[i].name)+'='+$escape(o[i].value));break
		}
	}
	return v.join('&')
}
}

/* Overlayer */
var D=document,Z=0,E=''
function sSub(a,b,c){var o=a.split(b);return(o.length>1)?o[1].split(c)[Z]:E}
function OverlayObj(){this.movies={}}
var p=OverlayObj.prototype

p.showCurtain=function(mode){
	var o=this,oc=hGet('overlayer')
	o.hideElements(mode)
	if(D.all)oc.style.width=D.body.clientWidth
	oc.style.display=mode?'block':'none'
}

p.hideElements=function(mode){
	var o=this,oa=D.getElementsByTagName('select'),i,oh=mode?'hidden':'visible'
	for(i=Z;i<oa.length;i++)oa[i].style.visibility=oh
}

p.show=function(fmn){
	var o=this,om=o.movies[fmn],oo=$('ovl_flash'),ww,wh,v=''
	W.scrollTo(0,0); 
	o.showCurtain(om.hide_page)
	if (om.flash_popup){om.width=parseInt(om.width)+2;om.height=parseInt(om.height)+34;om.flashvars+='&sub='+om.file+'&title='+om.title;om.file='/Images/flash_popup.swf';om.flash_popup=false;}
	oo.style.width=om.width+'px'
	oo.style.height=om.height+'px'
	if(om.top){oo.style.top=om.top+'px'}
	else{
		if(D.all)wh=D.body.clientHeight
		else wh=W.innerHeight
		oo.style.top=(wh-om.height)/2+'px'
	}
	if(om.left){oo.style.left=om.left+'px'}
	else{
		if(D.all)ww=D.body.clientWidth
		else ww=W.innerWidth
		oo.style.left=(ww-om.width)/2+'px'
	}
	Tme.flash.render([{movie:om.file,height:om.height,width:om.width,flashvars:om.flashvars},'ovl_flash'],om.name)
	oo.style.display='block'
	o.current=om.name;o.allow_drag=om.allow_drag
	o.track('WT.cg_n=E_Overlayer&WT.pn='+om.name+'&WT.pc=opened')
}
p.track=function(a){
	var o=this,om=o.movies[o.current]
	if(om.webtrends && W.dcsTrk)dcsTrk('WT.cg_n=E_Overlayer&WT.pc=flash&WT.cg_s='+om.name+'&WT.pn='+a)
}
p.exec=function(command,args,target){
	var o=this,oo=hGet('ovl_flash'),on=o.current,v,om=o.movies[on]
	switch(command){
	case'close':
		oo.innerHTML='&nbsp;'
		oo.style.display='none'
		o.track('closed')
		o.current=''
		if(om.hide_page)o.showCurtain(F)
		break
	case'jump':
		o.track(args,target)
		D.location.href=args
		break
	case'tag':
		o.track(args)
		break
	case'moveTo':
		v=args.split(',')
		oo.style.left=v[0]
		oo.style.top=v[1]
		break
	}
}

var OVL=new OverlayObj()

function ovl_do(command,args,target){OVL.exec(command,args,target)}
function showOverLayer(fmn){OVL.show(fmn)}
Tme.ovl={init:function(){var s=sSub(window.location.search,'ovl=','&');if(OVL.movies[s])showOverLayer(s)}}

/* functions from v4_menu.js */
var W=window,D=document,T=true,F=false,Z=0,N=null,E='',S=' '
function hGet(a){return(D.getElementById)?D.getElementById(a):N}
function switchlang(url){popupWin01=W.open(url+'?pagename='+location.href,'_new','width=400,height=300')}

/* open minisites */
function msLaunch(a,b){
	try{window.open(a,'minisite','menubar=0,status=0,scrollbars='+(b?b:0)).focus()}
	catch(e){alert('You have to allow popups to open a minisite.')}
}

/* carconfig */
function open_fullscreen(lnk,wd,ht,wn,parms){
	var strSb='scrollbars', strSt='status', strRsz='resizable', n='no',y='yes',s=screen,sw=s.availWidth-0,sh=s.availHeight-0,l,t,wp,sb='no'
	
	if(parms){wp = parms;} 
	else if (parms == undefined) {wp = strRsz+'='+n+', '+strSb+'='+n;}
	l=parseInt((sw-s.availWidth-10)/2);	if(l<0){w=sw-10;l=0;sb=y}
	t=parseInt((sh-s.availHeight-10)/2);if(t<0){h=sh-35;t=0;sb=y}
	if (sb==y){
	  if(parms.indexOf(strSb)!=-1){wp=wp.replace((strSb+'='+y),(strSb+'='+y))}
	  else {wp+= ', '+strSb+'='+y}}

	if (wp.indexOf(strRsz+'='+y) !=-1){wp+=','+strSt+'='+y;h=h-26}
        else{wp+=','+strSt+'='+n}

	window.open(lnk,wn,wp+',width='+w+',height='+h+',left='+l+',top='+t)
}

/* promo-overlayers */
Tme.promo={
init:function(){
	var m=Tme.promo,o,i,p
	if(document.body.className!='cc-promo')return
	o=Tme.tags('h2')
	for(i=0;i<o.length;i++){p=o[i];p.onmouseover=m.over;p.onmouseout=m.out;p.onclick=m.click}
},
add:function(a){
	var m=Tme.promo
	a.onclick=m.launch
},
launch:function(){
	var m=Tme.promo,o=m.layer,oo,i,p
	if(!o)o=m.layer=Tme.append(document.body,'div',{id:'ovl-page'})
	o.innerHTML=Tme.request.get(this.href+'?resid=main').responseText
	oo=Tme.tags('h2',o)
	for(i=0;i<oo.length;i++){p=oo[i];p.onmouseover=m.over;p.onmouseout=m.out;p.onclick=m.click}
	m.resize()
	window.scrollTo(0,0)
	o.style.display='block'
	try{
		p=Tme.get('ovl-dcsTrk').innerHTML
		if(p>"")dcsTrk(p.replace(/&amp;/g,'&'))
	}catch(e){}
	return false
},
over:function(){this.className='on'},
out:function(){this.className=''},
click:function(){
	var m=Tme.promo,o=this.parentNode,oc=o.className
	if(m.active){m.active.className=''}
	if(oc==''){o.className='on',m.active=o}
	m.resize()
},
resize:function(){
	var f=Tme.get
	f('ovl-page').style.height=f('canvas').offsetHeight+'px'
	f('ovl-info-bg').style.height=f('ovl-info-txt').offsetHeight+'px'
},
close:function(){Tme.promo.layer.style.display='none'}
}

/* Special model */
function $(a){return document.getElementById(a)}
function $$(a,b){return (b||document).getElementsByTagName(a)}

Tme.net={
init:function(){try {Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(Tme.net.pageBeginRequest);Sys.WebForms.PageRequestManager.getInstance().add_endRequest(Tme.net.pageEndRequest)} catch(e){}},
pageBeginRequest:function(sender, args) {var o=$('loading-indicator'); if (o) o.style.display='block';},
pageEndRequest:function(sender, args) {var o=$('loading-indicator'); if (o) o.style.display='none';}
}

Tme.folding={
items:[],
init:function(){var m=Tme.folding,o=$('sm-data');if(o)m.prepare(o);try {Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(Tme.folding.pageLoaded)} catch(e){}},
pageLoaded:function(sender, args) {var o=$('sm-data'); if (o) Tme.folding.prepare(o);},
prepare:function(a){
	var o=$$('b',a),i,v;
	for(i=0;i<o.length;i++){
	    v=o[i].className;
	    if(v=='sm-sub'|| v=='sm-sub-on'){
	        o[i].onclick=Tme.folding.click;
	    }
	}
},
nextSibling:function(a) {var o=a.nextSibling;if(o.nodeName=='#text')o=o.nextSibling;return o;},
click:function(){var m=Tme.folding,o=this,ob=Tme.folding.nextSibling(o);if(o.className=='sm-sub-on')m.unfold(o,ob);else m.fold(o,ob)},
fold:function(a,b){
    Tme.folding.items[b.id]=1;
	Tme.set(b,{h2:b.scrollHeight,start:Tme.time(),end:350,xx:a})
	b.style.overflow='hidden'
	b.step=function(){
		var t=Tme.time()-b.start,q,g,g2
		if(t>b.end){Tme.folding.end(b)}
		else{q=Tme.fn(t/b.end);b.style.height=b.h2-parseInt(q*b.h2)+'px'}
	}
	b.timer=setInterval(b.step,10)
	},
unfold:function(a,b){
    Tme.folding.items[b.id]=0;
	Tme.set(b,{h2:b.scrollHeight,start:Tme.time(),end:350,xx:a})
	b.step=function(){
		var t=Tme.time()-b.start,q,g,g2
		if(t>b.end){Tme.folding.end(b,1)}
		else{q=Tme.fn(t/b.end);b.style.height=parseInt(q*b.h2)+'px'}
	}
	b.timer=setInterval(b.step,10)
},
end:function(b,a){b.style.height=a?b.h2+'px':0;clearInterval(b.timer);b.timer=null;b.xx.className='sm-sub'+(a?'':'-on');}
}

/* **************************************** */
/* special models gallery and color chooser */
Tme.smMenu={
init:function(){var m=this,o;o=$('sm-g-fold');if(o)m.gPrepare(o);o=$('sm-c-fold');if(o)m.cPrepare(o)},
gPrepare:function(a){
	var m=this,o,oLess,oMore,i
	m.gMenu=a;a.onclick=m.gFold;m.gList=$('sm-g-list')
	o=m.sets=$$('ul',m.gList);for(i=0;i<o.length;i++)o[i].setNum=i
	o[0].style.display='block';m.setNum=0
	oLess=$('sm-g-less');oMore=$('sm-g-more')
	if(o.length<2){oLess.style.display='none';oMore.style.display='none'}
	else{oLess.onclick=m.less;oMore.onclick=m.more}
	o=m.imgList=$$('a',m.gList)
	for(i=0;i<o.length-2;i++)Tme.set(o[i],{imgNum:i,onclick:m.imgClick})
	m.imgNum=0;m.image=Tme.append($('sm-gallery'),'img',{src:o[0].href})
	m.imgSet(0);$('sm-prev').onclick=m.prev;$('sm-next').onclick=m.next
},
cPrepare:function(a){
	var m=this,o,i,c=$('sm-colourchooser'),p
	m.cMenu=a
	a.onclick=m.cFold
	m.cList=$('sm-c-list')
	o=$$('a',m.cList)
	for(i=0;i<o.length;i++)o[i].onclick=m.cClick
	if(!c){p=$('sm-content');c=p.parentNode.insertBefore(document.createElement('div'),p);c.setAttribute('id','sm-colourchooser')}
	Tme.append(c,'img',{src:o[0].href})
	o[0].className='on'
	$('sm-c-label').innerHTML=$$('img',o[0])[0].alt
	m.aColor=o
},
cClick:function(){
	var m=Tme.smMenu,o=this,c=$('sm-colourchooser')
	if(m.aColor)m.aColor.className=''
	o.className='on';o.blur()
	if(c)$$('img',c)[0].src=o.href
	$('sm-c-label').innerHTML=$$('img',o)[0].alt
	m.aColor=o
	return false
},
gFold:function(){
	var m=Tme.smMenu
	if(m.active=='g'){
		m.fold(m.gList,m.gList.scrollHeight,0,m.gClosed)
		m.active=''
	}else{
		if(m.active=='c')m.fold(m.cList,m.cList.scrollHeight,0,m.cClosed)
		m.fold(m.gList,0,m.gList.scrollHeight,m.gOpened)
		m.active='g'
	}
	return false
},
cFold:function(){
	var m=Tme.smMenu,o
	if(m.active=='c'){
		m.fold(m.cList,m.cList.scrollHeight,0,m.cClosed)
		m.active=''
	}else{
		if(m.active=='g')m.fold(m.gList,m.gList.scrollHeight,0,m.gClosed)
		m.fold(m.cList,0,m.cList.scrollHeight,m.cOpened)
		m.active='c'
	}
	return false
},
gOpened:function(){
	var m=Tme.smMenu,o=$('gal-text')
	m.gMenu.className='sm-sub'
	$('sm-gallery').style.display='block'
	$('sm-gal-actions').style.display='block'
	if(o)o.style.visibility='visible'
},
gClosed:function(){
	var m=Tme.smMenu,o=$('gal-text')
	m.gMenu.className='sm-sub-on'
	$('sm-gallery').style.display='none'
	$('sm-gal-actions').style.display='none'
	if(o)o.style.visibility='hidden'
},
cOpened:function(){
	var m=Tme.smMenu,h=$('sm-headline'),c=$('sm-colourchooser')
	m.cMenu.className='sm-sub'
	if(h)h.style.display='none'
	if(c)c.style.display='block'
},
cClosed:function(){
	var m=Tme.smMenu,h=$('sm-headline'),c=$('sm-colourchooser')
	m.cMenu.className='sm-sub-on'
	if(h)h.style.display='block'
	if(c)c.style.display='none'
},
fold:function(o,hStart,hEnd,fNext){
	Tme.set(o,{valA:hStart,valB:hEnd,start:Tme.time(),end:350,next:fNext})
	o.step=function(){
		var t=Tme.time()-o.start,q
		if(t>o.end){o.style.height=o.valB+'px';clearInterval(o.timer);o.timer=null;if(o.next)o.next()}
		else{q=Tme.fn(t/o.end);o.style.height=o.valA+parseInt(q*(o.valB-o.valA))+'px'}
	}
	o.timer=setInterval(o.step,10)
},
more:function(){
	var m=Tme.smMenu,q=m.setNum+1;
	if(q<m.sets.length){m.navSet(q);m.imgSet(q*6)}
	return false
},
less:function(){
	var m=Tme.smMenu,q=m.setNum-1;
	if(q>-1){m.navSet(q);m.imgSet(q*6+5);m.gList.style.height=m.gList.scrollHeight+'px'}
	return false
},
navSet:function(a){
	var m=Tme.smMenu,o=m.sets
	o[m.setNum].style.display='none';o[a].style.display='block'
	if(m.setNum)m.gList.style.height=m.gList.scrollHeight+'px'
	$('sm-g-less').style.visibility=(a>0)?'visible':'hidden'
	$('sm-g-more').style.visibility=(a<o.length-1)?'visible':'hidden'
	m.setNum=a
},
imgClick:function(){var m=Tme.smMenu,o=this;if(m.imgNum!=o.imgNum)m.imgSet(o.imgNum);return false},
prev:function(){var m=Tme.smMenu,v=m.imgNum-1;if(v>-1)m.imgSet(v);return false},
next:function(){var m=Tme.smMenu,v=m.imgNum+1,q=m.setNum;if(v<m.imgList.length){m.imgSet(v);if(m.setNum>q)m.gList.style.height=m.gList.scrollHeight+'px'}return false},
imgSet:function(a){
	var m=this,o=m.imgList,q=o[a],p,alt
	m.image.src=q.href
	o[m.imgNum].className=''
	q.className='on'
	q.blur()
	m.imgNum=a
	m.navSet(Math.floor(a/6))
	$('sm-prev').style.visibility=(a>0)?'visible':'hidden'
	$('sm-next').style.visibility=(a<o.length-3)?'visible':'hidden'
	o=$('sm-download')
	o.href=q.title
	o.style.visibility=(q.title)?'visible':'hidden'
	o.target='_blank'
	o=$('gal-text')
	if(o){
		alt=$$('img',q)[0].alt
		if(alt=='')o.style.visibility='hidden'
		else{
			o.innerHTML=alt
			if(o.offsetWidth>276)o.style.width=276+'px'
			if(o.className=='art')o.style.top=248-o.offsetHeight+'px'
			else o.style.top=334-o.offsetHeight+'px'
			if(m.gMenu.className=='sm-sub')o.style.visibility='visible'
		}
	}
}
}

/* addition Tme: */
Tme.win=function(){
	var w=window,d=document,dd=d.documentElement,b=d.body,hh=0,ww=0,x=0,y=0
	if(w.innerWidth){ww=w.innerWidth;hh=w.innerHeight}
	else if(dd && dd.clientWidth){ww=dd.clientWidth;hh=dd.clientHeight}
	else if(b && b.clientWidth){ww=b.clientWidth;hh=b.clientHeight}
	if(w.pageYOffset){y=w.pageYOffset;x=w.pageXOffset}
	else if(b && b.scrollLeft){y=b.scrollTop;x=b.scrollLeft}
	else if(dd && (dd.scrollLeft || dd.scrollTop)){y=dd.scrollTop;x=dd.scrollLeft}
	return{width:ww,height:hh,x:x,y:y}
}

/* homepage showroom*/
Tme.showroom={
init:function(){
	var m=this,v=$('nav-sr'),a=$('view-all'),an,ax,ad,az,i,o=[],oo;if(!v)return
	v=v.childNodes;for(i=0;i<v.length;i++){if(v[i].nodeName=='LI')o.push(v[i])}
	an=(770-a.offsetWidth-a.offsetLeft)
	ax=parseInt(an/o.length);az=parseInt(ax/2);if(ax/2!=parseInt(ax/2))az+=1;ax=parseInt(ax/2)
	for(i=0;i<o.length;i++){
		oo=$$('a',o[i])[0]
		oo.style.padding='8px '+ax+'px 9px '+az+'px'
		if(i<o.length-1){
			oo.onmouseover=m.over;oo.onmouseout=m.out
			m.prepare($$('div',o[i])[0],oo)
		}
	}
	ad=an-(ax+az)*o.length
	if(ad>0){
		ax=ax+parseInt(ad/2);az=az+parseInt(ad/2);if(ad/2!=parseInt(ad/2))az+=1
		$$('a',o[o.length-2])[0].style.padding='8px '+ax+'px 9px '+az+'px'
	}
},
prepare:function(a,b){
	var m=Tme.showroom,x=b.parentNode.offsetLeft,o,h,xx=Tme.gecko?336:212
	if(x>574)a.style.left=x+b.parentNode.offsetWidth-190+'px'
	else a.style.left=x+'px'
	a.onmouseover=m.subOver
	a.onmouseout=m.out
	o=$$('ul',b.parentNode);if(o.length<2)return
	o=o[o.length-1];if(o.className!="sr-ql")return
	h=xx-($$('li',o).length*26)
	//$('debug').value+=h+'\n'
	o.style.top=h+'px'
},
over:function(){
	var m=Tme.showroom,q=window.event?event.srcElement:this,o,h
	o=$$('div',q.parentNode)[0]
	if(m.timer)clearTimeout(m.timer)
	if(m.active)m.active.style.display='none'
	o.style.display='block'
	Tme.set($('panel-bg').style,{left:o.offsetLeft+'px',display:'block'})
	m.active=o
},
subOver:function(){
	var m=Tme.showroom
	if(m.timer)clearTimeout(m.timer)
},
out:function(){
	var m=Tme.showroom
	m.timer=setTimeout(m.stop,250)
},
stop:function(){
	var m=Tme.showroom
	m.active.style.display='none'
	$('panel-bg').style.display='none'
}
}

Tme.search={
init:function(){
	var m=this,o=$('search-button');if(!o)return
	o.onmouseover=function(){this.className="hover"}
	o.onmouseout=function(){this.className=""}
}
}

/* Specs and Equipment */

Tme.specs={
init:function(){
    try {Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(Tme.specs.prepare)} catch(e){};
    Tme.specs.prepare();
    },
prepare:function(){
	var m=Tme.specs,o=$('cg-check'),i,j,t,mr;if(!o)return
	mr=m.rows=[]
	if(Tme.gecko){m.removeEmpty($('sm-data'));m.removeEmpty($('equip-head').rows[0])}
	mr.push($('equip-head').rows[0])
	o=$('sm-data').childNodes
	for(i=0;i<o.length;i++){
		t=$$('table',o[i])[0].rows
		if(Tme.gecko){for(j=0;j<t.length;j++){m.removeEmpty(t[j]);mr.push(t[j])}}
		else{for(j=0;j<t.length;j++)mr.push(t[j])}
	}
	o=m.checks=$$('input',$('cg-check'))
	for(i=0;i<o.length;i++){o[i].indexNum=i;o[i].onclick=m.select}
	m.selectAll(true)
},
removeEmpty:function(a){
    var i=0,o=a.childNodes
    while(i<o.length){if(o[i] && o[i].nodeType==3 && !o[i].data.search(/^\s+$/))a.removeChild(o[i]);i++}
},
hideSafe:function(a){
	if(!Tme.ie6)return
	var o=$$('select'),i,x=a?'hidden':''
	for(i=0;i<o.length;i++)o[i].style.visibility=x
},
over:function(a,b){
	var m=Tme.specs,o=m.active=$(a),q=m.pos(b),cc=m.pos($('canvas')),x,y,win=Tme.win(),oi
	m.hideSafe(true)
	x=q[0];y=q[1]+16
	o.style.display='block'
	oi=$$('div',o)[1].offsetHeight
	if(y+oi-win.y>win.height)y=y-oi-20
	if(x-cc[0]+o.offsetWidth>770)x=cc[0]+776-o.offsetWidth
	Tme.set(o.style,{display:'block',left:x+'px',top:y+'px'})
},
over2:function(b){
	var m=Tme.specs,o=$('grade-tooltip'),q=m.pos(b),cc=m.pos($('canvas')),x,y
	m.hideSafe(true)
	y=q[1]+16
	o.style.display='block'
	x=cc[0]+776-o.offsetWidth
	Tme.set(o.style,{display:'block',left:x+'px',top:y+'px'})
	m.active=o
},
out:function(){
	var m=Tme.specs
	m.hideSafe(false)
	m.active.style.display='none'
},
pos:function(a) {var x=0,y=0;while(a){x+=a.offsetLeft;y+=a.offsetTop;a=a.offsetParent};return [x,y]},
hilite:function(a){
	$('sm-data').className=a?'hi-on':''
	$('hi-off').className=a?'':'hi-on'
	$('hi-on').className=a?'hi-on':''
},
select:function(){
	var m=Tme.specs,o=m.rows,i,n=this.indexNum*1+1,x=this.checked?'':'none'
	for(i=0;i<o.length;i++)o[i].childNodes[n].style.display=x
	setTimeout(m.compare,0)
},
compare:function(){
	var m=Tme.specs,o=$$('input',$('cg-check')),mc=[],i,v,r,x
	for(i=0;i<o.length;i++){if(o[i].checked)mc.push(i+1)}
 	o=m.rows
	if(mc.length<2){for(i=0;i<o.length;i++){
		try{o[i].firstChild.firstChild.className=''}
		catch(e){}
		}
	}
	else{
		for(i=0;i<o.length;i++){
			r=o[i].childNodes;v=r[mc[0]].innerHTML;x=false
			for(j=1;j<mc.length;j++){if(r[mc[j]].innerHTML!=v)x=true}
			try{r[0].firstChild.className=x?'highlight':''} catch(e){};
		}
	}
}
}

Tme.fix={
init:function(){
	var o=$('g-list'),i;if(!o)return
	if(o.className=='fix'){
		o=$$('li',o)
		for(i=0;i<o.length;i++){if((i % 6)<3)o[i].style.marginRight='4px'}
	}
}
}

Tme.gallery={
	init:function(){
		var m=this,o=$('g-list'),i;if(!o)return
		o=m.imgList=$$('a',o)
		for(i=0;i<o.length;i++)Tme.set(o[i],{imgNum:i,onclick:m.imgClick})
		m.imgNum=0
		m.image=$('sm-img')
		m.imgSet(0)
		$('sm-gal-actions').style.display='block'
		$('sm-prev').onclick=m.prev
		$('sm-next').onclick=m.next
		o=Tme.get('media')
		if(o){o=Tme.tags('a',o);for(i=0;i<o.length;i++)o[i].onclick=Tme.gallery.openMedia}
	},
	openMedia:function(){
		window.open(this.href,'Media','width=620,height=390,resizable=yes,scrollbars=yes,scrolling=yes')
		return false
	},
	imgClick:function(){var m=Tme.gallery,o=this;if(m.imgNum!=o.imgNum)m.imgSet(o.imgNum);return false},
	prev:function(){var m=Tme.gallery,v=m.imgNum-1;if(v>-1)m.imgSet(v);return false},
	next:function(){var m=Tme.gallery,v=m.imgNum+1;if(v<m.imgList.length)m.imgSet(v);return false},
	imgSet:function(a){
		var m=this,o=m.imgList,q=o[a],p,alt
		m.image.src=q.href
		o[m.imgNum].className=''
		q.className='on'
		q.blur()
		m.imgNum=a
		$('sm-prev').style.visibility=(a>0)?'visible':'hidden'
		$('sm-next').style.visibility=(a<o.length-1)?'visible':'hidden'
		o=$('sm-download')
		o.href=q.title
		o.style.visibility=(q.title)?'visible':'hidden'
		o.target='_blank'
		o=$('gal-text')
		alt=$$('img',q)[0].alt
		if(alt=='')o.style.visibility='hidden'
		else{
			o.innerHTML=alt
			if(o.offsetWidth>276)o.style.width=276+'px'
			if(o.className=='art')o.style.top=248-o.offsetHeight+'px'
			else o.style.top=334-o.offsetHeight+'px'
			o.style.visibility='visible'
		}
	}
}
var DcsL='dcs.gif'


