
function display(id) {

    vista = (document.getElementById(id).style.display == 'none') ? 'block' : 'none';
    document.getElementById(id).style.display = vista;
 
}

function validate_edit(){
	thefrm = document.frm_edit;
	
	if(!thefrm.fname.value)
	{
		alert('You must enter your first name.');
		thefrm.fname.focus();
		return;
	}
	
	if(!thefrm.lname.value)
	{
		alert('You must enter your last name.');
		thefrm.lname.focus();
		return;
	}

	thefrm.submit();
	
}

function validate_add(){
	thefrm = document.frm_add;
	
	if(!thefrm.fname.value)
	{
		alert('You must enter your first name.');
		thefrm.fname.focus();
		return;
	}
	
	if(!thefrm.lname.value)
	{
		alert('You must enter your last name.');
		thefrm.lname.focus();
		return;
	}

	if(!thefrm.email.value)
	{
		alert('You must an email address to be used as a username.');
		thefrm.email.focus();
		return;
	}

	thefrm.submit();
	
}

function validate_request(){
	thefrm = document.frm_request;
	if(!thefrm.fname.value)
	{
		alert('You must enter your first name.');
		thefrm.fname.focus();
		return;
	}
	
	if(!thefrm.lname.value)
	{
		alert('You must enter your last name.');
		thefrm.lname.focus();
		return;
	}
	
	if(!thefrm.email.value)
	{
		alert('You must enter your email address.');
		thefrm.email.focus();
		return;
	}
	
	if(!thefrm.connection.value)
	{
		alert('You must enter your connection to MLS.');
		thefrm.connection.focus();
		return;
	}

	thefrm.submit();
}

function validate_contact(){
	thefrm = document.frm_contact;
	if(!thefrm.name.value)
	{
		alert('You must enter your name.');
		thefrm.name.focus();
		return;
	}
	
	if(!thefrm.email.value)
	{
		alert('You must enter your email address.');
		thefrm.email.focus();
		return;
	}
	
	if(!thefrm.comments.value)
	{
		alert('You must enter a comment.');
		thefrm.comments.focus();
		return;
	}

	thefrm.submit();
}

function validate_password(){
	thefrm = document.frm_password;
	if(!thefrm.curr_pass.value)
	{
		alert('You must enter your current password.');
		thefrm.curr_pass.focus();
		return;
	}
	
	if(!thefrm.username.value)
	{
		alert('You must enter a username.');
		thefrm.username.focus();
		return;
	}
	
	if(thefrm.confirm_pass.value != thefrm.new_pass.value)
	{
		alert('Your new passwords do NOT match.');
		thefrm.confirm_pass.focus();
		return;
	}

	thefrm.submit();
}

function viewLocation(val) {
	if(val == 'WELS' || val == 'ELS'){
		document.getElementById('locate').style.display = 'block';
		document.getElementById('congOther').style.display = 'none';
		document.getElementById('homeCongOther').value= ''; 
	}
	else{
		document.getElementById('congOther').style.display = 'block';
		document.getElementById('locate').style.display = 'none';
		document.getElementById('cong').style.display = 'none';
		document.frm_edit.hdn_homecong.value = 0;
	}
}

function makeObject(){
	var x; 
	var browser = navigator.appName; 
	if(browser == "Microsoft Internet Explorer"){
		x = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		x = new XMLHttpRequest();
	}
	return x;
}
 
var request = makeObject();

function viewCong(synod, loc){
	
	request.open('get', 'getCongs.php?synod=' + synod + '&loc=' + loc);
	
	request.onreadystatechange = parseInfo;

	request.send('');
	
}

function parseInfo(){

	if(request.readyState == 1){
		document.getElementById('cong').style.display = 'block';
		document.getElementById('cong').innerHTML = 'Loading...';
	}
	if(request.readyState == 4){
		var answer = request.responseText;
		document.getElementById('cong').style.display = 'block';
		document.getElementById('cong').innerHTML = answer;
	}
}

function setValues(val){
	document.frm_edit.hdn_homecong.value = val;
}
