﻿function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function prepareInputsForHints() {
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++){
		// test to see if the hint span exists first
		if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
			// the span exists!  on focus, show the hint
			inputs[i].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			// when the cursor moves away from the field, hide the hint
			inputs[i].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
	// repeat the same tests as above for selects
	var selects = document.getElementsByTagName("select");
	for (var k=0; k<selects.length; k++){
		if (selects[k].parentNode.getElementsByTagName("span")[0]) {
			selects[k].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			selects[k].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
}
/*toggles show and hide*/
function showhide(id)
{ 
    if (document.getElementById)
    { 
        obj = document.getElementById(id); 
        if (obj.style.display == "none")
        { 
            obj.style.display = ""; 
        } 
        else 
        { 
            obj.style.display = "none"; 
        } 
    } 
} 
function showdiv(id)
{ 
    if (document.getElementById)
    { 
        obj = document.getElementById(id); 
        obj.style.display = ""; 
    } 
    else if (document.all)
    {
        obj = document.all[id];
        obj.style.display = ""; 
    }
    else if (document.layers)
    {
        obj = document.layers[id];
        obj.style.display = ""; 
    }
} 
function hidediv(id)
{ 
    if (document.getElementById)
    { 
        obj = document.getElementById(id); 
        obj.style.display = "none"; 
    } 
    else if (document.all)
    {
        obj = document.all[id];
        obj.style.display = "none"; 
    }
    else if (document.layers)
    {
        obj = document.layers[id];
        obj.style.display = "none"; 
    }
} 
/*
function hidediv(arg) 
{ 
    if (document.getElementById) 
    { // DOM3 = IE5, NS6 
        document.getElementById(arg).style.visibility = 'hidden'; 
    } 
    else 
    { 
        if (document.layers) 
        { // Netscape 4 
            document.hideShow.visibility = 'hidden'; 
        } 
        else 
        { // IE 4 
            document.all.hideShow.style.visibility = 'hidden'; 
        } 
    } 
}

function showdiv(arg) 
{ 
    if (document.getElementById) 
    { // DOM3 = IE5, NS6 
        document.getElementById(arg).style.visibility = 'visible'; 
    } 
    else 
    { 
        if (document.layers) 
        { // Netscape 4 
            document.hideShow.visibility = 'visible'; 
        } 
        else 
        { // IE 4 
            document.all.hideShow.style.visibility = 'visible'; 
        } 
    } 
} 
*/
function changeLocation(menuObj, arg1, arg2)
{
    obj = document.getElementById(arg1); 
    obj.style.display = "none";
    obj = document.getElementById(arg2); 
    obj.style.display = "none";

    var i = menuObj.options[menuObj.selectedIndex].value;
   
   switch(i)
    {
        case '13': case '14': case '15':
          /*show engine image*/
          if (document.getElementById)
            { 
                obj = document.getElementById(arg1); 
                obj.style.display = ""; 
            } 
          break;
        case '18': case '19': case '20': case '21': case '22':
          if (document.getElementById)
            { 
                obj = document.getElementById(arg2); 
                obj.style.display = ""; 
            } 
          break;
       default:
          /*hide engine and gearbox divs*/
          break;
    }
}