var selectArray = new Array();

function dropDownClick(selectId) {
	for (var i = 0; i < selectArray.length; i++) {
		if (document.getElementById(selectArray[i][0] + "DropDown").style.visibility == "visible" && i != selectId)
			document.getElementById(selectArray[i][0] + "DropDown").style.visibility = "hidden";
	}
	firstTry = false;
	highlightOption(selectId, selectArray[selectId][2], false);
	document.getElementById(selectArray[selectId][0] + "Option" + selectArray[selectId][2]).style.cssText = selectArray[selectId][3];
	highlightOption(selectId, selectArray[selectId][1], true);
	
	if (document.getElementById(selectArray[selectId][0] + "DropDown").style.visibility == "") {
		document.getElementById(selectArray[selectId][0] + "DropDown").style.visibility = "hidden";
		document.getElementById(selectArray[selectId][0] + "DropDown").style.display = "none";
	}
		
	if (document.getElementById(selectArray[selectId][0] + "DropDown").style.visibility == "hidden") {
		document.getElementById(selectArray[selectId][0] + "DropDown").style.visibility = "visible";
		document.getElementById(selectArray[selectId][0] + "DropDown").style.display = "block";
	}
	else
		hideDropDown(selectId);
}

function hideDropDown(selectId) {
	if (selectId == null) {
		for (var i = 0; i < selectArray.length; i++) {
			if (document.getElementById(selectArray[i][0] + "DropDown").style.visibility == "visible" && !firstTry) {
				document.getElementById(selectArray[i][0] + "DropDown").style.visibility = "hidden";
				document.getElementById(selectArray[i][0] + "DropDown").style.display = "none";
			}
		}
	}
	else {
		if (document.getElementById(selectArray[selectId][0] + "DropDown").style.visibility == "visible" && !firstTry) {
			document.getElementById(selectArray[selectId][0] + "DropDown").style.visibility = "hidden";
			document.getElementById(selectArray[selectId][0] + "DropDown").style.display = "none";
		}
	}
	firstTry = false;

	showlogin(document.TheForm.selectvalue.value)
}

function highlightOption(selectId, index, highlight) 
{
	selected = document.getElementById(selectArray[selectId][0] + "Option" + index);
	
	if (highlight) {
		selectArray[selectId][2] = index;
		if (selectArray[selectId][3] == null)
			selectArray[selectId][3] = selected.style.cssText;
		selected.style.cssText = selectArray[selectId][3] + "; background: highlight; color: highlighttext";
	}
	else {
		if (selectArray[selectId][3] != null)
			selected.style.cssText = selectArray[selectId][3];
	}
}

function optionClick(selectId, id, field, value) {
	
	selectArray[selectId][1] = id;

	document.getElementById(field).value = value;
	if (selectArray[selectId][3] != null)
		document.getElementById(selectArray[selectId][0] + "Option" + selectArray[selectId][1]).style.cssText = selectArray[selectId][3];
	document.getElementById(selectArray[selectId][0] + "SelectedBox").innerHTML = document.getElementById(selectArray[selectId][0] + "Option" + selectArray[selectId][1]).innerHTML;
	highlightOption(selectId, id, true);
	hideDropDown(selectId);
}

function optionOver(selectId, id) {
	if (selectArray[selectId][2] != id) {
		highlightOption(selectId, selectArray[selectId][2], false);
		document.getElementById(selectArray[selectId][0] + "Option" + id).style.cssText = selectArray[selectId][3];
		selectArray[selectId][2] = id;
	}
	highlightOption(selectId, id, false);
	document.getElementById(selectArray[selectId][0] + "Option" + id).style.cssText = selectArray[selectId][3] + "; background: highlight; color: highlighttext";
}

