function start_ajax() {
var xmlHttp;
try{
return xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
}
catch (e){
try{
return xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
}
catch (e){
try{
return xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("Your browser does not support AJAX.");
return false;
}
}
}
}

function price_edit(id) {

var xmlHttp = start_ajax();

fetch_unix_timestamp = function()
{
return parseInt(new Date().getTime().toString().substring(0, 20))
}

var url = "http://www.buycar.sk/price_edit.php";
var price = document.getElementById('id_'+id);
price = price.value;

var timestamp = fetch_unix_timestamp();
var nocacheurl = url+"?t="+timestamp+"&id="+id+"&cena="+price;

xmlHttp.open("GET",nocacheurl,true);
xmlHttp.send(null);

document.getElementById('id_'+id).style.borderWidth = '0px';
document.getElementById('id_'+id).style.height = '16px';
}

function price_border(id) {
document.getElementById('id_'+id).style.borderWidth = '1px';
document.getElementById('id_'+id).style.height = '14px';
}



function email_exist(arg) {

var xmlHttp = start_ajax();

fetch_unix_timestamp = function()
{
return parseInt(new Date().getTime().toString().substring(0, 20))
}
var no_cache = fetch_unix_timestamp();
var email = document.getElementById(arg).value;
var url = "http://www.buycar.sk/email_exist.php?t="+no_cache+"&email="+email;

xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState==4){
document.getElementById('email_exist').innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET", url);	
xmlHttp.send(null);
}



function change_model(model,page) {

var xmlHttp = start_ajax();

fetch_unix_timestamp = function()
{
return parseInt(new Date().getTime().toString().substring(0, 20))
}

var url = "http://www.buycar.sk/change_model.php";
var brand = document.getElementById('brand').value;

var timestamp = fetch_unix_timestamp();
var nocacheurl = url+"?t="+timestamp+"&page="+page+"+&brand="+brand+"&model="+model;

xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState==4){
document.getElementById('model').innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET",nocacheurl,true);
xmlHttp.send(null);
}



function textarea_show(type)
{
	var height = document.getElementById(type).offsetHeight;
	document.getElementById(type).style.display= "none";
	document.getElementById('textarea_'+type).style.display= "block";
	document.getElementById('textarea_'+type).style.height= 50+height+"px";
	document.getElementById('textarea_'+type).focus();
}
	
function textarea_hide(type,id)
{	
var xmlHttp = start_ajax();

fetch_unix_timestamp = function()
{
return parseInt(new Date().getTime().toString().substring(0, 20))
}

var url = "http://www.buycar.sk/uprava_inzeratu.php";
var text = document.getElementById('textarea_'+type).value;

var timestamp = fetch_unix_timestamp();
var nocacheurl = url+"?t="+timestamp+"&type="+type+"&text="+text+"+&id="+id;

xmlHttp.open("GET",nocacheurl,true);
xmlHttp.send(null);

document.getElementById(type).style.display= "block";
document.getElementById('textarea_'+type).style.display= "none";
document.getElementById(type).innerHTML = text; 
}

