// JavaScript Document
// libreria js per il catalogo dinamico
var prodname = '';


function copia(da, a, nomeForm) {
	
		
	switch (nomeForm) {
		case "FormUpdateProd": // dati prodotti
			
			// nome
			document.forms[nomeForm].elements['nome_prodotto['+a+']'].value=document.forms[nomeForm].elements['nome_prodotto['+da+']'].value;
			
			// descrizione
			copia_text_cuteeditor('breve_descrizione_'+da,'breve_descrizione_'+a);
			//contenuti=estraiValue('breve_descrizione_'+da, 'html');
			//alert(contenuti);
			//document.forms[nomeForm].elements['breve_descrizione['+a+']'].value=descrizione;
			//inserisciValue('breve_descrizione_'+a, contenuti)
			
		break;
		
		case "FormUpdateInfo": // maggiori info
		
			// descrizione_lunga
			copia_text_cuteeditor('descrizione_lunga_'+da,'descrizione_lunga_'+a);
			//contenuti=estraiValue('descrizione_lunga_'+da, 'html');
			//alert(contenuti);
			//document.forms[nomeForm].elements['breve_descrizione['+a+']'].value=descrizione;
			//inserisciValue('descrizione_lunga_'+a, contenuti)
			

			// title
			document.forms[nomeForm].elements['title['+a+']'].value=document.forms[nomeForm].elements['title['+da+']'].value;
			
			// keywords
			document.forms[nomeForm].elements['keywords['+a+']'].value=document.forms[nomeForm].elements['keywords['+da+']'].value;
			
			// description
			document.forms[nomeForm].elements['description['+a+']'].value=document.forms[nomeForm].elements['description['+da+']'].value;
			
			// testo_seo
			document.forms[nomeForm].elements['testo_seo['+a+']'].value=document.forms[nomeForm].elements['testo_seo['+da+']'].value;

		break;
		
		case "FormUpdateCat": // categorie

			// nome
			document.forms[nomeForm].elements['nome_categoria['+a+']'].value=document.forms[nomeForm].elements['nome_categoria['+da+']'].value;
			
			// descrizione
			document.forms[nomeForm].elements['descrizione['+a+']'].value=document.forms[nomeForm].elements['descrizione['+da+']'].value;
			// title
			document.forms[nomeForm].elements['title['+a+']'].value=document.forms[nomeForm].elements['title['+da+']'].value;
			
			// keywords
			document.forms[nomeForm].elements['keywords['+a+']'].value=document.forms[nomeForm].elements['keywords['+da+']'].value;
			
			// description
			document.forms[nomeForm].elements['description['+a+']'].value=document.forms[nomeForm].elements['description['+da+']'].value;

			// testo_seo
			document.forms[nomeForm].elements['testo_seo['+a+']'].value=document.forms[nomeForm].elements['testo_seo['+da+']'].value;

		break;
		
		case "FormUpdateTasse": // tasse
			// nome
			document.forms[nomeForm].elements['nome['+a+']'].value=document.forms[nomeForm].elements['nome['+da+']'].value;
		
		break;

		
		case "FormUpdateOpzioni": // opzioni attributi
			// nome
			document.forms[nomeForm].elements['nome['+a+']'].value=document.forms[nomeForm].elements['nome['+da+']'].value;
		
		break;

		
		case "FormUpdateAttributi": // attributi
			// nome
			document.forms[nomeForm].elements['nome['+a+']'].value=document.forms[nomeForm].elements['nome['+da+']'].value;
		
		break;


		case "FormUpdateDocumento":
		
			// descrizione
			document.forms[nomeForm].elements['descrizione_documento['+a+']'].value=document.forms[nomeForm].elements['descrizione_documento['+da+']'].value;
			
		break;
		
		case "FormUpdateG":
		
			// descrizione
			document.forms[nomeForm].elements['nome_gruppo['+a+']'].value=document.forms[nomeForm].elements['nome_gruppo['+da+']'].value;
			
		break;

		case "FormUpdatePromo":
		
			// descrizione
			document.forms[nomeForm].elements['descrizione['+a+']'].value=document.forms[nomeForm].elements['descrizione['+da+']'].value;
			
		break;

	}



} // end func copia

function copia_text_cuteeditor(source,dest){
	 
	var editor1 = document.getElementById('CE_'+source+'_ID');
	var content = editor1.getHTML();
	
	var editor2 = document.getElementById('CE_'+dest+'_ID');

	// setting the content of Cute Editor
	editor2.setHTML(content);

}



/*
// per fckEditor
function estraiValue (nomeCampo, tipo) {

	//bisogna trovare l'iframe eEditorArea all'interno dell'iframe NOMECAMPO___Frame

	// if contentDocument exists, W3C compliant (Mozilla)
	if (document.getElementById(nomeCampo+'___Frame').contentDocument){
		ifrRef = document.getElementById(nomeCampo+'___Frame').contentDocument;
	} else {
		// IE
		ifrRef = document.frames[nomeCampo+'___Frame'].document;
	}
	//alert(ifrRef);
	
	hCode = ifrRef.getElementById("xEditingArea");
	//alert(hCode); return false;

	var iFCode = hCode.getElementsByTagName("IFRAME")[0];
	//alert('iFCode '+iFCode); return false;

	//contentsHtml = iF.contentDocument.getElementsByTagName("BODY")[0].innerHTML;
	// if contentDocument exists, W3C compliant (Mozilla)
	if (iFCode.contentDocument){
		contentsHtml = iFCode.contentDocument.getElementsByTagName("BODY")[0].innerHTML;
	} else {
		// IE
		contentsHtml1 = hCode.document.frames[0].document;
		//alert('contentsHtml1 '+contentsHtml1);
		contentsHtml2 =contentsHtml1.getElementsByTagName("BODY")[0];

		contentsHtml = contentsHtml2.innerHTML;
	}

	// elaboro la stringa //

	// tolgo i tag
	var regExpTag = /<\/?[^>]+>/gi;
	contentsText = contentsHtml.replace(regExpTag, "");

	// tolgo gli spazi
	var regExpS = /\s+/gi;
	contentsText = contentsText.replace(regExpS, "");
	
	// tolgo gli &nbsp;
	var regExpS1 = /(&nbsp;)+/gi;
	contentsText = contentsText.replace(regExpS1, "");
	
	if (tipo=='txt') return contentsText;
	else return contentsHtml;
	
} // end func estraiValue


function inserisciValue (nomeCampo, contenuti) {

	//bisogna trovare l'iframe eEditorArea all'interno dell'iframe NOMECAMPO___Frame

	// if contentDocument exists, W3C compliant (Mozilla)
	if (document.getElementById(nomeCampo+'___Frame').contentDocument){
		ifrRef = document.getElementById(nomeCampo+'___Frame').contentDocument;
	} else {
		// IE
		ifrRef = document.frames[nomeCampo+'___Frame'].document;
	}
	//alert(ifrRef);
	
	hCode = ifrRef.getElementById("xEditingArea");
	//alert(hCode); return false;

	var iFCode = hCode.getElementsByTagName("IFRAME")[0];
	//alert('iFCode '+iFCode); return false;

	//contentsHtml = iFCode.contentDocument.getElementsByTagName("BODY")[0].innerHTML;
	// if contentDocument exists, W3C compliant (Mozilla)
	if (iFCode.contentDocument){
//		contentsHtml = iFCode.contentDocument.getElementsByTagName("BODY")[0].innerHTML;
		iFCode.contentDocument.getElementsByTagName("BODY")[0].innerHTML=contenuti;
		
	} else {
		// IE
		contentsHtml1 = hCode.document.frames[0].document;
		//alert('contentsHtml1 '+contentsHtml1);
		contentsHtml2 =contentsHtml1.getElementsByTagName("BODY")[0];

		//contentsHtml = contentsHtml2.innerHTML;
		
		contentsHtml2.innerHTML=contenuti;
	}
	
	
} // end func inserisciValue
*/

