// launch an event when DOM is loaded but images are not necessarily
window.oninit = function() {}
function init() {
	if (arguments.callee.done) return;
	arguments.callee.done = true;
	window.oninit();
};
if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", init, null);
}
window.onload = init;

window.blinksubInt = setTimeout("",1);
function blinksub(t) {
	var e = document.getElementById('submen');
	if (e) {
		e.style.display = (t)? 'block' : 'none';
		clearTimeout(window.blinksubInt);
		window.blinksubInt = setTimeout("blinksub(1)",300);
	}
}
oninit = function() {blinksub();}

var q;

function helper(file) {
window.open(file,'helper','width=350,height=450,scrollbars=1')
}


function sbg(id,img,left,m) {
  if (document.getElementById(id)) {
  a = document.getElementById(id).style;
  if (m == 1) a.background = 'url(../../_si/images/nav/img'+img+'.gif) no-repeat '+left+'px -19px';
  else a.background = 'url(../../_si/images/nav/img'+img+'.gif) no-repeat '+left+'px 0';
  }
}

function iet() {
//IE rendering bug bypass
document.getElementsByTagName('body')[0].style.display = 'none';
document.getElementsByTagName('body')[0].style.display = 'block';
  if (document.getElementById('leftnav')) {
  document.getElementById('leftnav').style.display = 'none';
  document.getElementById('leftnav').style.display = 'block';
  }
}


function tackle(obj) {
if (document.getElementById(obj)) obj = document.getElementById(obj);

if (obj.nextSibling) {

if(obj.nextSibling.nodeType == 3) s = obj.nextSibling.nextSibling;
else s = obj.nextSibling;

s.style.display = (s.style.display == 'none') ? 'block' : 'none';
   
  t = obj.parentNode.parentNode.parentNode.className;
  if (t.indexOf('parts1long') > -1 || t.indexOf('closedlo') > -1) {
  if (s.style.display == 'none') cClass(obj,'tackle parts1long closedlo');
  else cClass(obj,'tackle parts1long'); 
  }
    else {  
    if (s.style.display == 'none') cClass(obj,'tackle closed');  
    else cClass(obj,'tackle parts1');
    }

  //IE rendering bug bypass
  if (document.all && (s.style.display == 'block')) iet();

}

 else alert('DEBUG!\nwrong parameter!\nfuction: tackle()\nfile: nav.js');
  
}


function tackle3(obj) {

if (document.getElementById(obj)) obj = document.getElementById(obj);

if (obj.parentNode) {

var e,p,r;

o = obj.parentNode;
ho = o.parentNode.parentNode;
cName = 'active';

  if (o.parentNode && o.parentNode.childNodes) {

    for (var i=0;i<o.parentNode.childNodes.length;i++) {
      e = o.parentNode.childNodes[i];
      if (e.className == 'active') p = i;
      if (e.tagName == o.tagName) {
        e.className = e.className.replace(cName,'');
        if (e==o)  e.className += ''+cName;
      }
      if (e.className == 'active') r = i;
    }
    if (p == r) ho.className = (ho.className == 'tackle parts3') ? 'closed3' : 'tackle parts3';
    else ho.className = 'tackle parts3';

    //IE rendering bug bypass
    if (document.all && (ho.className == 'tackle parts3')) iet();

    return false;
  }
  return true;

}

 else alert('DEBUG!\nwrong parameter!\nfuction: tackle3()\nfile: nav.js');
}


function cClass(obj,cName) {
obj = obj.parentNode.parentNode.parentNode;
p = obj.className.substring(0,obj.className.lastIndexOf(' '));
  if (p == '') obj.className += ' '+cName;
  else obj.className = cName;
}


