// JavaScript Document
function getobj(oid){
	var obj = new Object();
	try{
		obj = document.getElementById(oid);
	}catch(e){
		alert("no such object");
		return;
	}
	return obj;
}

function high(obj){
	var oobj = obj;
	theobj = oobj;
	oobj.hlt=setInterval("highlightit(theobj)",50);
}

function low(obj){
	var shouldDarken = true;
	var oobj = obj;
	if(oobj.objGroup.length>1){
		//alert("need to think of group effect");
		if(theobj){
			var ids = theobj.objGroup.join(",");
			if(theobj.objGroup[0]!=oobj.objGroup[0]&&ids.indexOf(oobj.id)!=-1){
				//document.title = "we are not the same but we are in one group" + new Date().getSeconds();
				shouldDarken = false;
			}else{
				//document.title = "we are not in the same group" + new Date().getSeconds()+">me:"+oobj.objGroup[0]+", theobj:"+theobj.objGroup[0]+",shouldDarken:"+shouldDarken;
			}
		}
	}
	if(shouldDarken){
		//clearInterval(hlt);
		//clearTimeout(hlt);
		try{
			//IE
			for(var i = 0;i<oobj.objGroup.length;i++){
				document.getElementById(oobj.objGroup[i]).filters.alpha.opacity = 70;
				document.getElementById(oobj.objGroup[i]).filters.alpha.finishOpacity = 70;		
			}
		}catch(e){
			//Firefox
			for(var i = 0;i<oobj.objGroup.length;i++){
				document.getElementById(oobj.objGroup[i]).style.opacity = 0.7;
			}
		}
	}
	//if(oobj.hlt)
	clearInterval(oobj.hlt);
}

function highlightit(obj){
	var oobj = obj;
	//alert(oobj.filters.alpha.opacity);
	try{
		//IE
		if(oobj.filters.alpha.opacity<100){
			for(var i=0;i<oobj.objGroup.length;i++){
				document.getElementById(oobj.objGroup[i]).filters.alpha.opacity = parseInt(oobj.filters.alpha.opacity) + 10;
				document.getElementById(oobj.objGroup[i]).filters.alpha.finishOpacity = parseInt(oobj.filters.alpha.finishOpacity) + 10;
			}
		}else{
			clearInterval(obj.hlt);
		}
	}catch(e){
		//Firefox
		if(parseFloat(oobj.style.opacity)<1){
			for(var i=0;i<oobj.objGroup.length;i++){
				document.getElementById(oobj.objGroup[i]).style.opacity = parseFloat(oobj.style.opacity) + 0.1;
			}
		}else{
			clearInterval(obj.hlt);
		}
	}
}

function adjustPicScale(w){
  var statchanged=false;
  var imgObj=document.images;
  for(i in imgObj){
    if (parseInt(imgObj[i].width)>w){
      var ow=parseInt(imgObj[i].width);
      var oh=parseInt(imgObj[i].height);
      nh = parseInt(w*oh/ow);
      imgObj[i].width = w;
      imgObj[i].height = nh;
      statchanged=true;
    }
  }
  if(statchanged)setTimeout("adjustPicScale(590)",1500);
}

var theobj;

var tds = document.getElementsByTagName("td");
var p = 0;
for(var i=1;i<tds.length;i++){
	if(tds[i].id.indexOf("btn")!=-1){
		tds[i].objGroup = new Array();
		tds[i].objGroup.push(tds[i].id);
		var curId = tds[i].id;
		var curIdInit = tds[i].id.slice(0,5);
		//alert(curIdInit);
		var tds2 = document.getElementsByTagName("td");
		for(var g=1;g<tds2.length;g++){
			if(tds2[g].id.slice(0,5)==curIdInit&&tds2[g].id!=curId){
				tds[i].objGroup.push(tds2[g].id);
			}
		}
		//alert(++p + tds[i].id + " has friend and itself:\n" + tds[i].objGroup);
		tds[i].hlt = new Object();
		tds[i].onmouseover = function(){high(this)};
		//tds[i].onmouseout = function(){low(this)};
		tds[i].onmouseout = function(){setTimeout("low(document.getElementById('" + this.id + "'))",0);};
		low(tds[i]);
	}
}
