function openPicWin(theurl) {
	var photWin = window.open(theurl, 'Photo', "status,resizable,scrollbars,dependant,alwaysRaised=yes,height=420,width=530");
	photWin.focus();
}
//expands and contracts DIV tag to hide and show content
function openClose(tagToHide) {
	var divName = "box" + tagToHide;
	var whichLayer = document.getElementById(divName);
	if (whichLayer.style.display  == "inline") {
		whichLayer.style.display = "none";
        imgName = "minmax" + tagToHide
        var thisImage = eval("document."+imgName);
        thisImage.src="/images/max.gif";
	} else {
		whichLayer.style.display = "inline";
		imgName = "minmax" + tagToHide;
		var thisImage = eval("document."+imgName);
		thisImage.src="/images/min.gif";
	}
}

function highLight(tn, row) {
	
	tabId = "showtable" + tn; 
	var lastBar = document.getElementById(lastTabId);
	lastBar.rows[lastRow].style.backgroundColor = "#FFEEEE";

    var bar = document.getElementById(tabId);
	bar.rows[row].style.backgroundColor = "#FFFFFF"

	window.lastRow = row;
	window.lastTabId = tabId;
}

/*function addSponsPiece() {
	var spPcVal = document.postspons.sponsorPieceVal;
	var sponsList = document.postspons.addSponsType;
	var spAmountVal = document.postspons.spAmount;
	var showList = document.postspons.addshow;
	var sponsPieceList = document.postspons.sponsorPiece;
	
	var newValue =  showList.options[showList.selectedIndex].value + "~" + spAmountVal.value + "~" + sponsList.options[sponsList.selectedIndex].value;
	var newText = sponsList.options[sponsList.selectedIndex].text + " - $" + spAmountVal.value +" - "+showList.options[showList.selectedIndex].text+"\n";

	if (spPcVal.value != "") {
		spPcVal.value += "`";
	}
	spPcVal.value += newValue;	

	sponsPieceList.value += newText;
}
*/
function openCalWin(formName, dateField) {
	window.dateField = eval("document." + formName + "." + dateField);
	var calWin = window.open("/lib/popcalendar.html", "calendar", "status=yes,resizable,scrollbars=no,dependant,alwaysRaised=yes,height=200,width=275")
}

function findName(formName, fieldName, idField) {
	memidField = eval("document." + formName + "." + idField);
	displayField = eval("document." + formName + "." + fieldName);
	window.dispField = displayField;
	window.idField = memidField;
	theName = displayField.value;
	theloc = "/manage/lib/searchmem.php?fullname="+theName;
	var newWin = window.open(theloc,"searchWin","status=yes,resizable,scrollbars=yes,dependant,alwaysRaised=yes,height=300,width=500");
}

function populate(id, first, last) {
	fullNm = first+" "+last;
	opener.idField.value = id
	opener.dispField.value = fullNm;
	if (opener.name == "assoc") {
		opener.dispField.className="inputSizeRed";
		opener.document.remind.src = "/images/remind.gif";
	}
	self.close();
}

function switchPos() {
	var awardSel = document.postOpus.award;
	var theVal = awardSel.options[awardSel.selectedIndex].value;
	var pieceSel = document.postOpus.pieceId;
	var posSel = document.postOpus.mpId;
	var pieceVal = pieceSel.options[pieceSel.selectedIndex];
	posSel.options.length = 0;
	for (x = 0;x < piecePosition.length;x++) {
		thisArray = piecePosition[x];
		thisPcId = thisArray[0];
		thisTitle = thisArray[1]
		thisMPId = thisArray[2];
		thisPos = thisArray[3];
		thisName = thisArray[4];
		thisMemId = thisArray[5];
		if (pieceVal.value == thisPcId) {
			thisOptTxt = thisName + " - " + thisPos;
			thisOptVal = thisMPId+"~"+thisMemId+"~"+thisPos+"~"+thisTitle;
			posSel[posSel.length] = new Option(thisOptTxt, thisOptVal, "", "");
		}
	}

}
function makeActive() {
	if (document.postOpus) {
		var awardSel = document.postOpus.award;
		var theVal = awardSel.options[awardSel.selectedIndex].value;
		if (theVal == "Best Play") {
			document.postOpus.pieceId.disabled = false;
			document.postOpus.mpId.disabled = false;
			document.postOpus.name.value = "";
			document.postOpus.name.disabled = true;
			document.postOpus.memberId.value = "";
		} else if (theVal == "Founder's Award" || theVal == "Best Technical Support for the Season"){
			document.postOpus.mpId.disabled= true;
			document.postOpus.pieceId.disabled= true;
			document.postOpus.name.disabled= false;
		} else if (theVal == "") {
			document.postOpus.mpId.disabled= false;
			document.postOpus.name.disabled= false;
			document.postOpus.pieceId.disabled= false;
		} else {
			document.postOpus.mpId.disabled= false;
			document.postOpus.name.value = "";
			document.postOpus.name.disabled= true;
			document.postOpus.memberId.value = "";
			document.postOpus.pieceId.disabled= false;
		}
	}
}

function setfields(formName, hidField, selectField) {
	oldField = eval("document."+formName+"."+selectField);
	newField = eval("document."+formName+"."+hidField);
	
	newField.value = oldField.options[oldField.selectedIndex].value;
}
//AJAX RELATED FUNCTIONS
function httpCnxn() {
	var http = null;
	if(window.XMLHttpRequest) {
		http = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		http = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return http;
}
function checkKey(keystring) {
	document.postSurvey.go.value="searching";
	var theForm;
	theForm = document.forms["postSurvey"];
	var http = httpCnxn();
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			if (http.responseText == "false") {
				document.postSurvey.action = "";
				alert("Sorry that is not a valid key, please try again");
			} else {
				document.postSurvey.action = "/members/savenominate.php";
				document.getElementById('ballotfields').style.display="block";
				document.postSurvey.go.value="found";
				retrieve();
			}
		}
  	}
	http.open('post', "/members/checkKey.php", true);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.send("uniqueKey="+keystring);
}