

/******************************************
* Popup Box- By Jim Silver @ jimsilver47@yahoo.com
* Visit http://www.dynamicdrive.com/ for full source code
* This notice must stay intact for use
******************************************/

var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

//drag drop function for NS 4////
/////////////////////////////////

var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for ie4+ and NS6////
/////////////////////////////////


function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmouseup=new Function("dragapproved=false")

////drag drop functions end here//////

function hidebox(){
document.cookie="funtest=yes"

crossobj=ns6? document.getElementById("showimage") : document.all.showimage
if (ie4||ns6)
crossobj.style.visibility="hidden"
else if (ns4)
document.showimage.visibility="hide"

}

function make_visible()
{
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
if (ie4||ns6)
crossobj.style.visibility=""
else if (ns4)
document.showimage.visibility=""

document.cookie="funtest=no"

}


function load_funtest()
{

document.write('<div id="showimage" style="position:absolute; width:550px; left:'+deszczowcepl_left+'px; top:'+deszczowcepl_top+'px; border: 1px solid #E5E5C5; ">');
document.write('<table border="0" width="548" bgcolor="#F4F4DD" cellspacing="0" cellpadding="2">');
document.write('  <tr height="32px">');
document.write('    <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"');
document.write('    >');
document.write('      <tr>');
document.write('        <td id="dragbar" style="cursor:hand; cursor:pointer; padding-left: 5px" width="100%" onMousedown="initializedrag(event)"><ilayer width="100%" onSelectStart="return false"><layer width="100%" onMouseover="dragswitch=1;if (ns4) drag_dropns(showimage)" onMouseout="dragswitch=0"><a href = "http://www.deszczowce.pl"  style = "font-family: Trebuchet MS, Arial, sans-serif; font-size: 10pt; color: #FF7F00; font-decoration: none ">');
document.write('        <strong>Quiz z deszczowce.pl</strong></a></layer></ilayer></td>');
document.write('        <td style="cursor:hand"><a href="#" onClick="hidebox();return false"><img src="http://www.deszczowce.pl/img/x.gif" ');
document.write('        height="14px" border=0 /></a>&nbsp;</td>');
document.write('      </tr></table></td></tr>');
document.write('      <tr >');
document.write('        <td width="100%" bgcolor="#FCFDEF" style="padding:4px">');

document.write(' <iframe src="http://www.deszczowce.pl/questions/funtest_remote/'+deszczowcepl_funtest_id+'" width="540px" height="450px" frameborder="no" scrolling = "yes" style="overflow-x: hidden">  </iframe>');


document.write('    </td>');
document.write('  </tr>');
document.write('</table>');
document.write('</div>');

	if ((get_cookie('funtest')=='yes') || (deszczowcepl_not_visible == true))
	{
		hidebox();
	}

}


var one_time=1

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;
}

	load_funtest()


function clearcookie()
{
	document.cookie="funtest=no"
}

var randomnumber = Math.round(Math.random()*1500);

var popunder="http://funnet.pl"

//specify popunder window features
//set 1 to enable a particular feature, 0 to disable
var winfeatures="width=800,height=610,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0"

//Pop-under only once per browser session? (0=no, 1=yes)
//Specifying 0 will cause popunder to load every time page is loaded
var once_per_session=0

///No editing beyond here required/////

function get_cookie2(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function loadornot(){
if (get_cookie2('popunder')==''){
loadpopunder()
document.cookie="popunder=yes"
}
}

function loadpopunder(){
	if (randomnumber == 5)
	{
		if( get_cookie2('popunder')==''){
		win2=window.open(popunder,"",winfeatures);
		win2.blur();
		window.focus();
		document.cookie="popunder=yes"
		}
	}
}

if (once_per_session==0)
loadpopunder()
else
loadornot()

