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+"admin/srv/sendNewsletter.php?email=" + email;
	new Ajax.Updater("send_mail", getUrl)
}

function ric_prodotto(){

	var prodotto = document.getElementById("prodotto").value;
	if (prodotto == "") {
		alert("Scegli la marca!")
	} else {			
		var getUrl = site_root+"ricerca.php?prodotto="+prodotto;
		new Ajax.Updater("show_prodotti", getUrl);					
	}			
}

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 ricerca_marca() {
	
	  var marca;
	  if (document.getElementById("marca") != null) {
	    marca = document.getElementById("marca").value;
	  }	
		if (marca == "") {
			alert("Scegli la marca!")
		} else {			
			var getUrl = site_root+"ricerca.php?marca="+marca;
			new Ajax.Updater("show_prodotti", getUrl);	
			
			if((document.getElementById('details_prodotti') != null) && (document.getElementById('details_prodotti').style.display == "none")) {
				document.getElementById('show_all').style.display = "none";	
			  document.getElementById('details_prodotti').style.display = "block";		
	   	} 			
		}			
}

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 pacco_SI(pacco){
	document.getElementById('handlingCARRELLO').innerHTML = '<input type="hidden" name="handling" value='+pacco+'>';
	document.getElementById('handlingPAGA').innerHTML = '<input type="hidden" name="handling" value='+pacco+'>';	
	//	var getUrl = addr+"admin/srv/getPacco.php?pacco="+pacco;
	//	new Ajax.Updater("handling", getUrl)
}

function pacco_NO(pacco){
	document.getElementById('handlingCARRELLO').innerHTML = '<input type="hidden" id="handling" name="handling" value='+pacco+'>';
	document.getElementById('handlingPAGA').innerHTML = '<input type="hidden" id="handling" name="handling" value='+pacco+'>';	
	//	var getUrl = addr+"admin/srv/getPacco.php?pacco="+pacco;
	//	new Ajax.Updater("handling", getUrl)
}


