function anchorSubmitForm(formName)
{
    for (var i=0; i<document.forms.length; i++) {
       if (document.forms[i].name == formName) {
          document.forms[i].submit();
       }
    }
}
function processForm ( selectedProcess )
	{
		document.login.process.value = selectedProcess ;
		document.login.submit() ;
}
function cornerLogin ( )
{
	document.cornerLogin.submit() ;
}

function submitFormVar ( formName, varName, varValue )
{
    for (var i=0; i<document.forms.length; i++) {
       if (document.forms[i].name == formName) {
        document.forms[i].elements[varName].value = varValue;  
          document.forms[i].submit();
       }
    }
}

function ConfirmSubmitFormVar (confirmText, formName, varName, varValue )
{
	var agree=confirm(confirmText);
	if (agree) 
		submitFormVar( formName, varName, varValue );
	else
		return false ;
	
}


function toggleDisplay(id1,id2) {
	// if id1 is hidden, then show it and hide id2. else do the opposite.
	if (document.getElementById(id1).style.display == 'none') {
		document.getElementById(id1).style.display = 'block';
		document.getElementById(id2).style.display = 'none';
	} else {
		document.getElementById(id1).style.display = 'none';
		document.getElementById(id2).style.display = 'block';
	}
	return false;
}

function openDisplay(id1) {
	// display id1
	document.getElementById(id1).style.display = 'block';
	return false;
}

function hideDisplay(id1) {
	// hide id1
	document.getElementById(id1).style.display = 'none';
	return false;
}

// for fields that allow numbers only (such as zip code)
//
// ex: <INPUT NAME="dollar" SIZE=5 MAXLENGTH=5 onKeyPress="return numbersonly(this, event)">
//
// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place
function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}

// how to default the "other" button if info is entered:
//
// ex: onKeyPress="var m=this.form.media;m[m.length -1].checked=true"


// set up the default popup window size... if you want to override call the
// function launchWin directly
function popWin(URL, winName, overrideWidth, overrideHeight, Resizable, Scrollbars) {
	var width = 0;
	var height = 0;


	if (winName.length > 0) {
		switch (winName){
			case "weightcircles":
				width = 550; height = 430;
				break;
			case "tags":
				width = 550; height = 430;
				break;
			case "circles":
				width = 550; height = 430;
				break;
			Default:
				width = 550; height = 430;
				break;
		}
	} else {
		// calculate a default winName
		day = new Date();
		winName = day.getTime();
	}

	if ((overrideWidth == null) || (overrideWidth == "")) { width = 570; }
	if ((overrideHeight== null) || (overrideHeight== "")) { height = 340; }
	if ((Resizable == null) || (Resizable == "")) { Resizable = "no"; }
	if ((Scrollbars == null) || (Scrollbars == "")) { Scrollbars = "no"; }

	//only launch window if we ve set a width and height
	if (width > 0 && height > 0){
		launchWin(winName, URL, width, height, Resizable, Scrollbars);
	}

//	var positionX = (screen.availWidth - Width) / 2;
//	var positionY = (screen.availHeight - Height) / 2;

//	window.open(URL,WindowName,"width=" + Width + ",height=" + Height + ",left=" + positionX + ",top=" + positionY + ",channelmode=0,dependent=0,directories=0,location=0,menubar=0,resizable=" + Resizable + ",scrollbars=" + Scrollbars + ",status=0,toolbar=0");
}

// not using Resizeable or Scrollbars yet... but they're ready for use!
function launchWin(winName, URL, width, height, Resizable, Scrollbars){
	var ieIncrement = ((navigator.appName+"").indexOf("Netscape") == -1)? 15:0;
	eval(winName+"=window.open('"+ URL +"','"+ winName +"','resizable=yes,scrollbars=yes,width="+ (width + ieIncrement) +",height="+ (height + ieIncrement) +",top=5,left=75')");
	eval("window."+ winName +".focus()");	
}

// example use: <A class=LargeCommand href=javascript:OpenHelp();>Code of Conduct</A>
function OpenHelp()
{
    window.open('/_conduct.msnw', "Conduct", "width=450,height=480,resizable=yes,scrollbars=yes");
}


function tooLong(strTest,maxLength)
{
	if (strTest.value.length > maxLength) {
		alert("You've reached the maximum input length.");
		strTest.value = strTest.value.substr(0,maxLength);


	}
}
// custom message to user when they've reached the max limit of a field.  Use \' as escape sequence.  Ex: 'You\'ve reached...'
function tooLongText(strTest, maxLength, textMssg)
{
	if (strTest.value.length > maxLength) {
		alert( textMssg);
		strTest.value = strTest.value.substr(0,maxLength);


	}
}

// call this to make input text prompts disappear when user clicks on an input field
// the class styles make the font change color: grey text when it's our prompt, black when the user is entering text... will implement later
// example: <input class="inputfont inputpromptfont" onfocus="focusEdit(this, 'enter keyword')" onblur="focusEdit(this, 'enter keyword')" type="text" name="q" id="q" maxlength="150" value="Search&#32;for&#32;people" />
// (I'm not sure why the value has &#32; instead of spaces and whether this is necessary)
//  - ABowers
function focusEdit(editBox, defaultText)
{
	if ( editBox.value == defaultText )
	{
		editBox.value = '';
		// editBox.className = 'inputfont';
	}
	else if ( editBox.value.length == 0 )
	{
		// editBox.className = 'inputfont inputpromptfont';
		editBox.value = defaultText;
	}
	return true;
}