var but = new Array();
var i;

for (i = 0; i <= 10; i++)
{
	but[i] = new Array();
	but[i][0] = new Image();
	but[i][0].src = "templates/default/images/mainNav/but" + i + ".gif";
	but[i][1] = new Image();
	but[i][1].src = "templates/default/images/mainNav/but" + i + "_hi.gif";
}

function myOver(which)
{
	if (document.images)
	{
		document.images["but" + which].src = but[which][1].src;
	}
}

function myOut(which)
{
	if (document.images)
	{
		document.images["but" + which].src = but[which][0].src;
	}
}

function butOver(which, extension, myNumber)
{
	if (document.images)
	{
		if (myNumber == null)
		{
			myNumber = "";
		}

		document.images[which.toString() + myNumber].src = "buttonsRed/" + which.toString() + "_hi." + extension.toString();
	}
}

function butOut(which, extension, myNumber)
{
	if (document.images)
	{
		if (myNumber == null)
		{
			myNumber = "";
		}

		document.images[which.toString() + myNumber].src = "buttonsRed/" + which.toString() + "." + extension.toString();
	}
}

function check_submition(this_form)
{
	submit_form = true;
	message = new String();

	if(this_form.name != null)
	{
		if(!is_text(this_form.name.value, true))
		{
			submit_form = false;
			message += "Please ensure the NAME field is filled in correctly\n";
			this_form.name.style.background = "#FF9999";
		}
		else
		{
			this_form.name.style.background = "#F5F5F5";
		}
	}

	if(this_form.surname != null)
	{
		if(!is_text(this_form.surname.value, true))
		{
			submit_form = false;
			message += "Please ensure the SURNAME field is filled in correctly\n";
			this_form.surname.style.background = "#FF9999";
		}
		else
		{
			this_form.surname.style.background = "#F5F5F5";
		}
	}

	if(this_form.email != null)
	{
		if(!is_email(this_form.email.value, true))
		{
			submit_form = false;
			message += "Please ensure the EMAIL field is fill with a valide email address\n";
			this_form.email.style.background = "#FF9999";
		}
		else
		{
			this_form.email.style.background = "#F5F5F5";
		}
	}

	if(this_form.telephone != null)
	{
		if(this_form.telephone.value != '' && !is_phone(this_form.telephone.value, false))
		{
			submit_form = false;
			message += "Please ensure the TELEPHONE field is filled with a valid phone number\n";
			this_form.telephone.style.background = "#FF9999";
		}
		else
		{
			this_form.telephone.style.background = "#F5F5F5";
		}
	}

	if(this_form.fax != null)
	{
		if(this_form.fax.value != null && this_form.fax.value != "" && !is_phone(this_form.fax.value, false))
		{
			submit_form = false;
			message += "Please ensure the FAX field is filled with a valid fax number\n";
			this_form.fax.style.background = "#FF9999";
		}
		else
		{
			this_form.fax.style.background = "#F5F5F5";
		}
	}

	if(message != "")
	{
		alert(message);
	}

	return submit_form;
}

function is_text(form_data, is_required)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
	is_valid = true;
	var Char;

	if((is_required == true) && (form_data == "" || form_data == null))
	{
		is_valid = false;
	}

	for (i = 0; i < form_data.length; i++)
	{
		Char = form_data.charAt(i).toUpperCase();
		if (ValidChars.indexOf(Char) == -1)
		{
			is_valid = false;
		}
	}

	return is_valid;
}

function is_phone(form_data, is_required)
{
	var ValidChars = "0123456789()+ ";
	is_valid = true;
	var Char;

	if((is_required == true) && (form_data == "" || form_data == null))
	{
		is_valid = false;
	}

	for (i = 0; i < form_data.length; i++)
	{
		Char = form_data.charAt(i);
		if (ValidChars.indexOf(Char) == -1)
		{
			is_valid = false;
		}
	}

	return is_valid;
}

function is_email(form_data, is_required)
{
	is_valid = true;

	if((is_required == true) && form_data == "")
	{
		is_valid = false;
	}

	if (form_data.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
	{
		is_valid = false;
	}

	return is_valid;
}

function openCrimeSite()
{
	eyepop=window.open("http://www.criminal-solicitors.com");
}

function openDisclaimer()
{
	eyepop=window.open("./disclaimer.htm", "eyepop", "toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=no, width=220, height=310");
}

function openTerms()
{
	eyepop=window.open("./terms.htm", "eyepop", "toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=yes, width=320, height=410");
}

function openPrivacy()
{
	eyepop=window.open("./privacy.htm", "eyepop", "toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=yes, width=320, height=410");
}

function openUrgent()
{
	eyepop=window.open("./urgent.htm", "eyepop", "toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=no, width=250, height=400");
}
