/* Toyota v8 core javascript - 2007-02-27  */
if(!Array.prototype.push){
Array.prototype.push=function(a){this[this.length]=a}
window.noScript=true
}
/* global namespace: Tme */
var Tme={
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)},
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'}
}
window.onload=function(){Tme.init()}
/* top navigation */
Tme.nav={pos:[],
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
	
	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}.caption{font-size:12px;display:block;color:#999;padding:3px 6px;}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}td{vertical-align:text-top;}.normalSpan{margin:0;padding:0;font-size:12px;line-height:14px;}.closed{background-repeat: no-repeat;background-image: url(\'images/plus.jpg\');background-position:0px 3px;padding: 3px 0px 3px 15px;}.opened{background-repeat: no-repeat;background-image: url(\'images/mins.jpg\');background-position:0px 3px;padding: 3px 0px 3px 15px;}</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=p.parentNode.offsetLeft;o.pos[i]=0;break
			case q.length-1:o.pos[i]=1 + o.shift+p.parentNode.offsetLeft+p.offsetWidth-window.JsTopMenu[i].size;break
			default:o.pos[i]=o.shift+p.parentNode.offsetLeft
		}
		p.onmouseover=o.over;p.onmouseout=o.out
	}
},
over:function(){
    
	var o=Tme.nav,q=window.event?event.srcElement:this;
	if(typeof(q.index) == 'undefined')
	    q = q.parentNode;
	
	var nn=JsTopMenu[q.index].children,i,sb=o.body,qq;
	if(o.timer)o.stop()
	if(!nn) return; //mjw fix for item with no dropdown
	o.xx=q
	o.origid=q.parentNode.id
	q.parentNode.id='nav-on'
	o.body.innerHTML=''
	
	_table = sb.appendChild(Tme.create('table', null, null, o.doc))
	_tbody = _table.appendChild(Tme.create('tbody', null, null, o.doc))
	_tr = _tbody.appendChild(Tme.create('tr', null, null, o.doc));
	
	_td = _tr.appendChild(Tme.create('td', {valign:"top"}, null, o.doc));
	o.CreateChildren(_td, nn, o, "1");
	






	_td2 = _tr.appendChild(Tme.create('td', {valign:"top"}, null, o.doc));
	o.CreateChildren(_td2, nn, o, "2");
	
	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:(JsTopMenu[q.index].size)+'px',display:'block'})
	o.sub.style.height=o.doc.body.clientHeight+1+'px'
	o.drop() // in comment by ss, this creates a sliding effect, but does not work with images + text
	
	// reloop the menu and execute the CollapseOrExpand function(we can only do this now, because the height must be calculated with all nodes open)
	for(i=0;i<nn.length;i++)
	{
	    if(nn[i].collapsable == "1")
	    {
	        o.CollapseOrExpand("href" +  nn[i].id, "span" + nn[i].id);
	    }
	}
	
	






},
subover:function(){var o=Tme.nav;if(o.timer)clearTimeout(o.timer)},
out:function(){
var o=Tme.nav;
if(o.xx)o.timer=setTimeout(o.stop,250)},
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.url=='' && a.collapsable == '0') return Tme.create('span',{innerHTML:a.label,className:'caption'},n,o)
	if(a.label=='--SEPARATOR--')return Tme.create('div',n,n,o)
	if(a.target=='_blank')return Tme.create('a',{href:a.url,target:'_blank',innerHTML:a.label,title:a.title},n,o)
	return Tme.create('a',{href:a.url,target:'_parent',innerHTML:a.label,title:a.title},n,o)
},
column:function(a)
{
    return a.column;
},
size:function(a)
{
    return a.size;
},
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)
},
CollapseOrExpand:function(hrefId, collapsableObjId){
    var o=Tme.nav;
    collapsableObj = o.doc.getElementById(collapsableObjId)
    href = o.doc.getElementById(hrefId);
    if(collapsableObj.style.display == '')
    {
        collapsableObj.style.display = 'none';
        href.className = "closed";
    }
    else
    {
        collapsableObj.style.display = '';
        href.className = "opened";
    }
 },
CreateChildren:function(parentTd, nn, o, column) {

    var collapsing = false;
	var collapsinglvl = 0;
	var _span;
	var _lastCreatedChild;
	
	for(i=0;i<nn.length;i++)
	{
	    if(o.column(nn[i]) == column)
	    {
            if(collapsing)
            {
                if(nn[i].level > collapsinglvl)
                {
                    _lastCreatedChild = _span.appendChild(o.item(nn[i]))
                    
                }
                else
                {
                    collapsing = false;
                }
            }
            
            if(!collapsing)
            {
                _lastCreatedChild = parentTd.appendChild(o.item(nn[i]))
                _lastCreatedChild.style.paddingLeft = nn[i].level * 5;
            }
            else
            {
                _lastCreatedChild.style.paddingLeft = nn[i].level * 5 + 15;
            }
            
            
                
            if(nn[i].collapsable == "1")
            {
                collapsing = true;
                collapsinglvl = nn[i].level;
                
                _span = parentTd.appendChild(Tme.create('span', null, null, o.doc));
                _span.className = "normalSpan";
                _span.id = "span" + nn[i].id;
                
                _lastCreatedChild.id = "href" +  nn[i].id;
                _lastCreatedChild.className = "opened";
                _lastCreatedChild.href = "javascript:Tme.nav.CollapseOrExpand('" + _lastCreatedChild.id + "','" + _span.id + "');";
                _lastCreatedChild.style.marginLeft = nn[i].level * 5;
                _lastCreatedChild.style.paddingLeft = 15;
            }
        }
	} 
 }
}