var iEasterLen=2;

var iEasterCnt=0;

var sVPvalue="";

function SetEgg(iPos){
//alert("Ei Nr.: "+String(iPos));
   $("#EasterEgg").fadeOut("slow");
   sVPvalue=GetEasterParam();
//alert("sVPvalue = "+sVPvalue);

   if(sVPvalue.substr(0,9)!="EasterEgg"){
      sVPvalue="EasterEgg";
      for(i=0;i<iEasterLen;i++){
         sVPvalue+="0";
      }
   }
  SetEasterParam(sVPvalue.substr(0,8+iPos)+"1"+sVPvalue.substr(9+iPos,sVPvalue.length));
  CheckEgg(iPos);
}



function CheckEgg(iPos){
   sVPvalue=GetEasterParam();
//alert("CheckEgg\n\nsVPvalue = "+sVPvalue);
   if(sVPvalue.substr(0,9)=="EasterEgg"){
      if(sVPvalue.substr(8+iPos,1)!="1"){
         $("#EasterEgg").show();
      }
      iEasterCnt=0;
      for(i=0;i<iEasterLen;i++){
         if(sVPvalue.substr(9+i,1)=="1"){
            iEasterCnt++;
         }
      }
      if(iEasterCnt==iEasterLen){
         document.getElementById("EasterBar").innerHTML="You have found all eggs.<br> <a href=\"\" onClick=\"CatchEgg();return false;\">Click here to process.</a>.";
      }else{
         document.getElementById("EasterBar").innerHTML="You have found "+String(iEasterCnt)+" of "+String(iEasterLen)+".<br> Good luck for searching...";
      }
   document.getElementById("EasterBar").style.display="block";
   }
   else {
      $("#EasterEgg").show();
  }
}

function CheckEasterEgg(){
   sVPvalue=GetEasterParam();
   if(sVPvalue.substr(0,9)=="EasterEgg"){
      iEasterCnt=0;
      for(i=0;i<iEasterLen;i++){
         if(sVPvalue.substr(9+i,1)=="1"){
            iEasterCnt++;
         }
      }
      if(iEasterCnt==iEasterLen){
         return true;
      }else{
         return false;
      }
   }else{
      return false;
   }
}

function CatchEgg(){
   sVPvalue=GetEasterParam();
   iEasterCnt=0;
   for(i=0;i<iEasterLen;i++){
      if(sVPvalue.substr(9+i,1)=="1"){
         iEasterCnt++;
      }
   }
   if(iEasterCnt==iEasterLen){
      window.open("https://www.verpoorten.com/easteregg","_self");
   }else{
      alert("EiEiEi... you haven't found all eggs yet.");
   }
}


//#### ERweiterung IE8 ####
function SetEasterParam(wert){
//alert("SetEasterParam: "+window.name);
    window.name=wert;
    //sessvars.vpvalue=wert;
}

function GetEasterParam(){
/*
   if(sessvars.vpvalue){
      return sessvars.vpvalue;
   }else{
      return "";
   }
*/
//alert("GetEasterParam: "+window.name);
return window.name;
}