function confermaCancellazione (nome_form) {
	
	switch (nome_form) {
		
		case "FormDelFoto":
			
			if (confirm("L'operazione eliminera' definitivamente le foto selezionate. Confermi?")) return true; else return false;
			
		break;

		case "FormDelDoc":
			
			if (confirm("L'operazione eliminera' definitivamente i documenti selezionati. Confermi?")) return true; else return false;
			
		break;
		
		case "FormDelVideo":
			
			if (confirm("L'operazione eliminera' definitivamente i video selezionati. Confermi?")) return true; else return false;
			
		break;

	}
	
	return false;
	
} // end func confermaCancellazione


function compilaPrezzo() {
	
	var prezzo_lordo=document.forms['FormUpdateProd'].elements['prezzo_lordo'].value;
	var prezzo_netto=document.forms['FormUpdateProd'].elements['prezzo_netto'].value;
	var id_tassa=document.forms['FormUpdateProd'].elements['id_tassa'].value;
	
} // end func compilaPrezzo

////////////////// funzioni per aggiornare il prezzo del prodotto /////////////////////////
function doRound(x, places) {
	return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
} // end func doRound

function getTaxRate() {
	var selected_value = document.forms["FormUpdateProd"].id_tassa.selectedIndex;
	var parameterVal = document.forms["FormUpdateProd"].id_tassa[selected_value].value;
	
	if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) {
		return tax_rates[parameterVal];
	} else {
		return 0;
	}
} // end func getTaxRate

function updateGross(products_price_t) {
	var taxRate = getTaxRate(products_price_t);
	var grossValue = document.forms["FormUpdateProd"].elements[products_price_t].value;
	
	if (taxRate > 0) {
		grossValue = grossValue * ((taxRate / 100) + 1);
	}
	
	
	document.forms["FormUpdateProd"].elements["prezzo_lordo"].value = doRound(grossValue, 4);
} // end func updateGross

function updateNet(products_price_t) {
  var taxRate = getTaxRate();
  var netValue = document.forms["FormUpdateProd"].elements["prezzo_lordo"].value;

  if (taxRate > 0) {
    netValue = netValue / ((taxRate / 100) + 1);
  }

  document.forms["FormUpdateProd"].elements[products_price_t].value = doRound(netValue, 4);
} // end func updateNet

/////////////////////////////////////////////////////////////////////////////

/* prezzi per gruppi */

function updatePrezzo(id_gruppo) {
	
	var modulo = document.fprezzi;
	var netto = modulo.elements['prezzo_netto['+id_gruppo+']'].value;
	var lordo = netto * (modulo.aliquota.value/100 + 1);
	
	if (document.getElementById('prezzoLordo'+id_gruppo)) document.getElementById('prezzoLordo'+id_gruppo).innerHTML = doRound(lordo, 4);
	
} // end func updatePrezzo


/*
function getTaxRate2(i) {
	var selected_value = document.forms["FormPrezziProdotti"].elements['id_tassa_'+i].selectedIndex;
	var parameterVal = document.forms["FormPrezziProdotti"].elements['id_tassa_'+i][selected_value].value;
	
	if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) {
		return tax_rates[parameterVal];
	} else {
		return 0;
	}
} // end func getTaxRate2

function updateGross2(products_price_t, i) {
	var taxRate = getTaxRate2(i);
	var grossValue = document.forms["FormPrezziProdotti"].elements[products_price_t+'_'+i].value;
	
	if (taxRate > 0) {
		grossValue = grossValue * ((taxRate / 100) + 1);
	}
	
	
	document.forms["FormPrezziProdotti"].elements["prezzo_lordo_"+i].value = doRound(grossValue, 4);
} // end func updateGross2

function updateNet2(products_price_t,i) {
  var taxRate = getTaxRate2(i);
  var netValue = document.forms["FormPrezziProdotti"].elements["prezzo_lordo_"+i].value;

  if (taxRate > 0) {
    netValue = netValue / ((taxRate / 100) + 1);
  }

  document.forms["FormPrezziProdotti"].elements[products_price_t+'_'+i].value = doRound(netValue, 4);
} // end func updateNet2
*/

function setquerystring(form) {
	   
   var querystring = '';
  // if (!form) alert(form);
   var numberElement = form.elements.length;

	for(var i=0; i<numberElement; i++){
		if(i<numberElement-1){ 
		   querystring+= form.elements[i].name+"="+encodeURIComponent(form.elements[i].value)+"&";
		}else{
			querystring+= form.elements[i].name+"="+encodeURIComponent(form.elements[i].value);
		}
	}
	
	return querystring;
   
} // end func setquerystring

function send_data(form,url){
	var qstring = setquerystring(form);
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url + '?' + qstring;
	window.document.body.appendChild (jsel);
} // end func send_data

