﻿var tmr;
var mbValues=new Array();
var mbannerheight=1;
var mbannerdir=1;
var mbannertmr;
var mbannerinterval=5;
var ShadeOverlap=110;

function parentdoc()
{
	var doc=document;
	if(parent.parent.parent.document)
	{
		doc=parent.parent.parent.document;
	}
	else
	{
		if(parent.parent.document)
		{
			doc=parent.parent.document;
		}
		else
		{
			if(parent.document)
			{
				doc=parent.document;
			}
		}
	}
	return doc;
}
function truebody()
{
    return (!window.opera && parentdoc().compatMode && parentdoc().compatMode!="BackCompat")? parentdoc().documentElement : parentdoc().body
}
function scrollto(id)
{
	var g=parentdoc().getElementById(id);
	var curLeft=0;
	var curTop=0;
	if(g)
	{
		if(g.offsetParent) 
		{
			while(g)
			{
				curLeft += g.offsetLeft;
				curTop += g.offsetTop;
				g = g.offsetParent;
			}
		}
		else
		{
			curTop=g.offsetTop;
		}
		window.scrollTo(0,curTop);
	}
}
function getDocHeight()
{
	var height=0;
	if( self.innerHeight  && 1==2) 
	{
		height = self.innerHeight;
	} 
	else if( parentdoc().documentElement && parentdoc().documentElement.clientHeight ) 
	{
		height = parentdoc().documentElement.clientHeight;
	} 
	if( parentdoc().body ) 
	{
		height = parentdoc().body.clientHeight;
	}

	return height;
}
function getDocWidth()
{
	var docwidth=parentdoc().all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15;
	var tst=new String;

	return docwidth;
}
function ShowDivCenter(id, height, width, topOffset)
{
	var scrolledX, scrolledY;

	if( self.pageYOffset  && 1==2) 
	{
		scrolledX = self.pageXOffset;
		scrolledY = self.pageYOffset;
	} 
	else if( parentdoc().documentElement && parentdoc().documentElement.scrollTop ) 
	{
		scrolledX = parentdoc().documentElement.scrollLeft;
		scrolledY = parentdoc().documentElement.scrollTop;
	} 
	else if( parentdoc().body ) 
	{
		scrolledX = parentdoc().body.scrollLeft;
		scrolledY = parentdoc().body.scrollTop;
	}

	var centerX, centerY;
	if( self.innerHeight && 1==2) 
	{
		centerX = self.innerWidth;
		centerY = self.innerHeight;
	} 
	else if( parentdoc().documentElement && parentdoc().documentElement.clientHeight ) 
	{
		centerX = parentdoc().documentElement.clientWidth;
		centerY = parentdoc().documentElement.clientHeight;
	} 
	else if( parentdoc().body ) 
	{
		centerX = parentdoc().body.clientWidth;
		centerY = parentdoc().body.clientHeight;
	}

	var cw = scrolledX + (centerX - width) / 2;
	var ch = scrolledY + (centerY - height) / 2;
	
	if(ch + topOffset>10){ch=ch+topOffset;}

	showdivpos(id,ch,cw);
}
function hidediv(div)
{
	var sd=parentdoc().getElementById(div);
	if(sd)
	{
		sd.style.visibility="hidden";
		//sd.style.display="block";
		sd.style.overflow="hidden";
		sd.style.height="1px";
		//sd.style.position="absolute";
	}
}
function showdiv(div)
{
	var sd=parentdoc().getElementById(div);
	if(sd)
	{
		sd.style.visibility="visible";
		//sd.style.display="inline";
		sd.style.overflow="";
		sd.style.height="";
		sd.style.position="";
	}
}
function showdivpos(div,t,l)
{
	var sd=parentdoc().getElementById(div);
	if(sd)
	{
		showdiv(div);
		sd.style.position="absolute";
		sd.style.display="block";
        sd.style.left=l+"px";
        sd.style.top=t+"px";
	}
}
function showWait(caption)
{
	ShowDivCenter("await",110,130,-100);
	var sd=parentdoc().getElementById("await");
	sd.innerHTML='<div class="r"><img src="/i/tb/close.gif" alt="Close" title="Close" width="19" height="19" class="cb" onclick="hideWait();"></div><img src="/i/jccswait.gif" alt="' 
		+ caption + '" title="' + caption + '" width="32" height="32"><br /><br />'+ caption;
	sd.style.height="110px";
	sd.style.width="130px";
}
function hideWait()
{
	hidediv("await");
	var sd=parentdoc().getElementById("await");
	sd.innerHTML='';
}
function showError(id)
{
	var sd=parentdoc().getElementById(id);
	if(sd)
	{
		showdiv(id);
		sd.innerHTML='<img src="/i/exclaim.gif" height="16" width="16" alt="Error in Field" title="Error in Field" />';
	}
}
function ProcessErrors(flds,stats,caption,msg)
{
	for(l=0;l<flds.length;l++)
	{
		if(stats[l]=="1")
		{
			showError("e" +flds[l]);
		}
	}
	MessageBox(caption,msg);
}
function MessageBox(caption,msg,returnFunc,delay,width,height,ShowButtons)
{
	if(ShowButtons==null)
	{
		ShowButtons=true;
	}
	MessageBoxPop(caption,msg,returnFunc,delay,width,height,1,ShowButtons);
}
function MessageBox2(caption,msg,returnFunc,delay,width,height,ShowButtons)
{
	if(ShowButtons==null)
	{
		ShowButtons=true;
	}
	MessageBoxPop(caption,msg,returnFunc,delay,width,height,2,ShowButtons);
}
function MessageBoxPop(caption,msg,returnFunc,delay,width,height,lvl,ShowButtons)
{
	var curtainid="curt1";
	var msgid="msg1";
	if(width==null)
	{
		width=300;
	}
	if(height==null)
	{
		height=200;
	}
	mbValues=new Array();
	var boxDelay=9000;
	if(delay!=null)
	{
		boxDelay=delay;
	}
	var sd;

	if(lvl!=1)
	{
		curtainid="curt2";
		msgid="msg2";
	}
	sd=parentdoc().getElementById(msgid);

	var ClickFunc='if(tmr){clearTimeout(tmr);} hidediv(' + "'" + msgid + "'" + ');parentdoc().getElementById(' + "'" + curtainid + "'" + ').style.visibility=' + "'hidden'" + ';';
	var ClickOKFunc='';
	var ClickCancelFunc='';
	
	while(msg.indexOf('term;')>0)
	{
		ShowButtons=false;
		msg=msg.replace('term;',ClickFunc);
	}
	
	if(ShowButtons)
	{
		if(returnFunc)
		{
			if(returnFunc.length>1)
			{
				ClickOKFunc=returnFunc + "(1);";
				ClickCancelFunc=returnFunc + "(0);";
			}
		}
	}

	sd.style.height=height + "px";
	sd.style.width=width + "px";
	sd.style.overflow="hidden";
	

	
	var bdy='<div class="colr" style="padding:3px;"><img src="/i/tb/close.gif" alt="Close" title="Close" width="19" height="19" class="cb" onclick="clearTimeout(tmr);hidediv(' 
		+ "'" + msgid + "'" + ');parentdoc().getElementById(' 
		+ "'" + curtainid + "'" + ').style.visibility=' + "'hidden'" + ';"></div>';
	bdy+='<div style="background-color:#8db1ff;color:#000000;font-size:larger;padding:3px;border-bottom:1px solid #000000;">' + caption + '</div>';
	bdy+='<div style="padding:3px;overflow:auto;width:' + (width-10) + 'px;height:' + (height-90) + 'px;">' + msg + '</div><br/>';
	if(ShowButtons)
	{
		bdy+='<div class="c"><input type="button" value="  OK  " class="button" onclick="' + ClickFunc + ClickOKFunc + ';" />&nbsp;&nbsp;'
		bdy+='<input type="button" value=" Cancel " class="button" onclick="' + ClickFunc + ClickCancelFunc + ';" />';
		bdy+='</div><br/>';
	}
	sd.innerHTML=bdy;

	
	hideWait();
	
	
	parentdoc().getElementById(curtainid).style.height=(getDocHeight()+ShadeOverlap) + "px";  // +45 = height of Google Bar
	parentdoc().getElementById(curtainid).style.visibility="visible";
	
	ShowDivCenter(msgid,height,width,0);
	
	if(boxDelay>0)
	{
		tmr=setTimeout('hidediv(' + "'" + msgid + "'" + ');parentdoc().getElementById(' + "'" + curtainid + "'" + ').style.visibility="hidden";',boxDelay);
	}
	
	if(document.getElementsByName("fcs001")[0])
	{
		document.getElementsByName("fcs001")[0].focus();
	}
}

