var selOpened = null;

/**
 * returns the chosen field
 */
function getSelected(tag){
	a = eval("document.all."+tag+"O");
	return a.innerHTML;
}

function closeOpened(tag){

	if(tag!='true' && selOpened!=null){
		TOId = eval("document.all."+selOpened+"Options");
		TOId.style.visibility = 'hidden';
		selOpened = null;
	}
}

function showIt(tag,correct){
	if(selOpened!=null && selOpened!=tag){
		TOId = eval("document.all."+selOpened+"Options");
		TOId.style.visibility = 'hidden';
		selOpened = null;
	}
	Tid = eval("document.all."+tag);
	TOId = eval("document.all."+tag+"Options");
	if(TOId.style.visibility != 'visible'){
		topi = Tid.offsetTop;
		lefti = Tid.offsetLeft;
		if(correct==0)
			TOId.style.top = topi+10;
		else{
			TOId.style.top = topi+10+correct;
		}
		TOId.style.left = lefti;
		TOId.style.visibility = 'visible';
		selOpened = tag;
	}
	else{
		TOId.style.visibility = 'hidden';
		selOpened = null;
	}
}

function choose(tag,opt,inputCell,value){
	a = eval("document.all."+tag+"O");
	a.innerHTML = opt;	
	TOId = eval("document.all."+tag+"Options");
	TOId.style.visibility = 'hidden';
	eval(inputCell).value = value;
	selOpened = null;
	document.Form1.submit();
}

/**
 * @param correct is the upper-lower correction of the opening frame
 */
function makeSelect(options,values, tag, correct, inputCell,bodySelect){
	document.write("<table border='0' cellspacing='0' cellpadding='0' ");
	if(bodySelect){
		document.write("class='selectbOuter2' ");
	}
	else{
		document.write("class='selectbOuter' ");
	}
	document.write("scrl=true id='"+tag+"' onclick=showIt('"+tag+"',"+correct+") style='cursor:default'>");
	document.write("<tr><td class='selectbText' height='12' width='2' scrl=true><img src='pix/pix.gif' width='6' height='1' scrl=true></td>");
	document.write("<td class='selectbText' height='12' id='"+tag+"O' scrl=true>"+options[0]+"</td>");
	document.write("<td class='selectbText' height='12' width='2' scrl=true><img scrl=true src='pix/pix.gif' width='4' height='1' style='position:relative;top:2;'></td>");
	document.write("<td class='selectbText' height='12' width='9' scrl=true><img scrl=true src='pix/SelectArrow.gif' width='7' height='4' border='0'></td>");
	document.write("</tr></table>");
	document.write("<div style='position:absolute;top:0;left:0;visibility:hidden;z-index:10;' id='"+tag+"Options'>");
	document.write("<table border='0' cellspacing='0' cellpadding='0' class='selectb' bgcolor='#FFFFFF'>");
	for(i=0;i<options.length;i++){
		document.write("<tr><td class='selectbText' height='12' width='2'><img src='pix/pix.gif' width='5' height='1'></td>");
		document.write("<td class='selectbText' height='12' ><nobr><a href=javascript:choose('"+tag+"','"+options[i]+"',"+inputCell+",'"+values[i]+"') class='selectbText'>"+options[i]+"</a></nobr></td>");
		document.write("<td class='selectbText' height='12' width='2'><img src='pix/pix.gif' width='10' height='1'></td></tr>");
	}
	document.write("</table></div>");
}

