function readyAJAX(){
    try{
	return new XMLHttpRequest();
    }catch(e){
	try{
	    return new ActiveXObject('Msxm12.XMLHTTP');
	}catch(e){
	    try{
		return new ActiveXObject('Microsoft.XMLHTTP');
	    }catch(e){
		return "A newer browser is needed.";
	    }
	}
    }
}

var dbWriter = readyAJAX();
function dbWrite(VisitorID,action)
{
    if(dbWriter) 
    {
	var cel = document.getElementById('dbwriter');
	dbWriter.open('POST', 'http://faunavet.pl/dbWriter.php');
	dbWriter.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=iso-8859-2;');
	dbWriter.send('visitorid='+VisitorID+'&action='+action+'');
	dbWriter.onreadystatechange = function()
	{
	    if(dbWriter.readyState == 4)
	    {
	        cel.innerHTML = dbWriter.responseText; 
	    }
	}
    }
}


function parseScript(_source) {
    var source = _source;
    var scripts = new Array();

    // Strip out tags
    while(source.indexOf("<script") > -1 || source.indexOf("</script") > -1) {
	var s = source.indexOf("<script");
	var s_e = source.indexOf(">", s);
	var e = source.indexOf("</script", s);
	var e_e = source.indexOf(">", e);

	// Add to scripts array
	scripts.push(source.substring(s_e+1, e));

	// Strip from source
	source = source.substring(0, s) + source.substring(e_e+1);
    }

    // Loop through every script collected and eval it
    for(var i=0; i<scripts.length; i++) {
	try {
	    eval(scripts[i]);
	}
	catch(ex) {
	    // do what you want here when a script fails
	}
    }
    // Return the cleaned source
    return source;
}

