

function load_script(url)
{	var head = document.getElementsByTagName('head')[0];
	var script = document.createElement('script');
	script.setAttribute('src', url);
    script.setAttribute('type', 'text/javascript');
	head.appendChild(script);
}

function defined(variable)
{
    return (typeof(window[variable]) == "undefined")?  false : true;
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function ajax_request()
{


	// Set up the request
	var r = Math.floor(Math.random()*1000001);
	//var AJAX =  new XMLHttpRequest();


	if (!defined('eurointegrator_pub_style_border'))
		var eurointegrator_pub_style_border = '1px solid';
	if (!defined('eurointegrator_pub_style_margin'))
		var eurointegrator_pub_style_margin = 'auto';

	document.write('<div id="eurointegrator_slot_'+r+'" style="border:'+eurointegrator_pub_style_border+'; margin:'+eurointegrator_pub_style_margin+';">Se incarca reclama ...</div>');

	var AJAX;
	try
	{
		AJAX = new XMLHttpRequest();
	}
	catch(e)
	{
		try
		{
			AJAX = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				AJAX = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your browser does not support AJAX.");
				return false;
			}
		}
	}

	AJAX.open('POST', 'http://www.euroconcept.ro/adserver/serve?r='+r, true);

	// The callback function
	AJAX.onreadystatechange = function() {
	    if (AJAX.readyState == 4) {
	        if (AJAX.status == 200) {
	            document.getElementById('eurointegrator_slot_'+r).innerHTML = AJAX.responseText + '<div style="display:block; clear:both; border-top:1px dashed; text-align:right;" /><a href="http://www.euroconcept.ro/" style="text-decoration:none; margin:2px 5px;">Reclama prin EuroConcept</a></div>';
	        }
	        else {
                //alert('failed to load ads');
                document.getElementById('eurointegrator_slot_'+r).innerHTML = 'failed to load ads' + '<div style="display:block; clear:both; border-top:1px dashed; text-align:right;" /><a href="http://www.euroconcept.ro/" style="text-decoration:none; margin:2px 5px;">Reclama prin EuroConcept</a></div>';
            }
	    }
	}

	// Send the POST request
	AJAX.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	AJAX.send('pub_id='+eurointegrator_pub_id+'&slot_id='+eurointegrator_slot_id);
}

//load_script('http://www.euroconcept.ro/objects/jquery/jquery.js');
//load_script('http://www.euroconcept.ro/objects/jquery/jquery.init.js');

//$().ready(function() {

//ajax_request();

//function adserver()
//{



	if (!defined('eurointegrator_pub_style_border'))
		var eurointegrator_pub_style_border = 'none';

	if (!defined('eurointegrator_pub_style_margin'))
		var eurointegrator_pub_style_margin = 'auto';

	if (!defined('eurointegrator_pub_uniq'))
		var eurointegrator_pub_uniq = Math.floor(Math.random()*1000001);

	if (!defined('eurointegrator_slot_pref'))
		var eurointegrator_slot_pref = 0;

	var eurointegrator_pub_r = Math.floor(Math.random()*1000001);
	document.write('<div id="eurointegrator_slot_'+eurointegrator_pub_r+'" style="border:'+eurointegrator_pub_style_border+'; margin:'+eurointegrator_pub_style_margin+';">Se incarca reclama ...</div>');
	load_script('http://www.euroconcept.ro/adserver/adserver.php?' + 'pub_id='+eurointegrator_pub_id+'&slot_id='+eurointegrator_slot_id+'&pref_id='+eurointegrator_slot_pref+'&uniq_id='+eurointegrator_pub_uniq+'&rand='+eurointegrator_pub_r);


//}

//addLoadEvent(adserver);
//adserver();

/*
	var r = Math.floor(Math.random()*1000001);

	document.write('<div id="eurointegrator_slot_'+r+'" style="border:1px solid;">Se incarca reclama ...</div>');

	jQuery.ajax({
		url: '/adserver/serve?r='+r,
		type: 'POST',
	//	async: false,
		data: 'pub_id='+eurointegrator_pub_id+'&slot_id='+eurointegrator_slot_id,
		ifModified: false,
		complete: function(res, status){
			if ( status == "success" )
			{
				document.getElementById('eurointegrator_slot_'+r).innerHTML = res.responseText + '<div style="display:block; clear:both; border-top:1px dashed; text-align:right;" /><a href="http://www.euroconcept.ro/" style="text-decoration:none; margin:2px 5px;">Reclama prin EuroConcept</a></div>';
			}
			else
				document.getElementById('eurointegrator_slot_'+r).innerHTML = 'ads cannot be served' + '<div style="display:block; clear:both; border-top:1px dashed; text-align:right;" /><a href="http://www.euroconcept.ro/" style="text-decoration:none; margin:2px 5px;">Reclama prin EuroConcept</a></div>';
				//alert('ads cannot be served');
		}
	});
*/

//});
