/*
   VSS#630, requires usat.js
  
   Raul Miller  2002-02-04
  
   changed 2002-02-05
           use document level image's .src instead of document.write
           hard code usatoday.com domain
   	   modified to better follow coding standards
  
   usage: below this script, in the body of the front, include the javascript:
	count_user_only_once("front");
   where front is one of: money, life, sports, tech, weather, news, home
 */


function cookieOnce(objCrumbs, strFront) { // check to see if they're cookies
	/*
	   low level routine to check if we've seen user before for
           and mark them as having been here if we haven't
	 */
	var objImage;
	objImage= null;
	if (!objCrumbs.get(strFront)) { // we seen them here before?  If not:
		objCrumbs.add(strFront, 1);
		objImage= new Image;
		objImage.src=
			'/counters/'+strFront+'.gif?'+(new Date().getTime());
	} // ok, if we hadn't seen them before, we have now
	return(objImage);
} // cookieOnce

function countUserOnlyOnce(strFront) { // let page get counted only once
	/*
	   call function from body of front with string indicating which front
	   legitimate values:  money, life, sports, tech, weather, news, home
	 */
	var objCrumbs;
	objCrumbs= (new usat.URL).queryString;
	objCrumbs.parseQueryString(usat.cookie.get("countme"));
	if (!objCrumbs.get("global")) { // bug work around
		objCrumbs.add("fixit", 1);
	} // end bug workaround
	if (!usat.util.isEmpty(document.cookie)) {  // ignore them if they don't support cookies. 
		// This test relies on some other part of the system
		// (for example RealMedia) aggressively setting cookies.
		document.globalCountImage= cookieOnce(objCrumbs, "global");
		document.frontCountImage= cookieOnce(objCrumbs, strFront);
		if (!usat.util.isEmpty(document.frontCountImage)) { // only cookie first time users to this front
			usat.cookie.set("countme", objCrumbs.toString(), (new Date("2/28/2002")), "/", "usatoday.com");
		} // end only cookie first time users
	} // end of support for cookied users
} // countUserOnlyOnce

function count_user_only_once(strFront) { // backwards compatibility
	countUserOnlyOnce(strFront);
} // end count_user_only_once
