/* ty_v9_javascript_core */

var G={gecko:navigator.product=='Gecko',flashVer:'9.0.0',hasFla:false,autoFla:false,ie6:(!!document.all && !(typeof window.XMLHttpRequest=='object')),
init:function(){
G.detectFlash()
try{document.execCommand('BackgroundImageCache', false, true)}catch(err){}
for(var n in G)if(G[n].init)G[n].init()
},

set:function(a,b,c){for(var o in b)a[o]=b[o];if(c){for(var o in c)a.style[o]=c[o]};return a},
create:function(a,b,c,d){var 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:G.create(b,c,d,a.ownerDocument);a.appendChild(o);return o},
time:function(){return new Date().getTime()},
fn:function(a){return(0.5-Math.cos(a*Math.PI)/2)},
middle:function(o,a,b){o=o.split(a);return(o.length<2)?'':o[1].split(b)[0]},
pos:function(a){var x=0,y=0;if(a.y)return{x:a.x,y:a.y};while(a!=null){x+=a.offsetLeft;y+=a.offsetTop;a=a.offsetParent};return{x:x,y:y}},
stop:function(a){if(a){clearTimeout(a);a=null}},
sub:function(a,b,c){var o=a.split(b);return(o.length>1)?o[1].split(c)[0]:''},
remove:function(a){var o=a.tagName?a:Tme.get(a);o.parentNode.removeChild(o)},
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},
detectFlash:function(){if(G.middle(document.cookie,'acc_type=',';')=='html'){G.noFlash=true;return};var o=G.flash._o;G.hasFla=o.has(G.flashVer);G.autoFla=o.has('6.0.65')&&(o.ua.win||o.ua.mac)}
}
function $(a){return document.getElementById(a)}
function $$(a,b){return (b||document).getElementsByTagName(a)}
window.onload=G.init