function rateit(what) {
  var rform = document.forms['ratingform'].C_Rate.value;
  if(rform==what) {
    document.getElementById('rate'+what).src = '/_common/images/tools/rating/'+what+'_rating.gif';
    document.forms['ratingform'].C_Rate.value = '';
    return;
  }
  for (var i=1; i<6; i++) {
    if (what == i) {
    document.getElementById('rate'+i).src = '/_common/images/tools/rating/'+i+'_rating_on.gif';
    document.forms['ratingform'].C_Rate.value = i;
    }
      else {
      document.getElementById('rate'+i).src = '/_common/images/tools/rating/'+i+'_rating.gif';
      }
  }
}


function showme(visid) {
  if (!document.layers) {
    w3div = document.getElementById('child'+visid);
    if(!w3div) return;
    if (w3div.style.display == 'block' || w3div.style.display == 'inline') {
      w3div.style.display = 'none';
      w3div.style.visible = 'false';
      //document.getElementById('img'+visid).src = '/_common/images/tools/nav/plus.gif';
    } else {
      w3div.style.visible = 'true';
      if (!document.all) w3div.style.display='inline';
      else w3div.style.display='block';
      //document.getElementById('img'+visid).src = '/_common/images/tools/nav/minus.gif';
    }

    /*
    if (lastopen != '' && (visid != lastopen)) {
      w3div2 = document.getElementById('child'+lastopen);
      w3div2.style.display = 'none';
      w3div2.style.visible = 'false';
      document.getElementById('img'+lastopen).src = '/_common/images/tools/nav/plus.gif';
    }

    lastopen = visid;
    */

  }
}


function shopenImage(fn,w,h){
  if(!w)  w=100;
  if(!h) h = 130;
    var screenW = screen.width-100;
    var screenH = screen.height-100;
    if(screenW && w>screenW) w=screenW-100;
    if(screenH && h>screenH) h=screenH-100;
    fn=fn+'&w='+w+'&h='+h;
    w=w-(-50);
    h=h-(-60);
    //alert('width='+(w)+',height='+(h)+',scrollbars=0,menu=0,toolbar=0,status=0')
    window.open(fn,'image','width='+(w)+',height='+(h)+',scrollbars=0,menu=0,toolbar=0,status=0');

}
/*
function abc() {
  if (document.selection) {document.selection.empty();return false;}
  else if (window.getSelection) {window.getSelection().removeAllRanges();return false;}
}*/

function scrollstart(o,s,h) {
  o.id = 'currentlyscrolling';
  o.sd = new Object();
  o.sd.speed = s;
  o.sd.hitArea = h/4;
  o.sd.maxScroll = h-o.offsetHeight;
  if (!o.style.top) o.style.top = o.offsetTop+'px';
  o.onmousemove = scrollmodify;
}
function scrollmodify(e) {
  if (!this.sd) return;
  if (!e) e = window.event;
  var t = parseInt(this.style.top);
  var y = (e.layerY)? e.layerY : e.offsetY;
  if (y < this.sd.hitArea-t) {
    this.sd.d = this.sd.speed*(((this.sd.hitArea-t)-y)/this.sd.hitArea);
  } else if (y > this.sd.hitArea*3-t) {
    this.sd.d = this.sd.speed*(((this.sd.hitArea*3-t)-y)/this.sd.hitArea);
  } else {
    this.sd.d = 0;
  }
  if (this.sd.d && !this.sd.t) {
    this.sd.t = setInterval("scroll('currentlyscrolling')",20);
  }
}
function scrollstop(o) {
  if (!o.sd) return;
  if (o.sd.t) clearTimeout(o.sd.t);
  o.sd = null;
  o.id = null;
}
function scroll(id) {
  var o = document.getElementById(id);
  if (!o.sd || !o.sd.d) return;
  var y = parseInt(o.style.top) + o.sd.d;
  if (o.sd.d<0 && y<=o.sd.maxScroll) {
    y = o.sd.maxScroll;
    o.sd.d = 0;
  }  else if (o.sd.d>0 && y>=0) {
    y = 0;
    o.sd.d = 0;
  }
  o.style.top = y+'px';
  if (o.sd.d==0) {
    clearInterval(o.sd.t);
    o.sd.t = null;
  }
}