// modifica Michela 16/04/09
function centradiv(idDiv, width, height, top) { //Centra un div nella pagina

	var windowWidth;
	var windowHeight;
	
	if(typeof(window.innerWidth) == 'number') 
	{
		//Non-IE
		windowWidth = window.innerWidth;
		windowHeight = window.innerHeight;
  	} 
	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight )) 
	{
		//IE 6+ in 'standards compliant mode'
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	
	var scrollOffsetY = 0;
	
	if(typeof(window.pageYOffset) == 'number') 
	{
    	//Netscape compliant
    	scrollOffsetY = window.pageYOffset;
	} 
	else if(document.body && document.body.scrollTop)
	{
    	//DOM compliant
    	scrollOffsetY = document.body.scrollTop;
	} 
	else if(document.documentElement && document.documentElement.scrollTop)
	{
    	//IE6 standards compliant mode
    	scrollOffsetY = document.documentElement.scrollTop;
  	}
	
	var divLeft = Math.round(windowWidth / 2) - Math.round(width / 2);
	var divTop = Math.round(windowHeight / 2) - Math.round(height / 2) + scrollOffsetY;
	

	var opacity = 60;
	var opaque = (opacity / 100);
	
	if (!window.document.getElementById("darkLayer")) {
		var darkLayer = document.createElement("div");
		darkLayer.setAttribute("id", "darkLayer");
		darkLayer.style.position = "absolute";
		darkLayer.style.left = "0px";
		darkLayer.style.top = "0px";
		darkLayer.style.zIndex = "50";
		darkLayer.style.width = "100%";
		darkLayer.style.height = "2500px"; // + ( scrollOffsetY + ((document.height !== undefined) ? document.height : document.body.offsetHeight) )+ "px";	//"100%";
		darkLayer.style.backgroundColor = "#FFFFFF";
		darkLayer.style.opacity = opaque;                      
		darkLayer.style.MozOpacity = opaque;
		darkLayer.style.filter = 'alpha(opacity=' + opacity + ')';
		window.document.body.appendChild(darkLayer);
	}
	
	//var messagePopUp = document.createElement("div");
	//messagePopUp.setAttribute("id", ""+idDiv+"");
	var messagePopUp = document.getElementById(""+idDiv+"");
	messagePopUp.style.position = "absolute";
	//messagePopUp.style.position = "relative";	
	if(divLeft) messagePopUp.style.left = divLeft + "px"; 
	messagePopUp.style.top = divTop + "px";	
	messagePopUp.style.zIndex = "99999";
	messagePopUp.style.width = width + "px"; 
	if (height>1) messagePopUp.style.height = height + "px";
	//messagePopUp.className = 'messaggioPopup';
	//messagePopUp.innerHTML = "<div style=\"text-align: right; padding: 5px\"><a href=\"javascript:void(0);\" onclick=\"closeMessagePopup('"+idDiv+"'); return false\"><strong>X</strong></a></div><div style=\"text-align: center; padding: 5px\">" + '<img src="/admin/img/loading.gif" title="loading" alt="loading" width="32" height="32" border="0" />' + "</div>";
							 
	//window.document.body.appendChild(messagePopUp);
	messagePopUp.style.display = "block";

	
} // end func centradiv

function closeMessagePopup(idDiv)
{
	if (window.document.getElementById("darkLayer")) {
		divElement = window.document.getElementById("darkLayer");
		parentElement = divElement.parentNode;
		parentElement.removeChild(divElement);
	}
	
	/*divElement = window.document.getElementById(""+idDiv+"");
	parentElement = divElement.parentNode;
	parentElement.removeChild(divElement);*/
	if (document.getElementById(""+idDiv+"")) document.getElementById(""+idDiv+"").style.display='none';
	
} // end func closeMessagePopup

function centradiv_copia(nome_div,larghezza,altezza,top) { //Centra un div nella pagina

	var divobj = document.getElementById(''+ nome_div +''); 
	
	var ie=document.all && !window.opera
	var dom=document.getElementById
	
	var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body 
	
	var scroll_top=(ie)?  standardbody.scrollTop : window.pageYOffset
	var scroll_left=(ie)?  standardbody.scrollLeft : window.pageXOffset
	var docwidth=(ie)?  standardbody.clientWidth : window.innerWidth
	var docheight=(ie)?  standardbody.clientHeight: window.innerHeight
	var docheightcomplete=( standardbody.offsetHeight> standardbody.scrollHeight)?  standardbody.offsetHeight :  standardbody.scrollHeight //Full scroll height of document
	var objwidth=(larghezza>0?larghezza:divobj.offsetWidth); //width of div element
	var objheight=(altezza>0?altezza:divobj.offsetHeight); //height of div element
	//var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px" //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint
	var topposition=(docheight>objheight)? Math.round(scroll_top+docheight/2-objheight/2)+"px" : Math.round(scroll_top+10)+"px" //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint

//alert(docheight + ' - ' + objheight + ' - ' + scroll_top);
	if(divobj.style.display=='block') {
		divobj.style.display = 'none'; 
	} else {
		divobj.style.display = 'block'; 
	}
	
	//divobj.style.width = (screen.width) - 60 + 'px'; //100px or 100%
	if (larghezza>0) divobj.style.width = larghezza+'px'; //100px or 100%
	//divobj.style.height = ((docheight - scroll_top) - 60) + 'px'; //100px or 100% 
	if (altezza>0) divobj.style.height = altezza + 'px'; //100px or 100% 
	//if (top) divobj.style.top = (scroll_top + 30) + 'px'; //100px or 100% 
	//if (top) 
	divobj.style.top =  topposition;
		
	//divobj.style.left = ( (docwidth/2) - (divobj.offsetWidth/2) ) +"px"; //100px or 100% 
	divobj.style.left = Math.round( (docwidth/2) - (divobj.offsetWidth/2) ) +"px"; //100px or 100% 

	
} // end func centradiv_copia


