var temp = new Array(0);
//var subI = 0;

function CSFindElement(n,ly) { 
	var CSAg = window.navigator.userAgent; 
	var CSBVers = parseInt(CSAg.charAt(CSAg.indexOf("/")+1),10);

	if (CSBVers < 4) return document[n];
	var curDoc = ly ? ly.document : document; var elem = curDoc[n];
	if (!elem) { for (var i=0;i<curDoc.layers.length;i++) {
		elem = CSFindElement(n,curDoc.layers[i]); if (elem) return elem; }}
	return elem;
}

function CSURLPopupShow(formName, popupName, target) {
	var form  = CSFindElement(formName);
	var popup = form.elements[popupName];
	window.open(popup.options[popup.selectedIndex].value, target);
	popup.selectedIndex = 0;
}

function openSub(divId)
		{

			var myDiv;
			if (divId == 'subHome')
				myDiv = parent.window._right.window.document.getElementById(divId);
			else
				myDiv = document.getElementById(divId);

			if (myDiv.style.display == 'none') {
				myDiv.style.display = 'block';
//				if (temp != 0 && divId.indexOf('archive') != -1)	{
				if (temp != 0)	{
					temp.style.display = 'none';
//					temp.splice(subI, 1);
//					subI--;
				}
//				if (divId.indexOf('archive') != -1)	{
				temp = myDiv;
//					subI++;
//				}
			}
			else	
				{
					if (divId != 'subHome' && divId.indexOf('archive') != 0) {
						myDiv.style.display = 'none';
//						temp.splice(subI, 1);
//						subI--;
						temp = 0;
					}
				}

			goSetHeight();

		}

function showSub(divId, pTop)
		{
			var myDiv = document.getElementById(divId);

			myDiv.style.left = document.getElementById('mTD').offsetLeft + 167;
			myDiv.style.top = pTop;
			myDiv.style.visibility = "visible";

		}

function hideSub(divId)
		{

			document.getElementById(divId).style.visibility = "hidden";

		}

function highlight(tdId)
		{

			tdId.className = "subMenuOver";

		}

function unhighlight(tdId)
		{

			tdId.className = "subMenuNormal";

		}

function body_onload(iFrameC, iFrameR)
		{

			var iFrameWinC = window.frames[iFrameC];
			var iFrameCenter = document.getElementById? document.getElementById(iFrameC): document.all? document.all[iFrameC]: null;
			var iFrameWinR = window.frames[iFrameR];
			var iFrameRight = document.getElementById? document.getElementById(iFrameR): document.all? document.all[iFrameR]: null;

			var lengthCenter;
			var lengthRight;
			var opera = false;
			var netscape = false;
			var adj = 35;

			if (navigator.userAgent.indexOf('Opera') != -1)
				opera = true;
			if (navigator.appName == "Netscape")
				netscape = true;
		
			//window.frames['_center'].location.src = url
			//window.frames['center'].location.reload();
			//window.parent.location.reload(true); 

			if (opera)	{
				lengthCenter = iFrameCenter.contentDocument.document.body.scrollHeight;
				lengthRight = iFrameRight.contentDocument.document.body.scrollHeight;
				}

			else if (netscape)	{
				lengthCenter = iFrameCenter.contentWindow.document.body.scrollHeight;
				lengthRight = iFrameRight.contentWindow.document.body.scrollHeight;
				}

			else {
				adj = 5;
				if (iFrameWinC.document.height) {
					lengthCenter = iFrameWinC.document.height;
					lengthRight = iFrameWinR.document.height;
					}
				else if (iFrameWinC.document.body)	{

					if (iFrameWinC.document.body.scrollHeight)	{
						lengthCenter = iFrameWinC.document.body.scrollHeight;
						lengthRight = iFrameWinR.document.body.scrollHeight;
						}
					else if (iFrameWinC.document.body.offsetHeight) {
						lengthCenter = iFrameWinC.document.body.offsetHeight;
						lengthRight = iFrameWinR.document.body.offsetHeight;
						}
					}
				}

			//textCenter = center.page_center.innerHTML;
			//lengthCenter = center.page_center.innerHTML.length;
			//textRight = right.page_right.innerHTML;
			//lengthRight = right.page_right.innerHTML.length;

			//for (p = 0; p <= lengthCenter; p++) {
			//	if (textCenter.substring(p,p+2) == '<P') {
			//		pcount++;
			//		}
			//	}

			//lengthCenter = ((lengthCenter / 67) + pcount) * 18;
			//pcount = 0;

			//for (p = 0; p <= lengthRight; p++) {
			//	if (textRight.substring(p,p+2) == '<P') {
			//		pcount++;
			//		}
			//	}

			//lengthRight = ((lengthRight / 24) + pcount) * 18;

			if (lengthCenter > lengthRight) {		
				iFrameCenter.style.height = lengthCenter + adj;
				iFrameRight.style.height = lengthCenter + adj;
				}
			else {
				iFrameRight.style.height = lengthRight + adj;
				iFrameCenter.style.height = lengthRight + adj;
				}

			scroll(0); 

		}

function gourl(iFrameName, url1, url2)
		{

		if (url2 != '')
			window._right.location.href = url2;
		else if (window._center.location.href.indexOf('page_center') != -1)
			openSub('subHome');
		
		if ( window.frames[iFrameName] ) {
			window.frames[iFrameName].location.href = url1;
			scroll(0);
			return false;
			}
		else {
			scroll(0);
			return true;
			}

		}

function goSetHeight()
	{
	if (parent == window) return;
	else parent.body_onload('center', 'right');
	}
