var ns=document.all?false:true;
var rel_x=220;
var rel_y=200;
var relationsArray=new Array();

function oRelated(obj,title,reflayer){
	relationsArray[relationsArray.length]=obj;
	this.obj=obj;
	this.title=title;
	this.reflayer=reflayer;

	if(ns){
		this.x=document.layers[this.reflayer].pageX;
		this.y=document.layers[this.reflayer].pageY;
	}else{
		this.x=getLeft(document.all[this.reflayer]);
		this.y=getTop(document.all[this.reflayer]);
	}
	if(relationsArray.length>1){
		tempObj=relationsArray[relationsArray.length-2];
		tempY=((eval(tempObj+".rel.length")+2)*17)+eval(tempObj+".y");
		if(this.y<tempY){
			this.y=tempY;
		}
	}
	
	this.addrel=rel_addrel;
	this.addsub_to_lastrel=rel_addsub_to_lastrel;
	this.create=rel_create;
	
	this.rel=new Array();
	this.active_rel=0;
	this.l=null;
}

function rel_addrel(name){
	this.active_rel=this.rel.length;
	this.rel[this.active_rel]=new rel_oRel(this.active_rel,name);
}

function rel_oRel(id,name){
	this.id=id;
	this.name=name;

	this.subrel=new Array();
	this.show=rel_show;
	this.hide=rel_hide;
}

function rel_show(obj){
	this.l.visibility=ns?'show':'visible';
	if(ns){
		obj.l.document.images[obj.obj+"_img"+this.id].src=server+"images/downarrow_pressed.gif";
	}else{
		document.all[obj.obj+"_img"+this.id].src=server+"images/downarrow_pressed.gif";
	}
}
function rel_hide(obj){
	this.l.visibility=ns?'hide':'hidden';
	if(ns){
		obj.l.document.images[obj.obj+"_img"+this.id].src=server+"images/downarrow_unpressed.gif";
	}else{
		document.all[obj.obj+"_img"+this.id].src=server+"images/downarrow_unpressed.gif";
	}
}

function rel_addsub_to_lastrel(name,url){
	id=this.rel[this.active_rel].subrel.length;
	this.rel[this.active_rel].subrel[id]=new rel_oSubRel(id,name,url);
}

function rel_oSubRel(id,name,url){
	this.id=id;
	this.name=name;
	this.url=url;
}

function rel_create(){
	temp="";
	for(var a=0;a<this.rel.length;a++){
		temp+='<a href="Javascript:'+this.obj+'.rel['+a+'].show('+this.obj+');"><img src="'+server+'images/downarrow_unpressed.gif" width="16" height="11" align="top" border="0" hspace="4" vspace="3" name="'+this.obj+'_img'+a+'">'+this.rel[a].name+'</a><br>';
	}
	this.l=rel_createLayer(this.obj+"_layer",this.x,this.y,'<span class="rel"><b>'+this.title+'</b><br><nobr>'+temp+'</nobr></span>',300,400);
	this.l.visibility=ns?'show':'visible';
	for(var a=0;a<this.rel.length;a++){
		temp='<table border=0 cellpadding=1 cellspacing=0 width="320"><tr><td bgcolor="#999933"><table border=0 cellspacing=0 cellpadding=1 width="100%"><tr><td bgcolor="#cccc99" align="right" colspan="2"><a href="Javascript:'+this.obj+'.rel['+a+'].hide('+this.obj+');"><img src="'+server+'images/close_icon.gif" border=0></a></td></tr>';
		temp+='<tr><td bgcolor="#ffffff" width="10"><img src="'+server+'images/pix.gif" width="10" height="1" alt="" border="0"></td><td bgcolor="#ffffff" class="main" width="313">&nbsp;</td></tr>';
		temp+='<tr><td bgcolor="#ffffff" width="10"><img src="'+server+'images/pix.gif" width="10" height="1" alt="" border="0"></td><td bgcolor="#ffffff" class="rel" width="313"><b>'+this.rel[a].name+'</b></td></tr>';		
		for(b=0;b<this.rel[a].subrel.length;b++){
			if(this.rel[a].subrel[b].url.length!=0){
				temp+='<tr><td bgcolor="#ffffff" width="10"><img src="'+server+'images/pix.gif" width="10" height="1" alt="" border="0"></td><td bgcolor="#ffffff" width="313"><a href="'+this.rel[a].subrel[b].url+'">'+this.rel[a].subrel[b].name+'</a></td></tr>';
			}else{
				temp+='<tr><td bgcolor="#ffffff" width="10"><img src="'+server+'images/pix.gif" width="10" height="1" alt="" border="0"></td><td bgcolor="#ffffff" width="313"><b>'+this.rel[a].subrel[b].name+'</b></td></tr>';
			}
		}
		temp+='<tr><td bgcolor="#ffffff" width="10"><img src="'+server+'images/pix.gif" width="10" height="1" alt="" border="0"></td><td bgcolor="#ffffff" class="main" width="313">&nbsp;</td></tr>';
		temp+='</table></td></tr></table>';
		this.rel[a].l=rel_createLayer(this.obj+'_'+a,rel_x,rel_y,temp,320,400);
	}
}

/************************function createLayer START**************************************/
function rel_createLayer(name,x,y,text,width,height){
	if(ns){
		document.layers[name]=new Layer(width);
		document.layers[name].document.open();
		document.layers[name].document.write(text);
		document.layers[name].document.close();
		document.layers[name].resizeTo(width,height);
		document.layers[name].moveTo(x,y);
		document.layers[name].visibility='hide';
		return document.layers[name];
	}else{
		document.body.insertAdjacentHTML('BeforeEnd','<div id="'+name+'" style="position:absolute;width:'+width+';height:'+height+';top:'+y+';left:'+x+';visibility:hidden;">'+text+'</div>');
		return document.all[name].style;
	}
}
/************************function createLayer END**************************************/
function getTop(object){
	if(object.tagName=="BODY"){
		return object.clientTop;
	}else{
		return object.offsetTop+getTop(object.offsetParent);
	} 
}
function getLeft(object){
	if(object.tagName=="BODY"){
		return object.clientLeft;
	}else{
		return object.offsetLeft+getLeft(object.offsetParent);
	} 
}