function xmlhttpPost_method(strURL,query_string,metodo,divname) {
	
	//alert(strURL+' '+query_string+' '+metodo+' '+divname);
	var xmlHttpReq2 = false;
	var self2 = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self2.xmlHttpReq2 = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self2.xmlHttpReq2 = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self2.xmlHttpReq2.open('POST', strURL, true);
	self2.xmlHttpReq2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	self2.xmlHttpReq2.onreadystatechange = function() {
		if (self2.xmlHttpReq2.readyState == 4) {
			
			var response =  self2.xmlHttpReq2.responseText;
			
			switch (metodo) {
				
				case 'draw_listbox_regioni':
				
					document.getElementById(""+divname+"").innerHTML = response;
					document.getElementById("reg_user_provincia").innerHTML = '';
				
				break; // end draw_listbox_regioni
				
				case 'register_user':
					
					if(response==1){
						alert(str_ok_registrazione);
						//document.getElementById("cat_RegNewUser").style.display='none';
						closeMessagePopup("cat_RegNewUser");
						
					} else {
						document.getElementById("cat_response_register_user").innerHTML = div_chiudi_register_user + errore_compilazione_modulo + '<br /><br />' + response;
						document.getElementById("cat_response_register_user").style.display='block';
					}
	
				break; // end register_user
		
				case 'info_prodotto':
					
					if(response==1){
						alert(str_ok_invio_form);
						//document.getElementById("cat_InfoProdotto").style.display='none';
						closeMessagePopup("cat_InfoProdotto");
					} else {
						document.getElementById("cat_response_info_prodotto").innerHTML = div_chiudi_info_prodotto + errore_compilazione_modulo + '<br /><br />' + response;
						
						document.getElementById("cat_response_info_prodotto").style.display='block';
					}

				break; // end info_prodotto

				case 'add_cart':
				
					//alert('response'+response);
					
					
					if (response==1) {
						//alert(str_ok_add_cart);
						//document.getElementById("cat_addCart").style.display='none';
						
						closeMessagePopup("cat_addCart");
						
						// aggiorno il box carrello
						//alert('1');
						setTimeout("getContentCarrello(id_attivita,urlSite,sigla_lingua)",1000);
						//alert('2');
						setTimeout("getTotaleCarrello(id_attivita,urlSite,sigla_lingua)",2000);
						//alert('3');
						setTimeout("getNumeroProdottiCarrello(id_attivita,urlSite,sigla_lingua)",3000);
						
						//getContentCarrello(id_attivita,urlSite);
						//getTotaleCarrello(id_attivita,urlSite);
						
						if(document.getElementById("nome_prodotto_aggiunto")){
								prodname = document.getElementById("nome_prodotto_aggiunto").value;
						}
						
						// div con conferma aggiunta al carrello e scelta opzione:
						// vai alla cassa / prosegui con gli acquisti
						centradiv('cat_response_add_cart',400,120);
						document.getElementById("cat_response_add_cart").innerHTML = div_chiudi_add_cart +'<span style="font-size:1.3em"><b>'+prodname+'</b></span><br>'+ str_ok_add_cart + '<br /><br /><br />' + opzioni_dopo_acquisto;
						document.getElementById("cat_response_add_cart").style.display='block';
		
					} else {

						//document.getElementById("cat_response_add_cart").innerHTML = div_chiudi_add_cart + errore_add_cart + '<br /><br />' + response;
						//document.getElementById("cat_response_add_cart").style.display='block';
						alert(errore_add_cart+"\n\n"+response);
						
					}

				break; // end add_cart
				
				case 'send_password':
				
					if (response==1){
						alert(str_ok_send_psw);
						//document.getElementById("cat_ForgotPassword").style.display='none';
						closeMessagePopup("cat_ForgotPassword");
					} else {
						//document.getElementById("cat_response_send_password").innerHTML = div_chiudi_send_password + errore_compilazione_modulo + '<br /><br />' + response;
						alert(response);
						//document.getElementById("cat_response_send_password").style.display='block';
					}

				break; // end send_password

				case 'invia_amico':
				
					if (response==1){
						alert(str_ok_invia_amico);
						//document.getElementById("cat_SegnalaAmico").style.display='none';
						closeMessagePopup("cat_SegnalaAmico");
					} else {
						document.getElementById("cat_response_invia_amico").innerHTML = div_chiudi_invia_amico + errore_compilazione_modulo + '<br /><br />' + response;
						document.getElementById("cat_response_invia_amico").style.display='block';
					}

				break; // end invia_amico
				
				case "aggiungi-prodotto":
				
					hs.htmlExpand(document.getElementById('testancora'), { contentId: 'highslide-html' } );
					if (document.getElementById(divname)) document.getElementById(divname).innerHTML = response;
				
				break; // end aggiungi-prodotto
				
				case "calcola_cf":
				
				
					if (response==0){
						alert(str_errore_cf);
					} else {
						if (document.getElementById("codice_fiscale")) document.getElementById("codice_fiscale").value=response;
						document.getElementById(divname).style.display='none';
						closeMessagePopup(divname);
					}
				
				break; // end calcola_cf
				
				case "aggiorna-fattura":
					alert("Numero/Anno Fattura aggiornati.");
				break;

				default:
					//alert(divname);
					if (document.getElementById(divname)) document.getElementById(divname).innerHTML = response;
					
			} // end switch metodo
			
			nascondiLoading('cat_divLoad_'+metodo);

		}
	}
	self2.xmlHttpReq2.send(query_string);
	
} // end func xmlhttpPost_method
	



function visualizzaLoading(idDiv) {
	if(document.getElementById(""+idDiv+"")) {
		document.getElementById(""+idDiv+"").innerHTML = '<img src="http://www.abc.sm/catalog/img/loading.gif" title="loading" alt="loading" width="32" height="32" border="0" />';
		document.getElementById(""+idDiv+"").style.display='block';	
	}
	
} // end func loadingDiv

function nascondiLoading(idDiv) {
	if(document.getElementById(""+idDiv+"")) document.getElementById(""+idDiv+"").style.display='none';
	
} // end func loadingDiv

function getContentCarrello(id_attivita,urlSite,sigla_lingua) {
	xmlhttpPost_method(urlSite+'inc/ajax_proxy.php','pg=get_content_carrello&id_attivita='+id_attivita+'&sigla_lingua='+sigla_lingua,'get_content_carrello','cat_CartBox');
	
} // end func getContentCarrello

function getTotaleCarrello(id_attivita,urlSite,sigla_lingua) {
	xmlhttpPost_method(urlSite+'inc/ajax_proxy.php','pg=get_totale_carrello&id_attivita='+id_attivita+'&sigla_lingua='+sigla_lingua,'get_totale_carrello','cat_CartBoxTotale');
	
} // end func getTotaleCarrello

function getNumeroProdottiCarrello(id_attivita,urlSite,sigla_lingua) {
	xmlhttpPost_method(urlSite+'inc/ajax_proxy.php','pg=get_numero_prodotti_carrello&id_attivita='+id_attivita+'&sigla_lingua='+sigla_lingua,'get_numero_prodotti_carrello','cat_CartBoxNumero');
	
} // end func getNumeroProdottiCarrello

function setPrivacy(nomeform) {
	
	if (document.forms[nomeform].privacy_check.checked) document.forms[nomeform].privacy.value='1'; else document.forms[nomeform].privacy.value='0';
} // end func setPrivacy


function visualizzaDivOpz(nomeForm) {
	
	var id_div,id_div2,arrayDiv;
/*	
	if (document.forms[nomeForm].elements['id_opzioni'].value!="") {
		
		var id_div=document.forms[nomeForm].elements['id_opzioni'].value;
		//alert(id_div);
		document.getElementById('opz_'+id_div).style.display='block';	
		
	} 
*/
	// ciclo su tutti i valori
	//alert(document.forms[nomeForm].elements['id_opzioni'].length);
	for (var i=0;i<document.forms[nomeForm].elements['id_opzioni'].length;i++) {
		
		id_div2=document.forms[nomeForm].elements['id_opzioni'].options[i].value;
		
		arrayDiv=new Array();
		
		arrayDiv = id_div2.split('|');
	//	alert(arrayDiv);
		id_div = arrayDiv[0];
		
	//	alert(id_div);
		
		if (id_div!='0') {
			
			//alert(document.forms[nomeForm].elements['id_opzioni'].options[i].selected);
			if (document.forms[nomeForm].elements['id_opzioni'].options[i].selected) {
				
				//document.getElementById('opz_'+id_div).style.display='block';
				document.forms[nomeForm].elements['qt_opzioni'].value=arrayDiv[1];
				if (document.getElementById('quantita_opzioni')) document.getElementById('quantita_opzioni').innerHTML=arrayDiv[1];
				if (document.getElementById('cat_qtDisponibili')) document.getElementById('cat_qtDisponibili').innerHTML=arrayDiv[1];
				
				
				document.forms[nomeForm].elements['segno_variazione_prezzo'].value=arrayDiv[2];
				document.forms[nomeForm].elements['variazione_prezzo'].value=arrayDiv[3];
				
			} //else document.getElementById('opz_'+id_div).style.display='none';
			
		} else {
				if (document.getElementById('cat_qtDisponibili')) document.getElementById('cat_qtDisponibili').innerHTML=document.getElementById('quantita').value;
				document.forms[nomeForm].elements['qt_opzioni'].value='0';
				document.forms[nomeForm].elements['segno_variazione_prezzo'].value='+';
				document.forms[nomeForm].elements['variazione_prezzo'].value='0';
				
		} 
	}
	aggiornaImporto(nomeForm);
	
} // end func visualizzaDivOpz

