function coco( c ) {

	try {
		cocoPath	= "http://trs.cocomore.com/scripts";
// DEBUG
//		cocoPath	= "http://teqneers.dnsalias.com/users/oliver/coco_trs/htdocs/scripts";
		cocoVersion	= "1.0";
		cocoR		= escape(document.referrer);
		cocoT		= escape(document.title);
		cocoU		= escape(document.URL);

		cocoIMG			= new Image();
		cocoIMG.src		= cocoPath+"/tck.php";
		cocoInterval	= window.setInterval("cocoLoad("+c+")", 500);

		if( cocoSessionID == "" || cocoSessionID == null ) {
			cocoCID			= cocoGetCookie( "cocoCID" );
			if( cocoCID == null ) {
				var now = new Date();
				cocoCID		= now.getTime()+""+Math.round(Math.random()*100000000);
				cocoSetCookie( "cocoCID", cocoCID, 259200, "/" );
			}
		} else {
			cocoCID	= cocoSessionID;
		}

	} catch(e) {
		// debug
		alert(e);
	}
}

function cocoLoad( c ) {
	try {
		if( cocoIMG.complete == true ) {
			var now = new Date();
			idb	= new Image();
			idb.src	= cocoPath+"/tdb.php?c="+c+"&s="+cocoSiteID+"&ca="+cocoCampaignID+"&si="+cocoSequenceID+"&sc="+cocoSequenceCounter+"&st="+cocoSequenceType+"&t="+cocoT+"&k1="+cocoKeyword1+"&k2="+cocoKeyword2+"&k3="+cocoKeyword3+"&sn="+cocoSessionName+"&ci="+cocoCID+"&r="+cocoR+"&sv="+cocoVersion+"&bu="+cocoU+"&noc="+now.getTime();

			window.clearInterval(cocoInterval)
		}
	} catch(e) {
		// debug
		alert(e);
	}
}

function cocoGetCookie(Name) {
	var search = Name + "="
	var cookieString = document.cookie
	var result = null
	if (cookieString.length > 0) {
		offset = cookieString.indexOf(search)
		if (offset != -1) {
			offset += search.length
			end = cookieString.indexOf(";", offset)
			if (end == -1)
				end = cookieString.length
			result = unescape(cookieString.substring(offset, end))
		}
	}
	return result
}

function cocoSetCookie (name, value, lifespan, access_path) {

  var cookietext = name + "=" + escape(value)
    if (lifespan != null) {
      var today=new Date()
      var expiredate = new Date()
      expiredate.setTime(today.getTime() + 1000*60*lifespan)
      cookietext += "; expires=" + expiredate.toGMTString()
    }
    if (access_path != null) {
      cookietext += "; PATH="+access_path
    }
   document.cookie = cookietext
   return null
}



