// JavaScript Document

function checkemail(email)
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(email))
		testresults=true
	else
	{	
		testresults=false
	}
	
	return (testresults)
}

function limitText(limitField, limitNum)
{
	if (limitField.value.length > limitNum)
	{
		limitField.value = limitField.value.substring(0, limitNum);
	}
	else 
	{
		document.getElementById("charsLeft").innerHTML= (limitNum - limitField.value.length);
	}
}

function limitTextDIV(limitField, limitCount, limitNum)
{
	if (limitField.value.length > limitNum)
	{
		limitField.value = limitField.value.substring(0, limitNum);
	}
	else 
	{
		document.getElementById("charsLeft").innerHTML= "You have <SPAN style='color:#ff0000;'>" + (limitNum - limitField.value.length) + "</SPAN> characters left.";
		limitCount.value = limitNum - limitField.value.length;
	}
}


function isBlank(data)
{
	// Remove all cases of "<br>" and "&nbsp;"
	data = data.replace(/\r|\n|\<br>|\&nbsp;/g, "");
	// Remove all spaces
	data = data.replace(/\s/g, "");	

	if (data == '')
		return true;
	else
		return false;	
}

function removeSpacesFromURL(data)
{
	// Remove all cases of "<br>" and "&nbsp;"
	data = data.replace(/\r|\n|\<br>|\&nbsp;/g, "");
	// Remove all spaces
	data = data.replace(/\s/g, "");

	return data;
}

function confirmYesNo()
{
	return confirm("Are you sure?");
}

function validateCreateWebsiteForm(form)
{	
	var theMLSColumns = form.mlsColumns.value;
	theMLSColumns = theMLSColumns.replace(/\D/g, "");		
	if ((isBlank(theMLSColumns)) || (form.mlsColumns.value <= 0))
	{
		alert("You must enter a number greater than zero for columns!");
		return false;
	}				

	var theDomain = form.domain.value;
	var httpString = theDomain.match("http://www.");
	if ((isBlank(theDomain)) || (httpString == null))
	{
		alert("You must enter a domain and it must be in the format http://www.<domain name>\nExamples: http://www.yourdomain.com, http://www.yourdomain.net, http://www.yourdomain.org");
		return false;
	}				

	var theMLSRadius = form.mlsRadius.value;
	theMLSRadius = theMLSRadius.replace(/\D/g, "");		
	if ((isBlank(theMLSRadius)) || (form.mlsRadius.value <= 0))
	{
		alert("You must enter a number greater than zero for the MLS Radius!");
		return false;
	}				

	var theMLSNumberOfCities = form.mlsNumberOfCities.value;
	theMLSNumberOfCities = theMLSNumberOfCities.replace(/\D/g, "");		
	if ((isBlank(theMLSNumberOfCities)) || (form.mlsNumberOfCities.value <= 0))
	{
		alert("You must enter a number greater than zero for the MLS # of Cities!");
		return false;
	}				


	return true;
}

function validateReferralForm(form)
{	

	if (form.t_name)
	{
		if (isBlank(form.t_name.value))
		{
			alert("You must enter the recipients name!");
			return false;
		}			
		if (checkemail(form.t_email.value) == false)
		{
			alert("You must enter the recipients email!");
			return false;
		}		
		if (isBlank(form.t_phone.value))
		{
			alert("You must enter the recipients phone number!");
			return false;
		}
	}
	
	if (form.selectedType.value == 0)
	{	
		if (isBlank(form.l_name.value))
		{
			alert("You must enter the lead name!");
			return false;
		}			
		if (checkemail(form.l_email.value) == false)
		{
			alert("You must enter the lead email!");
			return false;
		}		
		if (isBlank(form.l_phone.value))
		{
			alert("You must enter the lead phone number!");
			return false;
		}		
		
		var theReferralPercent = form.referralPercent.value;
		var containsCharacters = theReferralPercent.match(/\D/g);
		if (isBlank(form.referralPercent.value) || (containsCharacters != null) || (form.referralPercent.value > 100) || (form.referralPercent.value < 1))
		{
			alert("You must enter the referral percent! (Valid values: 1 - 100)");
			return false;
		}		


		if (isBlank(form.l_communities.value))
		{
			alert("You must enter one or more communities (comma seperated for multiple communities)!");
			return false;
		}		
		if (isBlank(form.l_state.value))
		{
			alert("You must enter a state!");
			return false;
		}		
	}
	else
	{
		if (isBlank(form.l_name.value))
		{
			alert("You must enter the lead name!");
			return false;
		}			
		if (checkemail(form.l_email.value) == false)
		{
			alert("You must enter the lead email!");
			return false;
		}		
		if (isBlank(form.l_phone.value))
		{
			alert("You must enter the lead phone number!");
			return false;
		}		

		var theReferralPercent = form.referralPercent.value;
		var containsCharacters = theReferralPercent.match(/\D/g);
		if (isBlank(form.referralPercent.value) || (containsCharacters != null) || (form.referralPercent.value > 100) || (form.referralPercent.value < 1))
		{
			alert("You must enter the referral percent! (Valid values: 1 - 100)");
			return false;
		}		

		if (isBlank(form.s_city.value))
		{
			alert("You must enter a city!");
			return false;
		}		
		
		if (isBlank(form.s_state.value))
		{
			alert("You must enter a state!");
			return false;
		}		
	
	}
	return true;
}


