///************ Navigation Functions /// Navigation Functions ****************///

function loadSelected() 
{	
	var oDef, srcDef;
	oDef = "defaultNav";
	srcDef = document.getElementById(oDef);
		
	var t1_default;
	t1_default = srcDef.value;

	t1_default_grey		= 'nav1-' + t1_default + '-grey';
	t1_default_green	= 'nav1-' + t1_default + '-green';
	t1_default_text		= 'nav1-' + t1_default + '-text';
	//t2_default				= 't2-box-' + t1_default;
	
	resetT1();
	
	if(t1_default != 'NO_SELECTION') 
	{
		if(t1_default == 'overview') 
		{
			document.getElementById('nav1-left-cap-green').style.display = 'none';
			document.getElementById('nav1-left-cap-grey').style.display  = 'block';
		}
		else if(t1_default == 'register') 
		{
			document.getElementById('nav1-right-cap-green').style.display = 'none';
			document.getElementById('nav1-right-cap-grey').style.display  = 'block';
		}
		//document.getElementById(t2_default).style.display 				= 'block';
		document.getElementById(t1_default_grey).style.display			= 'block';
		document.getElementById(t1_default_green).style.display			= 'none';
		document.getElementById(t1_default_text).style.fontWeight		= 'bold';
	}
}


function changeT1(tab_id) 
{
	t1_grey		= 'nav1-' + tab_id + '-grey';
	t1_green	= 'nav1-' + tab_id + '-green';
	t1_text		= 'nav1-' + tab_id + '-text';
	//t2_div		= 't2-box-' + tab_id;
	
	resetT1();
	
	if(tab_id == 'overview') {
		document.getElementById('nav1-left-cap-green').style.display = 'none';
		document.getElementById('nav1-left-cap-grey').style.display  = 'block';
	}
	else if(tab_id == 'register') {
		document.getElementById('nav1-right-cap-green').style.display = 'none';
		document.getElementById('nav1-right-cap-grey').style.display  = 'block';
	}
	
	document.getElementById(t1_grey).style.display			= 'block';
	document.getElementById(t1_green).style.display			= 'none';
	document.getElementById(t1_text).style.fontWeight		= 'bold';
	
	
	
	try{
		//document.getElementById(t2_div).style.display 			= 'block';
	} catch(e) {
		alert("err changeT1");
	}
}


function resetT1() 
{
	var theDivs = document.getElementsByTagName('DIV');
	for(i=0;i<theDivs.length;i++)
	{
		var divId = theDivs[i].id;
		if(divId.indexOf('-grey') != -1) 
		{
			if(document.getElementById(divId).style.display != 'none') {
				document.getElementById(divId).style.display = 'none';
			}
		}
		if(divId.indexOf('-green') != -1) 
		{
			if(document.getElementById(divId).style.display != 'block') {
				document.getElementById(divId).style.display = 'block';
			}
		}
		if(divId.indexOf('-text') != -1) 
		{
			if(document.getElementById(divId).style.fontWeight != 'normal') {
				document.getElementById(divId).style.fontWeight = 'normal';
			}
		}		
	}

}

function changeLink(div_id,mouse) {

	if(mouse == 'over') {
		document.getElementById(div_id).style.background	= "#66cc33";
		document.getElementById(div_id).style.color			= "#FFFFFF";
	}
	if(mouse == 'out') {
		document.getElementById(div_id).style.background	= "#FFFFFF";
		document.getElementById(div_id).style.color			= "#000000";
	}

}

