/* Toyota v8 core javascript - 2007-11-07  */


if(!Array.prototype.push){Array.prototype.push=function(a){this[this.length]=a};window.noScript=true}

var Tme={
gecko:navigator.product=='Gecko',
ie6:(!!document.all && !window.XMLHttpRequest),
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()}

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 */
Tme.nav = { pos: [], size: 192,
    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

        if (!o.doc) return
        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:12px;line-height:14px}body{border:solid 1px #666;border-top:0;border-left:solid 1px #ddd;padding:3px 0 15px 0}a{display:block;color:#999;padding:3px 6px;text-decoration:none}a:hover{color:#e50000}div{height:1px;line-height:1px;overflow:hidden;background:url(/images/dot.gif);margin:3px 6px}span{display:block;font-size:9px;line-height:12px;color:#999;padding:9px 6px 0 6px}</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 : 192) + 'px', display: 'block' })
            o.sub.style.height = o.doc.body.clientHeight + 1 + 'px'
            o.sub.style['z-index'] = 0;
            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)
    }
}


