
 function openPlayerScore(obj){
	var tables = obj.getElementsByTagName('DIV');
	var app;
	for(var i=0;i<tables.length;i++){
		if(tables[i].className=='pTables'){
			app = tables[i];
			break;
		}
	}
	if(app.style.display=='none'){
		app.style.display='block';
	}else{
		app.style.display='none';
	}
 }
 
 function initMap(){
	resizePage();
	var latlng = new google.maps.LatLng(43.24856338012196,13.23253882510377);
	var myOptions = {
	  zoom: 13,
	  center: latlng,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	var myLatlng = new google.maps.LatLng(43.24856338012196,13.23253882510377);
	var marker = new google.maps.Marker({
		position: myLatlng, 
		map: map,
		title:"Multiclima SRL"
	});	
 }

 //cambia l'offerta visualizzata nella home
 function changeMainOffer(num){
	for(var i=1;i<4;i++){
		if(document.getElementById('divOffer'+i))document.getElementById('divOffer'+i).style.display = 'none';
	}
	if(document.getElementById('divOffer'+num))document.getElementById('divOffer'+num).style.display = 'block';
 }
 
//---------------------------------------------------------
//	RICERCA
//--------------------------------------------------------- 
 
  function clearSearch(obj){
	if(obj.value=='Cerca prodotto...'){
		obj.value = "";
	}
 }
 
 function searchNews(){
	var key = escape(document.getElementById('txtSearch').value);
	if(key.length<3)alert('Attenzione. La parola chiave deve essere di almeno 3 caratteri.');
	else window.location = 'results.php?type=1&key='+key;
 }
 
  function searchProduct(){
	var key = escape(document.getElementById('txtSearch').value);
	if(key=='Cerca prodotto...')return false;
	var cat = document.getElementById('selCat').value;
	if(cat==0)cat='';
	if(key.length<3)alert('Attenzione. La parola chiave deve essere di almeno 3 caratteri.');
	else window.location = 'results.php?type=2&key='+key+'&cat='+cat;
 }
 
  function searchCreations(){
	var key = escape(document.getElementById('txtSearch').value);
	if(key.length<3)alert('Attenzione. La parola chiave deve essere di almeno 3 caratteri.');
	else window.location = 'results.php?type=3&key='+key;
 }
 
//---------------------------------------------------------
//	INVIO EMAIL
//---------------------------------------------------------
  
 function sendMail(){
	var nome = escape(document.getElementById('txtNome').value);
	if(nome==""){
		alert("Attenzione. E' necessario specificare il nominativo.");
		return false;
	}
	var mail = escape(document.getElementById('txtMail').value);
	var phone = document.getElementById('txtTel').value;
	if(mail==""&&phone==""){
		alert("Attenzione. E' necessario specificare o l'indirizzo e-mail o un recapito telefonico.");
		return false;
	}
	var content = escape(document.getElementById('txtContent').value);
	if(content==""){
		alert("Attenzione. Nessun testo inserito.");
		return false;
	}
	var zone = document.getElementById('selZone').value;
	var risp = ajaxRequestPost('core.php','mode=1&name='+nome+'&mail='+mail+'&phone='+phone+'&content='+content+'&zone='+zone);	
	document.getElementById('txtNome').value = '';
	document.getElementById('txtMail').value = '';
	document.getElementById('txtTel').value = '';
	document.getElementById('txtContent').value = '';
	alert('Messaggio inviato correttamente');
 }
 
 
//---------------------------------------------------------
//	GESTIONE TRACCIABILITA'
//--------------------------------------------------------- 
 function changeTraceTime(val){
		document.getElementById('txtClientData').style.visibility = 'hidden';
	if(val==3||val==4){
		document.getElementById('txtClientData').style.visibility = 'visible';
		document.getElementById('txtClientData').focus();
	}
 }
 
 function traceSearch(){
	var type = document.getElementById('selDataClient').value;
	if(type==0)type = '';
	var name = document.getElementById('txtClient').value;
	var app = '';
	if(type==3||type==4)app = document.getElementById('txtClientData').value;
	var risp = ajaxRequestPost('core.php','mode=trace_1&type='+type+'&date1='+app+'&name='+name);
	document.getElementById('divTraces').innerHTML = risp;
 }
 
  function getExcelTrace(){
	var type = document.getElementById('selDataClient').value;
	if(type==0)type = '';
	var name = document.getElementById('txtClient').value;
	var app = '';
	if(type==3||type==4)app = document.getElementById('txtClientData').value;
	window.open('core.php?mode=trace_2&type='+type+'&date1='+app+'&name='+name);
 }
 
 function deleteTrace(){
 	var to = document.getElementById('txtDataDel').value;
	if (!to) {
		alert('Attenzione. Nessuna data specificata.');
		return false;
	}
	if(confirm('Si vuole veramente eliminare la cronologia?')){
		var risp = ajaxRequestPost('core.php','mode=trace_3&date1='+to);
		document.getElementById('divTraces').innerHTML = risp;
		alert('Cronologia eliminata correttamente');
	}
	
 }
 
//---------------------------------------------------------
//	GESTIONE UTENTI
//---------------------------------------------------------
 
 //apre la finestra per l'aggiunta di un utente
 function openNewUser(){
	//creo il nuovo utente nel db e prendo l'id
	var risp = ajaxRequestPost('core.php','mode=user_1');
	var app = parseInt(risp,10);
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=user_2&id_user='+app);
	document.getElementById('divUserData').innerHTML = risp2;
 }
 
 //apre il dettaglio del utente selezionato
 function changeUser(idUser){
	var risp = ajaxRequestPost('core.php','mode=user_2&id_user='+idUser);
	document.getElementById('divUserData').innerHTML = risp;
 }
 
 //svuoto la machera di modifica di un utente
 function clearUserData(){
	document.getElementById('divUserData').innerHTML = "";
 }
 
 //modifica i dati dell'utente selezionato
 function modifyUser(){
	var idUser = document.getElementById('hddUserId').value;
	var nome = escape(document.getElementById('txtUNome').value);
	var cog = escape(document.getElementById('txtUCog').value);
	var username = escape(document.getElementById('txtUUsername').value);
	var password = document.getElementById('txtUPassword').value;
	var admin = document.getElementById('chkAdmin').checked;
	if(idUser&&nome&&cog&&username&&password){
		var appStr = 'mode=user_3&id_user='+idUser+'&name='+nome+'&surname='+cog+'&username='+username+'&password='+password;
		if(admin)appStr = appStr + '&admin=1';
		var risp = ajaxRequestPost('core.php',appStr);
		document.getElementById('divUsers').innerHTML = risp;
		clearUserData();
		alert('Dati utente aggiornati.');
	}else{
		alert("Attenzione! Alcuni dati sono stati lasciati vuoti.");
	}
 }
 
 //eliminazione utente
 function deleteUser(){
	if(document.getElementById('hddUserId').value!=""){
		if(confirm("Si vuole veramente eliminare questo utente?")){
			var risp = ajaxRequestPost('core.php','mode=user_4&id_user='+document.getElementById('hddUserId').value);
			//aggiorno l'interfaccia
			clearUserData();
			document.getElementById('divUsers').innerHTML = risp;
		}
	}
 }

//---------------------------------------------------------
//	GESTIONE CLIENTI
//---------------------------------------------------------

 function openNewClient(){
	//creo il nuovo utente nel db e prendo l'id
	var risp = ajaxRequestPost('core.php','mode=user_1');
	var app = parseInt(risp,10);
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=client_1&id_user='+app);
	document.getElementById('divUserData').innerHTML = risp2;
 }
 
 function changeClient(idUser){
	var risp = ajaxRequestPost('core.php','mode=client_1&id_user='+idUser);
	document.getElementById('divUserData').innerHTML = risp;
 }
 
 function clearClientData(){
	document.getElementById('divUserData').innerHTML = "";
 }
 
 function modifyClient(clientP){
	if(!clientP){
		var username = escape(document.getElementById('txtUUsername').value);
		var nome = escape(document.getElementById('txtUNome').value);
		var cog = escape(document.getElementById('txtUCog').value);
		var azienda = escape(document.getElementById('txtUAzienda').value);
		var indirizzo = escape(document.getElementById('txtUIndirizzo').value);
		var client = document.getElementById('selUType').value;
	}
	var idUser = document.getElementById('hddUserId').value;
	var password = document.getElementById('txtUPassword').value;
	var email = escape(document.getElementById('txtUEmail').value);
	var telefono = document.getElementById('txtUTelefono').value;
	var fax = document.getElementById('txtUFax').value;
	if(clientP){
		if(!password||!email||!telefono){
			alert("Attenzione. Alcuni dati sono stati lasciati vuoti.");
		}else if(password.length<6){
			alert("Attenzione. La password deve essere di almeno 6 caratteri");
		}else{
			var appStr = 'mode=client_4&id_user='+idUser+'&phone='+telefono+'&fax='+fax+'&mail='+email+'&password='+password;
			var risp = ajaxRequestPost('core.php',appStr);
			alert('Dati aggiornati.');
		}
	}else{
		if(idUser&&nome&&cog&&username&&password){
			var appStr = 'mode=client_2&id_user='+idUser+'&name='+nome+'&surname='+cog+'&factory='+azienda+'&location='+indirizzo+'&phone='+telefono+'&fax='+fax+'&mail='+email+'&username='+username+'&password='+password+'&client='+client;
			var risp = ajaxRequestPost('core.php',appStr);
			document.getElementById('divUsers').innerHTML = risp;
			clearClientData();
			alert('Dati cliente aggiornati.');
		}else{
			alert("Attenzione! Alcuni dati sono stati lasciati vuoti.");
		}
	}
 }
 
 function deleteClient(){
	if(document.getElementById('hddUserId').value!=""){
		if(confirm("Si vuole veramente eliminare questo cliente?")){
			var risp = ajaxRequestPost('core.php','mode=client_3&id_user='+document.getElementById('hddUserId').value);
			//aggiorno l'interfaccia
			clearClientData();
			document.getElementById('divUsers').innerHTML = risp;
		}
	}
 }
 
//---------------------------------------------------------
//	GESTIONE EMAIL
//---------------------------------------------------------
 
 function editMail(id){
	var newM = escape(document.getElementById('txtMail_'+id).value);
	var risp = ajaxRequestPost('core.php','mode=mail_100&zone='+id+'&mail='+newM);
	alert('Indirizzo email aggiornato.');
 }
 

//---------------------------------------------------------
//	GESTIONE CATEGORIE
//---------------------------------------------------------
 
 //creazione
 function openNewCategory(){
	//creo il nuovo post nel db e prendo l'id
	var risp = ajaxRequestPost('core.php','mode=cat_112');
	var app = parseInt(risp,10);
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=cat_113&category='+app);
	document.getElementById('divCategoryEdit').innerHTML = risp2;
	//apro il text editor
	var risp3 = ajaxRequestPost('core.php','mode=cat_116&category='+app);
	openEditor(risp3);
 }
 
 //caricamento
 function loadCurrentCategory(obj){
	var id = obj.id.split('c_')[1];
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=cat_113&category='+id);
	document.getElementById('divCategoryEdit').innerHTML = risp2;
	//apro il text editor
	var risp3 = ajaxRequestPost('core.php','mode=cat_116&category='+id);
	openEditor(risp3);
 }
 
 //salvataggio
 function saveCategory(){
	var idCategory = document.getElementById('hddCatId').value;
	//salvataggio di un post titolo + testo + immagine
	var titolo = escape(document.getElementById('txtCatTitle').value);
	var testo = escape(document.getElementById('txtCatEditor').value);
	var titolo_e = escape(document.getElementById('txtCatTitleE').value);
	var testo_e = escape(document.getElementById('txtCatEditorE').value);
	var spec = escape(CKEDITOR.instances.txtPostEditor.getData());
	if(titolo!=""&&testo!=''){
		var risp = ajaxRequestPost('core.php','mode=cat_114&title='+titolo+'&content='+testo+'&title_e='+titolo_e+'&content_e='+testo_e+'&category='+idCategory+'&specifics='+spec);
		//aggiorno l'interfaccia
		document.getElementById('divCategoryEdit').innerHTML = "";
		document.getElementById('divCategories').innerHTML = risp;
	}else{
		alert('Attenzione. Alcuni campi sono stati lasciati vuoti.')
	}	
 }
 
 //eliminazione 
 function deleteCategory(){
	if(document.getElementById('hddCatId').value!=0){
		if(confirm("Si vuole procedere alla cancellazione di questa categoria e di tutti i suoi relativi prodotti?")){
			var risp = ajaxRequestPost('core.php','mode=cat_115&category='+document.getElementById('hddCatId').value);
			//aggiorno l'interfaccia
			document.getElementById('divCategoryEdit').innerHTML = "";
			document.getElementById('divCategories').innerHTML = risp;
		}
	}else{
		alert('Attenzione. Nessuna categoria selezionata.');
	}
 }

//---------------------------------------------------------
//	GESTIONE PRODOTTI
//---------------------------------------------------------
 
 //creazione
 function openNewProduct(){
	//creo il nuovo post nel db e prendo l'id
	var risp = ajaxRequestPost('core.php','mode=pro_112');
	var app = parseInt(risp,10);
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=pro_113&product='+app);
	document.getElementById('divProductEdit').innerHTML = risp2;
 }
 
 //caricamento
 function loadCurrentProduct(obj){
	var id = obj.id.split('pr_')[1];
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=pro_113&product='+id);
	document.getElementById('divProductEdit').innerHTML = risp2;
 }
 
 //salvataggio
 function saveProduct(){
	var idProduct = document.getElementById('hddProId').value;
	//salvataggio di un post titolo + testo + immagine
	var titolo = escape(document.getElementById('txtProTitle').value);
	var testo = escape(document.getElementById('txtProEditor').value);
	var dettagli = document.getElementById('txtProDetails').value;
	var titolo_e = escape(document.getElementById('txtProTitleE').value);
	var testo_e = escape(document.getElementById('txtProEditorE').value);
	var categoria = document.getElementById('selCat').value;
	if(titolo!=""){
		var risp = ajaxRequestPost('core.php','mode=pro_114&title='+titolo+'&content='+testo+'&title_e='+titolo_e+'&content_e='+testo_e+'&details='+dettagli+'&product='+idProduct+'&category='+categoria);
		//aggiorno l'interfaccia
		document.getElementById('divProductEdit').innerHTML = "";
		document.getElementById('divProducts').innerHTML = risp;
	}else{
		alert('Attenzione. Alcuni campi sono stati lasciati vuoti.')
	}	
 }
 
 //eliminazione 
 function deleteProduct(){
	if(document.getElementById('hddProId').value!=0){
		if(confirm("Si vuole procedere alla cancellazione di questo prodotto?")){
			var risp = ajaxRequestPost('core.php','mode=pro_115&product='+document.getElementById('hddProId').value);
			//aggiorno l'interfaccia
			document.getElementById('divProductEdit').innerHTML = "";
			document.getElementById('divProducts').innerHTML = risp;
		}
	}else{
		alert('Attenzione. Nessun prodotto selezionato.');
	}
 }


//---------------------------------------------------------
//	GESTIONE POST
//---------------------------------------------------------
 
 //termina l'upload dei file
 function uploadPostImage(filename){
	document.getElementById('imgUp').src=filename;
	document.getElementById('hddImgPost').value=filename;
 }
 
 //inserimento di un nuovo post
 function openNewPost(){
	//creo il nuovo post nel db e prendo l'id
	var risp = ajaxRequestPost('core.php','mode=post_112');
	var app = parseInt(risp,10);
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=post_113&post='+app);
	document.getElementById('divPostEdit').innerHTML = risp2;
 }
 
 //carica il post selezionato
 function loadCurrentPost(obj){
	var id = obj.id.split('p_')[1];
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=post_113&post='+id);
	document.getElementById('divPostEdit').innerHTML = risp2;
 }
 
 //salva il post 
 function savePost(){
	var idPost = document.getElementById('hddPostId').value;
	//salvataggio di un post titolo + testo + immagine
	var titolo = escape(document.getElementById('txtPostTitle').value);
	var testo = escape(document.getElementById('txtPostEditor').value);
	var titolo_e = escape(document.getElementById('txtPostTitle_e').value);
	var testo_e = escape(document.getElementById('txtPostEditor_e').value);
	if(titolo!=""&&testo!=''){
		var risp = ajaxRequestPost('core.php','mode=post_114&title='+titolo+'&content='+testo+'&title_e='+titolo_e+'&content_e='+testo_e+'&post='+idPost);
		//aggiorno l'interfaccia
		document.getElementById('divPostEdit').innerHTML = "";
		document.getElementById('divPosts').innerHTML = risp;
	}else{
		alert('Attenzione. Alcuni campi sono stati lasciati vuoti.')
	}	
 }
 
 //elimina il post selezionato
 function deletePost(){
	if(document.getElementById('hddPostId').value!=0){
		if(confirm("Si vuole procedere alla cancellazione di questa notizia?")){
			var risp = ajaxRequestPost('core.php','mode=post_115&post='+document.getElementById('hddPostId').value);
			//aggiorno l'interfaccia
			document.getElementById('divPostEdit').innerHTML = "";
			document.getElementById('divPosts').innerHTML = risp;
		}
	}else{
		alert('Attenzione. Nessuna notizia selezionata.');
	}
 }
 
 //completa l'upload di un'immagine su una news
 function addPostImage(imgSrc,id){
	document.getElementById('imgLoading').style.visibility = "hidden";
	var photo = document.createElement('SPAN');
	photo.id = 'sp_'+id;
	photo.className = 'albumImage';
	var photoImg = document.createElement('IMG');
	photoImg.src = imgSrc;
	photoImg.id = 'img_'+id;
	photo.appendChild(photoImg);
	document.getElementById('divImageList').appendChild(photo);
 }

//---------------------------------------------------------
//	GESTIONE CREAZIONI PERSONALIZZATE
//---------------------------------------------------------
 
 //termina l'upload dei file
 function uploadCreationImage(filename){
	document.getElementById('imgUp').src=filename;
	document.getElementById('hddImgCreation').value=filename;
 }
 
 //inserimento di un nuovo post
 function openNewCreation(){
	//creo il nuovo post nel db e prendo l'id
	var risp = ajaxRequestPost('core.php','mode=creation_112');
	var app = parseInt(risp,10);
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=creation_113&creation='+app);
	document.getElementById('divCreationEdit').innerHTML = risp2;
 }
 
 //carica il post selezionato
 function loadCurrentCreation(obj){
	var id = obj.id.split('cr_')[1];
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=creation_113&creation='+id);
	document.getElementById('divCreationEdit').innerHTML = risp2;
 }
 
 //salva il post 
 function saveCreation(){
	var idCreation = document.getElementById('hddCreationId').value;
	//salvataggio di un post titolo + testo + immagine
	var titolo = escape(document.getElementById('txtCreationTitle').value);
	var testo = escape(document.getElementById('txtCreationEditor').value);
	var titolo_e = escape(document.getElementById('txtCreationTitle_e').value);
	var testo_e = escape(document.getElementById('txtCreationEditor_e').value);
	if(titolo!=""&&testo!=''){
		var risp = ajaxRequestPost('core.php','mode=creation_114&title='+titolo+'&content='+testo+'&title_e='+titolo_e+'&content_e='+testo_e+'&creation='+idCreation);
		//aggiorno l'interfaccia
		document.getElementById('divCreationEdit').innerHTML = "";
		document.getElementById('divCreations').innerHTML = risp;
	}else{
		alert('Attenzione. Alcuni campi sono stati lasciati vuoti.')
	}	
 }
 
 //elimina il post selezionato
 function deleteCreation(){
	if(document.getElementById('hddCreationId').value!=0){
		if(confirm("Si vuole procedere alla cancellazione di questa offerta?")){
			var risp = ajaxRequestPost('core.php','mode=creation_115&creation='+document.getElementById('hddCreationId').value);
			//aggiorno l'interfaccia
			document.getElementById('divCreationEdit').innerHTML = "";
			document.getElementById('divCreations').innerHTML = risp;
		}
	}else{
		alert('Attenzione. Nessuna creazione selezionata.');
	}
 }
 
 //completa l'upload di un'immagine su una news
 function addCreationImage(imgSrc,id){
	document.getElementById('imgLoading').style.visibility = "hidden";
	var photo = document.createElement('SPAN');
	photo.id = 'sp_'+id;
	photo.className = 'albumImage';
	var photoImg = document.createElement('IMG');
	photoImg.src = imgSrc;
	photoImg.id = 'img_'+id;
	photo.appendChild(photoImg);
	document.getElementById('divImageList').appendChild(photo);
 } 
 
//---------------------------------------------------------
//	GESTIONE OFFERTE
//---------------------------------------------------------
 
 //termina l'upload dei file
 function uploadOfferImage(filename){
	document.getElementById('imgUp').src=filename;
	document.getElementById('hddImgOffer').value=filename;
 }
 
 //inserimento di un nuovo post
 function openNewOffer(){
	//creo il nuovo post nel db e prendo l'id
	var risp = ajaxRequestPost('core.php','mode=offer_112');
	var app = parseInt(risp,10);
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=offer_113&offer='+app);
	document.getElementById('divOfferEdit').innerHTML = risp2;
 }
 
 //carica il post selezionato
 function loadCurrentOffer(obj){
	var id = obj.id.split('o_')[1];
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=offer_113&offer='+id);
	document.getElementById('divOfferEdit').innerHTML = risp2;
 }
 
 //salva il post 
 function saveOffer(){
	var idOffer = document.getElementById('hddOfferId').value;
	//salvataggio di un post titolo + testo + immagine
	var titolo = escape(document.getElementById('txtOfferTitle').value);
	var testo = escape(document.getElementById('txtOfferEditor').value);
	var titolo_e = escape(document.getElementById('txtOfferTitle_e').value);
	var testo_e = escape(document.getElementById('txtOfferEditor_e').value);
	if(titolo!=""&&testo!=''){
		var risp = ajaxRequestPost('core.php','mode=offer_114&title='+titolo+'&content='+testo+'&title_e='+titolo_e+'&content_e='+testo_e+'&offer='+idOffer);
		//aggiorno l'interfaccia
		document.getElementById('divOfferEdit').innerHTML = "";
		document.getElementById('divOffers').innerHTML = risp;
	}else{
		alert('Attenzione. Alcuni campi sono stati lasciati vuoti.')
	}	
 }
 
 //elimina il post selezionato
 function deleteOffer(){
	if(document.getElementById('hddOfferId').value!=0){
		if(confirm("Si vuole procedere alla cancellazione di questa offerta?")){
			var risp = ajaxRequestPost('core.php','mode=offer_115&offer='+document.getElementById('hddOfferId').value);
			//aggiorno l'interfaccia
			document.getElementById('divOfferEdit').innerHTML = "";
			document.getElementById('divOffers').innerHTML = risp;
		}
	}else{
		alert('Attenzione. Nessuna offerta selezionata.');
	}
 }
 
 //completa l'upload di un'immagine su una news
 function addOfferImage(imgSrc,id){
	document.getElementById('imgLoading').style.visibility = "hidden";
	var photo = document.createElement('SPAN');
	photo.id = 'sp_'+id;
	photo.className = 'albumImage';
	var photoImg = document.createElement('IMG');
	photoImg.src = imgSrc;
	photoImg.id = 'img_'+id;
	photo.appendChild(photoImg);
	document.getElementById('divImageList').appendChild(photo);
 }

//---------------------------------------------------------
//	GESTIONE LISTINO PREZZI
//---------------------------------------------------------
  
 //inserimento
 function openNewPrice(){
	//creo il nuovo post nel db e prendo l'id
	var risp = ajaxRequestPost('core.php','mode=price_1');
	document.getElementById('divPriceEdit').innerHTML = risp;
 }
 
 //carica il post selezionato
 function loadCurrentPrice(obj){
	var id = obj.id.split('p_')[1];
	//carico la finestra di edit
	var risp2 = ajaxRequestPost('core.php','mode=price_2&price='+id);
	document.getElementById('divPriceEdit').innerHTML = risp2;
 }
 
 //salva il post 
 function savePrice(){
	var idPrice = document.getElementById('hddPriceId').value;
	//salvataggio di un post titolo + testo + immagine
	var titolo = escape(document.getElementById('txtTitle').value);
	var file = document.getElementById('selFile').value;
	var client = document.getElementById('selClient').value;
	if(titolo){
		var risp = ajaxRequestPost('core.php','mode=price_3&title='+titolo+'&file='+file+'&client='+client+'&price='+idPrice);
		//aggiorno l'interfaccia
		document.getElementById('divPriceEdit').innerHTML = "";
		document.getElementById('divPrices').innerHTML = risp;
	}else{
		alert('Attenzione. Alcuni campi sono stati lasciati vuoti.')
	}
 }
 
 //elimina il post selezionato
 function deletePrice(){
	if(document.getElementById('hddPriceId').value!=0){
		if(confirm("Si vuole procedere alla cancellazione di questo listino?")){
			var risp = ajaxRequestPost('core.php','mode=price_4&price='+document.getElementById('hddPriceId').value);
			//aggiorno l'interfaccia
			document.getElementById('divPriceEdit').innerHTML = "";
			document.getElementById('divPrices').innerHTML = risp;
		}
	}else{
		alert('Attenzione. Nessun listino selezionato.');
	}
 }
 
//---------------------------------------------------------
//	GESTIONE IMMAGINI
//---------------------------------------------------------
 
 //completa l'upload di un'immagine su un album
 function addAlbumImage(imgSrc,id){
	document.getElementById('imgLoading').style.visibility = "hidden";
	var album = document.getElementById('hddAlbum').value;
	var photo = document.createElement('SPAN');
	photo.id = 'sp_'+id;
	photo.className = 'albumImage';
	var photoImg = document.createElement('IMG');
	photoImg.src = imgSrc;
	photoImg.id = 'img_'+id;
	photo.appendChild(photoImg);
	document.getElementById('divImageList').appendChild(photo);
 }
 
 //crea un nuovo album
 function addAlbum(){
	var risp = ajaxRequestPost('core.php','mode=img_115');
	document.getElementById('divCurAlbum').innerHTML = risp;
 }
 
 //edita l'album attuale e ricarica la lista
 function editAlbum(){
	var id = document.getElementById('hddAlbum').value;
	var name = escape(document.getElementById('txtAName').value);
	var desc = escape(document.getElementById('txtADesc').value);
	var risp = ajaxRequestPost('core.php','mode=img_116&album='+id+'&name='+name+'&desc='+desc);
	document.getElementById('divAlbumGrid').innerHTML = risp;
	document.getElementById('divCurAlbum').innerHTML = "";
 }
 
 //carica l'album selezionato
 function loadAlbumEdit(id){
	var risp = ajaxRequestPost('core.php','mode=img_117&album='+id);
	document.getElementById('divCurAlbum').innerHTML = risp;
 }
 
 //elimina l'album selezionato e tutte le sue foto
 function deleteAlbum(id){
 	if(confirm("Si vuole veramente eliminare quest'album?")){
 		var risp = ajaxRequestPost('core.php','mode=img_118&album='+id);
 		document.getElementById('divCurAlbum').innerHTML = "";
		//ricarico la lista degli album
 		document.getElementById('divAlbumGrid').innerHTML = risp;
 	}
 }
 
 //elimina l'immagine selezionata
 function deleteImage(evt){
	var tar = getTarget(evt);
	if(tar.tagName=='IMG'){
		var id = tar.id.split('_')[1];
		var risp = ajaxRequestPost('core.php','mode=img_119&image='+id);
		document.getElementById('divImageList').removeChild(document.getElementById('sp_'+id));
	}
 }
 
 //richiesta creazione clienti
 function clientRequest(){
	var valori = getForm('divReqClient');
	if(!valori)return false;
	var risp = ajaxRequestPost('core.php','mode=req_1'+valori);
	alert('I vostri dati sono stati inviati ai nostri server. Sarete ricontattati al pił presto via email o telefono.');
	window.location = "http://www.multiclimasrl.com";
 }
 
