    var cnnSectionURLRegExp = /([^\d{4}][\w.][^\/]+)\//;
    var cnnSubSectionURLRegExp = /([^\d][\w.][^\/]+)\/([^\d]+)\//;
    var cnnSpecialsURLRegExp = /(\/SPECIALS)\/(\d{4})\/\w.*/;
	var cnnElectionsURLRegExp = /(\/ELECTION)\/(\d{4})\/\w.*/;
    var cnnInteractiveURLRegExp = /(\/interactive)\/(\w.*)\/([\d{4}]*)\/(\w.*)\//; 
    var cnnStoryURLRegExp = /(\d{4})\/([A-Z]+)\/(\d{2})\/(\d{2})\/(\w.*)\//;
    var cnnStorySubURLRegExp = /(\d{4})\/([A-Z]+)\/([A-Z|a-z|.]+)\/(\d{2})\/(\d{2})\/(\w.*)\//;     
    var cnnStoryStripDateRegExp = /(.*) - CNN.com/;

    var cnnGetURL = window.location.pathname;
    var cnnSectionPageName = document.title;

    var channel, pageName, cnnAuthor, cnnStoryDate, cnnStoryHeadline;

        if (cnnSectionPageName.match(/(CNN.com\s*-)/)) {
            cnnSectionPageName = cnnSectionPageName.replace(/(CNN.com\s*-)/, "");
        }

    if (cnnGetURL == "/index.html" || cnnGetURL == "/" || cnnGetURL == "//index.html") {
        pageName = "CNN Home Page";
        channel = "/";
    } else if(cnnStoryURLRegExp.test(cnnGetURL)) {
        var cnnStoryURLArray = cnnStoryURLRegExp.exec(cnnGetURL);
       pageName = cnnGetURL;
       cnnStoryDate = cnnStoryURLArray[3] + "/" + cnnStoryURLArray[4] + "/" +cnnStoryURLArray[1]; 
       cnnStoryHeadline = cnnStoryStripDateRegExp.exec(document.title)[1];
        channel = "Story: /" + cnnStoryURLArray[2];        
    } else if(cnnStorySubURLRegExp.test(cnnGetURL)) {
        var cnnStorySubURLArray = cnnStorySubURLRegExp.exec(cnnGetURL);
       pageName = cnnGetURL;
       cnnStoryDate = cnnStorySubURLArray[4] + "/" + cnnStorySubURLArray[5] + "/" +cnnStorySubURLArray[1]; 
       cnnStoryHeadline = cnnStoryStripDateRegExp.exec(document.title)[1];
       channel = "Story: /" + cnnStorySubURLArray[2] + "/"+cnnStorySubURLArray[3];
    } else if(cnnSpecialsURLRegExp.test(cnnGetURL)) {
        var cnnSpecialsURLArray = cnnSpecialsURLRegExp.exec(cnnGetURL);
        pageName = "Special: "+ cnnSpecialsURLArray[0];
        channel = "Special: " + cnnSpecialsURLArray[1]+ "/" +cnnSpecialsURLArray[2];
	} else if(cnnElectionsURLRegExp.test(cnnGetURL)) {
        var cnnElectionsURLArray = cnnElectionsURLRegExp.exec(cnnGetURL);
        pageName = "Election: "+ cnnElectionsURLArray[0];
        channel = "Election: " + cnnElectionsURLArray[2];           
    } else if(cnnInteractiveURLRegExp.test(cnnGetURL)) {
        var cnnInteractiveURLArray = cnnInteractiveURLRegExp.exec(cnnGetURL);
        pageName = "Interactive: " + cnnInteractiveURLArray[0];
        channel = "Interactive: " + cnnInteractiveURLArray[1] + "/" + cnnInteractiveURLArray[2];
    } else if(cnnSubSectionURLRegExp.test(cnnGetURL)) {
        var cnnSubSectURLArray = cnnSubSectionURLRegExp.exec(cnnGetURL);
        pageName = cnnSectionPageName + " " + cnnSubSectURLArray[0];
        channel = "Section: " + cnnSubSectURLArray[0];
    } else if(cnnSectionURLRegExp.test(cnnGetURL)) {
        var cnnSectURLArray = cnnSectionURLRegExp.exec(cnnGetURL);
        pageName = cnnSectionPageName + " "+ cnnSectURLArray[1];
        channel = "Section: " + cnnSectURLArray[1];
    } else {
        pageName = "Defaulting to " + cnnSectionPageName + " " + cnnGetURL;
        channel = "Defaulting to " + cnnGetURL;
    }

if (document.getElementsByTagName) {
    var metaTags = document.getElementsByTagName('meta');
    for ( var m = 0; m < metaTags.length; ++m  ) {
        var metaTagName = metaTags[m].getAttribute('name');
        var metaTagNameContent = metaTags[m].getAttribute('content');   
        if (metaTagName && metaTagName.toLowerCase() == "author") {
            cnnAuthor = metaTagNameContent.replace(/(By|From)\s*:?/, "");
            cnnAuthor = cnnAuthor.replace(/^[^\w]/, "");
        }
    }                                
}

function cnnGetParamQueryString(query,param)
{
    var returnValue = '';
    var keyValPairs = query.split('&');
    if(!keyValPairs) { keyValPairs = new Array();  
    keyValPairs[keyValPairs.length]=query}
    for(var counter=0;counter<keyValPairs.length;counter++)
    {
        var keyVal = keyValPairs[counter].split('=');
        if(keyVal[0]==param)
        {
        	returnValue = keyVal[1];
        	break;
        }
    }
    return returnValue;
}
var cnnQueryString = window.location.search.substring(1);
var cnnRefString="";
var cnnErefStart = cnnGetParamQueryString(cnnQueryString,'eref');
var cnnSectStart = cnnGetParamQueryString(cnnQueryString,'section');
if (cnnErefStart) {
	cnnRefString = cnnErefStart;
}
if (cnnSectStart) {
	cnnRefString = cnnSectStart;
}
