//Global Variables
var winW = 300;
var winY = 300;
var ready="no";

/*********************************
*  Makes Div cols equal height ***
*********************************/
//function for two columns
function fixH(one,two) {
	if (document.getElementById(one)) {
		var lh=document.getElementById(one).offsetHeight;
		var rh=document.getElementById(two).offsetHeight;
		var nh = Math.max(lh, rh); 
		document.getElementById(one).style.height=nh+"px";
		document.getElementById(two).style.height=nh+"px";
	}
}

//function for three columns (sortNum and fixH2)
function sortNum(a,b) { return b-a} 

function fixH2(one,two,three) {
	if (document.getElementById(one)) {
		var obj=new Array(3);
		var option=[one,two,three];
		for(var i=0; i<option.length; i++) {
			document.getElementById(option[i]).style.height="auto";
			obj[i]=document.getElementById(option[i]).offsetHeight;
			nh=obj.sort(sortNum);
		} 
		nh1=nh.splice(1,2);
		for(var i=0; i<option.length; i++) {
			document.getElementById(option[i]).style.height=nh+"px";
		}
	}
}

//Executes fixH2 function on document load.  fixH is fired in the body html tag when specified.
//This prevents conflicts between the two functions.
window.onload=function(){
	fixH2('left_nav','main','right');
}


/*********************************
*****  Other Functions      ******
*********************************/

function ImgOn(img_name)
{
	var x;
	for(x = 0; x < document.images.length; x++)
	{
		if(document.images[x].name == img_name)
		{
			document.images[x].src = '/images/' + img_name + '_yellow.gif';
			break;
		}
	}
}

function ImgOff(img_name)
{
	var x;
	for(x = 0; x < document.images.length; x++)
	{
		if(document.images[x].name == img_name)
		{
			document.images[x].src = '/images/' + img_name + '_white.gif';
			break;
		}
	}
}

function CFRSearch()
{
	var winW = 0;
	var winY = 0;
	if(window.innerWidth)
		winW = window.innerWidth;
	else if(document.body)
	{
		if(document.body.offsetWidth)
			winW = document.body.offsetWidth;
	}
	if(window.innerHeight)
		winY = window.innerHeight;
	else if(document.body)
	{
		if(document.body.offsetHeight)
			winY = document.body.offsetHeight;
	}
	
	if(winW < 300)
		winW = 300;
	else
		winW = winW - 50;
	
	if(winW > 1000)
		winW = 1000;

	if(winY < 300)
		winY = 300;
	else
		winY = winY - 100;

	window.open('/un/cfr_table.asp?height=' + winY, 'cfr_win', 'width=' + winW + ',height=' + (winY + 100) + ',left=25,top=20,scrollbars=yes,toolbar=no,menubar=no,location=no,status=yes,resizable=yes');
}

function NavPDFOpen(vArg1)
{
	var winW = 0;
	var winY = 0;
	if(window.innerWidth)
		winW = window.innerWidth;
	else if(document.body)
	{
		if(document.body.offsetWidth)
			winW = document.body.offsetWidth;
	}
	if(window.innerHeight)
		winY = window.innerHeight;
	else if(document.body)
	{
		if(document.body.offsetHeight)
			winY = document.body.offsetHeight;
	}
	
	if(winW < 300)
		winW = 300;
	else
		winW = winW - 50;
	
	if(winW > 1000)
		winW = 1000;

	if(winY < 300)
		winY = 300;
	else
		winY = winY - 100;
	window.open('/un/pdfs/' + vArg1 + '.pdf', 'pdfwin3', 'location=no,menubar=yes,toolbar=no,scrollbars=both,resizable,width=' + winW + ',height=' + winY + ',left=65,top=65');
}
