var site_root = "http://www.cosebelleonline.it/";

function mostraMenu(menuCorrente) {
	if (document.getElementById) {
		questoMenu = document.getElementById(menuCorrente).style
		if (questoMenu.display == "block") {
			questoMenu.display = "none"
		}
		else {
			questoMenu.display = "block"
		}
		return false
	}
	else {
		return true
	}
}

function sendMail(){
	var email = document.getElementById("email").value;
	var getUrl = site_root+"srv/sendNewsletter.php?email=" + email;
	new Ajax.Updater("send_mail", getUrl)
}

function ric_prodotto(){
	var prodotto = document.getElementById("prodotto").value;				
	window.open (site_root+"ricerca.php?prodotto="+prodotto,"_self");
}

function ricerca_marca() {
	var marca = document.getElementById("marca").value;	
	window.open (site_root+"ricerca.php?marca="+marca,"_self");		
}

function result_search(){
	var getUrl = addr+"srv/getPlatformCont.php?dettaglio="+dettaglio;
	new Ajax.Updater("platformCont", getUrl)
}

function get_sottocategoria(){
	var id_categoria = document.getElementById("ID_categoria").value;
	var getUrl = "http://www.cosebelleonline.it/admin/srv/getSottoCat.php?ID_categoria="+id_categoria;
	new Ajax.Updater("select_sottocat", getUrl)
}

function setID_gruppo(id_mailing, i){
	var destinatari = document.getElementById("destinatari"+i).value;
	location.href="/admin/srv/sendMsgMailing.php?id_mailing="+id_mailing+"&id_cat_mail="+destinatari;
}

/*
function asyncEmbVote(){
	var id_prodotto = document.getElementById("id_prodotto").value;
	var voto = document.getElementById("voto").value;		
	var id_account = document.getElementById("id_account").value;
	var getUrl = "http://www.cosebelleonline.it/admin/srv/getStar.php?id_prodotto="+id_prodotto+"&voto="+voto"&id_account="+id_account;
	new Ajax.Updater("media_voto_contenuto", getUrl)
}
*/

function swap_type() {
    if(document.getElementById("tipopersona").checked){
        document.getElementById("div_piva").style.visibility = "hidden";
        document.getElementById("div_ragsociale").style.visibility = "hidden";
				document.getElementById("div_ragsociale_input").style.visibility = "hidden";
				
        document.getElementById("div_nomecognome").style.visibility = "visible";
        document.getElementById("div_nomecognome_input").style.visibility = "visible";
        document.getElementById("div_cf").style.visibility = "visible";
        
    }
    else{
        document.getElementById("div_piva").style.visibility = "visible";
        document.getElementById("div_ragsociale").style.visibility = "visible";
        document.getElementById("div_ragsociale_input").style.visibility = "visible";
        
        document.getElementById("div_nomecognome").style.visibility = "hidden";
        document.getElementById("div_nomecognome_input").style.visibility = "hidden";
        document.getElementById("div_cf").style.visibility = "hidden";
    }	
}	


function asyncEmbVote(id_prodotto, id_account, voto){
	var getUrl = site_root+"admin/srv/getStar.php?id_prodotto="+id_prodotto+"&voto="+voto+"&id_account="+id_account;
	new Ajax.Request(getUrl, {
		method: 'GET',
		onSuccess: function(transport) {
			var arr = transport.responseText.split('-');	
				$('media_voto_contenuto').setStyle({width: arr[0]+'%'});
				$('tot_voti_contenuto').update('&nbsp;' + arr[1] + ' votes');
			}
	});
}

function delete_prod(id_prodotto){
	var bConfirm = window.confirm("ATTENZIONE! \r\nSei sicuro di cancellare questo prodotto?");
	if(!bConfirm)
		{
			return false;
		}	 					
	window.open ("/admin/prodotti/delete.php?id_prodotto="+id_prodotto,"_self");
}

function delete_sottocategoria(ID_sotto_categoria){
	var bConfirm = window.confirm("ATTENZIONE! \r\nSei sicuro di cancellare questa sottocategoria?");
	if(!bConfirm)
		{
			return false;
		}	 					
	window.open ("/admin/sottocategorie/delete.php?ID_sotto_categoria="+ID_sotto_categoria,"_self");
}

function delete_categoria(ID_categoria){
	var bConfirm = window.confirm("ATTENZIONE! \r\nSei sicuro di cancellare questa categoria?");
	if(!bConfirm)
		{
			return false;
		}	 					
	window.open ("/admin/categorie/delete.php?ID_categoria="+ID_categoria,"_self");
}

function aggiorna_pacco(){
	alert("dddd")
	var getUrl = addr+"admin/srv/getPacco.php?pacco="+pacco;
	new Ajax.Updater("handling", getUrl)
}

function torna_indietro(page, marca, prodotto) {
	
	if(marca != "") {		
		var getUrl = site_root+"ricerca.php?marca=" + marca + "&Page=" + page;		
	} else {
		var getUrl = site_root+"ricerca.php?prodotto=" + prodotto + "&Page=" + page;		
	}
	 				
return false;	
}


