//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=0;                     //distance from left border
var divtop=0;                      //distance from top
var divheight=520;                   //height of maincontent window
var divheight1=60;                   //height of Accept
var divwidth=1000;
var divborder='4px solid #CCCCCC';      //border style main window
var divborder1='0px solid #CCCCCC';                   //width
//var divborder='4px solid #FAEBD7';      //border style main window
//var divborder1='0px solid #FAEBD7';     //border style accept
var divbackground='#F0F8FF';            //background color
var divbackground1='';            //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 = '1300'                 //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());
}

rounder();

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 realpopup;
var formelements;


function sleep(ms){
var zeit=(new Date()).getTime();
var stoppZeit=zeit+ms;
while((new Date()).getTime()<stoppZeit){};
return true;
} 


var Adresse = escape(document.referrer);

if(Adresse)
{
}
else
{
Adresse ="noscript";
}

function dlcounter(downloading, sites, countit, AGBs, mustac, email, realpopup)
{

Adresse = Adresse +"&savename="+countit;

//alert(Adresse);
filetocount = countit;
downloads = downloading;
sitepath = sites +"/";
//sitepath=sitepath.replace("//","/");
AGBfile = AGBs;
acceptit = mustac;
mailaccept = email;
thisrealpopup = realpopup;

rounder();

//alert(sitepath);
//alert(downloading);
/*
if(thisrealpopup==0)
{
sitepath = "";
}
*/

if (thisrealpopup==0 || thisrealpopup=="")
{
//alert('test');

	

         document.getElementById("userresponder").innerHTML = '<iframe src="'+sitepath+'dlcounter.php?count=1&file='+filetocount+'&downloading='+downloading+'&idcount='+idcount1+'" scrolling="no" frameborder="0"></iframe><img src="http://test.klickkraft.at/soft_itc/system/counter/count.php?ref='+Adresse+'" width=1 height=1 border=0 >';
         sleep(1100);
         if(AGBfile=="1")
         {
           htmlcontent = "<center><div style='position:absoulte; top:0px; left:0px;'><iframe src='"+ sitepath +"agb.php?accept="+ acceptit +"&targeturl="+ downloads +"&idcount="+ idcount1 +"' width='"+ divwidth+ "' height='"+ divheight +"' scrolling='no' frameborder='0' ></iframe></div></center>";

           creatediv('AGB', htmlcontent, (divwidth+8), (divheight+8), divleft, (divtop-5), divborder, divbackground,divcolor,'visible');
	    if(thisrealpopup==0)
	    {
		  creatediv('close','<div align="center" valign="top" onclick="closefunction(0);"></div>', 35, 35, (divleft+(divwidth-40)), divtop, divborder1,divbackground1,divcolor, 'visible');
	    }
	     else
	    {
		  creatediv('close','<div align="center" valign="top" onclick="closefunction(0);"><a href="#"><img src="http://test.klickkraft.at/chirurgencheck/popup_neu/bload1-0/bload1-0/images/closeit.gif" border="0" style="position:relative; top:0px; left:0px;"></a></div>', 35, 35, (divleft+(divwidth-40)), divtop, divborder1,divbackground1,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:0px;"><input type="hidden" name="email" id="email" value="' +entervalue+ '" style="width:130px; border:1px solid #000">&nbsp;&nbsp;<a href="#" onclick="accepted(1);" style="position:relative; top:400px;"></a>&nbsp;&nbsp;<a href="#" onclick="closefunction(1);"></a></form><a href="#" onclick="accepted(0);"><img src="http://test.klickkraft.at/chirurgencheck/popup_neu/bload1-0/bload1-0/images/hcc-transp.gif" style="position:relative; left:10px; top:-20px; width:' +(divwidth-18)+ '; height:' +(divheight-65)+ ';" border="0"></a>';
           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, (divheight-25), divleft, (divtop+25),divborder1,divbackground1,divcolor, 'visible');
	   }

           document.getElementById("userresponder").innerHTML = '<iframe src="'+sitepath+'dlcounter.php?agbshow=1&file='+filetocount+'&idcount='+idcount1+'" scrolling="no" frameborder="0"></iframe><img src="http://test.klickkraft.at/soft_itc/system/counter/count.php?ref='+Adresse+'" width=1 height=1 border=0 >';

            
          
          if(acceptit=="0" && mailaccept=="0")
          {
          setTimeout("downloader()",ajaxtime);
          }
          }
         else
        { 
        closefunction1(3);
        setTimeout("downloader()",ajaxtime);
        }        
}
else
{
//alert("dfsf");
//PopUnder Power
//Credit notice must stay intact for use.
//Paste this entire javascript between the <head> & </head> tags of your page, 
// Visit http://www.mikenew.net for more scripts. 
// by Mike New, with special thanks to Jeff Phillips of http://www.cadwebsitedesign.com

// Begin. Specify URLs to randomly select from and pop-under. Edit & add freely.
var popunder=new Array()
popunder[0]=sitepath +"window.php?counter=1&filetocount="+filetocount+"&downloads="+downloads+"&AGBfile="+AGBfile+"&acceptit="+acceptit+"&mailaccept="+mailaccept+"&sitepath="+sitepath+"&idcount="+idcount1;
//popunder[1]="http://www.classadrivers.com"
//popunder[2]="http://www.myezshop.com"

// Specify the width and height of new popunder window (in pixels).
var width = divwidth; 
var height = divheight;

var p = 'scrollbars=yes,resizable=yes,toolbar=yes,' + //these are obvious variables. set "yes" or "no".
'menubar=yes,status=yes,location=yes,left=85,top=20,height=' +  //yes/no, & the screen location
height + ',width=' + width;

// Load new PopUnder only once per browser session? (0=no, 1=yes)
// Putting 0 will cause the Popunder to load every time page is loaded
// Specifying 1 will cause it to load only once per session
var one_time=0

// That's it! Don't edit the code below unless you're really good. :-P //

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if the cookie exists
      offset += search.length
      end = document.cookie.indexOf(";", offset); // set the index of beginning value
      
    if (end == -1) // set the index of the end of cookie value
         end = document.cookie.length;
         returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function loadornot(){
if (get_cookie('popunder')==''){
load_pop_power()
document.cookie="popunder=yes"
}
}

function load_pop_power(){
if(thisrealpopup==2)
{
win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"bw",p)
}
else
{
win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"bw",p)
}
win2.blur()
  if (realpopup==2)
  {
    win2.focus()
  }
  else if(realpopup==1)
  {
   window.focus()
  }

}

