//now set the clone cookie
function setClone()
{
  var now = new Date;
  
  if((now.getTime() > b_date.getTime()) && (now.getTime() < e_date.getTime()))
  {
    var oldClone = GetCookie("KL");

    if(!oldClone) 
	{
      // take a random number
   	  var rand = Math.floor(RAND_RANGE * Math.random());

	  // sum the configured weighting so we can scale
      var weightingSum = 0;
      for(var i = 0; i < CLONE_WEIGHTING.length; i++)
      {
        weightingSum += CLONE_WEIGHTING[i];
      }

      var cloneScale = RAND_RANGE / weightingSum;
      var accumalativeCloneFraction = 0;
      var cloneValue = "1";
      var ablauf = new Date();
      var expiredate = ablauf.getTime() + (7 * 24 * 60 * 60 * 1000);
      ablauf.setTime(expiredate);
      
	  // now accumulate our weightings until we pass our random number
	  // when this happens we determined our clone
      for(var i = 0; i < CLONE_WEIGHTING.length; i++)
      {
        accumalativeCloneFraction += cloneScale * CLONE_WEIGHTING[i];
        if(rand < accumalativeCloneFraction)
        {  
         cloneValue = CLONE_VALUE[i];
		  document.cookie = "KL=" + cloneValue + ";path=/; expires=" + ablauf.toGMTString();
		  return;
        }
      }
    }
	
	// no cookie need to be set
	return;
  }
}
