﻿function ShowAds()
{
	var div='', isimg=true;
	try {
	div=document.getElementById('rdn-img-ads');
	div.style.visibility = 'visible';
	div.style.display = 'block';
	div.style.top = FromTop() + ScreenHeight() - 72 + "px";
	div.style.left = ScreenWidth() - 140 + "px";
	} catch (e) {isimg=false}
	try {
	div=document.getElementById('rdn-txt-ads');
	div.style.visibility = 'visible';
	div.style.display = 'block';
	div.style.top = FromTop() + ScreenHeight() - 24 + "px";
	if (isimg) {
		div.style.left = ScreenWidth() - div.offsetWidth - 140 + "px";
	} else {
		div.style.left = ScreenWidth() - div.offsetWidth - 18 + "px";
	}
	} catch (e) {}
}

function HideAds()
{
	var div='';
	try {
	div=document.getElementById('rdn-img-ads');
	div.style.visibility = 'hidden';
	div.style.display = 'none';
	} catch (e) {}
	try {
	div=document.getElementById('rdn-txt-ads');
	div.style.visibility = 'hidden';
	div.style.display = 'none';
	} catch (e) {}
}

function FromTop()
{
	var ScrollTop = document.body.scrollTop;
	if (ScrollTop == 0)
	{
	    if (window.pageYOffset)
	        ScrollTop = window.pageYOffset;
	    else
	        ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	return ScrollTop;
}

function ScreenWidth() {
	var result = 2000;

	if (window.innerWidth) {
		// all except Explorer
		result = parseInt(window.innerWidth);
	} else if (document.documentElement && document.documentElement.clientWidth) {
		// Explorer 6 Strict Mode
		result = parseInt(document.documentElement.clientWidth);
	} else if (document.body) {
		// other Explorers
		result = parseInt(document.body.clientWidth);
	}
	if (isNaN(result)) {
		result = 2000;
	}
	return result;
}

function ScreenHeight() {
	var result = 2000;

	if (window.innerHeight) {
		// all except Explorer
		result = parseInt(window.innerHeight);
	} else if (document.documentElement && document.documentElement.clientHeight) {
		// Explorer 6 Strict Mode
		result = parseInt(document.documentElement.clientHeight);
	} else if (document.body) {
		// other Explorers
		result = parseInt(document.body.clientHeight);
	}
	if (isNaN(result)) {
		result = 2000;
	}
	return result;
}






var xmlHttp;
function AdsClicked(type, id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url="response.php";
	var p ="type=addclick" + type + "ads&id=" + id;
	//xmlHttp.onreadystatechange=editAdsStateChanged;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", p.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(p);
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}