//FAC

function fac(){

this.drwbx=drawBox;
this.gobx=goBox;
this.cl=cenLay;
this.co=changeOpacity;
this.se=showElement;
this.he=hideElement;
this.sep=setElementPosition;
this.cb=cancelBox;
this.to=toObject;

	function drawBox(){
		strout=new String();
			strout+='<TABLE id="'+this.boxName+'" ALIGN=center BORDER=0 CELLPADDING=0 CELLSPACING=0 style="position:absolute;font-weight:bold;width:'+this.boxWidth+';height:'+this.boxHeight+';display:none;filter:alpha(opacity=100);-moz-opacity:1;font-size:10px">';
			strout+='<TR>';
			strout+='<TD background="../resources/images/graphics/fac/overLay_01.gif" WIDTH=18 HEIGHT=16>&nbsp;</TD>';
			strout+='<TD background="../resources/images/graphics/fac/overLay_02.gif" HEIGHT=16>&nbsp;</TD>';
			strout+='<TD background="../resources/images/graphics/fac/overLay_03.gif" WIDTH=15 HEIGHT=16>&nbsp;</TD>';
					
			strout+='</TR>';
			
			strout+='<TR>';
			strout+='<TD background="../resources/images/graphics/fac/overLay_04.gif" WIDTH=18>&nbsp;&nbsp;&nbsp;</TD>';
			strout+='<TD valign="top" align="center">';
			strout+='<div id="'+this.boxName+'_content" class="facPanel">';
			//strout+="loading...";
			strout+='</div>';
			strout+='<div align="left" id="data_content_caption" class="facPanelCaption"></div>';
			strout+='</TD>';
			strout+='<TD background="../resources/images/graphics/fac/overLay_06.gif" WIDTH=15>&nbsp;</TD>';
			strout+='</TR>';
			
			strout+='<TR>';
			strout+='<TD background="../resources/images/graphics/fac/overLay_07.gif" WIDTH=18 HEIGHT=16>&nbsp;</TD>';
			strout+='<TD background="../resources/images/graphics/fac/overLay_08.gif" HEIGHT=16>&nbsp;</TD>';
			strout+='<TD background="../resources/images/graphics/fac/overLay_09.gif" WIDTH=15 HEIGHT=16>&nbsp;</TD>';
			
			
			strout+='</TR>';
			strout+='</TABLE>';
			
		if(!this.dynamic){
			document.write(strout);
		}else{
			toObject(this.dynoContainer).innerHTML=strout;
		}
		
	}
	function goBox(imgName,imgIndex){
		
		lnkID=new String("lnk"+imgIndex);
		imgID=new String("img"+imgIndex);
		imgDivID=new String("imgDiv"+imgIndex);
		authorDivID=new String("authorDiv"+imgIndex);
		imgName=new String(imgName);
		contentStr=new String();
		contentStr+="<a href='javascript:"+this.objName+".cb()'><img src='../resources/images/graphics/fac/close_btn.jpg' border='0' align='right'></a><br><br>";
		contentStr+="<div style='text-align:left;font-weight:normal;'>"+document.getElementById(authorDivID).innerHTML+"</div><br>";
		contentStr+="<div align='center'><a href='javascript:"+this.objName+".cb()'><img src='../resize_image.aspx?file="+imgName+"&width=500&type=photoGallery' border='0' align='center'></a></div><br><div style='text-align:left;font-weight:normal'>"+document.getElementById(imgDivID).innerHTML+"</div>";

		this.boxContent=contentStr;

	 	this.co(this.boxName,100);
			
		this.co('mask',this.maskDensity);
			if(this.dynoContainer){
				this.to(this.dynoContainer).style.width=this.boxWidth;
				this.to(this.dynoContainer).style.height=this.boxHeight;
				this.se(this.dynoContainer);
				this.sep(this.dynoContainer);
			}else{
				this.sep(this.boxName);
			}
		this.se(this.boxName);
		this.se('mask');
		document.getElementById("overLayDiv_content").innerHTML=this.boxContent;
		//document.getElementById(lnkID).style.border="1px solid #ff0000";

		this.co(imgID,100);
		//if(document.getElementById("stepperDiv")){
		//document.getElementById("stepperDiv").style.display="none";
		//}
	
	}
	function setElementPosition(e){
		this.cl(e);
	}
	function cancelBox(){
	 	this.co('mask',0);
	 	this.to('mask').style.display="none";
		if(this.dynoContainer){
		this.he(this.dynoContainer);
		}else{
	 	this.he(this.boxName);
		}
		//if(document.getElementById("stepperDiv")){
		///document.getElementById("stepperDiv").style.display="";
		//}
	}
	function showElement(e){
		this.to(e).style.display="";
	}
	function hideElement(e){
		this.to(e).style.display="none";
	}
	function changeOpacity(e,v){
		if(document.all){
			this.to(e).filters.alpha.opacity=v;
		}
		if(!document.all && document.getElementById){
			this.to(e).style.MozOpacity=v/100;
		}
	}
	function toObject(e){
		eoID=new String(e);
		return document.getElementById(eoID);
	}
	function cenLay(l){ 

		var maskWidth,maskHeight;
		var thelayerw,thelayerh,thelayer;
		var newleft,newtop,scrTop;
	    var h,w,st; 

		maskWidth=0;
		maskHeight=0;
		
		thelayerw=0;
		thelayerh=0;
		thelayer=0;
		
		newtop=0;
		newleft=0;
		scrTop=0;
		
		h=0; 
	    w=0; 
		st=0;
		
	    if(document.compatMode == "CSS1Compat"){ 
	        //IE Standard mode 
	       w=document.body.parentNode.scrollWidth; 
	       h=(document.body.parentNode.scrollHeight<document.body.parentNode.clientHeight)?document.body.parentNode.clientHeight:document.body.parentNode.scrollHeight; 
		   st=document.body.parentNode.scrollTop;
		   
		   
	    }else{ 
	        //IE Quirks Mode 
	       w=document.body.scrollWidth; 
	       h=(document.body.scrollHeight<document.body.clientHeight)?document.body.clientHeight:document.body.scrollHeight; 
		   st=document.body.scrollTop;
		   
	    } 
	    if(w==0){ 
	        //Netscape 
	        w = window.innerWidth; 
	        h = window.innerHeight; 
			st=document.body.scrollTop;
	    } 

//alert(w+"-"+h+"-"+st);

		thelayer=this.to(l);
		
	    thelayerw = parseInt(thelayer.style.width);
		thelayerh = parseInt(thelayer.style.height);
		
		maskWidth=(thelayerw>w)?thelayerw:w;
		maskHeight=(thelayerh>h)?thelayerh:h;

	    //newleft= ((w/2)-(thelayerw/2)); 
	    //newtop= ((h/2)-(thelayerh/2));
	    
	    newleft= ((w/2)-(thelayerw/2)); 
	    newtop= st+125; //(((h-st)/2)-(thelayerh/2));
		
		newleft=(newleft <= 0)?0:newleft;
		newtop=(newtop <= 0)?0:newtop;
		
		//if(parseInt(this.boxYOffset)>0){
		//newtop=((thelayerh+st)<h)?(st+parseInt(this.boxYOffset)):newtop;
		//}

		thelayer.style.left=newleft+"px";
		thelayer.style.top=parseInt(newtop)+"px";
		
		this.to("mask").style.width=maskWidth+"px";
		this.to("mask").style.height=maskHeight+"px";

	}

}

 function OnWindowResize()
{
	if(document.getElementById("overLayDiv"))
	{
	// we only need to move the dialog based on scroll position if
	//   we're using a browser that doesn't support position: fixed, like < IE 7
	var left = window.XMLHttpRequest == null ? document.documentElement.scrollLeft : 0;
	var top = window.XMLHttpRequest == null ? document.documentElement.scrollTop : 0;
	var div = document.getElementById("overLayDiv");
	
	div.style.left = Math.max(((GetWindowWidth() - div.offsetWidth) / 2), 0) + 'px';
	div.style.top = Math.max(((GetWindowHeight() - div.offsetHeight) / 2), 0) + 'px';
	}
}


//window.onresize = OnWindowResize;

