var http_request = false;
function makeRequest(url, parameters, divId) {
   divToChange = divId;
   http_request = false;
   // url = "ergebnisschleife.inc.php";
   // alert("suche datei: (" + url + ") \n" + parameters + " ..." + divToChange);
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType) {
      	// set type accordingly to anticipated content type
         //http_request.overrideMimeType('text/xml');
         http_request.overrideMimeType('text/html');
      }
   } else if (window.ActiveXObject) { // IE
      try {
         http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
         try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (e) {}
      }
   }
   if (!http_request) {
      alert('Cannot create XMLHTTP instance');
      return false;
   }
   http_request.onreadystatechange = alertContents;
   http_request.open('GET', url + parameters, true);
   http_request.send(null);
}

function alertContents() {
   if (http_request.readyState == 4) {
      if (http_request.status == 200) {
         //alert(http_request.responseText);
         result = http_request.responseText;
         document.getElementById(divToChange).innerHTML = result;
         // oeffnen von sisplaynone            
      } else {
         // alert('There was a problem with the request.');
         alert('There was a problem with the request.' + http_request.readyState + ' ... ' + http_request.status + ' ... ');
      }
   }
}

function wrapToRequest(url, parameters, divId)
{
   // divToChange = divId;
   // alert('Dieser Alert wurde angefordert von der ID: ' + divId);
   makeRequest(url, parameters, divId);
   window.setTimeout("makeRequest('/typo3conf/ext/dt_tagungsnavigator/tagungsnavigator/ajax_info_leaflet.php', '?count=now', 'leafletContent')", 1000);
   // schmeissAlert(divId);
}




function CheckBox(feld, myform, picpath, chkimg, uchkimg)
{
 var theForm = document.forms[myform];
 var theCheckImg = picpath + chkimg;
 var theUnCheckImg = picpath + uchkimg;
 if(theForm[feld].value == 'true')
 {
  theForm[feld].value = 'false';
  document.images[feld].src = theUnCheckImg; // '/typo3conf/ext/dt_tagungsnavigator/tagungsnavigator/images/colset_specific/colset_orange/uncheckedbox.gif';
 }
 else
 {
  theForm[feld].value = 'true';
  document.images[feld].src = theCheckImg; // '/typo3conf/ext/dt_tagungsnavigator/tagungsnavigator/images/colset_specific/colset_orange/checkedbox.gif';
  
  if (feld != 'uncheck_all' && theForm['uncheck_all'].value == 'true')
  {
      theForm['uncheck_all'].value = 'false';
      document.images['uncheck_all'].src = theUnCheckImg; // '/typo3conf/ext/dt_tagungsnavigator/tagungsnavigator/images/colset_specific/colset_orange/uncheckedbox.gif';
  }
  
 }
}

function unCheckAll (feldbasis, myform, maxVal, picpath, chkimg, uchkimg)
{
    var theForm = document.forms[myform];
    var theCheckImg = picpath + chkimg;
    var theUnCheckImg = picpath + uchkimg;
    for (i=1;i<=maxVal;i++)
    {
        var einFeld = feldbasis + '[' + i + ']';
        if (theForm[einFeld])
        {
            theForm[einFeld].value = 'false';
            document.images[einFeld].src = theUnCheckImg; // '/typo3conf/ext/dt_tagungsnavigator/tagungsnavigator/images/colset_specific/colset_orange/uncheckedbox.gif';
        }
    }
}


function RadioButton(feld,index,maxindex, myform, picpath, chkimg, uchkimg)
{
 var theForm = document.forms[myform];
 var theCheckImg = picpath + chkimg;
 var theUnCheckImg = picpath + uchkimg;
 theForm[feld].value = index;
 for(i=0;i<maxindex;i++)
 {
  if(index != i){document.images[feld+''+i].src = theUnCheckImg;}
  else{document.images[feld+''+i].src = theCheckImg;}
 }
}

function RadioButtonStars(feld,index,maxindex, myform, picpath, chkimg, uchkimg)
{
 var theForm = document.forms[myform];
 var theCheckImg = picpath + chkimg;
 var theUnCheckImg = picpath + uchkimg;
 theForm[feld].value = index;
 for(i=0;i<maxindex;i++)
 {
  if(index < i){document.images[feld+''+i].src = theUnCheckImg;}
  else{document.images[feld+''+i].src = theCheckImg;}
 }
}

function displayOnOff(div)
{
    with (document.getElementById(div).style)
    { 
        if (display == "none")
        { 
            display = "block";
        }
        else
        {
            display = "none"; 
    	}
    }
}

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}

function decStr(input)
{
    var output = decode64(input);
    parent.location='mailto:' + output;
}
