//============ SPECIALIZED FUNCTIONS FOR "LIA ONLINE SCRIPTING" LINKING ==============//
function gotoLIALogin(){
	msg_err_sponsor = "Please select a Sponsor.";
	msg_err_subsponsor = "Please select a sub-Sponsor.";

    	var field = document.forms[0].mainCat;	
    	
	if (isNotSelected( field, msg_err_sponsor)) return false;   

	var assoKey="";
	for ( i=0; i<field.length; i++) {
		if ( field[i].checked) assoKey = assoKey + field[i].value
	}  

	if (assoKey.charAt(0)=="*"){
		fieldKey = assoKey.substr(1);
		fieldName = "document.forms[0].subCat_" + fieldKey;
		field = eval(fieldName);	
	
	
		if (isNotSelected( field, msg_err_subsponsor)) return false;   

		//var ctp = field;
		var assoKey="";
		for ( i=0; i<field.length; i++) {
			if ( field[i].checked) assoKey = assoKey + field[i].value
		}  
	}


	if (assoKey==""){
		return false;
	}
	parent.location = "../../afge.nsf/quote?Open&_fn=agent&as="+assoKey;
}


function showExpandedGroup(grp_id){
	hideAllExpandedGroups();
	showTxt(grp_id);
}

function hideAllExpandedGroups(){
	hideTxt('alumni');
	hideTxt('f_alumni');
}


function popupLIAPageScript(){
	//added by Art to disabled other browser's display of lia script
	if (getPageInfo("browser")!= 'IE') return false; 
	
	winWidth = LIA_winW;
	winHeight = LIA_winH;

	if (winWidth==null | winWidth==""){
		winWidth = 635;
	}
	if (winHeight==null | winHeight==""){
		winHeight=500;
	}
	
	page = LIA_pageID + "?open&winW=" + winWidth  + "&winH=" + winHeight;
	openWindow_TopRight(page,winWidth,winHeight,'lia');
}
function displayLIA(displayType){
	if (displayType=="hide"){
		var idHide = "hideLIA";
		var idShow = "showLIA"
	} else {
		var idHide = "showLIA";
		var idShow = "hideLIA"
	}


	hideTxt(idHide);
	showTxt(idShow);
	return;
}

function openWindow_TopRight( url, winWidth, winHeight, winName, openFullWindow) {
	var winTop = 10;
	var winLeft = screen.width - winWidth - 20;
	var winNM = winName? winName:"win";
	if ( openFullWindow && openFullWindow !="") {
		winFeatures = "";
	} else {
		winFeatures ="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=" + winLeft + ",top=" + winTop + ",width=" + winWidth + ",height=" + winHeight;
	}       
	
	var thisWin = window.open(url, winNM, winFeatures);
	thisWin.focus();

}

function autoResizeToFit(){
	//- get width/height from QS....
	winWidth = getQueryString("winW");
	if (winWidth==null | winWidth==""){
		return;
	}
	winHeight = getQueryString("winH");
	if (winHeight==null | winHeight==""){
		return;
	}
	
	//- Based on browser, determine the width/height offsets....
	var browserName=navigator.appName; 
	if (browserName=="Netscape"){
		offsetH = 65;
		offsetW = 10;
	} else {
		offsetH = 40;
		offsetW = 10;
	}

	//- Determine new window width/height and resize to fit content....
	winWidth = parseInt(winWidth,10) + offsetW;
	winHeight = parseInt(winHeight,10) + offsetH;
	resizeTo(winWidth,winHeight);
	
	//- Respoisiton window in top-right cornder according to new size...
	var winTop = 10;
	var winLeft = screen.width - winWidth - 10;
	moveTo(winLeft,winTop);
	self.focus();
}
//===========================================================================================//

//=============================== GENERAL EDIT/CHECK FUNCTIONS ==============================//
function wrongField(field, text,errorSection) {
	if(text != null && text != "")  alert(text);
	if ( errorSection != null && errorSection != "") navSection( errorSection ); 
	if ( field != null)   field.focus();  
	return false;
}
function isNotSelected(field, text, errorSection, focusnum) {
	var l = field.length;
	var i;
	for (i = 0; i < l; i++) {
		if (field[i].checked)  return false;
	}
	if( focusnum != null ) f = eval("field["+focusnum+"]")
	else f=field[0];
	wrongField(f, text, errorSection);
	return true;
}
function setCheckedValue(field, value){
	var l = field.length;
	var i;
	value = value.toLowerCase();
	
	for (i = 0; i < l; i++) {
		if (field[i].value == value){
			field[i].checked = true;
			return;
		}
	}
}
//===========================================================================================//


autoResizeToFit();


//================================ OBSOLETE FUNCTIONS =======================================//
function popupLIAPageScript2(){
	page = LIA_pageID;
	winWidth = LIA_winW;
	winHeight = LIA_winH;
	
	if (winWidth==null | winWidth==""){
		winWidth = 635;
	}
	if (winHeight==null | winHeight==""){
		winHeight=500;
	}
	
	openWindow_TopRight(page,winWidth,winHeight,'lia');
}
//===========================================================================================//

