/*
  website integration code (survey)
    yalst LiveSupportTool
    Author: Dr. Markus Jasinski
    Copyright (c) 2003-2010 by Visisoft, Rostock, Germany
    http://www.visisoft.de
*/

// Cookie handling
function setcookie8(value)
  { //v2.0
  var expDate = new Date();
  expDate.setFullYear(expDate.getFullYear() + 30);
  document.cookie = "YALSTSESSION=" + value + "; path=/; expires=" + expDate.toGMTString();
  }
function readcookie8()
  {
  var allcookies = document.cookie;
  var pos = allcookies.indexOf("YALSTSESSION=");
  if (pos != -1)
    {
    var start = pos + 13;
    var end = allcookies.indexOf(";",start);
    if (end == -1)
      end = allcookies.length;
    var value = allcookies.substring(start,end);
    if (value != "")
      {return value;}
    else
      {return "none";}
    }
  else
    {return "none";}
  }

function open_marketing1(url,width,height)
  {
  var parms="";
  if (document.ysurvey.formAnswer5.checked==true)
    {parms=parms+"&formAnswer5=true";}
  if (document.ysurvey.formAnswer4.checked==true)
    {parms=parms+"&formAnswer4=true";}
  if (document.ysurvey.formAnswer3.checked==true)
    {parms=parms+"&formAnswer3=true";}
  if (document.ysurvey.formAnswer2.checked==true)
    {parms=parms+"&formAnswer2=true";}
  if (document.ysurvey.formAnswer1.checked==true)
    {parms=parms+"&formAnswer1=true";}
  if (!width) width=500;
  if (!height) height=350;
  Fpopupwindow=open(url+parms,"survey_24000_1","width="+width+",height="+height+",location=no,menubar=no,statusbar=no,scrollbars=no,dependent=no,screenX=20,screenY=20,left=20,top=20");
  if (Fpopupwindow.opener == null) Fpopupwindow.opener = self;
  Fpopupwindow.focus();
  }

function open_marketing2(url,width,height)
  {
  var btn=document.ysurvey.formAnswer;
  var cnt=-1;
  for (var i=0; i < btn.length; i++)
    {if (btn[i].checked) {cnt=i; i=btn.length;}}
  parms="&formAnswer="+btn[cnt].value;
  if (!width) width=500;
  if (!height) height=350;
  Fpopupwindow=open(url+parms,"survey_24000_1","width="+width+",height="+height+",location=no,menubar=no,statusbar=no,scrollbars=no,dependent=no,screenX=20,screenY=20,left=20,top=20");
  if (Fpopupwindow.opener == null) Fpopupwindow.opener = self;
  Fpopupwindow.focus();
  }

function validate1()
  {
  if (
    document.ysurvey.formAnswer5.checked==false &&
    document.ysurvey.formAnswer4.checked==false &&
    document.ysurvey.formAnswer3.checked==false &&
    document.ysurvey.formAnswer2.checked==false &&
    document.ysurvey.formAnswer1.checked==false)
    {
    alert('Bitte wählen Sie mindestens eine Antwort!');
    return false;
    }
  else
    {return true;}
  }
function validate2()
  {
  var btn=document.ysurvey.formAnswer;
  var cnt=-1;
  for (var i=0; i < btn.length; i++)
    {if (btn[i].checked) {cnt=i; i=btn.length;}}
  if (cnt>-1)
    {btnvalue=btn[cnt].value;}
  else
    {btnvalue=null;}
  if (btnvalue==null)
    {
    alert('Bitte wählen Sie eine Antwort!');
    return false;
    }
  }

function survey()
  {
  mycookie=readcookie8();
  if (mycookie=="none")
    {
    setcookie8('');
    var newcookie=readcookie8();
    if (newcookie=='')
      {mycookie=newcookie;}
    else
      {mycookie="none";}
    }
  else
    {
    if (mycookie.length!=30)
      {
      setcookie8('');
      var newcookie=readcookie8();
      if (newcookie=='')
        {mycookie=newcookie;}
      else
        {mycookie="none";}
      }
    }
  murl="http://rd.livesupportserver.de/yalst-dev/result.php?site=24000-1&id=56&cookie="+escape(mycookie)+"&lang=1";
    table="<form action='javascript:open_marketing2(murl,350,320)' method='post' name='ysurvey' onsubmit='return validate2();'>";
    table=table+"<table border='0' cellpadding='0' cellspacing='0' width='350'>";
  table=table+"<tr><td colspan='3'>Wie haben Sie von &quot;yalst&quot; erfahren?</td></tr>";
    table=table+"<tr>";
    table=table+"<td><input type='radio' name='formAnswer' value='1'></td>";
    table=table+"<td>&nbsp;</td><td width='100%'>durch eine Suchmaschine im Internet</td>";
  table=table+"</tr>";
    table=table+"<tr>";
    table=table+"<td><input type='radio' name='formAnswer' value='2'></td>";
    table=table+"<td>&nbsp;</td><td width='100%'>durch eine Site, auf der yalst verwendet wird</td>";
  table=table+"</tr>";
    table=table+"<tr>";
    table=table+"<td><input type='radio' name='formAnswer' value='3'></td>";
    table=table+"<td>&nbsp;</td><td width='100%'>aus der Presse</td>";
  table=table+"</tr>";
    table=table+"<tr>";
    table=table+"<td><input type='radio' name='formAnswer' value='4'></td>";
    table=table+"<td>&nbsp;</td><td width='100%'>durch einen Bekannten</td>";
  table=table+"</tr>";
    table=table+"<tr>";
    table=table+"<td><input type='radio' name='formAnswer' value='5'></td>";
    table=table+"<td>&nbsp;</td><td width='100%'>auf eine andere Weise</td>";
  table=table+"</tr>";
    table=table+"<tr><td colspan='3'><input type='submit' value='abstimmen' class='surveybutton'></td></tr>";
  table=table+"</table>";
  table=table+"</form>";
  document.write(table);
  }

survey();
