var vodeCodes = ['105','107','115','117','125','127','135','137','165','167','205','207','215','217','305','307','405','407','413','415','417','505','507','805','807'];

var vodeCodeTitles = ['105 - Modular Light Rail System','107 - Modular Light Rail System','115 - MLR Sidekick System','117 - MLR Sidekick System','125 - MLR Worklight','127 - MLR Worklight','135 - MLR Monopoint','137 - MLR Monopoint','165 - MLR Bus System','167 - MLR Bus System','205 - Sconce/Pendant','207 - Sconce/Pendant','215 - Sconce/Pendant','217 - Sconce/Pendant','305 - Monopoint','307 - Monopoint','405 - Monopoint System','407 - Monopoint System','413 - Monopoint System','415 - Monopoint System','417 - Monopoint System','505 - Desk Light','507 - Desk Light','805 - Floor Light','807 - Floor Light'];

var vodeCodeLinks = ['mlr-system.html','mlr-system.html','mlr-sidekick-system.html','mlr-sidekick-system.html','mlr-worklight.html','mlr-worklight.html','mlr-monopoint.html','mlr-monopoint.html','mlr-bus-system.html','mlr-bus-system.html','200-series.html','200-series.html','200-series.html','200-series.html','300-series.html','300-series.html','400-series.html','400-series.html','400-series.html','400-series.html','400-series.html','500-series.html','500-series.html','800-series.html','800-series.html'];

var vodeCodeShowing = false;

function vodeCodeClear(obj) {
	obj.value='';
	obj.style.color='#888';
	var b = document.getElementById('vode_code_list');
	b.style.display='none';
	vodeCodeShowing = false;
}
function vodeCodeHide(e) {
	var clicked = null;
	if (e)
		clicked = e.target;
	else
		clicked = window.event.srcElement;

	if (clicked.id == 'vode_code_submit' || clicked.id == 'vode_code_input')
		return;

	var b = document.getElementById('vode_code_list');
	b.style.display='none';
	vodeCodeShowing = false;
	document.getElementById('vode_code_input').value = 'enter VodeCode';
}
function vodeCodeListAdd(obj, num, link) {
	obj.innerHTML += "<a href='"+link+"'>"+num+"</a><br>";
}
function vodeCodeList(obj) {
	var b = document.getElementById('vode_code_list');
	b.innerHTML = "";
	var c = obj.value;
	var f = false;
	for (var i = 0; i < vodeCodes.length; i++) {
		 if (vodeCodes[i].indexOf(c) == 0){
			 vodeCodeListAdd(b, vodeCodeTitles[i], vodeCodeLinks[i]);
			 f = true;
		 }
	}
	if (f) {
		b.style.display='block';
		vodeCodeShowing = true;
		obj.style.color='#888';
	}
	else {
		b.style.display='none';
		vodeCodeShowing = false;
		if (c.length > 0)
			obj.style.color='red';
		else
			obj.style.color='#888';
	}
}
function vodeCodeFillList() {
	var b = document.getElementById('vode_code_list');
	if (vodeCodeShowing) {
		b.style.display='none';
		vodeCodeShowing = false;
		document.getElementById('vode_code_input').value = 'enter VodeCode';
		return;
	}
	b.innerHTML = "";
	for (var i = 0; i < vodeCodes.length; i++) {
		vodeCodeListAdd(b, vodeCodeTitles[i], vodeCodeLinks[i]);
	}
	b.style.display='block';
	vodeCodeShowing = true;
}

// when editorloaded is undefined then we can activate the vodecodehide function onclick
try {
	if (editorloaded){}
}
catch(e){document.onclick = vodeCodeHide;}