function aggiornaImporto(nomeForm) {
	
	var prezzo,segno,variazione,prezzo_base;
	
	if (isNaN(document.forms[nomeForm].elements['qt_cart'].value)) {
		if (document.getElementById('cat_importoProdotto')) document.getElementById('cat_importoProdotto').innerHTML=str_nan;
	} else {
		segno = document.forms[nomeForm].elements['segno_variazione_prezzo'].value;
		variazione = eval(segno + document.forms[nomeForm].elements['variazione_prezzo'].value);
		prezzo_base = document.forms[nomeForm].elements['prezzo_base'].value;
		//alert(variazione);
		prezzo=( document.forms[nomeForm].elements['qt_cart'].value * (prezzo_base*1 + variazione*1));
		prezzo=prezzo.toFixed(2);
		prezzo = prezzo.replace('.','-');
		prezzo = prezzo.replace(',','.');
		prezzo = prezzo.replace('-',',');
	
		if (document.getElementById('cat_importoProdotto')) document.getElementById('cat_importoProdotto').innerHTML=prezzo+' '+document.forms[nomeForm].elements['simbolo_valuta'].value;
	}
	
} // end func aggiornaImporto

var liste_txt='';

function assegnaCheckNewsletter(nome_form, nome_campo) {
	
		
	if (document.forms[nome_form].elements[nome_campo].checked) liste_txt +=nome_campo.substr(6);
	else liste_txt =liste_txt.replace(nome_campo.substr(6),'');

	document.forms[nome_form].elements['listeNL'].value = liste_txt;
	
//	alert(document.forms[nome_form].elements['listeNL'].value);
	
} // end func assegnaCheckNewsletter



/*
function assegnaSesso(nome_form, valore) {

	document.forms[nome_form].elements['sesso'].value = valore;

} // end func assegnaSesso
*/

/*
function verificaCampoData(nomeForm, nomeCampo) {
	if (document.forms[nomeForm].elements[nomeCampo+'[d]'].value!='' && document.forms[nomeForm].elements[nomeCampo+'[m]'].value!='' && document.forms[nomeForm].elements[nomeCampo+'[Y]'].value!='') return true; else return false;
}
*/

//FormUpdateUtente
function verificaDataNascita() {
	if (document.forms['FormUpdateUtente'].elements['data_di_nascita[d]'].value!='' && document.forms['FormUpdateUtente'].elements['data_di_nascita[m]'].value!='' && document.forms['FormUpdateUtente'].elements['data_di_nascita[Y]'].value!='') return true; else return false;
}

//FormRegUser
function verificaDataNascita2() {
	if (document.forms['FormRegUser'].elements['data_di_nascita[d]'].value!='' && document.forms['FormRegUser'].elements['data_di_nascita[m]'].value!='' && document.forms['FormRegUser'].elements['data_di_nascita[Y]'].value!='') return true; else return false;
}

//FormUpdate
function verificaDataInizio() {
	if (document.forms['FormUpdate'].elements['data_inizio[d]'].value!='' && document.forms['FormUpdate'].elements['data_inizio[m]'].value!='' && document.forms['FormUpdate'].elements['data_inizio[Y]'].value!='') return true; else return false;
}

//FormUpdate
function verificaDataFine() {
	if (document.forms['FormUpdate'].elements['data_fine[d]'].value!='' && document.forms['FormUpdate'].elements['data_fine[m]'].value!='' && document.forms['FormUpdate'].elements['data_fine[Y]'].value!='') return true; else return false;
}


function attivaSelect(nomeForm, nomeCampoCheck, nomeCampoCheck2, nomeCampoSelect, nomeCampoSelect2) {
	if (document.forms[nomeForm].elements[nomeCampoCheck].checked) {
		document.forms[nomeForm].elements[nomeCampoSelect].className ='cat_modulo';
		document.forms[nomeForm].elements[nomeCampoSelect].disabled=false;
		
		if (document.forms[nomeForm].elements[nomeCampoCheck2].checked) {
			
			document.forms[nomeForm].elements[nomeCampoCheck2].checked=false;
			document.forms[nomeForm].elements[nomeCampoSelect2].className ='cat_modulo_disabled';
			document.forms[nomeForm].elements[nomeCampoSelect2].disabled=true;
			
		}

	} else {
		document.forms[nomeForm].elements[nomeCampoSelect].className ='cat_modulo_disabled';
		document.forms[nomeForm].elements[nomeCampoSelect].disabled=true;
/*
		document.forms[nomeForm].elements[nomeCampoCheck2].checked=true;
		document.forms[nomeForm].elements[nomeCampoSelect2].className ='cat_modulo';
		document.forms[nomeForm].elements[nomeCampoSelect2].disabled=false;
*/
	}
}


// inibisce l'incolla sul campo testo
var oldText = '';
function pasteControl(idCampo) {	
	var text = document.getElementById(idCampo).value;
	if (text.length > (oldText.length+6)) document.getElementById(idCampo).value = oldText;
	else oldText = text;
}



/* verifica la validità della partita iva italiana */

// partita iva italiana
function ControllaPIVA(pi) {
	
	//var pi = document.FormAnagrafica.partita_iva.value;

	if( pi == '00000000000' )  return false; //return 'Partita iva ERRATA';

	// eseguo il controllo solo se il paese è IT
	if (document.getElementById('codice_paese')) {
		if (document.getElementById('codice_paese').value!='IT') return true;
	} else return true;
	
	if( pi == '' ) return true; //return '';
	
	if( pi.length != 11 ) return false;
	//return "La lunghezza della partita IVA non è\n" + "corretta: la partita IVA dovrebbe essere lunga\n" + "esattamente 11 caratteri.\n";

	validi = "0123456789";
	
	for( i = 0; i < 11; i++ ) {
		if( validi.indexOf( pi.charAt(i) ) == -1 ) return false;
		//return "La partita IVA contiene un carattere non valido `" + pi.charAt(i) + "'.\nI caratteri validi sono le cifre.\n";
							   
	}
	
	s = 0;
	for( i = 0; i <= 9; i += 2 ) s += pi.charCodeAt(i) - '0'.charCodeAt(0);
	for( i = 1; i <= 9; i += 2 ) {
	   c = 2*( pi.charCodeAt(i) - '0'.charCodeAt(0) );
	   if( c > 9 )  c = c - 9;
	   s += c;
	}
	
	if( ( 10 - s%10 )%10 != pi.charCodeAt(10) - '0'.charCodeAt(0) ) return false;
	// return  "La partita IVA non è valida:\n" + "il codice di controllo non corrisponde.\n";

	// return '';
	return true;

}