if (one_time==0)
load_pop_power()
else
loadornot()


}


}
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)
{
document.getElementById("userresponder").innerHTML = '<iframe src="'+sitepath+'dlcounter.php?closecount='+count+'&file='+filetocount+'&idcount='+idcount1+'&entervalue1='+document.entervalue.email.value+'" scrolling="no" frameborder="0"></iframe><img src="http://test.klickkraft.at/soft_itc/system/counter/count.php?ref='+Adresse+'" width=1 height=1 border=0 >';


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)
{
document.getElementById("userresponder").innerHTML = '<iframe src="'+sitepath+'dlcounter.php?closecount='+count+'&file='+filetocount+'&idcount='+idcount1+'" scrolling="no" frameborder="0"></iframe><img src="http://test.klickkraft.at/soft_itc/system/counter/count.php?ref='+Adresse+'" width=1 height=1 border=0 >';

}

function downloader()
{
//var win = window.open(downloads);
//window.open(downloads, 'welcome','fullscreen=yes,scrollbars=yes,menubar=yes,status=yes,location=yes,toolbar=yes')

var openwindows = downloads.indexOf("mailto:");
var openwindows1 = downloads.indexOf("@");

if(openwindows>"" || openwindows1>"")
{
document.write('<a href="' + downloads + '">' + downloads + '</a> - <br>Klicken Sie Bitte auf den Link um Ihr bevozugtes Mailprogramm zu starten');
}
else
{
if(downloads)
{
    window.location.href=downloads;
}
}
 

//var newWindow = window.open(this.getAttribute('href'), '_blank');

//document.getElementById("userresponder").innerHTML = "<a href='"+downloads+"' class=\"non-html\">open</a>";
}