
$(function(){
  // Document is ready
  
  
  toffel = $.cookie('show_toffel');
  
  if(toffel) {
	  toffel = 1 + parseInt(toffel);
	  
	  var show_toffel = false;
	  if(toffel > 4 ) 
	  {
	    show_toffel = true;
	  }
	  else 
	  {
	    var ran_unrounded=Math.random()*4;
	    var ran_number=Math.floor(ran_unrounded); 
	    if(ran_number == 2) {
	        show_toffel = true;
	    }
	    $.cookie('show_toffel', toffel, {path: '/'});
	  }
	  
	  if(show_toffel) {
	    
	    var top=Math.floor(Math.random()*990) + 10;
	    var left=Math.floor(Math.random()*990) + 10;
	    
	    $("body").append("<div style=\"position:absolute;top:0px;left:50%;margin-left:-500px;width:1000px; border:1px solid red;\"><div id=\"toffelholder\" style=\"position:relative;\"></div></diV>"); 
	    $("#toffelholder").append("<div style=\"position:absolute; left: " + left + "px;top: " + top + "px;display:block\"><a href=\"#\" onclick=\"window.open('http://toffel.strateg.nu/?_reset=1','','width=780px; height=630px; titlebar=0; menubar=0')\" ><img src=\"http://toffel.strateg.nu/toffel.png\" border=\"0\" /></a></div>");
	
	  }  
  }
});