function oeffneFenster(url){
  fenster = window.open(url, "fenster1", "width=600,height=250,status=yes,scrollbars=no,resizable=yes");
  fenster.focus();
}

function oeffneFenster2(url){
  fenster = window.open(url, "fenster1", "width=480,height=740,status=yes,scrollbars=no,resizable=yes");
  fenster.focus();
}

function oeffneFenster3(url){
  fenster = window.open(url, "fenster1", "width=600,height=500,status=yes,scrollbars=no,resizable=yes");
  fenster.focus();
}

function setCookie(name, wert, domain, expires, path, secure){
   var cook = name + "=" + unescape(wert);
   cook += (domain) ? "; domain=" + domain : "";
   cook += (expires) ? "; expires=" + expires : "";
   cook += (path) ? "; path=" + path : "";

   cook += (secure) ? "; secure" : "";
   document.cookie = cook;
}

function eraseCookie(name, domain, path) {
   var cook="name=; expires=Thu, 01-Jan-70 00:00:01 GMT";
   cook += (domain) ? "domain=" + domain : "";
   cook += (path) ? "path=" + path : "";
   document.cookie = cook;
}

function getCookie(name) {
   var i=0;  //Suchposition im Cookie
   var suche = name + "=";
   while (i<document.cookie.length) {
      if (document.cookie.substring(i, i + suche.length)
      == suche) {
	 var ende = document.cookie.indexOf(";", i
	 + suche.length);
	 ende = (ende > -1) ? ende :
	 document.cookie.length;
	 var cook = document.cookie.substring(i
	    + suche.length, ende);
	 return unescape(cook);
      }
      i++;
   }
   return "";
}	

function loginCookie(){
	setCookie("Username", document.all.user.value, null, setExpiration());
}

function logoutCookie(){
	eraseCookie("Username", null, null);
}

function setExpiration(){
	var a = new Date(); 
	var b = a.getYear(); 
	b++;
    var c = new Date(b, 0, 1);
    return c;
}  

function submitConfirm(str_meldung, str_formname){
	Check = confirm(str_meldung);
	if(Check == true){
		document.forms[str_formname].submit();
	}
}

function copyProject(str_extid){
  Check = confirm('Organisation in Ihre Favoriten kopieren?');
  if(Check == true){
		window.location.href='index.php?id=449&extid=' + str_extid;
	}
}

function confirmStorno(str_orderid, str_uid){
	Check = confirm("Buchung stornieren?");
	if(Check == true){
		window.location.href='index.php?id=188&storno=true&orderid=' + str_orderid + "&uid=" + str_uid;
	}
}

function confirmStorno2(str_orderid, str_uid){
	Check = confirm("Spende stornieren?");
	if(Check == true){
		window.location.href='index.php?id=189&storno=true&orderid=' + str_orderid + "&uid=" + str_uid;
	}
}

function deleteAccount(str_uid){
	Check = confirm("Benutzerkonto wirklich löschen?");
	if(Check == true){
		window.location.href='index.php?id=487&action=deleteaccount&uid=' + str_uid;
	}
}

function confirmDeletedAccount(){
	alert('Ihr Benutzerkonto wurde gelöscht!');
	window.location.href='index.php?id=521&logintype=logout&PID=99';
}

function confirmDeletePartner(str_action, str_uid){
  if(str_action == "Delete"){
  	Check = confirm("Partner löschen?");
  	if(Check == true){
  		window.location.href='index.php?id=576&action=delete&pid=' + str_uid;
  	}
	}
  if(str_action == "Deactivate"){
  	Check = confirm("Partner (de-) aktivieren?");
  	if(Check == true){
  		window.location.href='index.php?id=576&action=deactivate&pid=' + str_uid;
  	}
	}
}

function confirmDelete2(str_action, str_pid, str_pgid, str_search){
    if(str_action == "Deactivate"){
    	Check = confirm("Projekt (de-) aktivieren?");
    	if(Check == true){
    		window.location.href='index.php?id=' + str_pgid + '&action=deactivate&pid=' + str_pid + '&src=' + str_search;
    	}
  	}
  	if(str_action == "Delete"){
    	Check = confirm("Projekt löschen?");
    	if(Check == true){
    		window.location.href='index.php?id=' + str_pgid + '&action=delete&pid=' + str_pid + '&src=' + str_search;
    	}
  	}
  	if(str_action == "Unelete"){
    	Check = confirm("Projekt wiederherstellen?");
    	if(Check == true){
    		window.location.href='index.php?id=' + str_pgid + '&action=undelete&pid=' + str_pid + '&src=' + str_search;
    	}
  	}
  	if(str_action == "Sperrung"){
    	Check = confirm("Projekt entsperren?");
    	if(Check == true){
    		window.location.href='index.php?id=' + str_pgid + '&action=unblock&pid=' + str_pid + '&src=' + str_search;
    	}
  	}
  	if(str_action == "Beenden"){
    	Check = confirm("Projekt beenden?");
    	if(Check == true){                                                 
    		window.location.href='index.php?id=197&action=end&pid=' + str_pid + '&src=' + str_search;
    	}
  	}
  	if(str_action == "Abschluss"){
    	Check = confirm("Auszahlungsantrag versenden?");
    	if(Check == true){
    		window.location.href='index.php?id=' + str_pgid + '&action=finishmail&pid=' + str_pid + '&src=' + str_search;
    	}
  	}
}

