var xmlHttp;
function createXMLHTTPRequest() {
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
		}
};

function openContactForm(clasified_id)
	{
	document.getElementById('contact_form').innerHTML='<img src='+script_path+'_img/ajax-loader-big.gif />';
	createXMLHTTPRequest();
	xmlHttp.onreadystatechange = processContactForm;
	xmlHttp.open('GET', script_path+'ajax/contact_form.php?clasified_id='+clasified_id+'&stamp='+ new Date().getTime(), true);
	xmlHttp.send(null);
	};
	
function processContactForm() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			document.getElementById('contact_form').innerHTML='';
			newdiv = document.createElement('div');
			newdiv.innerHTML = xmlHttp.responseText;
			document.getElementById('contact_form').appendChild(newdiv);
			};
		};
	}


	
function secureCode()
	{
	document.getElementById('secure_code').innerHTML='<img src='+script_path+'_img/ajax-loader-big.gif />';
	createXMLHTTPRequest();
	xmlHttp.onreadystatechange = processSecureCode;
	xmlHttp.open('GET', script_path+'ajax/secure_code.php?stamp='+ new Date().getTime(), true);
	xmlHttp.send(null);
	};
	
function processSecureCode() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			document.getElementById('secure_code').innerHTML='';
			newdiv = document.createElement('div');
			newdiv.innerHTML = xmlHttp.responseText;
			document.getElementById('secure_code').appendChild(newdiv);
			};
		};
	};
	
function sendConfMail(hash)
	{
	document.getElementById('mail_area').innerHTML='<img src='+script_path+'_img/ajax-loader-big.gif />';
	createXMLHTTPRequest();
	xmlHttp.onreadystatechange = processSendConfMail;
	xmlHttp.open('GET',script_path+'ajax/sendConfMail.php?hash='+hash, true);
	xmlHttp.send(null);
	};
	
function processSendConfMail() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			document.getElementById('mail_area').innerHTML='';
			newdiv = document.createElement('div');
			newdiv.innerHTML = xmlHttp.responseText;
			document.getElementById('mail_area').appendChild(newdiv);
			};
		};
	};
	
function setCategory(cat_id) {
		document.getElementById('quicksearch_category').value = cat_id;
		getQuickSearchManufacturer(cat_id);
		return true;
	};
	
function getCategories(sel, cat_id)
	{
	createXMLHTTPRequest();
	if (sel==0) xmlHttp.onreadystatechange = processCategories1;
	if (sel==1) xmlHttp.onreadystatechange = processCategories2;
	if (sel==2) xmlHttp.onreadystatechange = processCategories3;
	if (sel==3) xmlHttp.onreadystatechange = processCategories4;
	if (sel==4) xmlHttp.onreadystatechange = processCategories5;
	xmlHttp.open('GET',script_path+'ajax/getCategories.php?id='+cat_id+'&sel='+sel, true);
	xmlHttp.send(null);
	};
	
function processCategories1() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			selectelement = document.getElementById('cat_id1');
			selectelement.innerHTML = xmlHttp.responseText;
			getCategories(1, -1);
			};
		};
	};
	
function processCategories2() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			selectelement = document.getElementById('cat_id2');
			selectelement.innerHTML = xmlHttp.responseText;
			getCategories(2, -1);
			};
		};
	};
	
function processCategories3() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			selectelement = document.getElementById('cat_id3');
			selectelement.innerHTML = xmlHttp.responseText;
			getCategories(3, -1);
			};
		};
	};
	
function processCategories4() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			selectelement = document.getElementById('cat_id4');
			selectelement.innerHTML = xmlHttp.responseText;
			getCategories(4, -1);
			};
		};
	};
	
function processCategories5 () 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			selectelement = document.getElementById('cat_id5');
			selectelement.innerHTML = xmlHttp.responseText;
			};
		};
	};
	
	
function getBanners()
	{
	createXMLHTTPRequest();
	xmlHttp.onreadystatechange = processBanners;
	xmlHttp.open('GET',script_path+'ajax/getBanners.php', true);
	xmlHttp.send(null);
	};
	
