// from http://groups.google.com/group/analytics-help-roi/browse_thread/thread/8047277b6dca0c69/c8a6793e44ebf803?lnk=gst&q=utmSetVar&rnum=5#
// author: caleb at pop.us Google Analytics

/*******************************************************
 * code for ensuring segments don't override eachother
 * to set a segment overtop this, simply use the normal
 * utmSetVar() function
 *******************************************************/
 
function POPsegmentGetCookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name !=document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function POPsetSegmentSafe(name) {
    if (!POPsegmentGetCookie('__utmv')) {
        __utmSetVar(name);
    }
}


/**
alternatively this could be used like this: 
Next, you'll want to implement utmSetVar() to exist on every page and
to report the page name as the value.  Use code like this:

//code//
var entryPage = document.location.pathname+document.location.search;
POPsetSegmentSafe('entry-'+entryPage);
//end code//

*/