function getSchName(pValue,pNum){
	document.getElementById("schname" + pNum).value = pValue;

}

function getSchAmount(pValue,pNum){
	document.getElementById("schamount" + pNum).value = pValue;
}

function replaceSingleQuote(pObj)
{
	var obj1 = 0;
	var obj2 = pObj;
	
	while (obj1 != -1){
		obj1 = 	obj2.indexOf("'",obj1);
		if (obj1 != -1){
			obj2 = obj2.replace("'", "&#39;");
		}		
	}		

	return obj2;		
}

function displayScholarship(pValue)
{
	var objSch = document.getElementById("lyrScholarship");
	var objAwarded = document.getElementById("numAwarded");
	
	if (objAwarded.value != 0) {
		for (i=1;i<= objAwarded.value;i++){
			document.getElementById("schname" + i).value   = document.getElementById("txtScholarName" + i).value;
			document.getElementById("schamount" + i).value = document.getElementById("txtScholarAmount" + i).value;
		}
	}
	
	objSch.innerHTML = "";
	for (i=1;i<= pValue;i++){
		var valSchName   = document.getElementById("schname" + i).value;
		valSchName = replaceSingleQuote(valSchName);	
		var valSchAmount = document.getElementById("schamount" + i).value;
		
		objSch.innerHTML +=	"<table width='100%' class='profileForm' cellpadding=02 cellspacing=0 border=01>" +
							"   <tr>" +
							"		<td colspan='3'>&nbsp;&nbsp;&nbsp;&nbsp;<b>Scholarship #" + i + "</b></td>" +
							"   <tr>" +
							"		<td align=left width='50%'><label id='lblScholarName" + i + "' name='lblScholarName" + i + "' >&nbsp;&nbsp;&nbsp;&nbsp;Scholarship Name</label></td>" +
							"		<td><img src='/images/spacer.gif' width='5' height='1' border='0'></td>" +
							"		<td align=left>" +
							"			<input type='text' name='txtScholarName" + i + "' maxlength='200' value='" + valSchName + "' style='width:300px' ID='txtScholarName" + i + "' size='20' onChange='getSchName(this.value," + i + ")'>" +
							"		</td>" +
							"	</tr>" +
							"	<tr>" +
							"		<td align=left><label id='lblScholarAmount" + i + "' name='lblScholarAmount" + i + "'>&nbsp;&nbsp;&nbsp;&nbsp;Scholarship Amount</label></td>" +
							"		<td><img src='/images/spacer.gif' width='5' height='1' border='0'></td>" +
							"		<td align=left>" +
							"			<input type='text' name='txtScholarAmount" + i + "' maxlength='10' value='" + valSchAmount + "' style='width:100px' ID='txtScholarAmount" + i + "' size='20' onKeypress='return KeyCheck(event);' onChange='getSchAmount(this.value," + i +")'>&nbsp;($)" +
							"		</td>" +
							"	</tr>" +
							"</table>";
	}
	
	document.getElementById("numAwarded").value = pValue; 
}

function displayScholarship2(pValue)
{
	var objSch = document.getElementById("lyrScholarship");
	var objAwarded = document.getElementById("numAwarded");

	if (objAwarded.value != 0) {
		for (i=1;i<= objAwarded.value;i++){
			document.getElementById("schname" + i).value   = document.getElementById("txtScholarName" + i).value;
			document.getElementById("schamount" + i).value = document.getElementById("txtScholarAmount" + i).value;
		}
	}
	
	objSch.innerHTML = "";
	for (i=1;i<= pValue;i++){
		var valSchName   = document.getElementById("schname" + i).value;
		valSchName = replaceSingleQuote(valSchName);
		var valSchAmount = document.getElementById("schamount" + i).value;
		
		objSch.innerHTML +=	"<table width='100%' class='bodyText' cellpadding=02 cellspacing=0 border=0>" +
							"   <tr>" +
							"		<td colspan='3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Scholarship #" + i + "</b></td>" +
							"   <tr>" +
							"		<td align=left width='50%'><label id='lblScholarName" + i + "' name='lblScholarName" + i + "' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Scholarship Name</label></td>" +
							"		<td><img src='/images/spacer.gif' width='5' height='1' border='0'></td>" +
							"		<td align=left>" +
							"			<input type='text' name='txtScholarName" + i + "' maxlength='200' value='" + valSchName + "' style='width:300px' ID='txtScholarName" + i + "' size='20' onChange='getSchName(this.value," + i + ")'>" +
							"		</td>" +
							"	</tr>" +
							"	<tr>" +
							"		<td align=left><label id='lblScholarAmount" + i + "' name='lblScholarAmount" + i + "'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Scholarship Amount</label></td>" +
							"		<td><img src='/images/spacer.gif' width='5' height='1' border='0'></td>" +
							"		<td align=left>" +
							"			<input type='text' name='txtScholarAmount" + i + "' maxlength='10' value='" + valSchAmount + "' style='width:100px' ID='txtScholarAmount" + i + "' size='20' onKeypress='return KeyCheck(event);' onChange='getSchAmount(this.value," + i +")'>&nbsp;($)" +
							"		</td>" +
							"	</tr>" +
							"</table>";
	}
	
	document.getElementById("numAwarded").value = pValue; 
}

function generateHidden(pValue,pValue2) {
	var objHidden = document.getElementById("lyrHiddenSchs")
	for (i=1;i<= pValue;i++){
		//if (pValue2 == i) { 
		//	objHidden.innerHTML += "<input type=hidden id='schname" + i + "' name='schname" + i + "' value='" + document.getElementById("txtScholarName" + i).value + "'>" +
		//	                       "<input type=hidden id='schamount" + i + "' name='schamount" + i + "' value='" + document.getElementById("txtScholarAmount" + i).value + "'>" ; 	
		//}else {
			objHidden.innerHTML += "<input type=hidden id='schname" + i + "' name='schname" + i + "' value=''>" +
		                           "<input type=hidden id='schamount" + i + "' name='schamount" + i + "' value=''>" ; 	
		//}
	}
}