/* verifica la validità del codice fiscale italiano */
// codice fiscale
function ControllaCF(cf) {
	
	//var cf = document.FormAnagrafica.codice_fiscale.value;
	var validi, i, s, set1, set2, setpari, setdisp;
	
	
	if( cf == '' ) return true; //return '';
	
	// eseguo il controllo solo se il paese è IT
	if (document.getElementById('codice_paese')) {
		if (document.getElementById('codice_paese').value!='IT') return true;
	} else return true;
	
	
	//if( cf.length != 16 ) return false;
	//return "La lunghezza del codice fiscale non è\n"+"corretta: il codice fiscale dovrebbe essere lungo\n"+"esattamente 16 caratteri.\n";
	
	// Modifica: se è un'azienda, potrebbe essere un codice fiscale aziendale, con gli stessi parametri della partita iva ControllaPIVA(pi)
	if( cf.length != 16 ) {
		
		if( cf.length == 11 && document.getElementById('ragione_sociale').value!='') return ControllaPIVA(cf); else return false;
		
	}
	
	cf = cf.toUpperCase();
	
	
	validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	
	for( i = 0; i < 16; i++ ){
		if( validi.indexOf( cf.charAt(i) ) == -1 ) return false;															   
		// return "Il codice fiscale contiene un carattere non valido `" + cf.charAt(i) + "'.\nI caratteri validi sono le lettere e le cifre.\n";
	}
	
	set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
	setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
	s = 0;
	
	for( i = 1; i <= 13; i += 2 ) s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
	for( i = 0; i <= 14; i += 2 ) s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
	if( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) ) return false;
	// return "Il codice fiscale non è corretto:\n"+ "il codice di controllo non corrisponde.\n";
	
	//return "";
	return true;

} // enf func ControllaCF

function ControllaPIVACF(paese) {
	
	if (document.getElementById('codice_paese')) {

		if (paese=='IT' && document.getElementById('partita_iva').value=='' && document.getElementById('codice_fiscale').value=='') return false;

		if (paese!='IT' && js_paesi_ue.indexOf(paese)>=0 && document.getElementById('partita_iva').value=='' && js_richiesto_fiscal_number==1) return false;

	} else {
		
		if (document.FormRegUser.elements['provincia[0]'].value=='IT' && document.getElementById('partita_iva').value=='' && document.getElementById('codice_fiscale').value=='') return false;
		
		if (document.FormRegUser.elements['provincia[0]'].value!='IT' && js_paesi_ue.indexOf(document.FormRegUser.elements['provincia[0]'].value)>=0 && document.getElementById('partita_iva').value=='' && js_richiesto_fiscal_number==1) return false;
	}
	
	return true;
	
} // end func ControllaPIVACF



function ControllaCodiceAzienda(rs) {

	if (document.getElementById('ragione_sociale') && document.getElementById('partita_iva')) {
		
		if (document.getElementById('ragione_sociale').value!='' && document.getElementById('partita_iva').value=='') return false;

	}

	return true;

} // end func ControllaCodiceAzienda

function RichiestoSelect() {

	if (document.getElementById('id_regione')) {
		if (document.getElementById('id_regione').length>1 && document.getElementById('id_regione').value=='') return false;
	}

	if (document.getElementById('sigla_provincia')) {
		if (document.getElementById('sigla_provincia').length>1 && document.getElementById('sigla_provincia').value=='') return false;
	}

	return true;

} // end func RichiestoSelect


function RichiestoCFIT() {

	if (document.getElementById('codice_fiscale')) {
		if (document.getElementById('codice_fiscale').value=='' && document.getElementById('codice_paese').value=='IT') return false;
	}

	return true;

} // end func RichiestoCFIT

/*
function ControllaVatCode(paese) {

	if (document.getElementById('codice_paese')) {

		if (paese!='IT' && js_paesi_ue.indexOf(paese)>=0 && document.getElementById('fiscal_number').value=='') return false;

	} else {
		
		if (document.FormRegUser.elements['provincia[0]'].value!='IT'  && js_paesi_ue.indexOf(document.FormRegUser.elements['provincia[0]'].value)>=0 && document.getElementById('fiscal_number').value=='') return false;
		
	}

	return true;

} // end func ControllaVatCode
*/

function controllaFormLogin(nomeForm) {
	
	if (document.forms[nomeForm].elements['login_email'].value=='') {
		alert(js_no_email);
		return false;
	}
	
	if (document.forms[nomeForm].elements['login_password'].value=='') {
		alert(js_no_password);
		return false;
	}
	
	return true;
	
} // end func controllaFormLogin




function verificaProvincia() {
	
	if (document.getElementById('sigla_provincia')) {
		if (document.getElementById('sigla_provincia').value == '') return false; else return true;
	}
	
	return true;
	
} // end func verificaProvincia

function verificaRegione() {
	
	if (document.getElementById('id_regione')) {
		if (document.getElementById('id_regione').value == '') return false; else return true;
	}
	
	return true;
	
} // end func verificaRegione


function verifica_qt() {
	
	var da = 0;
	var a = 0;
	
	if (document.getElementById('qt_da')) da = document.getElementById('qt_da').value + 0;
	if (document.getElementById('qt_a')) a = document.getElementById('qt_a').value + 0;
	
	if (da<2 || a<3) return false;
	
	return true;

} // end func verifica_qt

/*
function controllo_data(stringa){
	var espressione = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/;
	if (!espressione.test(stringa))
	{
	    return false;
	}else{
		anno = parseInt(stringa.substr(6),10);
		mese = parseInt(stringa.substr(3, 2),10);
		giorno = parseInt(stringa.substr(0, 2),10);
		
		var data=new Date(anno, mese-1, giorno);
		if(data.getFullYear()==anno && data.getMonth()+1==mese && data.getDate()==giorno){
			return true;
		}else{
			return false;
		}
	}
} // end func controllo_data
*/








