function NSresize()
{
	if(navigator.appName=="Netscape")
	{
		location.reload();
	}
}


function EndNow()
{
	var yesOrNow =  confirm("Are you sure you would like to close this application and go to the main MBDA Portal?");
	if(yesOrNow)
	{
		self.close();
		mbda.window.focus();
	}
}

function goTo (page) {
/* This function is called from the navigation menu
   to jump to the designated URL. Empty values
   are ignored and "--" indicates a menu seperator    */
   
	if (page != "" ) {
		if (page == "--" ) {
			resetMenu();
		} else {
			document.location.href = page;
		}
	}
	return false;
}


function openApp(pageToLoad) {

	var winName = "mbda";
	var width;
	var height;
	var center;
	                               
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    args = "width=" + width + "," 
    + "height=" + height + "," 
    + "location=0," 
    + "menubar=0,"
    + "resizable=0,"
    + "scrollbars=1,"
    + "status=1," 
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    window.open( pageToLoad,winName,args );
	return false;
	
}

function openAWindow( pageToLoad, winName, width, height, center) {
                                 
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    args = "width=" + width + "," 
    + "height=" + height + "," 
    + "location=0," 
    + "menubar=0,"
    + "resizable=0,"
    + "scrollbars=1,"
    + "status=1," 
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    window.open( pageToLoad,winName,args );
	
}

function expandit(hideThis,curobj,img){
	if(img){
		var temp = curobj.src.split("/");
		//alert();
		if(temp[temp.length-1] == 'open_folder.gif')
			curobj.src = '/images/closed_folder.gif';
		else
			curobj.src = '/images/open_folder.gif';
	}
	
	if (document.all)
		folder=document.all[hideThis].style;
	else
		folder=document.layers[hideThis];

//var temo = eval(layerRef+'["'+hideThis+'"]'+styleSwitch+'.display');
//alert(document.all[hideThis].style.display);

//folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+10].style
 if (folder.display=="")
  folder.display="none"
 else
  folder.display=""
}

/*function closeAll (hideThis,curobj,img)
{
 	for(i=1;i<=10;++i)
	{
		
		if (document.all)
			folder= document.all["goal_"+i].style;
		else
			folder=document.layers["goal_"+i];
	   //folder = eval("goal_" + i + ".style");
	   
	   //alert(folder);
	  	folder.display="none"
		
		//the_tr = eval("document.tr_"+i);
		//setPointer(hold_this, 'out', '#ffffff', '#fffaf0', '#f5deb3');
	}
	expandit(hideThis,curobj,img);
	
}*/

function isValid(fld, maxm)
{
	var color = 'ffcc00';
	var color2 = 'ffffff';
	if (maxm == "zip")
	{
		if (fld.value.length != 5 && fld.value.length != 0 && fld.value.length != 10)
			fld.style.background=color;
		else fld.style.background=color2;
	}
	else
	{
		if (fld.value.length != maxm && fld.value.length != 0)
			fld.style.background=color;
		else fld.style.background=color2;
	}
}

function currencyFormat(fld, mode,totallen)
{
	var key = '';
	var strCheck = '1234567890-';
	var whichCode = (window.Event) ? this.event.which : this.event.keyCode;
	
	if (whichCode == 13) 
		return true;  // Enter
	
	key = String.fromCharCode(whichCode);  // Get key value from key code
	
	if (strCheck.indexOf(key) == -1)
		return false;  // Not a valid key

	isNamedFone = true;
	var tmpStr = "";
    keyCount = fld.value.length;
	keyEntered = fld.value.substring(keyCount-1,keyCount);
	if (keyCount <= 1) isNamedFone = false;
    keyCount++;
	
	switch (mode)
	{
		case "fed_num":
		{
			if (keyCount == 3 || keyCount == 6 || keyCount == 12)
				tmpStr = fld.value += "-";
			if (fld.value.length > 13)
				return false;
		}
		break;
		
		case "phone":
		case "valueaddednetwork":
		{
			if (keyCount == 4 || keyCount == 8)
				fld.value += "-";
			if (fld.value.length > 11)
				return false;
		}
		break;
		
		case "duns":
		{
			if (keyCount == 3 || keyCount == 7)
				tmpStr = fld.value += "-";
			if (fld.value.length > 10)
				return false;
		}
		break;
		
		case "zip":
		{
			if (keyCount == 6)
				tmpStr = fld.value += "-";
			if (fld.value.length > 9)
				return false;
		}
		break;
		
		case "ssn":
		{
			if (keyCount == 4 || keyCount == 7)
				tmpStr = fld.value += "-";
			if (fld.value.length > 10)
				return false;
		}
		break;
		
		case "year" :
		{
			if (key == "0" && fld.value.length == 0)
				return false;
			if (fld.value.length > 3)
				return false;
		}
		break;
	}
}



