var xmlHttp;
var root = 'http://'+location.hostname+'/projects/bolgari/';

function ajax_http()
{
	try
    {
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
	return xmlHttp;
}

function clean_str(str)
{
	str=str.replace(/&/gi,"");
	str=str.replace(/</gi,"");
	str=str.replace(/>/gi,"");
	
	return str;
}

function setMaxLength() {
	var x = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.className = 'counter';
	for (var i=0;i<x.length;i++) {
		if (x[i].getAttribute('maxlength')) {
			var counterClone = counter.cloneNode(true);
			counterClone.relatedElement = x[i];
			counterClone.innerHTML = '<span>0</span>/'+x[i].getAttribute('maxlength');
			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

			x[i].onkeyup = x[i].onchange = checkMaxLength;
			x[i].onkeyup();
		}
	}
}

function checkMaxLength() {
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
		this.value = this.value.substring(0,maxLength);
	else
		this.relatedElement.className = '';
	this.relatedElement.firstChild.nodeValue = currentLength;
	// not innerHTML
}

function add_click_to_banner(id)
{
	xmlHttp_1=ajax_http();
	
	var url= root + "includes/ajax/adsClicks.inc.php";
	var parameters="id="+ encodeURI(id);
	
	xmlHttp_1.onreadystatechange=function()
	{
	
	}
	 xmlHttp_1.open('POST', url, true);
	 xmlHttp_1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     xmlHttp_1.setRequestHeader("Content-length", parameters.length);
     xmlHttp_1.setRequestHeader("Connection", "close");
     xmlHttp_1.send(parameters);
}