///////////////////////////////////////////////////////////////////////////////
//Scroller
//left e up aggiornati e funzionanti, right e down non aggiornati
function Scroller(param)
{ 
	var delayArray = new Array();
	delayArray[0] = 0;
	delayArray[1] = 90;
	delayArray[2] = 90;
	delayArray[3] = 90;
	delayArray[4] = 89;
	delayArray[5] = 88;
	delayArray[6] = 86;
	delayArray[7] = 86;
	delayArray[8] = 86;
	delayArray[9] = 86;
	delayArray[10] =85;
	
	var divname = param['divname'];//parameters['divname']; //nome del div che contiene il testo
	var containername = param['containername']; //parameters['containername']; //nome del div contenitore dello scroller
	var direction = param['direction']; //Specify direction of movement
	var scrollamount = param['speed']; //Specify marquee scroll speed (larger is faster 1-10)
	if(param['pauseScroll'] == 0)
	{
		var scrolldelay = delayArray[scrollamount]; //intervallo di tempo per l' aggiornamento della grafica
	}
	else
	{
		var scrolldelay = 10; //intervallo di tempo per l' aggiornamento della grafica
		//costruzione dell'array di valori dei div per il calcolo dello scarto
		var divnameWidth = document.getElementById(divname).offsetWidth;
		var divnameHeight = document.getElementById(divname).offsetHeight;
		var elementDivWidth = divnameWidth / param['pauseNumber'];
		var elementDivHeight = divnameHeight / param['pauseNumber'];
		switch(direction)
		{
			case 'up':
			case 'down':
				var divArraySeed = elementDivHeight;
			break;
			case 'left':
			case 'right':
				var divArraySeed = elementDivWidth;
			break;
		}
		
		var divArray = new Array();
		
		if(param['numScroll'] > 1)
		{			
			var scrollIndex = Math.round(param['pauseNumber'] / param['numScroll']);
			for(i = 0; i < (scrollIndex - 1); i++)
			{
				divArray[i] = ((divArraySeed * param['numScroll']) * (i + 1)); 
			}
			divArray[scrollIndex - 1] = 0;
		}
		else
		{
			var scrollIndex = param['pauseNumber'];
			for(i = 0; i < (scrollIndex - 1); i++)
			{
					divArray[i] = (divArraySeed * (i + 1)); 
			}
			divArray[(param['pauseNumber'] - 1)] = 0;
		}
		//fine costruzione dell'array di valori dei div per il calcolo dello scarto
		
		var currentDiv = divArray.shift();
		var pauseInterval = param['pauseInterval'];
	}
	
	var pause = param['pause']; //Pause marquee onMousever (0=no. 1=yes)?	
	
	var pauseScroll = param['pauseScroll'];	

	this.pauseFunction = function () 
	{
		copyspeed = pausespeed;
	}

	this.copyFunction = function ()
	{
		copyspeed = scrollamount;
	}

	var copyspeed = scrollamount;
	var pausespeed = (pause == 0) ? copyspeed : 0;
	var actualheight = '';
	var actualwidth = '';
	var cross_marquee;
	
	var marqueeheight;
	
	var interval;
	
	var firstCicle = true;
	
	function initializemarquee(self)
	{
		cross_marquee = document.getElementById(divname);
		if (direction == "up" || direction == "down")
		{
			cross_marquee.style.top = 0;
			marqueeheight = document.getElementById(containername).offsetHeight;
			actualheight = cross_marquee.offsetHeight;
			if (window.opera || navigator.userAgent.indexOf("Netscape/7") != -1) //if Opera or Netscape 7x, add scrollbars to scroll and exit
			{
				cross_marquee.style.height = marqueeheight + "px";
				cross_marquee.style.overflow = "scroll";
				return;
			}
		}
		else
		{
			cross_marquee.style.left = 0;
			marqueewidth = document.getElementById(containername).offsetWidth;
			actualwidth = cross_marquee.offsetWidth;
			if (window.opera || navigator.userAgent.indexOf("Netscape/7") != -1) //if Opera or Netscape 7x, add scrollbars to scroll and exit
			{
				cross_marquee.style.width = marqueewidth + "px";
				cross_marquee.style.overflow = "scroll";
				return;
			}
		}			
		this.scrollmarquee;
		interval = setInterval(scrollmarquee, scrolldelay);
	}
	
	this.initializemarquee = function()
	{
		initializemarquee(this);
	}
	
	
	function scrollmarquee()
	{
		if (direction == "up")
		{
			if (parseInt(cross_marquee.style.top) > (actualheight * (-1) - 8)) //scorrimento
			{
				if(pauseScroll == 1)
				{
					var posizione = parseInt(cross_marquee.style.top);
					var scarto = Math.abs(Math.abs(posizione) - currentDiv);
					//document.getElementById('debug').innerHTML = Math.abs(Math.abs(posizione) - currentDiv);
					if(!firstCicle && scarto <= 3)
					{
						cross_marquee.style.top = '-' + currentDiv + 'px';	
						clearInterval(interval);
						setTimeout(update, pauseInterval);
						divArray.push(currentDiv);
						currentDiv = divArray.shift();
					}
					else
					{
						firstCicle = false;
						cross_marquee.style.top = (parseInt(cross_marquee.style.top) - copyspeed) + "px";
					}
				}
				else
				{
					cross_marquee.style.top = (parseInt(cross_marquee.style.top) - copyspeed) + "px";	
				}
			}
			else //ricarica
			{	
				cross_marquee.style.top = (parseInt(marqueeheight) + 8) + "px";
			}					
		}
		else if (direction == "down")
		{
			if (parseInt(cross_marquee.style.top) < (marqueeheight + 8)) //scorrimento
			{
				if(pauseScroll == 1)
				{
					var posizione = parseInt(cross_marquee.style.top);
					
					if(!firstCicle && (posizione <= 0) && (posizione > -1 * divnameHeight) && ((posizione % pauseHeight) == 0))
					{
						clearInterval(interval);
						setTimeout(update, pauseInterval);
					}
					else
					{
						firstCicle = false;
						cross_marquee.style.top = (parseInt(cross_marquee.style.top) + copyspeed) + "px";
					}
				}
				else
				{
					cross_marquee.style.top = (parseInt(cross_marquee.style.top) + copyspeed) + "px";	
				}
			}
			else //ricarica
			{
				cross_marquee.style.top = (actualheight * (-1) + 8) + "px";
			}
		}
		else if (direction == "left") //scorrimento
		{
			if (parseInt(cross_marquee.style.left) > (actualwidth * (-1) - 8))
			{
				if(pauseScroll == 1)
				{
					var posizione = parseInt(cross_marquee.style.left);
					var scarto = Math.abs(Math.abs(posizione) - currentDiv);
					//document.getElementById('debug').innerHTML = Math.abs(Math.abs(posizione) - currentDiv);
					if(!firstCicle && scarto <= 3)
					{
						cross_marquee.style.left = '-' + currentDiv + 'px';	
						clearInterval(interval);
						setTimeout(update, pauseInterval);
						divArray.push(currentDiv);
						currentDiv = divArray.shift();
					}
					else
					{
						firstCicle = false;
						cross_marquee.style.left = (parseInt(cross_marquee.style.left) - copyspeed) + "px";
					}
				}
				else
				{
					cross_marquee.style.left = (parseInt(cross_marquee.style.left) - copyspeed) + "px";	
				}
			}
			else //ricarica
			{
				//cross_marquee.style.left = (parseInt(marqueewidth) + 8) + "px";
				cross_marquee.style.left = parseInt(marqueewidth) + "px";
			}
		}
		else 
		{
			if (parseInt(cross_marquee.style.left) < (marqueewidth)) //scorrimento
			{
				if(pauseScroll == 1)
				{
					var posizione = parseInt(cross_marquee.style.left);
					if(!firstCicle && (posizione <= 0) && (posizione > -1 * divnameWidth) && ((posizione % pauseWidth) == 0))
					{
						clearInterval(interval);
						setTimeout(update, pauseInterval);
					}
					else
					{
						firstCicle = false;
						cross_marquee.style.left = (parseInt(cross_marquee.style.left) + copyspeed) + "px";
					}
				}
				else
				{
					cross_marquee.style.left = (parseInt(cross_marquee.style.left) + copyspeed) + "px";
				}
			}
			else //ricarica
			{
				cross_marquee.style.left = (actualwidth * (-1) - 8) + "px";
			}
		}		
	}
	
	function update()
	{
		switch(direction)
		{
			case 'up':
				cross_marquee.style.top = (parseInt(cross_marquee.style.top) - copyspeed) + "px";
				interval = setInterval(scrollmarquee, scrolldelay);	
			break;
			
			case 'down':
				cross_marquee.style.top = (parseInt(cross_marquee.style.top) + copyspeed) + "px";
				interval = setInterval(scrollmarquee, scrolldelay);	
			break;
			
			case 'left':
				cross_marquee.style.left = (parseInt(cross_marquee.style.left) - copyspeed) + "px";
				interval = setInterval(scrollmarquee, scrolldelay);
			break;
			
			case 'right':
				cross_marquee.style.left = (parseInt(cross_marquee.style.left) + copyspeed) + "px";
				interval = setInterval(scrollmarquee, scrolldelay);
			break;
		}
	}
}
//////////////////////////////// end scroller