function processBanners() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			document.getElementById('banner_full').innerHTML = xmlHttp.responseText;
			};
		};
	};
	
	
function resetAds(ads_id)
	{
	createXMLHTTPRequest();
	xmlHttp.onreadystatechange = processResetAds;
	xmlHttp.open('GET',script_path+'ajax/resetAdminAds.php?ads_id='+ads_id, true);
	xmlHttp.send(null);
	};
	
function processResetAds() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			document.getElementById('prepaids_area').innerHTML = xmlHttp.responseText;
			};
		};
	};
	
function disableAds(ads_id)
	{
	createXMLHTTPRequest();
	xmlHttp.onreadystatechange = processDisableAds;
	xmlHttp.open('GET',script_path+'ajax/disableAdminAds.php?ads_id='+ads_id, true);
	xmlHttp.send(null);
	};
	
function processDisableAds() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			document.getElementById('prepaids_area').innerHTML = xmlHttp.responseText;
			};
		};
	};
	
function getQuickSearchManufacturer(cat_id)
	{
	createXMLHTTPRequest();
	xmlHttp.onreadystatechange = processQSManufacturer;
	xmlHttp.open('GET',script_path+'ajax/createSelect.php?cat_id='+cat_id+'&sel=manufacturer', true);
	xmlHttp.send(null);
	};

function processQSManufacturer() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			document.getElementById('qs_manufacturer').innerHTML = xmlHttp.responseText;
			document.getElementById('quicksearch_model').options.length = 1;
			document.getElementById('quicksearch_year').options.length = 1; 
			};
		};
	};
	
function getQuickSearchModel(cat_id, manufacturer)
	{
	createXMLHTTPRequest();
	xmlHttp.onreadystatechange = processQSModel;
	xmlHttp.open('GET',script_path+'ajax/createSelect.php?cat_id='+cat_id+'&sel=model&opt1='+manufacturer, true);
	xmlHttp.send(null);
	};

function processQSModel() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			document.getElementById('qs_model').innerHTML = xmlHttp.responseText;
			document.getElementById('quicksearch_year').options.length = 1;
			};
		};
	};
	
function getQuickSearchYear(cat_id, manufacturer, model)
	{
	createXMLHTTPRequest();
	xmlHttp.onreadystatechange = processQSYear;
	xmlHttp.open('GET',script_path+'ajax/createSelect.php?cat_id='+cat_id+'&sel=year&opt1='+manufacturer+'&opt2='+model, true);
	xmlHttp.send(null);
	};

function processQSYear() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			document.getElementById('qs_year').innerHTML = xmlHttp.responseText;
			};
		};
	};
	
function sendContactMail(clasified_id, subject, text) 
	{
	createXMLHTTPRequest();
	xmlHttp.onreadystatechange = processSendContactMail;
	xmlHttp.open('POST',script_path+'ajax/sendContactMail.php', true);
	params = 'clasified_id='+clasified_id+'&subject='+subject+'&text='+text;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
	};

function processSendContactMail() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200) 
			{
			finishSendContactMail();
			};
		};
	};
	
function delContactMail(reply_id) 
	{
	createXMLHTTPRequest();
	xmlHttp.onreadystatechange = processDelContactMail;
	xmlHttp.open('GET',script_path+'ajax/delContactMail.php?reply_id='+reply_id, true);
	xmlHttp.send(null);
	};

function processDelContactMail() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200)  
			{
			document.getElementById('replies').innerHTML = xmlHttp.responseText;
			};
		};
	};
	
	
	
function refreshAuction(auction_id) 
	{
	createXMLHTTPRequest();
	xmlHttp.onreadystatechange = processRefreshAuction;
	xmlHttp.open('GET',script_path+'ajax/refreshAuction.php?auction_id='+auction_id, true);
	xmlHttp.send(null);
	};

function processRefreshAuction() 
	{
	if (xmlHttp.readyState == 4)
		{
		if (xmlHttp.status == 200)  
			{
			document.getElementById('refresh').innerHTML = xmlHttp.responseText;
			};
		};
	};