G.sifr={movie:'/swf/toyota-display.swf',
cGroup:{corp:'e50000','urban-iq':'92539a','urban-aygo':'c90123','urban-cruiser':'c90123',life:'ae9f6d',recreation:'7e6f5d',energy:'5cbac8',together:'c47e3d',work:'808b83'},on:0,
init:function(){
	var m=this,cn=$$('body')[0].className,o=$('img-focus'),i
	m.set($('hdrt'),{css:'.sIFR-root{color:#999999;font-weight:bold;text-align:left}strong{color:#'+m.cGroup[cn||'corp']+'}',size:16,offsettop:-2,thickness:20})
	if(o){
		m.items=$$('li',o)
		o=$$('h2',o);for(i=0;i<o.length;i++)m.setTitle(o[i])
		m.prev=G.set($('sm-prev'),{onclick:m.doPrev})
		m.next=G.set($('sm-next'),{onclick:m.doNext})
		m.go(0)
	}
	o=$('one-focus')
	//if(o){m.setTitle($$('h1',o)[0])}
	
},
escape:function(a){return a.replace(/\%/g, '%2525').replace(/&nbsp;/g,' ').replace(/\+/g,'%2B')},
set:function(a,b){
	var m=this,o,v=[],p,s;if(!a)return
	a.style.visibility='visible'
	if(G.noFlash)return
	o={movie:m.movie,height:a.offsetHeight,width:a.offsetWidth}
	for(p in b)v.push(p+'='+b[p])
	s=m.escape(a.innerHTML)
	v.push('content='+s)	
	v.push('version=beta2')
	v.push('width='+o.width)
	v.push('height='+o.height)
	o.flashvars=v.join('&amp;')
	G.flash.render([o,a])
},
doPrev:function(){G.sifr.go(-1);return false},
doNext:function(){G.sifr.go(1);return false},
go:function(a){
	var m=this,v=m.on+a,n=m.items.length
	if(!(v>-1 && v<n))return
	if(v!=m.on)m.items[m.on].style.display='none'
	m.items[v].style.display='block'
	m.prev.style.visibility=(v>0)?'visible':'hidden'
	m.next.style.visibility=(v<n-1)?'visible':'hidden'
	m.on=v
},
setTitle:function(o){
	var m=this,ta=m.getStyle(o,'text-align'),c=m.getColor(o,'color'),so=$$('strong',o)[0],s=m.getColor(so||o,'color'),cn=o.className
	if(so)so.removeAttribute('style')
	if(cn=='BL'||cn=='BR'){
		if(o.offsetHeight==38)o.style.top=o.offsetTop+38+'px'
	}
	m.set(o,{css:'.sIFR-root{color:'+c+';font-weight:bold;text-align:'+ta+'}strong{color:'+s+'}',size:32},true)
},
getStyle:function(a,b){
	var m=this,v=''
	if(a.currentStyle)v=a.currentStyle[m.ieProp(b)]
	else if(window.getComputedStyle)v=document.defaultView.getComputedStyle(a,null).getPropertyValue(b)
	return v
},
ieProp:function(a){var v=a.split('-'),i;if(v.length<2)return a;for(i=1;i<v.length;i++)v[i]=v[i].substr(0,1).toUpperCase()+v[i].substr(1);return v.join('')},
colorHex:function(a){
	var m=this,v=a.replace(/[#| ]/g,'')
	if(v.indexOf('rgb(')==0){v=v.split('(')[1].split(')')[0].split(',');v=m.hex(v[0])+m.hex(v[1])+m.hex(v[2])}
	else if(v.length==3){v=v.split('');v=v[0]+v[0]+v[1]+v[1]+v[2]+v[2]}
	return '#'+v
},
hex:function(a){return (a*1).toString(16)},
getColor:function(a,b){var m=this;return m.colorHex(m.getStyle(a,b))}
}

/* navigation */
G.nav={timer:null,base:'/css/',
init:function(){
	var m=this,qn=$('nav'),q,i,o,n
	if(!qn)return
	m.sub=$('xNav')||G.append(document.body,'iframe',{frameBorder:0,allowTransparency:'true'})
	m.doc=(m.sub.contentWindow||m.sub).document;if(!m.doc)return
	m.doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head></head><body></body></html>')
	m.doc.close()
	try{m.doc.execCommand('BackgroundImageCache', false, true)}catch(err){}
	G.append($$('head',m.doc)[0],'link',{rel:'stylesheet',type:'text/css',href:m.base+'style_navi.css'})
	o=m.body=$$('body',m.doc)[0]
	m.div=G.append(o,'div',{id:'dd-1'})
	m.strip=G.append(o,'div',{id:'dds'})
	G.append(o,'div',{id:'dd-2'})
	m.set(o,m.subover,m.out)
	if(!window.JsTopMenu)return
	q=$$('a',qn);n=q.length
	for(i=0;i<n;i++){
		if(JsTopMenu[i].children.length>0){
			m.set(q[i],m.over,m.out,i)
			if(q[i].className=='on')m.subm=JsTopMenu[i].children
		}
	}
	m.max=n-1
	if(!m.sub)return
	qn=$('subnav');if(!qn)return
	if(qn.className=='final')return
	m.prepareSub()
	q=$$('a',qn);n=q.length;for(i=0;i<n;i++)m.set(q[i],m.over2,m.out,i)
},
prepareSub:function(){
	var m=this,o=m.subm,v=$$('a',$('subnav'))[0].innerHTML.replace('&amp;','&'),i
	for(i=0;i<o.length;i++){if(o[i].label==v){m.group=i;i=o.length}}
},
set:function(a,b,c,d){G.set(a,{onmouseover:b,onmouseout:c,index:d})},
over2:function(){
	var m=G.nav,q=this,o=m.subm[m.group+q.index].children,i,pos=G.pos(q),x=pos.x-1,y=pos.y+32;if(!o)return
	G.stop(m.timer)
	if($('subnav').className=='dbh')y+=13
	if(m.xx)m.xx.className=m.orig
	m.xx=q;m.orig=q.className;q.className='on'
	m.div.innerHTML=''
	m.body.className='nav2'
	G.set(m.sub.style,{top:y+'px',left:x+'px'})
	for(i=0;i<o.length;i++)G.append(m.div,m.item(o[i]))
	G.set(m.sub.style,{height:0,display:'block'})
	m.drop()
},
over:function(){
	var m=G.nav,q=this,p=q.parentNode,pos=G.pos(p),o,i,x=pos.x,y=pos.y+30,w=p.offsetWidth-2,s=1,ss
	G.stop(m.timer)
	if(m.xx)m.xx.className=m.orig
	m.xx=q;m.orig=q.className;q.className='on'
	ss=$('wrapper').offsetLeft
	if(x-ss>634){s=x-ss-634;x=ss+634}
	else if(q.index>0) x-=1
	m.strip.className=(q.index==m.max)?'x':''
	w+=1
	G.set(m.sub.style,{top:y+'px',left:x+'px'})
	G.set(m.strip.style,{width:w+'px',left:s+'px'})
	m.body.className=''
	m.div.innerHTML=''
	o=JsTopMenu[q.index].children
	for(i=0;i<o.length;i++)G.append(m.div,m.item(o[i]))
	G.set(m.sub.style,{height:0,display:'block'})
	G.ieFix.hide()
	m.drop()
},
subover:function(){G.stop(G.nav.timer)},
out:function(){try{var m=G.nav;if(m.xx)m.timer=setTimeout(m.stop,250)}catch(e){}},
stop:function(){var m=G.nav;G.ieFix.hide(true);m.xx.className=m.orig;G.stop(m.timer);m.sub.style.display='none'},
item:function(a){var o=G.nav.doc,n=null;return(a.label=='--SEPARATOR--')?G.create('div',{innerHTML:'&nbsp;'},n,o):G.create('a',{href:a.url,target:'_parent',innerHTML:a.label},n,o)},
drop:function(){
	var m=G.nav,s=m.sub
	if(G.halt)return
	if(G.ie6){s.style.height=m.body.clientHeight+1+'px';return}
	G.set(s,{h2:m.body.clientHeight+1,start:G.time(),end:350})
	s.step=function(){
		var t=G.time()-s.start,q,g,g2
		if(t>s.end){s.style.height=s.h2+'px';G.stop(s.timer)}
		else{q=G.fn(t/s.end);s.style.height=parseInt(q*s.h2)+'px'}
	}
	s.timer=setInterval(s.step,10)
}
}

G.ieFix={hide:function(a){
	if(!G.ie6)return
	var o=$$('select'),i
	for(i=0;i<o.length;i++)o[i].style.visibility=a?'visible':'hidden'
}}


G.fixnav={
init:function(){
	var o=$('nav'),p,i,tt=0;if(!o)return
	p=$$('li',o)
	for(i=0;i<p.length;i++) {
        tt+=p[i].offsetWidth;
    }
    
	//if(G.ie6)tt+=p.length*19
	//o.style.width='770px';
    //o.style.textAlign='right';
    //o.style.width=tt+'px'
}
}

/* quick fixes dede demo */
var Tme=G
G.get=$

G.fix={
init:function(){
	var o=$('subnav'),i,v=0;if(!o)return
	o=$$('a',o)
	for(i=0;i<o.length;i++)v=(o[i].offsetHeight>v)?o[i].offsetHeight:v
	if(v>40)$('subnav').className='dbh'
}
}

/* 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)
}

G.flash={items:[],
init:function(){setTimeout(G.flash.exec,200)},
exec:function(){
	if(G.noFlash)return
	var m=G.flash,o=m.items,i;if(o.length<1)return
	if(m._o.has('9.0.0'))for(i=0;i<o.length;i++)m.render(o[i],i)
	else m.alert()
},
add:function(a,b){this.items.push([a,b])},
render:function(a,b){
	var v=[],q=G.set({wmode:'transparent',quality:'high',AllowScriptAccess:'always'},a[0]),x,pp
	pp=location.search.substr(1);if(pp!='')q.flashvars+='&amp;'+pp
	if(G.gecko)q.flashvars+='&amp;agent=Firefox'
	v.push('<object type="application/x-shockwave-flash" id="obj_flash_'+b+'" width="'+q.width+'" height="'+q.height+'" data="'+q.movie+'">');for(x in q){switch(x){case'height':case'width':break;default:v.push('<param name="'+x+'" value="'+q[x]+'" />')}};v.push('</object>')
	if(a[1].tagName)a[1].innerHTML=v.join('\n')
	else try{$(a[1]).innerHTML=v.join('\n')}catch(e){}
},
 alert:function(){
	var m=this,o=m._o,q,v='/sys_flash.html'
/*
	flash auto update
if(o.has('6.0.65')&&(o.ua.win||o.ua.mac)){m.render([{height:340,width:770,movie:'inc/expressInstall.swf',flashvars:'MMredirectURL='+location.href  },'flash1'])};else{} 
*/
	q=G.append($('wrapper'),'iframe',{id:'fl-install',src:v,allowTransparency:'true',frameBorder:'0'})
}, 
_o:function(){
var SF="Shockwave Flash",SX="ShockwaveFlash.ShockwaveFlash",win=window,D=document,B=navigator,N=null,F=false,T=true,i$=function(a){return typeof a!='undefined'};var ua=function(){var w3cdom=i$(D.getElementById)&&i$(D.getElementsByTagName)&&i$(D.createElement)&&i$(D.appendChild)&&i$(D.replaceChild)&&i$(D.removeChild)&&i$(D.cloneNode),playerVersion=[0,0,0],d=N;
if(i$(B.plugins)&&typeof B.plugins[SF]=='object'){d=B.plugins[SF].description;if(d){d=d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");playerVersion[0]=parseInt(d.replace(/^(.*)\..*$/,"$1"),10);playerVersion[1]=parseInt(d.replace(/^.*\.(.*)\s.*$/,"$1"),10);playerVersion[2]=/r/.test(d)?parseInt(d.replace(/^.*r(.*)$/,"$1"),10):0}}else if(i$(win.ActiveXObject)){var a=N,fp6Crash=F;try{a=new ActiveXObject(SX+".7")}catch(e){try{a=new ActiveXObject(SX+".6");playerVersion=[6,0,21];a.AllowScriptAccess="always"}catch(e){if(playerVersion[0]==6){fp6Crash=T}};if(!fp6Crash){try{a=new ActiveXObject(SX)}catch(e){}}};if(!fp6Crash&&a){try{d=a.GetVariable("$version");if(d){d=d.split(" ")[1].split(",");playerVersion=[parseInt(d[0],10),parseInt(d[1],10),parseInt(d[2],10)]}}catch(e){}}};var u=B.userAgent.toLowerCase(),p=B.platform.toLowerCase(),webkit=/webkit/.test(u)?parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):F,ie=F,windows=p?/win/.test(p):/win/.test(u),mac=p?/mac/.test(p):/mac/.test(u);/*@cc_on;ie=true;@if(@_win32)windows=true;@elif(@_mac)mac=true;@end;@*/return{w3cdom:w3cdom,pv:playerVersion,webkit:webkit,ie:ie,win:windows,mac:mac}}();function hasPlayerVersion(rv){var pv=ua.pv,v=rv.split(".");v[0]=parseInt(v[0],10);v[1]=parseInt(v[1],10);v[2]=parseInt(v[2],10);return(pv[0]>v[0]||(pv[0]==v[0]&&pv[1]>v[1])||(pv[0]==v[0]&&pv[1]==v[1]&&pv[2]>=v[2]))?T:F};return{get:function(){return{major:ua.pv[0],minor:ua.pv[1],release:ua.pv[2]}},has:hasPlayerVersion,ua:ua}}()
}


G.opacity={
init:function(){
	var o=$$('div'),i,v;if(!o[0].currentStyle)return
	for(i=0;i<o.length;i++){v=o[i].currentStyle.opacity;if(v)o[i].style.filter='alpha(opacity='+v*100+')'}
}
}

function displayCarChapter(modell_name) {
    if( carChapter ) {
        var carChapters     = eval('(' + carChapter + ')');
        var carChapterLink  = eval('carChapters.'+ modell_name +'');
    
        if( carChapterLink ) {
            window.location.href = carChapterLink;
        }
    }
}

function displayEvent(event_url) {
    popHeight = 457;
	popWidth = 480;
    popY = (screen.height/2)-(popHeight/2);
	popX = (screen.width/2)-(popWidth/2);
	window.open(event_url,'eventPopup','scrollbars=no,resizable=no,width='+popWidth+',height='+popHeight+',left='+popX+',top='+popY);
}

function displayCarGroups(page_url) {
	window.open(page_url,'t');
}

function dcsTrk() {}
