/**
 * @author Mike Cousins
 */

// used to submit the logout form from a text link
function submitLogoutForm()
{
	document.logoutform.submit();
}

// used to check the register form
function checkRegisterForm()
{

var result = true;
var errorMessage = "You have the following errors in your registration:\n";

// check the emails
if ((document.registerform.email1.value != document.registerform.email2.value) ||
(document.registerform.email1.value == '') ||
(document.registerform.email2.value == '')) {
	document.registerform.email1.style.background = "#ffcccc";
	document.registerform.email2.style.background = "#ffcccc";
	result = false;
	errorMessage += "Emails do not match\n";
}
else
{
	document.registerform.email1.style.background = "#ffffff";
	document.registerform.email2.style.background = "#ffffff";
}

// check the passwords
if ((document.registerform.password1.value != document.registerform.password2.value) ||
(document.registerform.password1.value == '') ||
(document.registerform.password2.value == '')) {
	document.registerform.password1.style.background = "#ffcccc";
	document.registerform.password2.style.background = "#ffcccc";
	result = false;
	errorMessage += "Passwords do not match\n";
}
else
{
	document.registerform.password1.style.background = "#ffffff";
	document.registerform.password2.style.background = "#ffffff";
}

// check result
if (result == false) {
	alert(errorMessage);
	return false;
}
else {
	return true;
}

}

// used to check the account form
function checkAccountForm()
{

var result = true;
var errorMessage = "You have the following errors in your account:\n";

// check the email field
if (document.accountform.email.value == '') {
	document.accountform.email.style.background = "#ffcccc";
	result = false;
	errorMessage += "Blank e-mail\n";
}
else
{
	document.accountform.email.style.background = "#ffffff";
}

// check the passwords
if (document.accountform.password1.value != document.accountform.password2.value) {
	document.accountform.password1.style.background = "#ffcccc";
	document.accountform.password2.style.background = "#ffcccc";
	result = false;
	errorMessage += "Passwords do not match\n";
}
else
{
	document.accountform.password1.style.background = "#ffffff";
	document.accountform.password2.style.background = "#ffffff";
}

// check result
if (result == false) {
	alert(errorMessage);
	return false;
}
else {
	return true;
}

}

// used to check the address form
function checkAddressForm()
{

var result = true;
var errorMessage = "You have the following errors in your addresses:\n";

// check result
if (result == false) {
	alert(errorMessage);
	return false;
}
else {
	return true;
}
}

// used to check the directory form
function checkDirectoryForm()
{

var result = true;
var errorMessage = "You have the following errors in your directory info:\n";

// check result
if (result == false) {
	alert(errorMessage);
	return false;
}
else {
	return true;
}
}



// used to check the account form
function checkWatermarkForm()
{

var result = true;
var errorMessage = "You have the following errors in your watermark:\n";

// check the email field
if (document.watermarkform.email.value == '') {
	document.watermarkform.email.style.background = "#ffcccc";
	result = false;
	errorMessage += "Blank e-mail\n";
}
else
{
	document.watermarkform.email.style.background = "#ffffff";
}

// check the passwords
if (document.watermarkform.password1.value != document.accountform.password2.value) {
	document.watermarkform.password1.style.background = "#ffcccc";
	document.watermarkform.password2.style.background = "#ffcccc";
	result = false;
	errorMessage += "Passwords do not match\n";
}
else
{
	document.watermarkform.password1.style.background = "#ffffff";
	document.watermarkform.password2.style.background = "#ffffff";
}

// check result
if (result == false) {
	alert(errorMessage);
	return false;
}
else {
	return true;
}

}


// copies the fields from the shipping address to the billing address fields
function copyBillingClickedAddressPage()
{
document.addressform.shippingname.value = document.addressform.billingname.value;
document.addressform.shippingaddress1.value = document.addressform.billingaddress1.value;
document.addressform.shippingaddress2.value = document.addressform.billingaddress2.value;
document.addressform.shippingcity.value = document.addressform.billingcity.value;
document.addressform.shippingprovince.selectedIndex = document.addressform.billingprovince.selectedIndex ;
document.addressform.shippingpostal.value = document.addressform.billingpostal.value;
document.addressform.shippingcountry.selectedIndex = document.addressform.billingcountry.selectedIndex;
}

function showPhotographer(elementID)
{
var element = document.getElementById(elementID)

if (element.style.display == 'block')
{
	element.style.display = 'none';
}
else
{
	element.style.display = 'block';
}
}
