//browser check lite ------------------------------------->
var ie = (document.all)? true:false 
var ns4 = (document.layers)? true:false 
var ns6 = (document.addEventListener)? true:false
//-------------------------------------
toWrite='';
initx=158;
visLay = new Array();
if(ns4){
	visLay[0] = "show"; 
	visLay[1]=  "hide";
}else{
	visLay[0] = "visible"; 
	visLay[1]=  "hidden";
}
//fixed point for reposition of content layer----------
var IEFixedPoint=351
var NS4FixedPoint=360
var NS6FixedPoint=360
//-------------------------------------
function myCompare(a, b) {
	strA = a[0].toLowerCase();
	strB = b[0].toLowerCase();
	if (strA < strB) { return -1; }
	else {
		if (strA > strB) { return 1; }
		else { return 0; }
	}
}
//-------------------------------------
function create(){
	toWrite+='<div id="rubricaBox" style="position:absolute;top:180px;left:'+initx+'px;visibility:hidden;width:0px">\n';
	toWrite+='<table width="453" cellpadding="0" cellspacing="0" border="0">';
	toWrite+='\n<tr>\n\t<td></td>\n\t<td>\n\t\t<table width="453" cellpadding="0" cellspacing="0" border="0">\n<tr>'
	for (g=0;g<group.length;g++){
		toWrite+='\n\t<td align="center" width="70" Height="15" class="tabtop" valign="top" id="tabtop'+g+'"><a href="javascript:void(0);" onclick="showHide('+g+')">';
		for(l=0;l<group[g].length;l++){
			toWrite+=group[g][l]
		}
		toWrite+='</a></td>'
	}
	toWrite+='\n<td width="20" class="TRTop">&nbsp;</td>\n\t\t\t</tr>\n\t\t</table>\n\t</td>\n</tr>';
	
	for(g=0;g<group.length;g++){
		toWrite+='\n<tr>\n\t<td align="center" width="15" class="tab" valign="top" id="tab'+g+'"><a href="javascript:void(0);" onclick="showHide('+g+')">';
		for(l=0;l<group[g].length;l++){
			toWrite+=group[g][l]
			if(l != (group[g].length-1)){
				toWrite+='<br>';
			}
		}
		toWrite+='</a></td>\n'
		if(g==0){
			toWrite+='\t<td rowspan="'+group.length+1+'" valign="top" width="423" class="TRB">';
			toWrite+='<div id="spacer" style="position:relative;top:0px;left:0px;visibility:'+visLay[1]+';border:1px solid #FF0000;width:50px;heigth:50px;clip:rect(0,50,50,0);"></div></td>';
		}
		toWrite+='\n</tr>';
	}
	toWrite+='\n<tr><td height="100%" class="TR">&nbsp;</td></tr></table></div>';
	document.open();
	document.write(toWrite);
}
//-------------------------------------
function writeOrderDiv(){
	var l;
	divCodes = '';
	l = Members.sort(myCompare);
	for(r=0;r<group.length;r++){
		divCodes+='<div id="lTab'+r+'" style="position:absolute;top:0px;left:0px;visibility:'+visLay[1]+';">\n';
		divCodes+='<table width="423" cellpadding="0" cellspacing="0" border="0">\n<tr>';
		divCodes+='\n<td width="163" style="padding:4px 4px 4px 4px"><b>NAME</b></td>';
		divCodes+='\n<td width="128" style="padding:4px 4px 4px 4px"><b>E-MAIL</b></td>';
		divCodes+='\n</tr>\n<tr><td colspan="3" bgcolor="#000000"></td></tr>';
		var nameM;
		for(p=0;p<group[r].length;p++){
			for(i=0;i<Members.length;i++){
			nameM = Members[i][1];
			if (nameM=="Niccolo"){
				nameM = "Niccol&ograve;";
			}
			
					if(group[r][p]==Members[i][0].substring(0,1)){
						divCodes+='\n<tr>\n<td valign="top" style="padding:4px 4px 4px 4px"><a href="memb_'+Members[i][0].split(" ")[0].toLowerCase()+'_'+Members[i][1].toLowerCase().replace(/ /gi,"_")+'.html">'+Members[i][0]+'</a>, '+nameM+'</td>\n<td valign="top" style="padding:4px 4px 4px 4px"><a href="mailto:'+Members[i][2]+'">'+Members[i][2]+'</a></td></tr><tr>\n<td valign="top" style="padding:4px 4px 4px 4px" class="tdpractice" colspan="2"><b>PRACTICE AREAS</b><br>'+((Members[i][3]=="")?"&nbsp;":Members[i][3])+'<br><br><hr size="1" color="#234947"><br></td>\n</tr>';
					} 
			}					
		}
		divCodes+='\n</table>\n</div>\n';
	}
	sel=0;oldSel=0;
	document.write(divCodes);
	document.close();
	/*w2=window.open("","","")
	w2.document.open();
	w2.document.write(divCodes);
	w2.document.close();*/
}
//-------------------------------------
function showHide(selClick){
	if(ie){
		document.all["tab"+oldSel].className="tab";
		document.all["tab"+selClick].className="tabSel";
		document.all["tabtop"+oldSel].className="tabtop";
		document.all["tabtop"+selClick].className="tabtopSel";
		document.all["lTab"+oldSel].style.visibility=visLay[1];
		document.all["lTab"+selClick].style.visibility=visLay[0];
	}
	if (ns4){
		document.layers["lTab"+oldSel].visibility=visLay[1];
		document.layers["lTab"+selClick].visibility=visLay[0];
	}
	if (ns6){
		document.getElementById("tab"+oldSel).className="tab";
		document.getElementById("tab"+selClick).className="tabSel";
		document.getElementById("tabtop"+oldSel).className="tabtop";
		document.getElementById("tabtop"+selClick).className="tabtopSel";
		document.getElementById("lTab"+oldSel).style.visibility=visLay[1];
		document.getElementById("lTab"+selClick).style.visibility=visLay[0];
	}
	sel=selClick;
	oldSel=sel;
}
//-------------------------------------
function repNames(){
	maxWidth=0;
	maxHeight=0;
	for(r=0;r<group.length;r++){
		if (ie){
			
			document.all["lTab"+r].style.pixelLeft=document.all["rubricaBox"].style.pixelLeft+26;
			document.all["lTab"+r].style.pixelTop=document.all["rubricaBox"].style.pixelTop+30;
		}
		if (ns4){
			document.layers["lTab"+r].left=document.layers["rubricaBox"].left+26;
			document.layers["lTab"+r].top=document.layers["rubricaBox"].top+8;
		}
		if (ns6){
			indiceL=document.getElementById("rubricaBox").style.left.indexOf("p");
			indiceT=document.getElementById("rubricaBox").style.top.indexOf("p");
			document.getElementById("lTab"+r).style.left=Number(document.getElementById("rubricaBox").style.left.substring(0,indiceL))+26;
			document.getElementById("lTab"+r).style.top=Number(document.getElementById("rubricaBox").style.top.substring(0,indiceT))+8;
		}
	}
	for(r=0;r<group.length;r++){
		if (ie){
			if(document.all["lTab"+r].offsetHeight>maxHeight)maxHeight=document.all["lTab"+r].offsetHeight;
		}
		if (ns4){
			if(document.layers["lTab"+r].clip.height>maxHeight)maxHeight=document.layers["lTab"+r].clip.height;
		}
		if (ns6){
			if(document.getElementById("lTab"+r).offsetHeight>maxHeight)maxHeight=document.getElementById("lTab"+r).offsetHeight;
		}
	}
	if (ie){
		document.all["falsediv"].style.height=maxHeight+16;
		document.all["spacer"].style.height=maxHeight+16;
	}
	if(ns4){
		document.layers["rubricaBox"].document.layers["spacer"].clip.heigth=maxHeight+16;
		//document.layers["rubricaBox"].document.layers["spacer"].resizeTo(10,(maxHeight+16));
	}
	if (ns6){
		document.getElementById("falsediv").style.height=maxHeight+16;
		document.getElementById("spacer").style.height=maxHeight+16;
	}
	//document.layers["rubricaBox"].document.layers["spacer"]
}
//-------------------------------------
 function reposition(resvar){
	if(ie){
		HalfSize = document.body.clientWidth/2;
		if(HalfSize>370){document.all["rubricaBox"].style.pixelLeft = HalfSize + initx - IEFixedPoint}
		else{document.all["rubricaBox"].style.pixelLeft = initx}
		document.all["rubricaBox"].style.visibility = visLay[0];
	}
	if(ns4)
	{	
		if(resvar=="true"){			
			resvar="false";
			location.reload()			
		}
		HalfSize = window.innerWidth/2;
		if(HalfSize>370){
			document.layers["rubricaBox"].left = HalfSize + initx - NS4FixedPoint;
		}
		else{
			document.layers["rubricaBox"].left = initx
		}
		document.layers["rubricaBox"].visibility = visLay[0];
	}
	if(ns6)
	{
		HalfSize = window.innerWidth/2;
		if(HalfSize>370){document.getElementById("rubricaBox").style.left = HalfSize + initx - NS6FixedPoint}
		else{document.getElementById("rubricaBox").style.left = initx}
		document.getElementById("rubricaBox").style.visibility = visLay[0];
	}	
	repNames();
}