function confirmDelete2mail(str_action, str_pid, str_pgid, str_search){
    if(str_action == "Deactivate"){
    	Check = confirm("Projekt (de-) aktivieren?");
    	if(Check == true){
    		window.location.href='index.php?id=' + str_pgid + '&action=deactivate&pid=' + str_pid + '&src=' + str_search;
    	}
  	}
  	if(str_action == "Delete"){
    	Check = confirm("Projekt löschen?");
    	if(Check == true){
    		window.location.href='index.php?id=' + str_pgid + '&action=delete&pid=' + str_pid + '&src=' + str_search;
    	}
  	}
  	if(str_action == "Sperrung"){
    	Check = confirm("Projekt entsperren?");
    	if(Check == true){
    		window.location.href='index.php?id=' + str_pgid + '&action=unblock&pid=' + str_pid + '&src=' + str_search;
    	}
  	}
  	if(str_action == "Beenden"){
    	Check = confirm("Projekt beenden?");
    	if(Check == true){
    		window.location.href='index.php?id=' + str_pgid + '&action=end&pid=' + str_pid + '&src=' + str_search;
    	}
  	}
}

function submitConfirm2(str_meldung, str_formname, str_field, min_value){
 var a = document.forms[str_formname].elements[str_field].value / 1;
 var b = min_value / 1;

	if((a < min_value) || isNaN(a)){
		alert("FEHLER: Geben Sie mindestens " + min_value + " ein!");
		document.forms[str_formname].elements[str_field].value = min_value;
	}
	else{
		Check = confirm(str_meldung);
		if(Check == true){
			document.forms[str_formname].submit();
		}
	}
}

function writeErrorBox(num, addtxt){
  var txt = "";
  switch(num){
    case "1":
    txt = "<div width=\"100%\" class=\"errorheadline\">Fehler</div><br />";
    txt += "Bitte geben Sie einen h&ouml;heren iDO-Betrag ein!<br/><br />";
    txt += "<a href=\"index.php?id=104\" class=\"lbOff\">&gt;&gt; Mehr iDOs sammeln</a><br /><br />";
    txt += "<a href=\"javascript:hideErrorBox();\">&lt;&lt; Zur&uuml;ck</a>";
    break;
    
    case "2":
    txt = "<div class=\"csc-textpicHeader csc-textpicHeader-25\">";
    txt += "<span style=\"color:red;font-size:14pt;font-weight:bold;\">Vielen Dank</span></div>";
    txt += "<br /><b>Ihre Spende entspricht einem Betrag von " + addtxt + " Euro.</b><br /><br />";
    txt += "<a href=\"javascript:hideErrorBox();\">&lt;&lt; Zur&uuml;ck</a>";
    break;
  }
  
  document.getElementById("errortext").innerHTML = txt;
      
}

function submitConfirm2a(str_meldung, str_formname, str_field, min_value){
 var a = document.forms[str_formname].elements[str_field].value / 1;
 var b = min_value / 1;
 
 if(document.getElementById('projectcell')){
  str_meldung = str_meldung + "\n" + document.getElementById('projectcell').innerHTML;
 }

	if((a < min_value) || isNaN(a)){
		writeErrorBox("1");
    showErrorBox();
	}
	else{
		Check = confirm(str_meldung);
		if(Check == true){
			document.forms[str_formname].submit();
		}
	}
}

function showErrorBox(){
		window.scrollTo(0, 0);
		with(document.getElementById("errordiv").style){
		  width = document.body.clientWidth;
		  height = document.body.clientHeight;
      display = "block";
    }
		with(document.getElementById("zentriertDiv").style){
		  visible = "visible";
      display = "block";
      zIndex = 9999;
    }
}

function hideErrorBox(){
		with(document.getElementById("errordiv").style){
		  width = 0;
		  height = 0;
      display = "none";
    }
    with(document.getElementById("zentriertDiv").style){
      display = "none";
    }
}