function insertDynamicHeading(element_id, useDynamicVerb, useDynamicDirectObj, useDynamicAdjective)
{
try
{
var elem = document.getElementById(element_id);
if (typeof(elem) != 'undefined' && elem != null) {
elem.innerHTML = getDynamicHeading(useDynamicVerb, useDynamicDirectObj, useDynamicAdjective);
}
}
catch(err)
{
// do nothing
}
}
function getDynamicHeading(useDynamicVerb, useDynamicDirectObj, useDynamicAdjective, skipFree /* = false */)
{	
try
{
querystring = getQueryStringToUse();
var rules = new Object();
rules.useDynamicVerb = useDynamicVerb;
rules.useDynamicDirectObj = useDynamicDirectObj;
rules.useDynamicAdjective = useDynamicAdjective;
// Unless the client said true, assume false. If true, we won't use the word "FREE".
rules.skipFree = skipFree ? true : false;
return constructDynamicSplashHeading(querystring, rules);
}
catch(err)
{
// do nothing
}
}
function getQueryStringToUse()
{
try
{
var ref = GetCookie("BASEREFERER");
if(!ref || ref.indexOf("?") < 0)
ref = document.referrer;
var querystring = "";
var parameterIndex = ref.indexOf("?") + 1;
if (parameterIndex > 0)
{
querystring = ref.substr(parameterIndex);
}
querystring = scrubString(querystring);
return querystring;
}
catch(err)
{
// if we broke, we'll return blank
return "";
}
}
function constructDynamicSplashHeading(querystring, rules)
{
try
{
var staticText = " and Get Found by Customers";
var defaultDirectObject = " Website";
var actionVerb = "Get";	// To replace the first verb in the default heading
var articles = " a", directObject = defaultDirectObject;	// Leaving in 'articles' for later expansion
var primaryOptionAdjective = "";	// Adjectives for the heading (secondaryOptionAdjective can be changed for later expansions)
var secondaryOptionAdjective = (rules.skipFree ? "" : " FREE");	// If we've explicitly set a rule to skip free, skip it.
var heading = generateHeadline(actionVerb, articles, secondaryOptionAdjective, primaryOptionAdjective, directObject, staticText);
if (querystring && rules)
{
if(rules.useDynamicVerb)
{
if (querystring.match(/\bbuild/))
actionVerb = "Build";
else if (querystring.match(/\bcreat/))
actionVerb = "Create";
else if (querystring.match(/\bmak/))
actionVerb = "Make";
else if (querystring.match(/\bdesign/))
actionVerb = "Design";
}
if(rules.useDynamicDirectObj)
{
directObject = getDirectObject(querystring, directObject);
}
if(rules.useDynamicAdjective)
{
if (querystring.match(/\bpersonal\b/))
primaryOptionAdjective = " Personal";
else if (querystring.match(/\bbusiness\b/))
primaryOptionAdjective = " Business";
}
var max_heading_length = 55;
heading = generateHeadline(actionVerb, articles, secondaryOptionAdjective, primaryOptionAdjective, directObject, staticText);
if (heading.length > max_heading_length) {
primaryOptionAdjective = "";
heading = generateHeadline(actionVerb, articles, secondaryOptionAdjective, primaryOptionAdjective, directObject, staticText);
if (heading.length > max_heading_length) {
directObject = defaultDirectObject;
heading = generateHeadline(actionVerb, articles, secondaryOptionAdjective, primaryOptionAdjective, directObject, staticText);
}
}
}
return heading;
}
catch(err)
{
// return something reasonable
return "Get a Website and Get Found by Customers";
}
}
function generateHeadline(verb, articles, secondaryAdjective, primaryAdjective, object, staticText)
{
return (verb + articles + secondaryAdjective + primaryAdjective + object + staticText);
}
function convertTitleCase(value) 
{
return value.charAt(0).toUpperCase() + value.substring(1);
}
function scrubString(s)
{
// To properly put spaces in the place of %20's
s = s.replace(/%20/g," ");
// make it lower case so we don't have to do case-insensitive matching later
s = s.toLowerCase();
// we're never going to care about non alpha-numeric characters, so let's get rid of them
s = s.replace(/[^a-z0-9]/g, " ");
return s;
}
function getDirectObject(querystring, directObject)
{
// Check for a space/newline at the beginning and a space/endline at the end. Just in case they
// were spelling something different (though unlikely).
if (querystring.match(/\bweb\s+site\b/))
directObject = " Web Site";
else if (querystring.match(/\bweb\s+page\b/))
directObject = " Web Page";
else if (querystring.match(/\bwebpage\b/))
directObject = " Webpage";
else if (querystring.match(/\bsite\b/))
directObject = " Site";
else if (querystring.match(/\bhomepage\b/))
directObject = " Homepage";
else if (querystring.match(/\bhome\s+page\b/))
directObject = " Home Page";
else if (querystring.match(/\bfrontpage\b/))
directObject = " Frontpage";
else if (querystring.match(/\bfront\s+page\b/))
directObject = " Front Page";
return directObject;
}
function getDynamicPPCSubheadline()
{
var querystring = getQueryStringToUse();
var verb = " Start";
var adjective = " Fully-Customizable";
if (querystring.match(/\bown\b/))
verb = " Own";
else if (querystring.match(/\bstart\b/))
verb = " Start"
else if (querystring.match(/\bsetup\b/))
verb = " Setup";
else if (querystring.match(/\bpublish\b/))
verb = " Publish";
if (querystring.match(/\bsmall\s+business\b/))
adjective = " Small Business";
else if (querystring.match(/\bonline\s+business\b/))
adjective = " Online Business";
else if (querystring.match(/\bonline\s+business\b/))
adjective = " Home Business";
else if (querystring.match(/\bbusiness\b/))
adjective = " Business";
else if (querystring.match(/\bpersonal\b/))
adjective = " Personal";
else if (querystring.match(/\bnon-profit\b/))
adjective = " Non-profit";
var subheadline = "Easily" + verb + " Your" + adjective + " Website Today!";
return subheadline;
}
function getDynamicPPCBullet()
{
try
{
var querystring = getQueryStringToUse();
var noun = "Website";
noun = getDirectObject(querystring, noun);
var bullet = noun + " in Minutes";
return bullet;
}
catch(err)
{
// return something reasonable
return "Website in Minutes";
}
}