function GenPage()
{
	var self = this;
	var pageHeight;
		
	GenPage.prototype.initPage = function(pageName)
	{
		switch(pageName)
		{
			case "index":
				pageHeight = "750px";
				document.getElementById("homeSpan").onmouseover = function(evt){self.changeTextColor('homeList', 'true')};
				document.getElementById("homeSpan").onmouseout = function(evt){self.changeTextColor('homeList', 'false')};
		
				document.getElementById("businessSpan").onmouseover = function(evt){self.changeTextColor('businessList', 'true')};
				document.getElementById("businessSpan").onmouseout = function(evt){self.changeTextColor('businessList', 'false')};
		
				document.getElementById("financialSpan").onmouseover = function(evt){self.changeTextColor('financialList', 'true')};
				document.getElementById("financialSpan").onmouseout = function(evt){self.changeTextColor('financialList', 'false')};
				break;
				
			case "contact":
				pageHeight = "250px";
				document.getElementById("goldenLink").onclick = function(evt){self.addAddress('golden', '16399 South Golden Road', '', 'Golden, Colorado 80401', '800-928-7244', '', '303-379-6606 fax', 'TammyB@UsaInsuranceGroup.com', 'mailto:TammyB@usainsurancegroup.com')};
				document.getElementById("phoenixLink").onclick = function(evt){self.addAddress('phoenix', '9124 East Apache Trail', 'Suite 11', 'Mesa, Arizona 85220', '800-344-7605', '', '480-983-0766 fax', 'DavidF@UsaInsuranceGroup.com', 'mailto:DavidF@usainsurancegroup.com')};
				break;			
			case "partners":
				pageHeight = "1000px";
				break;			
			case "business":
				pageHeight = "650px";
				break;
			case "auto":
				pageHeight = "580px";
				break;
			case "home":
				pageHeight = "580px";
				break;
			case "life":
				pageHeight = "350px";
				break;
			case "annuities":
				pageHeight = "800px";
				break;
			case "lifeform":
				pageHeight = "1270px";
				this.writeStateOptions();
				break;
			case "homeform":
				pageHeight = "1750px";
				this.writeStateOptions();
				break;
			case "homeformsite":
				pageHeight = "2100px";
				this.writeStateOptions();
				break;
			case "autoform":
				pageHeight = "2840px";
				this.writeStateOptions();
				break;
			case "thankYou":
				pageHeight = "300px";
				break;
		}
		
		//if click on top banner - go to index page
		document.getElementById('topDiv').style.cursor = 'hand';
		document.getElementById('topDiv').onclick = function(evt){window.location = 'index.htm'};
		
		
		//customize the height of the page 
		document.getElementById('leftDiv').style.height = pageHeight;
		document.getElementById('rightDiv').style.height = pageHeight;	
					
	}
	
	GenPage.prototype.changeTextColor = function(idName, isOver)
	{
		for(var i=0; i < document.getElementById(idName).childNodes.length; i++)
		{
			if(isOver == 'true')
			{
				document.getElementById(idName).childNodes[i].style.color = "#3333FF";
			}
			else
			{
				document.getElementById(idName).childNodes[i].style.color = "black";
			}	
		}			
	}
	
	GenPage.prototype.addAddress = function(idName, add1, add2, state, phone1, phone2, fax, email, url)
	{
		var addNum;
		switch(idName)
		{
			case "golden":
				addNum = 85;
				break;
			case "phoenix":
				addNum = 120;
				break;
			case "vegas":
				addNum = 125;
				break;
		}
		
		var tempNum = parseInt(pageHeight.substring(0,3)) + addNum;
		pageHeight = tempNum + "px";
		
		document.getElementById('rightDiv').style.height = pageHeight;
		document.getElementById('leftDiv').style.height = pageHeight;
				
		var location = document.getElementById(idName).firstChild.firstChild.nodeValue;
		var addArray = new Array(location, add1, add2, state, phone1, phone2, fax);		
		var node = document.getElementById(idName);		
		node.removeChild(node.firstChild);
		
		for (var i = 0; i < addArray.length; i++)
		{
			if(addArray[i] != "")
			{
				node.appendChild(document.createTextNode(addArray[i]));
				node.appendChild(document.createElement("br"));				
			}		
		}
		
		//email
		var emailElement = document.createElement("a"); 
		emailElement.appendChild(document.createTextNode(email));
		emailElement.setAttribute("href", url);
		node.appendChild(emailElement);
	}
	
	GenPage.prototype.stopAnimation = function(elmentObj)
	{
		var idTitle = elmentObj.id + 'Title'; 
		document.getElementById(idTitle).onmouseover = null;
	}
	
	GenPage.prototype.writeStateOptions = function()
	{
		var counter;
		var stateArray = new Array('AL', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'FL', 'GA', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD',		'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY');
		var stateString = '<select name="required-stateResidence" id="required-stateResidence">';
	
		//build options from stateArray
		for (counter = 0; counter < stateArray.length; counter++)
		{
			stateString = stateString + '<option value=' + stateArray[counter] + '>' + stateArray[counter] + '</option>';		
		}			
	
		stateString = stateString + '</select>';
		document.getElementById("stateSelect").innerHTML = stateString;
	}
	
	GenPage.prototype.formTest = function()
	{
		alert('you are in the form test');
	}
}


/*old form validation from js class*/
function FormValidator(FormType)
{
	var self = this;
	var formType;
	var formPath;
	var fName;
	var lName;
	var hPhone;	
	var bPhone;
	var email;
	var spouseFName;
	var spouseLName;
	
	self.formType = FormType;
	
	//methods//////////////////////////////////////////
	FormValidator.prototype.validateForm = function()
	{
		var result;
		result = self.setFormValues();
		
		if(result)
		{
			result = self.checkAllFields(); 			
		}		
		return result;
	}
	
	FormValidator.prototype.setFormValues = function()
	{
		switch(self.formType)
		{
			case 'lifeForm':
				self.formPath = document.lifeForm;
				
				//fields specific to lifeForm
				//set spouse FName if entered
				if (self.formPath.spouseFName.value != '')
				{
					self.spouseFName = self.formPath.spouseFName.value;
				}
				
				if (self.formPath.spouseLName.value != '')
				{
					self.spouseLName = self.formPath.spouseLName.value;
				}
				break;
		}
		
		//set first name
		self.fName = self.formPath.FName.value;
						
		//set last name
		self.lName = self.formPath.LName.value;	
		
		//set home phone number
		self.hPhone = self.formPath.hPhone.value;
		
		//set business phone if entered
		if (self.formPath.hPhone.value != '')
		{
			self.bPhone = self.formPath.bPhone.value;
		}
		
		//set email
		self.email = self.formPath.email.value;
								
		return true;
	}	
	
	FormValidator.prototype.checkAllFields = function()
	{
		//first name required
		if((self.fName != '') &&  (self.checkPattern(self.fName, '^[\\D]+$','')))
		{
			//do nothing all is well
		}
		else
		{
			alert('Please enter your first name again.');
			self.formPath.FName.focus();
			self.formPath.FName.select();
			return false;
		}
		
		//last name required
		if((self.lName != '') &&  (self.checkPattern(self.lName, '^[\\D]+$','')))
		{
			//all is well
		}
		else
		{
			alert('Please enter your last name again.');
			self.formPath.LName.focus();
			self.formPath.LName.select();
			return false;
		}
		
		//home phone required
		if((self.hPhone != '') &&  (self.checkPattern(self.hPhone, '^\\s*\\d{3}-\\d{3}-\\d{4}\\s*$','')))
		{
			//all is well
		}
		else
		{
			alert('Please enter your home phone number in the 000-000-0000 format.');
			self.formPath.hPhone.focus();
			self.formPath.hPhone.select();
			return false;
		}
		
		//business phone is not required
		if(self.bPhone != '') 
		{
			if(!self.checkPattern(self.bPhone, '^\\s*\\d{3}-\\d{3}-\\d{4}\\s*$',''))
			{
				alert('Please enter your business phone number in the 000-000-0000 format.');
				self.formPath.bPhone.focus();
				self.formPath.bPhone.select();
				return false;
			}			
		}
		
		//email required
		if((self.email != '') &&  (self.checkPattern(self.email, '^\\s*[\\w\\.]+@[\\w\.]+\\s*$','')))
		{
			//all is well
		}
		else
		{
			alert('Please enter your email address.');
			self.formPath.email.focus();
			self.formPath.email.select();
			return false;
		}
		
		//these are form specific fields
		switch(self.formType)
		{
			case 'lifeForm':
				//spouseFName
				if(self.spouseFName != '') 
				{
					if(!self.checkPattern(self.spouseFName, '^[\\D]+$',''))
					{
						alert('Please enter the spouse first name again.');
						self.formPath.spouseFName.focus();
						self.formPath.spouseFName.select();
						return false;
					}			
				}
				
				//spouseLName
				if(self.spouseLName != '') 
				{
					if(!self.checkPattern(self.spouseLName, '^[\\D]+$',''))
					{
						alert('Please enter the spouse last name again.');
						self.formPath.spouseLName.focus();
						self.formPath.spouseLName.select();
						return false;
					}			
				}
				break;
		}
				
		return true;
	}
	
	FormValidator.prototype.checkPattern = function(stringText, regexString, stringOptions)
	{
		//for debugging//alert('stringText is ' + stringText + ' regexString is  ' + regexString + ' stringOptions is ' + stringOptions);
		regex = new RegExp(regexString, stringOptions) ;
		
		return regex.test(stringText);
	}
}
	
