//<!--
// includes/scripts.js


function classChange(element,newclass)
{
	element.className = newclass;
}



function classToggle(element,class1,class2)
{
	if (element.className==class1)
	{
		element.className = class2;
	}
	else if (element.className==class2)
	{
		element.className = class1;
	}
}


function showHide(id)
{
	var current = document.getElementById(id).style.display;
		
	if (current == '')
	{
		document.getElementById(id).style.display='none';
	}
	else
	{
		document.getElementById(id).style.display='';
	}
}



function showHideFam()
{
	famcount = document.getElementById('nfm').value;
	
	if (famcount == "0")
	{
		document.getElementById('afm').style.display='none';	
	}
	else
	{
		document.getElementById('afm').style.display='';
	}
	
	for (i = 1; i <= 10; i++)
	{
		if (i <= famcount)
		{
			document.getElementById('afm' + i).style.display='';
		}
		else
		{
			document.getElementById('afm' + i).style.display='none';
		}
	}
}

function writeCookie(clicked,dstring)
{
	//alert('nav=' + clicked + '; expires=' + dstring + ' UTC; path=/');
	document.cookie = 'nav=' + clicked + '; expires=' + dstring + ' UTC; path=/';
}



function doHash()
{
	if (document.uform.password.value != '')
	{
		var str1 = document.uform.challenge.value;
		var str2 = document.uform.password.value;
		if (document.forms[0].confpassword)
		{
			if (document.uform.confpassword.value != '')
			{
				var str3 = document.uform.confpassword.value;
				var t3 = hex_md5(str3);
				document.uform.confpassword.value = t3;
			}
		}
		var t = hex_md5(str2);
		var newstr = hex_md5(str1 + t);
		document.uform.challenge.value = '';
		document.uform.password.value = '';
		document.uform.challenge.value = newstr;
	}
	else
	{
		document.uform.challenge.value = '';
	}
}


function doHashChange()
{
	var str1 = document.upass.challenge.value;
	var str2 = document.upass.oldpassword.value;
	var str3 = document.upass.newpassword.value;
	var str4 = document.upass.confnewpassword.value;
	
	var t2 = hex_md5(str2);
	var t3 = hex_md5(str3);
	var t4 = hex_md5(str4);
	
	document.upass.challenge.value = '';
	document.upass.oldpassword.value = t2;
	document.upass.newpassword.value = hex_md5(str1 + t3);
	document.upass.confnewpassword.value = t4;
}


function doHashNew()
{
	var str1 = document.upass.challenge.value;
	var str3 = document.upass.newpassword.value;
	var str4 = document.upass.confnewpassword.value;
	
	var t3 = hex_md5(str3);
	var t4 = hex_md5(str4);
	
	document.upass.challenge.value = '';
	document.upass.newpassword.value = hex_md5(str1 + t3);
	document.upass.confnewpassword.value = t4;
}


function reCalc()
{
	// read each value and submit via ajax and recalc total.
	subtype = document.newform.subtype.value;
	student = document.newform.student.checked;  // or checked=checked? read up on this
	years = document.newform.years.value;
	numfam = document.newform.numfam.value;
	nopaypal = document.newform.nopaypal.checked;
	
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			string = xmlhttp.responseText;
			len = string.length;
			if (len < 28)
			{
				width = "170px";
			}
			else
			{
				width = "200px";
			}
			document.getElementById("total").style.width = width;
			document.getElementById("total").value = string;
			if (string.indexOf("Cash") != -1)
			{
				notestr = "Your membership will not be active until your payment has been processed.";
			}
			else
			{
				notestr = "Please return to this site when you are done with Paypal.";
			}
			document.getElementById('note').innerHTML = notestr;
		}
	}
	posturl = "/myaccount/recalc.php?actionflag=set&subtype="+subtype+"&student="+student+"&years="+years+"&numfam="+numfam+"&nopaypal="+nopaypal;
//	alert(posturl);
	xmlhttp.open("GET",posturl,true);
	xmlhttp.send();
}


function getEmail(cs)
{
	// get callsign
	var callsign = cs; //document.getElementById('callsign').innerHTML;
	
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById('outer'+cs).innerHTML = xmlhttp.responseText;
		}
	}
	posturl = "/emailReturn.php?actionflag=set&callsign="+callsign;
	xmlhttp.open("GET",posturl,true);
	xmlhttp.send();
}


function disableFormSubmit()
{
	document.getElementById('total').disabled=true;
	document.getElementById('total').value='Sending...';
	document.getElementById('total').submit();
}




function reCalcA()
{
	// read each value and submit via ajax and recalc total.
	subtype = document.newform.subtype.value;
	student = document.newform.student.checked;  // or checked=checked? read up on this
	years = document.newform.years.value;
	numfam = document.newform.numfam.value;
	nopaypal = "true";
	
	if (subtype == 'honorary')
	{
		document.getElementById('sttr').style.display = 'none';
		document.getElementById('ytr').style.display = 'none';
		document.getElementById('nfmtr').style.display = 'none';
	}
	else
	{
		document.getElementById('sttr').style.display = '';
		document.getElementById('ytr').style.display = '';
		document.getElementById('nfmtr').style.display = '';
	}
	
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			string = xmlhttp.responseText;
			len = string.length;
			if (len < 28)
			{
				width = "170px";
			}
			else
			{
				width = "200px";
			}
			document.getElementById("total").style.width = width;
			document.getElementById("total").value = string;
			if (string.indexOf("Cash") != -1)
			{
				notestr = "Your membership will not be active until your payment has been processed.";
			}
			
			document.getElementById('note').innerHTML = notestr;
			// orig
			//document.getElementById("total").value = xmlhttp.responseText;
		}
	}
	posturl = "/myaccount/recalc.php?actionflag=set&subtype="+subtype+"&student="+student+"&years="+years+"&numfam="+numfam+"&nopaypal="+nopaypal;
	//alert(posturl);
	xmlhttp.open("GET",posturl,true);
	xmlhttp.send();
}



// -->

