function validate_login_form()
{
    valid = true;

    if ( document.login_form.username.value == "" || document.login_form.password.value == "")
    {
        alert ( "Please provide a username and password." );
        valid = false;
    }   
    
	showLoader(valid);
    return valid;
}


function validate_registration_form()
{
    valid = true;

    if ( document.registration_form.username.value == "" || document.registration_form.password.value == "" || document.registration_form.monkey.value == "" || document.registration_form.email.value == "" || document.registration_form.first_name.value == "" || document.registration_form.last_name.value == "")
    {
        alert ( "Please complete all fields marked with *." );
        valid = false;
    }   
    
    if ( document.registration_form.password.value != document.registration_form.monkey.value)
    {
        alert ( "Your passwords do not match." );
        valid = false;
    }   
    
	showLoader(valid);
    return valid;
}

function validate_account_form()
{
    valid = true;

    if ( document.account_form.email.value == "" || document.account_form.first_name.value == "" || document.account_form.last_name.value == "")
    {
        alert ( "Please complete all fields marked with *." );
        valid = false;
    }   
    

    
	showLoader(valid);
    return valid;
}

function validate_comment_form()
{
    valid = true;

    if ( document.comment_form.content.value == "" )
    {
        alert ( "You didn't say anything!" );
        valid = false;
    }   
    

    
	showLoader(valid);
    return valid;
}


function validate_contact_form()
{
        
	valid = true;


	if(document.contact_form.name.value == "" || document.contact_form.address.value == "" || document.contact_form.message.value == "")
	{
	    alert("Please complete all fields marked with *.");
	    valid = false;
	}
	    else if(document.contact_form.message.value.length>400)
	    {
		alert ( "Your message must be less than 400 characters." );
		valid = false;
	    }
    	
	showLoader(valid);
	return valid;

}

function validate_org_form()
{
        
	valid = true;


	if( document.org_form.name.value == "" || document.org_form.descr.value == "" || document.org_form.geoarea.value == "" || document.org_form.what.value == "" || document.org_form.contactname.value == "" || document.org_form.contacttel.value == "" || document.org_form.contactemail.value == "" || document.org_form.keyevents.value == "" || document.org_form.postcode.value == "" )
	{
	    alert("Please complete all fields marked with *.");
	    valid = false;
	}
    	
	showLoader(valid);
	return valid;

}

function validate_event_form()
{
        
	valid = true;

	if(document.event_form.title.value == "" || document.event_form.categories.value == "" || document.event_form.orgs.value == "" || document.event_form.descr.value == "" || document.event_form.venue.value == "" || document.event_form.postcode.value == "" || document.event_form.contactname.value == "" || document.event_form.start_date.value == "" || document.event_form.start_time_h.value == "" || document.event_form.start_time_m.value == "")
	{
	    alert("Please complete all fields marked with *.");
	    valid = false;
	}

	showLoader(valid);
	return valid;

}


function showOptions()
{
	document.getElementById('options').style.display = 'inline';
}

function hideOptions()
{
	document.getElementById('options').style.display = 'none';
}




function showLogin()
{

	document.getElementById('loginSmall').style.display = 'inline';
	
	document.getElementById('notLoggedIn').style.display = 'none';
	

}

function validate_password_form()
{
    valid = true;

    if ( document.password_form.cur_pwd.value == "" || document.password_form.new_pwd.value == "" || document.password_form.monkey_pwd.value == "" )
    {
        alert ( "Please complete all fields marked with *." );
        valid = false;
    }   
    
    if ( document.password_form.new_pwd.value != document.password_form.monkey_pwd.value)
    {
        alert ( "Your passwords do not match." );
        valid = false;
    }   
    
	showLoader(valid);
    return valid;
}

function validate_images_form()
{
    valid = true;

    
    if ( document.images_form.replace_main.checked == 1 )
    {
 	if ( document.images_form.main.value == "" )
 	{
 		alert ( "Please complete all fields marked with *." );
        	valid = false;
 	}
 
    }
    
    
    if ( document.images_form.replace_icon.checked == 1 )
    {
 	if ( document.images_form.icon.value == "" )
 	{
 		alert ( "Please complete all fields marked with *." );
        	valid = false;
 	}
 
    }    
   
	showLoader(valid);
    return valid;
}



function popup(page)
{
	window.open(page,'newwindow','scrollbars=yes,status=no,width=500,height=410')
}



function showLoader(valid)
{
	if(valid==true)
	{
		window.scrollTo(0,0);
		document.getElementById('overlay').style.display = 'block';
		document.getElementById('overlay_message').style.display = 'block';
	}

}