function loadNavigation(tourneyID)
{
	var thisO, oSource;
	
	thisO = "innerNavigation";
	oSource = document.getElementById(thisO);	
	
	if (window.XMLHttpRequest) { 
		xmlhttp = new XMLHttpRequest(); 
	} else if (window.ActiveXObject) { 
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	
	var url = "VolunteerNavigation.aspx?iTourneyid=" + tourneyID;
	xmlhttp.open("GET",url,false); 
	xmlhttp.setRequestHeader('Accept','message/x-jl-formresult') 
	xmlhttp.send(null); 
	if (xmlhttp.status == 200) { 
		oSource.innerHTML = xmlhttp.responseText;
	} 
	else { 
		// handle different response status here 
		alert("There was an error loading the navigation");
	} 
	
	//loadSelected();
	
	//showContent('1','tourneyID');
}

///************ End Navigation Functions /// End Navigation Functions ****************///



///************ Content Functions /// Content Functions ****************///
function showContent(contentID, tourneyID)
{
	var oDef, srcDef;
	oDef = "defaultNav";
	srcDef = document.getElementById(oDef);
	
	if(contentID==1)
	{
		srcDef.value = "overview";
	}
	else if(contentID==2)
	{
		srcDef.value = "benefits";
	}
	else if(contentID==3)
	{
		srcDef.value = "committees";
	}
	else if(contentID==4)
	{
		srcDef.value = "uniforms";
	}
	else if(contentID==7)
	{
		srcDef.value = "directions";
	}
	else if(contentID==8)
	{
		srcDef.value = "volunteerofyear";
	}
	else if(contentID==9)
	{
		srcDef.value = "schedule";
	}	
	else if(contentID==10)
	{
		srcDef.value = "register";
	}
	
	loadSelected();

	var thisO, oSource;
	
	thisO = "innerContent";
	oSource = document.getElementById(thisO);	
	
	if (window.XMLHttpRequest) { 
		xmlhttp = new XMLHttpRequest(); 
	} else if (window.ActiveXObject) { 
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	
	var url = "VolunteerContent.aspx?contentid=" + contentID + "&tourneyid=" + tourneyID;
	xmlhttp.open("GET",url,false); 
	xmlhttp.setRequestHeader('Accept','message/x-jl-formresult') 
	xmlhttp.send(null); 
	if (xmlhttp.status == 200) { 
		oSource.innerHTML = xmlhttp.responseText;
	} 
	else { 
		// handle different response status here 
		alert("There was an error loading the selected content");
	} 
}

function loadLogout(vname, tourneyID)
{
	var inID, inSrc, outID, outSrc;
	//inID = "login-box2";
	inID = "loginbox";
	inSrc = top.document.getElementById(inID);
	inSrc.style.display="none";
	
	outID = "logout-box2";
	outSrc = top.document.getElementById(outID);
	outSrc.style.display="block";
	
	var lID, lSrc;
	lID = "loginName";
	lSrc = top.document.getElementById(lID);
	
	lSrc.innerHTML = "Welcome back " + vname;
}

function loadLogin(tourneyID)
{
	var inID, inSrc, outID, outSrc;
	//inID = "login-box2";
	inID = "loginbox";
	inSrc = top.document.getElementById(inID);
	inSrc.style.display="block";
	
	outID = "logout-box2";
	outSrc = top.document.getElementById(outID);
	outSrc.style.display="none";
	
	var lID, lSrc;
	lID = "loginName";
	lSrc = top.document.getElementById(lID);
	
	lSrc.innerHTML = "";
}

function volunteerLogout(contentID, tourneyID)
{
	var thisO, oSource;	
	thisO = "innerContent";
	oSource = document.getElementById(thisO);
	oSource.innerHTML = "<br><br><br><br><p align='center'>One moment while we verify your login and load your information...</p>";	
	
	if (window.XMLHttpRequest) { 
		xmlhttp = new XMLHttpRequest(); 
	} else if (window.ActiveXObject) { 
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	
	var url = "VolunteerContent.aspx?contentid=" + contentID + "&tourneyid=" + tourneyID + "&docSrc=VolunteerLogout";
	xmlhttp.open("GET",url,false); 
	xmlhttp.setRequestHeader('Accept','message/x-jl-formresult') 
	xmlhttp.send(null); 
	if (xmlhttp.status == 200) { 
		oSource.innerHTML = xmlhttp.responseText;
	} 
	else { 
		// handle different response status here 
		alert("There was an error logging you out.");
	} 
}

function volunteerLogin(contentID, tourneyID)
{
	var oDef, srcDef;
	oDef = "defaultNav";
	srcDef = document.getElementById(oDef);	
	srcDef.value = "overview";
	
	//Get Username
	var uID, uSrc, pID, pSrc;
	
	uID = "txtusername";
	uSrc = document.getElementById(uID);
	
	pID = "txtpassword";
	pSrc = document.getElementById(pID);
	
	var thisO, oSource;	
	thisO = "innerContent";
	oSource = document.getElementById(thisO);
	oSource.innerHTML = "<br><br><br><br><p align='center'>One moment while we verify your login and load your information...</p>";	
		
	if (window.XMLHttpRequest) { 
		xmlhttp = new XMLHttpRequest(); 
	} else if (window.ActiveXObject) { 
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	
	var url = "VolunteerContent.aspx?contentid=" + contentID + "&tourneyid=" + tourneyID + "&docSrc=VolunteerLogin&usr=" + uSrc.value + "&pwd=" + pSrc.value;
	xmlhttp.open("GET",url,false); 
	xmlhttp.setRequestHeader('Accept','message/x-jl-formresult') 
	xmlhttp.send(null); 
	if (xmlhttp.status == 200) { 
		oSource.innerHTML = xmlhttp.responseText;
		uSrc.value = "";
		pSrc.value = "";
	} 
	else { 
		// handle different response status here 
		alert("There was an error loading the login page");
	} 
}


function showSubContent(contentID, tourneyID, docSrc)
{
	var oDef, srcDef;
	oDef = "defaultNav";
	srcDef = document.getElementById(oDef);	
	srcDef.value = "overview";
	
	var thisO, oSource;
	
	thisO = "innerContent";
	oSource = document.getElementById(thisO);	
	
	if (window.XMLHttpRequest) { 
		xmlhttp = new XMLHttpRequest(); 
	} else if (window.ActiveXObject) { 
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	
	var url = "VolunteerContent.aspx?contentid=" + contentID + "&tourneyid=" + tourneyID + "&docSrc=" + docSrc;
	xmlhttp.open("GET",url,false); 
	xmlhttp.setRequestHeader('Accept','message/x-jl-formresult') 
	xmlhttp.send(null); 
	if (xmlhttp.status == 200) { 
		oSource.innerHTML = xmlhttp.responseText;
	} 
	else { 
		// handle different response status here 
		alert("There was an error loading the selected sub content");
	} 
}


///************ End Content Functions /// End Content Functions ****************///

var y       = 0;
var spd     = 20;
var show    = 0;

function changeheight(thisSection){
	
	bg = document.getElementById(thisSection + "-regbackground");
	e  = document.getElementById(thisSection + "RegMenu");
		
	//var dID, dSrc;
	//dID = "volMenu";
	//dSrc = document.getElementById(dID);
		
	var bcID, bcSrc;
	bcID = "breadcrumb";
	bcSrc = parent.document.getElementById(bcID);
	
	if(y > 11 && show == 0){
		//dSrc.style.display = "none";		
	}
	if(y > 470 && show == 0){
	
		if(thisSection=="contact")
		{
			bcSrc.innerHTML = "- Contact Information";
		}
		else if(thisSection=="secondary")
		{
			bcSrc.innerHTML = "- Secondary Information";
		}
		else if(thisSection=="1stcommittee")
		{
			bcSrc.innerHTML = "- 1st Committee Choice";
		}
		else if(thisSection=="2ndcommittee")
		{
			bcSrc.innerHTML = "- 2nd Committee Choice";
		}
		else if(thisSection=="3rdcommittee")
		{
			bcSrc.innerHTML = "- 3rd Committee Choice";
		}
		else if(thisSection=="selectproducts")
		{
			bcSrc.innerHTML = "- Select Items";
		}
		else if(thisSection=="makepayment")
		{
			bcSrc.innerHTML = "- Payment Information";
		}
		else if(thisSection=="confirmation")
		{
			bcSrc.innerHTML = "- Registration Complete";
		}
		show = 1;		
		return;
	}
	if(y <= 5 && show == 1){
		show = 0;
		e.style.display = 'none';
		bg.style.display = 'none';
		
		//dSrc.style.display = "block";
		
		if(thisSection=="intro")
		{
			changeheight('contact');
		}
		if(thisSection=="contact")
		{
			changeheight('secondary');
		}
		if(thisSection=="secondary")
		{
			changeheight('1stcommittee');
		}
		if(thisSection=="1stcommittee")
		{
			changeheight('2ndcommittee');
		}
		if(thisSection=="2ndcommittee")
		{
			changeheight('3rdcommittee');
		}
		if(thisSection=="3rdcommittee")
		{
			changeheight('selectproducts');
		}
		if(thisSection=="selectproducts")
		{
			changeheight('makepayment');
		}
		if(thisSection=="makepayment")
		{
			changeheight('confirmation');
		}
		if(thisSection=="confirmation")
		{
			changeheight('confirmation');
		}
	return;
	}
	if(show){
		spd = -7;
	}
	if(!show){
		spd = 10;
	}
	y = y + spd;
	e.style.display		= 'block';
	e.style.height		= y + 2 + 'px';
	bg.style.display	= 'block';
	bg.style.height		= y + 2 + 'px';
	
	t=setTimeout("changeheight('" + thisSection + "');",0);
}


function changeNextPage(thisSection, vID)
{
	//populate vid
	var vfld, vsrc;
	vfld = "vid";
	vsrc = document.getElementById(vfld);
	vsrc.value = vID;
	
	var tfld, tsrc;
	tfld = "tid";
	tsrc = document.getElementById(tfld);
	
	var fID, fSrc;
	
	var bcID, bcSrc;
	bcID = "breadcrumb";
	bcSrc = parent.document.getElementById(bcID);
	
	//alert(thisSection);
	if(thisSection=="secondarytoconfrim")
	{
		closeOnly('secondary');
		fID = "confirmationfraViewer";
		fSrc = document.getElementById(fID);
		fSrc.src = "VolunteerConfirmationInformation.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID;
		closeOnly('confirmation');
		bcSrc.innerHTML = "- Registration Complete";
	}
	else if(thisSection=="secondarytoproducts")
	{
		closeOnly('secondary');
		fID = "makepaymentfraViewer";
		fSrc = document.getElementById(fID);
		fSrc.src = "VolunteerSelectProducts.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID;
		closeOnly('selectproducts');
		bcSrc.innerHTML = "- Select Items";
	}
	
	else if(thisSection=="secondarytoproducts2")
	{
		closeOnly('secondary');
		fID = "selectproductsfraViewer";
		fSrc = document.getElementById(fID);
		fSrc.src = "VolunteerSelectProducts.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID;
		closeOnly('selectproducts');
		//thisSection = "selectproducts";
		bcSrc.innerHTML = "- Select Items";
	}
	
	else
	{		
		if(thisSection=="contact")
		{
			//close contact, open secondary
			fID = "secondaryfraViewer";
			fSrc = document.getElementById(fID);
			fSrc.src = "VolunteerNewSecondaryInformation.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID;
		}
		else if(thisSection=="secondary")
		{
			//close contact, open secondary
			fID = "1stcommitteefraViewer";
			fSrc = document.getElementById(fID);
			fSrc.src = "VolunteerNewCommitteeInformation.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID + "&cStart=1";
		}
		else if(thisSection=="1stcommittee")
		{
			//close contact, open secondary
			fID = "2ndcommitteefraViewer";
			fSrc = document.getElementById(fID);
			fSrc.src = "VolunteerNewCommitteeInformation.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID + "&cStart=2";
		}
		else if(thisSection=="2ndcommittee")
		{
			//close contact, open secondary
			fID = "3rdcommitteefraViewer";
			fSrc = document.getElementById(fID);
			fSrc.src = "VolunteerNewCommitteeInformation.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID + "&cStart=3";
		}
		else if(thisSection=="3rdcommittee")
		{
			//close contact, open secondary
			fID = "selectproductsfraViewer";
			fSrc = document.getElementById(fID);
			fSrc.src = "VolunteerSelectProducts.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID;
		}
		else if(thisSection=="selectproducts")
		{
			//close contact, open secondary
			fID = "makepaymentfraViewer";
			fSrc = document.getElementById(fID);
			fSrc.src = "VolunteerMakePaymentInformation.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID;
		}
		else if(thisSection=="makepayment")
		{
			//close contact, open secondary
			fID = "confirmationfraViewer";
			fSrc = document.getElementById(fID);
			fSrc.src = "VolunteerConfirmationInformation.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID;
		}
		
		changeheight(thisSection);
	}
}

function changeNextPageComDone(thisSection, vID, nextPage)
{
	closeOnly(thisSection);
	
	//populate vid
	var vfld, vsrc;
	vfld = "vid";
	vsrc = document.getElementById(vfld);
	vsrc.value = vID;
	
	var tfld, tsrc;
	tfld = "tid";
	tsrc = document.getElementById(tfld);
	
	var fID, fSrc;
	
	//close this, open next
	fID = "selectproductsfraViewer";
	fSrc = document.getElementById(fID);
	fSrc.src = "VolunteerSelectProducts.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID;
		
	//changeheight2('selectproducts');
	closeOnly(nextPage);
	//changeheight('selectproducts');
	changeheight('3rdcommittee');
	
	
}


function changeNextPageComDoneToConfirm(thisSection, vID)
{
	closeOnly(thisSection);
	
	//populate vid
	var vfld, vsrc;
	vfld = "vid";
	vsrc = document.getElementById(vfld);
	vsrc.value = vID;
	
	var tfld, tsrc;
	tfld = "tid";
	tsrc = document.getElementById(tfld);
	
	var fID, fSrc;
	
	//close this, open next
	fID = "confirmationfraViewer";
	fSrc = document.getElementById(fID);
	fSrc.src = "VolunteerConfirmationInformation.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID;
		
	changeheight('confirmation');
	
}

function closeOnly(thisSection)
{
	bg = document.getElementById(thisSection + "-regbackground");
	e  = document.getElementById(thisSection + "RegMenu");

	//var dID, dSrc;
	//dID = "volMenu";
	//dSrc = document.getElementById(dID);
	
	var bcID, bcSrc;
	bcID = "breadcrumb";
	bcSrc = parent.document.getElementById(bcID);
	
	if(y > 11 && show == 0){
		//dSrc.style.display = "none";		
	}
	if(y > 470 && show == 0){
	
		show = 1;		
		return;
	}
	if(y <= 5 && show == 1){
		show = 0;
		e.style.display = 'none';
		bg.style.display = 'none';
		
		//dSrc.style.display = "block";		
		
	return;
	}
	if(show){
		spd = -7;
	}
	if(!show){
		spd = 10;
	}
	y = y + spd;
	e.style.display		= 'block';
	e.style.height		= y + 2 + 'px';
	bg.style.display	= 'block';
	bg.style.height		= y + 2 + 'px';
	
	t=setTimeout("closeOnly('" + thisSection + "');",0);
}


function changeNextPageAltWithData(thisSection, vID, altData)
{
	//populate vid
	var vfld, vsrc;
	vfld = "vid";
	vsrc = document.getElementById(vfld);
	vsrc.value = vID;
	
	var tfld, tsrc;
	tfld = "tid";
	tsrc = document.getElementById(tfld);
	
	var fID, fSrc;
	
	//alert(thisSection);
	
	if(thisSection=="1stcommittee")
	{
		//close 1st, open 2nd
		fID = "2ndcommitteefraViewer";
		fSrc = document.getElementById(fID);
		fSrc.src = "VolunteerNewCommitteeInformation.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID + "&" + altData;
	}
	else if(thisSection=="2ndcommittee")
	{
		//close 2nd, open 3rd
		fID = "3rdcommitteefraViewer";
		fSrc = document.getElementById(fID);
		fSrc.src = "VolunteerNewCommitteeInformation.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID + "&" + altData;
		
	}
	else if(thisSection=="3rdcommittee")
	{
		//close 3rd, open products
		//fID = "selectproductsfraViewer";
		//fSrc = document.getElementById(fID);
		//fSrc.src = "VolunteerNewCommitteeInformation.aspx?iTourneyID=" + tsrc.value + "&vid=" + vID + "&" + altData;
		alert("should not execute this code. please review common.js");
	}
	
	changeheight(thisSection);
}


var y2       = 0;
var spd2     = 20;
var show2    = 0;

function changeheight2(thisSection){
	
	bg2 = document.getElementById(thisSection + "-regbackground");
	e2  = document.getElementById(thisSection + "RegMenu");
	//ee = document.getElementById("loginMenuBottom");
	
	//var dID, dSrc;
	//dID = "volMenu";
	//dSrc = document.getElementById(dID);
	
	var bcID, bcSrc;
	bcID = "breadcrumb";
	bcSrc = parent.document.getElementById(bcID);
	
	if(y2 > 11 && show2 == 0){
		//dSrc.style.display = "none";		
	}
	if(y2 > 470 && show2 == 0){
	
		if(thisSection=="secondary")
		{
			bcSrc.innerHTML = "- Secondary Informationyy";
		}
		else if(thisSection=="1stcommittee")
		{
			bcSrc.innerHTML = "- 1st Committee Choice";
		}
		else if(thisSection=="2ndcommittee")
		{
			bcSrc.innerHTML = "- 2nd Committee Choice";
		}
		else if(thisSection=="3rdcommittee")
		{
			bcSrc.innerHTML = "- 3rd Committee Choice";
		}
		else if(thisSection=="selectproducts")
		{
			bcSrc.innerHTML = "- Select Items";
		}
		else if(thisSection=="makepayment")
		{
			bcSrc.innerHTML = "- Payment Information";
		}
		else if(thisSection=="confirmation")
		{
			bcSrc.innerHTML = "- Registration Complete";
		}
	
		show2 = 1;		
		return;
	}
	if(y2 <= 5 && show2 == 1){
		show2 = 0;
		e2.style.display = 'none';
		bg2.style.display = 'none';
		
		//dSrc.style.display = "block";
		
	return;
	}
	if(show2){
		spd2 = -7;
	}
	if(!show2){
		spd2 = 10;
	}
	y2 = y2 + spd2;
	e2.style.display		= 'block';
	e2.style.height			= y2 + 2 + 'px';
	bg2.style.display		= 'block';
	bg2.style.height		= y2 + 2 + 'px';
	
	t=setTimeout("changeheight2('" + thisSection + "');",0);
}



function hideMsg(section)
{
	var sID, sSrc;
	sID = section + "-msg";
	sSrc = document.getElementById(sID)
	
	sSrc.style.display = "none";
}

function showMsg(section)
{
	var sID, sSrc;
	sID = section + "-msg";
	sSrc = document.getElementById(sID)
	
	sSrc.style.display = "block";
}