function addOnloadEvent(fnc)
{
	if(typeof window.addEventListener != "undefined")
		window.addEventListener( "load", fnc, false );
	else if(typeof window.attachEvent != "undefined") 
	{
		window.attachEvent("onload", fnc);
	}
	else 
	{
		if(window.onload != null) 
		{
			var oldOnload = window.onload;
			window.onload = function(e) 
							{
								oldOnload( e );
								window[fnc]();
							};
		}
		else
			window.onload = fnc;
	}
} // end func addOnloadEvent

/*

function aggiorna_regioni(valore) {
	
	
	if (regioni[valore].length > 0) {
		
		for (var i in regioni[valore]) {
			alert(regioni[valore][i]);
			break;
		}
	}
	
} // end func aggiorna_regioni



function aggiorna_province(valore) {
	
	if (province[valore].length > 0) {
		
		
	}
	
} // end func aggiorna_province
*/

function loadMyFuncModule(stufftoeval) {  
	var dj_global = this; // global scope reference  
	if (window.execScript) {
		
		String.prototype.trim = function() {
			a = this.replace(/^\s+/, '');
			return a.replace(/\s+$/, '');
		};
		window.execScript(stufftoeval.trim());    
		return null; // execScript doesn’t return anything  
	}  
	return dj_global.eval ? dj_global.eval(stufftoeval) : eval(stufftoeval);
}


function aggiorna_regioni(urlSite, valore, sigla_lingua, id_attivita){
	
	var url = urlSite+'inc/ajax_proxy.php?pg=agg_opt_regioni&codice_paese='+valore+'&sigla_lingua='+sigla_lingua+'&id_attivita='+id_attivita;
	new Ajax.Request(url, {
	method: 'get',
	timeout: 0,
	asynchronous: false,  //false=chiamata bloccante; true=asincrona (non bloccante)
		onSuccess: function(transport) {
			var responso = transport.responseText
			//alert(responso);
			loadMyFuncModule(responso);
			

		}
	});
} // end func aggiorna_regioni


function aggiorna_province(urlSite, valore, sigla_lingua, id_attivita){
	
	var url = urlSite+'inc/ajax_proxy.php?pg=agg_opt_province&id_regione='+valore+'&sigla_lingua='+sigla_lingua+'&id_attivita='+id_attivita;
	new Ajax.Request(url, {
	method: 'get',
	timeout: 0,
	asynchronous: false,  //false=chiamata bloccante; true=asincrona (non bloccante)
		onSuccess: function(transport) {
			var responso = transport.responseText
			//alert(responso);
			loadMyFuncModule(responso);
			

		}
	});
} // end func aggiorna_province

function aggiorna_province2(urlSite, valore, sigla_lingua, id_attivita){
	
	var url = urlSite+'inc/ajax_proxy.php?pg=agg_opt_province2&codice_paese='+valore+'&sigla_lingua='+sigla_lingua+'&id_attivita='+id_attivita;
	new Ajax.Request(url, {
	method: 'get',
	timeout: 0,
	asynchronous: false,  //false=chiamata bloccante; true=asincrona (non bloccante)
		onSuccess: function(transport) {
			var responso = transport.responseText
			//alert(responso);
			loadMyFuncModule(responso);
			

		}
	});
} // end func aggiorna_province2



function insertData(nomeForm,campo) {
	
	var modulo = document.forms[nomeForm];
	var campo2 = campo.replace(/_/g,'');
	//alert(campo2);
	
	if (modulo.elements[campo2+'[Y]'].value.length==4 && modulo.elements[campo2+'[m]'].value.length > 0 && modulo.elements[campo2+'[d]'].value.length > 0) modulo.elements[campo].value = modulo.elements[campo2+'[Y]'].value + '-' + modulo.elements[campo2+'[m]'].value + '-' + modulo.elements[campo2+'[d]'].value;
	else modulo.elements[campo].value = '';
	
	
} // end insertData





function assegnaBuonoSconto(id_attivita,sigla_lingua,id_utente,session_id){
							
	var url = urlSite+'inc/ajax_proxy.php?pg=assegna-buono-sconto&sigla_lingua='+sigla_lingua+'&id_attivita='+id_attivita+'&id_buono_sconto='+document.getElementById('id_buono_sconto').value+'&valore_buono_sconto='+document.getElementById('valore_buono_sconto').value+'&sessione='+session_id+'&id_utente='+id_utente;
	//alert(url);
	new Ajax.Request(url, {
	method: 'get',
	timeout: 0,
	asynchronous: false,  //false=chiamata bloccante; true=asincrona (non bloccante)
		onSuccess: function(transport) {
			var responso = transport.responseText;
			//alert(responso);
			//loadMyFuncModule(responso);
		}
	});
	
} // end func assegnaBuonoSconto


function update_pubbl_box_offerte(obj,id_attivita,id_offerta){
	
	if(obj){
		if(obj.checked==true){
			var operazione = 'pubblica';	
		}else{
			var operazione = 'escludi';	
		}
		
	}
	
							
	var url = '../404.html?action=update_pubbl_box_offerte&amp;id_attivita='+id_attivita+'&operazione='+operazione+'&id_offerta='+id_offerta;
	//alert(url);
	new Ajax.Request(url, {
	method: 'get',
	timeout: 0,
	asynchronous: false,  //false=chiamata bloccante; true=asincrona (non bloccante)
		onSuccess: function(transport) {
			//var responso = transport.responseText;
			//alert(responso);
			//loadMyFuncModule(responso);
		}
	});
	
} // end func assegnaBuonoSconto