function showlogin(clientid)
{
	vtype="0";
	for(fe=0;fe<ctx;fe++)
	{
		if(ArrayClientID[fe]==clientid)
		{
			vtype=ArrayClientLogin[fe];
			break;
		}
	}

	//if ((clientid==0)||(vtype==0))
	if ((clientid!=0)&&(vtype==0))
	{
		vdsp="<div><img src='images/spacer.gif' width='1' height='25'></div><div align='right'><a href='javascript:sendf()'><img src='images/bt_entrer.gif' width='74' height='22' border='0'></a></div>";
		SetDivValue("Div_Login", vdsp);
		vdsp="<div><img src='images/i_femme_01.jpg' width='253' height='232'></div><div><img src='images/i_femme_02.jpg' width='171' height='195'><img src='images/i_femme_03.jpg' width='82' height='195'></div>";
		SetDivValue("Div_AA", vdsp);
	}
	else
	{
		vdsp="<div><img src='images/spacer.gif' width='1' height='33'></div><div><img src='images/ti_identification.gif' width='255' height='17'></div><div><img src='images/spacer.gif' width='1' height='8'></div><table width='267' height='143' border='0' cellspacing='0' cellpadding='0' background='images/i_bgacces.gif'><tr valign='top'><td><div><img src='images/spacer.gif' width='1' height='40'></div><div><input name='username' type='text' size='40' maxlength='8' class='texte2' onBlur='ReplaceChar(this.value,this.name)' onKeyPress='entervalid()'></div><div><img src='images/spacer.gif' width='1' height='40'></div><div><input name='password' type='password' size='40' maxlength='8' class='texte2' onBlur='ReplaceChar(this.value,this.name)' onKeyPress='entervalid()'></div></td></tr></table><div><img src='images/spacer.gif' width='1' height='15'></div><div align='right'><a href='javascript:send();'><img src='images/bt_entrer.gif' width='74' height='22' border='0'></a></div>";
		SetDivValue("Div_Login", vdsp);
		vdsp="<div><img src='images/i_femme_01.jpg' width='253' height='232'></div><div><img src='images/i_femme_02.jpg' width='171' height='195'><img src='images/i_femme_03_acces.jpg' width='82' height='195'></div>";
		SetDivValue("Div_AA", vdsp);
	}
}

function showSelect(optionArray, id, java, width) {
	var selectId = selectArray.length;
	
	document.write("<span class=\"select\" id=\"" + id + "\" style=\"width: " + width + "px;\">\n");
	document.write("<table width=\"" + width + "\" class=\"selectTable\" cellspacing=\"0\" cellpadding=\"0\" onclick=\"javascript:dropDownClick('" + selectId + "');\" style=\"height: 21px;\"><tr><td class=\"selected\" id=\"" + id + "SelectedBox\">" + optionArray[0][0] + "</td><td align=\"center\" valign=\"middle\" class=\"button\" onMouseDown=\"javascript:this.style.border='2px inset buttonhighlight'\" onmouseup=\"javascript:this.style.border='2px outset buttonhighlight'\"><img src=\"images/i_dropDown.gif\" alt=\"\"></td></tr></table>\n");
	document.write("<div class=\"dropDown\" id=\"" + id + "DropDown\" style=\"width: " + width + "px; display: none;\">\n");
		
	for (var i = 0; i < optionArray.length; i++)
		document.write("<div id=\"" + id + "Option" + i + "\" onClick=\"javascript:optionClick('" + selectId + "', '" + i + "', '" + java + "', '" + optionArray[i][1] + "');\" onMouseOver=\"javascript:optionOver('" + selectId + "', '" + i + "');\" class=\"option\" style=\"" + optionArray[i][2] + "\">" + optionArray[i][0] + "</div>\n");

	document.write("</div>\n");
	document.write("</span>\n");
	document.getElementById(id + "DropDown").style.zIndex = 99;
	selectArray[selectId] = new Array();
	selectArray[selectId][0] = id;
	selectArray[selectId][1] = 0;
	selectArray[selectId][2] = 0;
	selectArray[selectId][3] = "";
	if (document.getElementById(java).value != "")
		optionClick(selectId, document.getElementById(java).value, java, document.getElementById(java).value);
}