var hold_this;



function buttoncheck(){
pressed_button = event.button;
if (pressed_button == 2){
	return false}
else{return true}
}
 

function setPointer(theRow, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
	 
 
   
	changeColor = buttoncheck();

   
	if(changeColor == true)
	{

	    var theCells = null;
		var hold_this = theRow;
		
	    // 1. Pointer and mark feature are disabled or the browser can't get the
	    //    row -> exits
	    if ((thePointerColor == '' && theMarkColor == '')
	        || typeof(theRow.style) == 'undefined') {
	        return false;
	    }
	
	    // 2. Gets the current row and exits if the browser can't get it
	    if (typeof(document.getElementsByTagName) != 'undefined') {
	        theCells = theRow.getElementsByTagName('td');
	    }
	    else if (typeof(theRow.cells) != 'undefined') {
	        theCells = theRow.cells;
	    }
	    else {
	        return false;
	    }
	
	    // 3. Gets the current color...
	    var rowCellsCnt  = theCells.length;
	    var domDetect    = null;
	    var currentColor = null;
	    var newColor     = null;
	    // 3.1 ... with DOM compatible browsers except Opera that does not return
	    //         valid values with "getAttribute"
	    if (typeof(window.opera) == 'undefined'
	        && typeof(theCells[0].getAttribute) != 'undefined') {
	        currentColor = theCells[0].getAttribute('bgcolor');
	        domDetect    = true;
	    }
	    // 3.2 ... with other browsers
	    else {
	        currentColor = theCells[0].style.backgroundColor;
	        domDetect    = false;
	    } // end 3
	
	    // 4. Defines the new color
	    // 4.1 Current color is the default one
	    if (currentColor == ''
	        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
	        if (theAction == 'over' && thePointerColor != '') {
	            newColor = thePointerColor;
	        }
	        else if (theAction == 'click' && theMarkColor != '') {
	            newColor = theMarkColor;
	        }
	    }
	    // 4.1.2 Current color is the pointer one
	    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()) {
	        if (theAction == 'out') {
	            newColor = theDefaultColor;
	        }
	        else if (theAction == 'click' && theMarkColor != '') {
	            newColor = theMarkColor;
	        }
	    }
	    // 4.1.3 Current color is the marker one
	    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
	        if (theAction == 'click') {
	            newColor = (thePointerColor != '')
	                     ? thePointerColor
	                     : theDefaultColor;
	        }
	    } // end 4
	
	    // 5. Sets the new color...
	    if (newColor) {
	        var c = null;
	        // 5.1 ... with DOM compatible browsers except Opera
	        if (domDetect) {
	            for (c = 0; c < rowCellsCnt; c++) {
	                theCells[c].setAttribute('bgcolor', newColor, 0);
	            } // end for
	        }
	        // 5.2 ... with other browsers
	        else {
	            for (c = 0; c < rowCellsCnt; c++) {
	                theCells[c].style.backgroundColor = newColor;
	            }
	        }
	    } // end 5
	
	    return true;
	}// end of changeColor var
} // end of the 'setPointer()' function

// Begin Grant Award Perdiod
	function sum(form)
	{
		n1 = eval(form.fed_amount.value);
		n2 = eval(form.audit_fee.value);
		n3 = eval(form.non_fed.value);
		if (!n2)
			n2 = 0;
		if (!n3)
			n3 = 0;
		ntotal = n1+n2;
		ntotal2 = ntotal+n3;
		form.total_fed.value = ntotal;
		form.project_cost.value = ntotal2;
	}
// End Grant Award Perdiod 

function confirmDelete(msg,location)
{
	var YesorNo = confirm(msg)
	
	
	if (YesorNo)
		goTo(location);
	else		
		return false;
}
function open_window(url) {
//	email = //window.open(url,"mbda1","toolbar=0,location=0,directories=0,status=0,menubar=0,s//crollbars=no,resizable=no,width=800,height=600");
	var popupwindow_window = null;
	if(popupwindow != null) {
		popupwindow.focus();
	} else { 
		var popupwindow = open(url, "popupwindow", "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=no,resizable=no,width=800,height=600");
		popupwindow_window = popupwindow;
	}

}
