/*   COMMON FUNCTIONS   */
//
// DETERMINE BROWSER MAXIMUM DIMENSIONS
function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;}
function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;}
function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;}
function posRight() {return posLeft()+pageWidth();} function posBottom() {return posTop()+pageHeight();}
//




// SWAP IMAGES ON HOVER OVER
function roll_over_fn(img_name, img_src)
	{
		document[img_name].src = img_src;
	}
//



















//
//   VALIDATE IF ALL REQUIRED FIELDS HAVE VALID DATA.
//
function ValidateForm(form_name)
	{
		var count_valid = 0;
		var total_to_validate = 0;
		//
		//
		//   DETERMINE IF THIS ELEMENT EXISTS AND NEEDS TO BE VERIFIED. IF PRESENT, ASSIGN VARIABLE NAME.
		//
		/*var validate_first_name = form_name.check_first_name;
		var validate_last_name = document.getElementById("check_last_name");
		var validate_company = document.getElementById("check_company");
		var validate_phone_number = document.getElementById("check_phone_number");
		var validate_extension = document.getElementById("check_extension_number");
		var validate_fax_number = document.getElementById("check_fax_number");*/
		var validate_email = form_name.email.value;
		//
		//
		//
		/*var test_first_name = false;
		var test_last_name = false;
		var test_company = false;
		var test_phone_number = false;
		var test_extension = false;
		var test_fax_number = false;*/
		var test_email = false;
		//
		//
		//
		/*if (validate_first_name != null || validate_first_name != "")
			{
				test_first_name = true;
				//
				total_to_validate = total_to_validate + 1;
			}
		//
		if (validate_last_name != null || validate_last_name != "")
			{
				test_last_name = true;
				//
				total_to_validate = total_to_validate + 1;
			}
		//
		if (validate_company != null || validate_company != "")
			{
				test_company = true;
				//
				total_to_validate = total_to_validate + 1;
			}
		//
		if (validate_phone_number != null || validate_phone_number != "")
			{
				test_phone_number = true;
				//
				total_to_validate = total_to_validate + 1;
			}
		//
		if (validate_extension != null || validate_extension != "")
			{
				test_extension = true;
				//
				total_to_validate = total_to_validate + 1;
			}
		//
		if (validate_fax_number != null || validate_fax_number != "")
			{
				test_fax_number = true;
				//
				total_to_validate = total_to_validate + 1;
			}*/
		//
		if (validate_email != null || validate_email != "")
			{
				test_email = true;
				//
				total_to_validate = total_to_validate + 1;
			}
		//
		//
		//
		if (test_email == true)
			{
				var user_input = validate_email;
				var user_email_valid = true;
				//
				if (user_input == null || user_input == "")
					{
						alert("The E-mail Address field is required. Please try again.");
						user_email_valid = false;
					}
					else
					{
						var at_symbol = "@";
						var period_symbol = ".";
						//
						var string_length = user_input.length;
						var at_position = user_input.indexOf(at_symbol);
						var period_position = user_input.indexOf(period_symbol);
						//
						if (user_input.indexOf(at_symbol) == -1 || user_input.indexOf(at_symbol) == 0 || user_input.indexOf(at_symbol) == string_length)
							{
								user_email_valid = false;
							}
						if (user_input.indexOf(period_symbol) == -1 || user_input.indexOf(period_symbol) == 0 || user_input.indexOf(period_symbol) == string_length)
							{
								user_email_valid = false;
							}
						if (user_input.indexOf(at_symbol, (at_position + 1)) != -1)
							{
								user_email_valid = false;
							}
						if (user_input.substring(at_position - 1, at_position) == period_symbol || user_input.substring(at_position + 1, at_position + 2) == period_symbol)
							{
								user_email_valid = false;
							}
						if (user_input.indexOf(period_symbol, (at_position + 2)) == -1)
							{
								user_email_valid = false;
							}
						if (user_input.indexOf(" ") != -1)
							{
								user_email_valid = false;
							}
						//
						if (user_email_valid == false)
							{
								alert("Invalid E-mail Address. Please try again.");
							}
					}
				//
				if (user_email_valid == true)
					{
						count_valid = count_valid + 1;
					}
			}
		//
		//
		//
		if (count_valid == total_to_validate)
			{
				return true;
			}
			else
			{
				return false;
			}
	}
//
//
//

