function changeBackgroundAnunt(idElementFirst,idElementSecond, color){
    document.getElementById(idElementFirst).style.background = color;
    document.getElementById(idElementSecond).style.background = color;
}

function changeBackgroundAnuntSimple(idElementFirst, color){
    document.getElementById(idElementFirst).style.background = color;
}


function depunOferta() {
	new Ajax.Request("depunere_oferta.php", 
		{ 
			method: 'post', 
			postBody: $('depunere_oferta').serialize(),
			onComplete: responseDepunOferta 
		});
}


function responseDepunOferta(req){

	$('responseOferta').innerHTML= req.responseText;

	if(document.getElementById('succesOferta') && (document.getElementById('succesOferta').value == 1) ){
		// update lista oferte
		new Ajax.Request("lista_oferte_anunt.php", 
			{ 
				method: 'post', 
				postBody: $('depunere_oferta').serialize(),
				onComplete: updateListaOferte 
			});
		
	}
}


function updateListaOferte(req) {
	$('licitatieAnunt').innerHTML= req.responseText;
}



function userInteresatAnunt() {

	var message = '';
	//alert(document.getElementById("interesatDezinteresatAnunt").checked);

	if(document.getElementById("interesatDezinteresatAnunt").checked == true){
		message = "Doriti sa fiti informat in legatura cu acest anunt?";		
	} else {
		message = "Sunteti sigur ca doriti sa nu mai fiti informat in legatura cu acest anunt?";
	}

	if(!confirm(message)){
		return false;
	}

	new Ajax.Request("user_interesat_anunt.php", 
		{ 
			method: 'post', 
			postBody: $('user_interesat_anunt').serialize(),
			onComplete: responseUserInteresatAnunt 
		});
}

function responseUserInteresatAnunt(req) {
	$('responseInteresatAnunt').innerHTML= req.responseText;
}






function searchAnunturi() {
	new Ajax.Request("listSearchAnunturi.php", 
		{ 
			method: 'post', 
			postBody: $('moro').serialize(),
			onComplete: responseSearchAnunturi 
		});
}


function responseSearchAnunturi(req){
	$('listSearchAnunturi').innerHTML= req.responseText;
}



function paginateAnunt(str){
	new Ajax.Request("listSearchAnunturi.php", 
		{ 
			method: 'post', 
			postBody: str,
			onComplete: responseSearchAnunturi 
		});
}