function CloseMessageBox(boxnumber)
{
	if(!boxnumber)
	{
		boxnumber=1;
	}
	clearTimeout(tmr);
	hidediv("msg" +  boxnumber);
	
	parentdoc().getElementById("curt" +  boxnumber).style.visibility="hidden";
}
function getValue(id)
{
	var returnValue="";
	
	var g=parentdoc().getElementById(id);
	if(g)
	{
		var idType=g.type;
		if(idType)
		{
			if(idType=="text" || idType=="hidden" || idType=="password" || idType=="textarea")
			{
				returnValue=g.value;
			}
			if(idType.indexOf("select",0)>-1)
			{
				try
				{
					returnValue=g.options[g.selectedIndex].value;
				}
				catch(exp)
				{
					returnValue="";
				}
			}
			if(idType=="checkbox")
			{
				returnValue=(g.checked)?"1":"0";
			}
			if(idType=="radio")
			{
				returnValue=(g.checked)?"1":"0";
			}
		}
	}
	return returnValue;
}
function setem(elm,dom,to)
{
	parentdoc().getElementById(elm).innerHTML = '<a class="n" href="mailto:' + to + '@' + dom + '">' + to + '@' + dom + '</a>';
}
function disableContextMenu(element) 
{
    element.oncontextmenu = function() 
    {
		return false;
	}
}
function BannerMessageShow(base,message)
{

	window.scrollTo(0,0);
	var m=document.getElementById("msgbnr");
	var mbduration=20000;
	mbannerheight=1;
	document.getElementById("msgbnr").style.visibility="hidden";
	document.getElementById("msgbnr").style.position="absolute";

	switch(base)
	{
		case "b":
			m.style.border="solid 1px #000080";
			m.style.backgroundColor="#0000ff";
			m.style.color="#ffffff";
			break;
		default:
			m.style.border="solid 1px #800000";
			m.style.backgroundColor="#FF0000";
			m.style.color="#FFFF00";
			mbduration=50000;
			break;
	}
	mbannerdir=mbannerinterval;
	m.innerHTML="<div class='coll' style='padding:5px;'>" + message 
		+ "</div><div class='r'><img src='/i/tb/close.gif' alt='Close' title='Close' width='19' height='19' class='cb' onclick='BannerMessageClose();' /></div>";
	m.style.height="1px"; 
	m.style.visibility="visible";
	m.style.position="relative";
	setTimeout('BannerMessageStretch();',20);
	mbannertmr=setTimeout('BannerMessageClose();',20000);

}
function BannerMessageClose()
{
	if(mbannertmr!=null)
	{
		try
		{
			clearTimeout(mbannertmr);
		}
		catch(e)
		{
		}
	}
	mbannerdir=-mbannerinterval;
	setTimeout('BannerMessageStretch();',20);
}
function BannerMessageStretch()
{
	mbannerheight+=mbannerdir;
	if(mbannerheight<1){mbannerheight=1;}
	if(mbannerheight>50){mbannerheight=50;}
	document.getElementById("msgbnr").style.height=mbannerheight + "px";
	
	if(mbannerdir<0)
	{
		if(mbannerheight>1)
		{
			setTimeout('BannerMessageStretch();',20);
		}
		else
		{
			mbannerheight=1;
			document.getElementById("msgbnr").style.visibility="hidden";
			document.getElementById("msgbnr").style.position="absolute";
		}
	}
	else
	{
		if(mbannerheight<50)
		{
			setTimeout('BannerMessageStretch();',20);
		}
		else
		{
			mbannerheight=50;
		}
	}
}