function open_login(fragebogen){
  var VisitorName = GetCookie('VisitorName');
  if (VisitorName == null) { 
			openWindow("login/login.html?fragebogen=" + fragebogen,"Enviro_LogIn",600,537,0);
              }
   else {
   if (top.navigation.myCookiecheck){
   	openWindow("frageboegen/" + fragebogen + ".pdf","Fragebogen",425,600,1);
   }
   else{
   RefreshCookie('VisitorName');
   	openWindow("frageboegen/" + fragebogen + ".pdf","Fragebogen",425,600,1);
   	top.navigation.myCookiecheck = true;
   }
  }
}

function openWindow(theURL, winName, myWidth, myHeight, resize) {
	var x = 50, y = 50;	
	 if(self.popup){
	 if (!(self.popup.closed))(self.popup.close());
	}
	//popup = window.open(theURL,winName,"fullscreen=yes");
  popup = window.open(theURL,winName,'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable='+resize+',width='+myWidth+',height='+myHeight+',top='+y+',screenY='+y+',left='+x+',screenX='+x);
  self.popup.focus();
}
   
  function getCookieVal (offset) {  
          var endstr = top.navigation.document.cookie.indexOf (";", offset);  
          if (endstr == -1)    
                  endstr = top.navigation.document.cookie.length;  
                  return unescape(top.navigation.document.cookie.substring(offset, endstr));
  }
  
  function GetCookie (name) {  
          var arg = name + "=";  
          var alen = arg.length;  
          var clen = top.navigation.document.cookie.length;  
          var i = 0;  
          while (i < clen) {    
          var j = i + alen;    
          if (top.navigation.document.cookie.substring(i, j) == arg)      
                  return getCookieVal (j);    
                  i = top.navigation.document.cookie.indexOf(" ", i) + 1;    
                  if (i == 0) break;   
          }  
          return null;
  }
  function SetCookie (name, value) {
          var argv = SetCookie.arguments;  
          var argc = SetCookie.arguments.length;  
          var expires = (argc > 2) ? argv[2] : null;  
          var path = (argc > 3) ? argv[3] : null;  
          var domain = (argc > 4) ? argv[4] : null;  
          var secure = (argc > 5) ? argv[5] : false;  
          opener.top.navigation.document.cookie = name + "=" + escape (value) + 
          ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
          ((path == null) ? "" : ("; path=" + path)) +  
          ((domain == null) ? "" : ("; domain=" + domain)) +    
          ((secure == true) ? "; secure" : "");
  }
  
  
  function DeleteCookie (name) {  
          var exp = new Date();  
          exp.setTime (exp.getTime() - 1);  
          var cval = GetCookie (name);  
          top.navigation.document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  }
  
    function RefreshCookie (name) {  
          var expDays = 30;
          var exp = new Date(); 
          exp.setTime(exp.getTime() + (expDays*24*60*60*1000));  
          var cval = GetCookie (name);  
          top.navigation.document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  }