function validateSponsorForm(form)
{		
	var errorString='';

	if (isBlank(form.name.value))
	{
		errorString = errorString + "- Name\n";
	}

	if (isBlank(form.phone.value))
	{
		errorString = errorString + "- Phone\n";
	}

	if (checkemail(form.email.value) == false)
	{
		errorString = errorString + "- Email\n";
	}

	if (isBlank(form.company.value))
	{
		errorString = errorString + "- Company\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}

}

function validatePrequalForm(form)
{		
	var errorString='';

	if (isBlank(form.l_fname.value))
	{
		errorString = errorString + "- First name\n";
	}

	if (isBlank(form.l_lname.value))
	{
		errorString = errorString + "- Last name\n";
	}

	if (checkemail(form.l_email.value) == false)
	{
		errorString = errorString + "- Email\n";
	}

	if (isBlank(form.l_phone.value))
	{
		errorString = errorString + "- Phone\n";
	}

	if (isBlank(form.l_income.value))
	{
		errorString = errorString + "- Income\n";
	}

	if (isBlank(form.l_debt.value))
	{
		errorString = errorString + "- Debt\n";
	}

	if (isBlank(form.l_down.value))
	{
		errorString = errorString + "- Down Payment\n";
	}

	if (isBlank(form.l_credit.value) || form.l_credit.value == "Select Credit Score")
	{
		errorString = errorString + "- Credit Score\n";
	}

	if (isBlank(form.l_state.value) || form.l_state.value == "Select a State")
	{
		errorString = errorString + "- State\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}



function validateContactForm(form)
{
	var errorString='';
	if (isBlank(form.name.value))
	{		
		errorString = errorString + "- Name\n";
	}

	if (checkemail(form.email.value) == false)
	{
		errorString = errorString + "- Email\n";
	}

	if (isBlank(form.phone.value))
	{
		errorString = errorString + "- Phone\n";
	}

	if (isBlank(form.content.value))
	{
		errorString = errorString + "- Comments\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}


function validateMarketReportForm(form)
{
	var errorString='';
	if (isBlank(form.title.value))
	{		
		errorString = errorString + "- Title\n";
	}

	if (isBlank(form.homes.value))
	{
		errorString = errorString + "- Homes currently on the market\n";
	}

	if (isBlank(form.sellDays.value))
	{
		errorString = errorString + "- Average number of days to sell a home\n";
	}

	if (isBlank(form.description.value))
	{
		errorString = errorString + "- Brief Description\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}


function validateListingForm(form)
{
	var errorString='';
	if (isBlank(form.title.value))
	{		
		errorString = errorString + "- Title\n";
	}

	if (isBlank(form.price.value))
	{
		errorString = errorString + "- Price\n";
	}

	if (isBlank(form.sf.value))
	{
		errorString = errorString + "- Sq. Feet\n";
	}

	if (isBlank(form.city.value))
	{
		errorString = errorString + "- City\n";
	}

	if (isBlank(form.state.value))
	{
		errorString = errorString + "- State\n";
	}

	if (isBlank(form.zip.value))
	{
		errorString = errorString + "- Zip\n";
	}

	if (isBlank(form.address1.value))
	{
		errorString = errorString + "- Address 1\n";
	}


	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}


function validateArticleForm(form)
{			
	var errorString='';
	if (isBlank(form.title.value))
	{
		errorString = errorString + "- Article Title\n";
	}

	if (isBlank(form.author.value))
	{
		errorString = errorString + "- Article Author\n";
	}

	if (isBlank(form.source.value))
	{
		errorString = errorString + "- Article Source\n";
	}
	
	if (isBlank(form.hyperlink.value))
	{
		errorString = errorString + "- Link to your website\n";
	}

	if (checkFCKEditorContent("fckEditorContent") == false)
	{
		errorString = errorString + "- Article content\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}


function validateBlah(form)
{			
	var errorString='';
	if (isBlank(form.name.value))
	{		
		errorString = errorString + "- Name\n";
	}

	if (isBlank(form.phone.value))
	{
		errorString = errorString + "- Phone\n";
	}

	if (checkemail(form.email.value) == false)
	{
		errorString = errorString + "- Email\n";
	}

	if (isBlank(form.title.value))
	{
		errorString = errorString + "- Title of Article\n";
	}

	if (isBlank(form.author.value))
	{
		errorString = errorString + "- Article Author\n";
	}

	if (isBlank(form.source.value))
	{
		errorString = errorString + "- Article Source\n";
	}
	
	if (isBlank(form.hyperlink.value))
	{
		errorString = errorString + "- Link to your website\n";
	}

	if (checkFCKEditorContent("fckEditorContent") == false)
	{
		errorString = errorString + "- Article content\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}



function validateHomeSearchForm(form)
{	
	var errorString='';
	var communitiesChosen = false;

	for (i=0; i < 100; i++)
	{
		if (document.getElementById('community'+i) && document.getElementById("community"+i).checked)
		{
			communitiesChosen = true;
		}		
	}

	if (communitiesChosen == false)
	{
		errorString = errorString + "- Communities (one or more)\n";
	}

	if (isBlank(form.name.value))
	{		
		errorString = errorString + "- Name\n";
	}

	if (isBlank(form.phone.value))
	{
		errorString = errorString + "- Phone\n";
	}

	if (checkemail(form.email.value) == false)
	{
		errorString = errorString + "- Email\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}

function validateHomeValuesForm(form)
{	
	var errorString='';
	if (isBlank(form.name.value))
	{		
		errorString = errorString + "- Name\n";
	}

	if (isBlank(form.phone.value))
	{
		errorString = errorString + "- Phone\n";
	}

	if (checkemail(form.email.value) == false)
	{
		errorString = errorString + "- Email\n";
	}

	if (isBlank(form.city.value))
	{
		errorString = errorString + "- City\n";
	}

	if (isBlank(form.zip.value))
	{
		errorString = errorString + "- Zip\n";
	}

	if (isBlank(form.address1.value))
	{
		errorString = errorString + "- Address 1\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
	
}


function validateCommentsForm(form)
{			
	if (isBlank(form.name.value))
	{
		alert("You must enter a name");
		return false;
	}

	if (isBlank(form.comments.value))
	{
		alert("You must enter comments!");
		return false;
	}

	return true;
}



function validatePendingArticleForm(form)
{			
	if (isBlank(form.name.value))
	{
		alert("You must enter a name");
		return false;
	}
	
	if (isBlank(form.phone.value))
	{
		alert("You must enter a phone");
		return false;
	}

	if (checkemail(form.email.value) == false)
	{
		alert("You must enter a email");
		return false;
	}
	
	if (isBlank(form.title.value))
	{
		alert("You must enter a title");
		return false;
	}

	if (isBlank(form.author.value))
	{
		alert("You must enter an author!");
		return false;
	}

	if (isBlank(form.source.value))
	{
		alert("You must enter a source");
		return false;
	}
	
	if (isBlank(form.hyperlink.value))
	{
		alert("You must enter a link!");
		return false;
	}

	if (checkFCKEditorContent("fckEditorContent") == false)
	{
		alert("You must enter the article content!");
		return false;
	}

	return true;
}


function validateCityProfileForm(form)
{			
	var errorString='';

	if (isBlank(form.city.value))
	{
		errorString = errorString + "- City\n";
	}

	if (checkFCKEditorContent("fckContent") == false)
	{
		errorString = errorString + "- City Description\n";
	}

	if (isBlank(form.metaTitle.value))
	{
		errorString = errorString + "- Meta Title\n";
	}
	if (isBlank(form.metaDescription.value))
	{
		errorString = errorString + "- Meta Description\n";
	}
	if (isBlank(form.metaKeywords.value))
	{
		errorString = errorString + "- Meta Keywords\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}

}



function validateCityProfileLinkForm(form)
{			
	var errorString='';

	if (isBlank(form.title.value))
	{
		errorString = errorString + "- Title\n";
	}

	if ((isBlank(form.hyperlink.value)) || (form.hyperlink.value == "http://"))
	{
		errorString = errorString + "- Link\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}

}


function validateDirectoryLinkForm(form)
{			
	var errorString='';

	if (isBlank(form.title.value))
	{
		errorString = errorString + "- Title\n";
	}

	if ((isBlank(form.hyperlink.value)) || (form.hyperlink.value == "http://"))
	{
		errorString = errorString + "- Link\n";
	}

	if (isBlank(form.linkDescription.value))
	{
		errorString = errorString + "- Description\n";
	}


	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}


function validateExchangeLinkForm(form)
{			
	var errorString='';

	if (isBlank(form.name.value))
	{		
		errorString = errorString + "- Name\n";
	}

	if (isBlank(form.phone.value))
	{
		errorString = errorString + "- Phone\n";
	}

	if (checkemail(form.email.value) == false)
	{
		errorString = errorString + "- Email\n";
	}

	if (isBlank(form.title.value))
	{
		errorString = errorString + "- Link Title\n";
	}

	if ((isBlank(form.hyperlink.value)) || (removeSpacesFromURL(form.hyperlink.value) == "http://"))
	{
		errorString = errorString + "- URL of Link\n";
	}

	if ((isBlank(form.location.value)) || (removeSpacesFromURL(form.location.value) == "http://"))
	{
		errorString = errorString + "- Link Location\n";
	}
	
	if (isBlank(form.linkDescription.value))
	{
		errorString = errorString + "- Description\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}

function validateFrontPageExchangeLinkForm(form)
{			
	var errorString='';

	if (isBlank(form.name.value))
	{		
		errorString = errorString + "- Name\n";
	}

	if (isBlank(form.phone.value))
	{
		errorString = errorString + "- Phone\n";
	}

	if (checkemail(form.email.value) == false)
	{
		errorString = errorString + "- Email\n";
	}

	if (isBlank(form.title.value))
	{
		errorString = errorString + "- Link Title\n";
	}

	if ((isBlank(form.hyperlink.value)) || (removeSpacesFromURL(form.hyperlink.value) == "http://"))
	{
		errorString = errorString + "- URL of Link\n";
	}

	if ((isBlank(form.location.value)) || (removeSpacesFromURL(form.location.value) == "http://"))
	{
		errorString = errorString + "- Link Location\n";
	}
	
	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}

function validateExchangeCategoryForm(form)
{			
	var errorString='';

	if (isBlank(form.name.value))
	{
		errorString = errorString + "- Category Name\n";
	}

	if (isBlank(form.categoryDescription.value))
	{
		errorString = errorString + "- Category Description\n";
	}

	if (isBlank(form.metaTitle.value))
	{
		errorString = errorString + "- Meta Title\n";
	}
	if (isBlank(form.metaDescription.value))
	{
		errorString = errorString + "- Meta Description\n";
	}
	if (isBlank(form.metaKeywords.value))
	{
		errorString = errorString + "- Meta Keywords\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}

}




function validateBDLF(form)
{			
	if (isBlank(form.name.value))
	{
		alert("You must enter a name!");
		return false;
	}

	if (isBlank(form.phone.value))
	{
		alert("You must enter a phone number!");
		return false;
	}

	if (checkemail(form.email.value) == false)
	{
		alert("You must enter an email!");
		return false;
	}

	if (isBlank(form.title.value))
	{
		alert("You must enter a title!");
		return false;
	}

	if (isBlank(form.hyperlink.value))
	{
		alert("You must enter a link!");
		return false;
	}
	
	if (isBlank(form.categoryID.value))
	{
		alert("You must enter a category!");
		return false;
	}

	if (isBlank(form.description.value))
	{
		alert("You must enter a description!");
		return false;
	}

	return true;
}

function validateTestimonialForm(form)
{			
	
	if (form.name.value == '')
	{
		alert("You must enter a name!");
		return false;
	}

	if (form.location.value == '')
	{
		alert("You must enter a location!");
		return false;
	}

	if (checkFCKEditorContent("testimonial") == false)
	{
		alert("You must enter a description!");
		return false;
	}

	return true;
}

function directoryTitleCheck(data)
{
	var violation = data.match("'|\"|\/");

	if (violation != null)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function validateDirectoryCategoryForm(form)
{					
	var errorString='';

	if (directoryTitleCheck(form.name.value) == false)
	{
		alert("The category title cannot have single quotes, double quotes, or a forward slash in the title!");
		return false;
	}

	if (isBlank(form.name.value))
	{
		errorString = errorString + "- Category Name\n";
	}

	if (isBlank(form.categoryDescription.value))
	{
		errorString = errorString + "- Category Description\n";
	}

	if (isBlank(form.metaTitle.value))
	{
		errorString = errorString + "- Meta Title\n";
	}
	if (isBlank(form.metaDescription.value))
	{
		errorString = errorString + "- Meta Description\n";
	}
	if (isBlank(form.metaKeywords.value))
	{
		errorString = errorString + "- Meta Keywords\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}

}


function validateTeamInfoForm2(form)
{					 
	var errorString='';

	if (isBlank(form.name_business.value))
	{		
		errorString = errorString + "- Team Name\n";
	}

	if (isBlank(form.team_office.value))
	{
		errorString = errorString + "- Team Office\n";
	}

	if (isBlank(form.addr.value))
	{
		errorString = errorString + "- Address 1\n";
	}

	if (isBlank(form.city.value))
	{
		errorString = errorString + "- City\n";
	}

	if (isBlank(form.state.value))
	{
		errorString = errorString + "- State\n";
	}

	if (isBlank(form.zip.value))
	{
		errorString = errorString + "- Zip\n";
	}

	if (isBlank(form.phone.value))
	{
		errorString = errorString + "- Phone\n";
	}

	if (checkemail(form.email.value) == false)
	{
		errorString = errorString + "- Email\n";
	}

	if (checkFCKEditorContent("team_description") == false)
	{
		errorString = errorString + "- Team Description\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}

}



function validateTeamMemberForm(form)
{					 
	var errorString='';

	if (isBlank(form.name.value))
	{		
		errorString = errorString + "- Name\n";
	}

	if (isBlank(form.title.value))
	{
		errorString = errorString + "- Title\n";
	}

	if (checkFCKEditorContent("fckContent") == false)
	{
		errorString = errorString + "- Team Description\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}


function validateFrontPageMLSLogin(form)
{					 
	var errorString='';

	if (checkemail(form.email.value) == false)
	{		
		errorString = errorString + "- Email\n";
	}

	if (isBlank(form.password.value))
	{
		errorString = errorString + "- Password\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}


function validateAddMemberForm(form)
{					 
	var errorString='';

	if (isBlank(form.newMemberName.value))
	{		
		errorString = errorString + "- Member Name\n";
	}

	if (isBlank(form.newMemberTitle.value))
	{
		errorString = errorString + "- Member Title\n";
	}

	if (checkFCKEditorContent("newMemberDescription") == false)
	{
		errorString = errorString + "- Member Description\n";
	}

	if (errorString!='')
	{
		alert("The following member information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}


function validateRelocationGuide(form)
{	
	if (isBlank(form.first_name.value))
	{
		alert("You must enter your first name!");
		return false;
	}		
	
	if (isBlank(form.last_name.value))
	{
		alert("You must enter your last name!");
		return false;
	}		

	if (checkemail(form.email.value) == false)
	{
		alert("You must enter your email address!");
		return false;
	}		
	if (isBlank(form.address_1.value))
	{
		alert("You must enter your address!");
		return false;
	}		
	if (isBlank(form.city.value))
	{
		alert("You must enter your City!");
		return false;
	}		
	if (isBlank(form.state.value))
	{
		alert("You must enter your State!");
		return false;
	}		
	if (isBlank(form.zip.value))
	{
		alert("You must enter your zip code!");
		return false;
	}		
	if (isBlank(form.phone.value))
	{
		alert("You must enter your Main Telephone number!");
		return false;
	}		

	return true;
}



function checkFCKEditorContent(fckEditorInstanceName)
{
	var oEditor = FCKeditorAPI.GetInstance(fckEditorInstanceName);		
	var content = oEditor.GetHTML(true);

	// Remove all cases of "<br>" and "&nbsp;"
	content	= content.replace(/\r|\n|\<br>|\&nbsp;/g, "");
	// Remove all spaces
	content = content.replace(/\s/g, "");	

	// Check if content is empty
	if (content == '')
	{
		return false;
	}
	else
	{
		return true;
	}
}

function removeCharacters( strValue, strMatchPattern ) 
{
/************************************************
DESCRIPTION: Removes characters from a source string
  based upon matches of the supplied pattern.

PARAMETERS:
  strValue - source string containing number.

RETURNS: String modified with characters
  matching search pattern removed

USAGE:  strNoSpaces = removeCharacters( ' sfdf  dfd',
								'\s*')
*************************************************/
 var objRegExp =  new RegExp( strMatchPattern, 'gi' );

 //replace passed pattern matches with blanks
  return strValue.replace(objRegExp,'');
}

function changeImage(img1,ref1)
{
	browser_name = navigator.appName;
	browser_version = parseFloat(navigator.appVersion);

	if (browser_name == "Netscape" && browser_version >= 3.0)
	{
			roll = 'true';
	}
	else if (browser_name == "Microsoft Internet Explorer" && browser_version >= 4.0)
	{
			roll = 'true';
	}
	else
	{
			roll = 'false';
	}

	if (roll == 'true')
	{
			document.images[img1].src = ref1;
	}
}

function MM_findObj(n, d)
{ //v4.01
  var p,i,x;  
  
  if(!d) 
	 d=document;
  
  if((p=n.indexOf("?"))>0&&parent.frames.length)
  {
	d=parent.frames[n.substring(p+1)].document;
	n=n.substring(0,p);
  }
  
  if(!(x=d[n])&&d.all) 
	  x=d.all[n];

  for (i=0;!x&&i<d.forms.length;i++) 
	  x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++)
	  x=MM_findObj(n,d.layers[i].document);


  if(!x && d.getElementById) 
	  x=d.getElementById(n);
  
  return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// Demo Agent Signup Javascript
// check multi checkboxes based on the name passed in.
function CheckMultiple(name) 
{
	theFrm = document.frmSS;
	for (var i=0; i < theFrm.length; i++) 
	{
		fldObj = theFrm.elements[i];
		var fieldnamecheck=fldObj.name.indexOf(name);
		if (fieldnamecheck != -1) {
			if (fldObj.checked) {
				return true;
			}
		}
	}
	return false;
}


function CheckSS()
{
	theFrm = document.frmSS;

	hasDot = theFrm.Email.value.indexOf(".");
	hasAt = theFrm.Email.value.indexOf("@");
	
	if (hasDot == -1 || hasAt == -1)
	{
		alert("Please enter a valid email address.");
		theFrm.Email.focus();
		theFrm.Email.select();
		return false;
	}

	valcheck = document.getElementById("Fields[1]");
	if (valcheck.value == "") {
		alert("Please enter a value for the 'Name' field.");
		valcheck.focus();
		valcheck.select();
		return false;
	} else {
		var minsize_1 = 0;
		var maxsize_1 = 100;
		var fieldlength = 0;
		fieldlength = valcheck.value.length;
		if (fieldlength < minsize_1) {
			alert("You must enter a value for the 'Name' field longer than " + minsize_1 + " characters");
			valcheck.focus();
			return false;
		}
		if (fieldlength > maxsize_1) {
			alert("You must enter a value for the 'Name' field no longer than " + maxsize_1 + " characters");
			valcheck.focus();
			return false;
		}
	}

	valcheck = document.getElementById("Fields[2]");
	if (valcheck.value == "") {
		alert("Please enter a value for the 'Phone' field.");
		valcheck.focus();
		valcheck.select();
		return false;
	} else {
		var minsize_2 = 0;
		var maxsize_2 = 100;
		var fieldlength = 0;
		fieldlength = valcheck.value.length;
		if (fieldlength < minsize_2) {
			alert("You must enter a value for the 'Phone' field longer than " + minsize_2 + " characters");
			valcheck.focus();
			return false;
		}
		if (fieldlength > maxsize_2) {
			alert("You must enter a value for the 'Phone' field no longer than " + maxsize_2 + " characters");
			valcheck.focus();
			return false;
		}
	}
				
	return true;
}
