	function OpenPagina(pagina, titolo, w, h)
	{
	   eval('window.open(pagina,titolo,"toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,screenX=' + ( screen.width - w ) / 2 + ', screenY=' + ( screen.height - h ) / 2 + ',top=' + ( screen.height - h ) / 2 + ',left=' + ( screen.width - w ) / 2 + ',resizable=0,copyhistory=0,width=' + w + ',height=' + h + '");');
	}

var Nav4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4));

// One object tracks the current modal dialog opened from this window.
var dialogWin = new Object();

// Generate a modal dialog.
// Parameters:
//    url -- URL of the page/frameset to be loaded into dialog
//    width -- pixel width of the dialog window
//    height -- pixel height of the dialog window
//    returnFunc -- reference to the function (on this page)
//                  that is to act on the data returned from the dialog
//    args -- [optional] any data you need to pass to the dialog
function openDialog(url, width, height, returnFunc, args) {
	if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) {
		// Initialize properties of the modal dialog object.
		dialogWin.returnFunc = returnFunc
		dialogWin.returnedValue = ""
		dialogWin.args = args
		dialogWin.url = url
		dialogWin.width = width
		dialogWin.height = height
		// Keep name unique so Navigator doesn't overwrite an existing dialog.
		dialogWin.name = (new Date()).getSeconds().toString()
		// Assemble window attributes and try to center the dialog.
		if (Nav4) {
			// Center on the main window.
			dialogWin.left = window.screenX +
			   ((window.outerWidth - dialogWin.width) / 2)
			dialogWin.top = window.screenY +
			   ((window.outerHeight - dialogWin.height) / 2)
			var attr = "screenX=" + dialogWin.left +
			   ",screenY=" + dialogWin.top + ",resizable=no,width=" +
			   dialogWin.width + ",height=" + dialogWin.height
		} else {
			// The best we can do is center in screen.
			dialogWin.left = (screen.width - dialogWin.width) / 2
			dialogWin.top = (screen.height - dialogWin.height) / 2
			var attr = "left=" + dialogWin.left + ",top=" +
			   dialogWin.top + ",resizable=no,width=" + dialogWin.width +
			   ",height=" + dialogWin.height
		}

		// Generate the dialog and make sure it has focus.
		dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr)
		dialogWin.win.focus()
	} else {
		dialogWin.win.focus()
	}
}

// Event handler to inhibit Navigator form element
// and IE link activity when dialog window is active.
function deadend() {
	if (dialogWin.win && !dialogWin.win.closed) {
		dialogWin.win.focus()
		return false
	}
}

// Since links in IE4 cannot be disabled, preserve
// IE link onclick event handlers while they're "disabled."
// Restore when re-enabling the main window.
var IELinkClicks

// Disable form elements and links in all frames for IE.
function disableForms() {
	IELinkClicks = new Array()
	for (var h = 0; h < frames.length; h++) {
		for (var i = 0; i < frames[h].document.forms.length; i++) {
			for (var j = 0; j < frames[h].document.forms[i].elements.length; j++) {
				frames[h].document.forms[i].elements[j].disabled = true
			}
		}
		IELinkClicks[h] = new Array()
		for (i = 0; i < frames[h].document.links.length; i++) {
			IELinkClicks[h][i] = frames[h].document.links[i].onclick
			frames[h].document.links[i].onclick = deadend
		}
	}
}

// Restore IE form elements and links to normal behavior.
function enableForms() {
	for (var h = 0; h < frames.length; h++) {
		for (var i = 0; i < frames[h].document.forms.length; i++) {
			for (var j = 0; j < frames[h].document.forms[i].elements.length; j++) {
				frames[h].document.forms[i].elements[j].disabled = false
			}
		}
		for (i = 0; i < frames[h].document.links.length; i++) {
			frames[h].document.links[i].onclick = IELinkClicks[h][i]
		}
	}
}

// Grab all Navigator events that might get through to form
// elements while dialog is open. For IE, disable form elements.
function blockEvents() {
	if (Nav4) {
		window.captureEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS)
		window.onclick = deadend
	} else {
		disableForms()
	}
	window.onfocus = checkModal
}
// As dialog closes, restore the main window's original
// event mechanisms.
function unblockEvents() {
	if (Nav4) {
		window.releaseEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS)
		window.onclick = null
		window.onfocus = null
	} else {
		enableForms()
	}
}

// Invoked by onFocus event handler of EVERY frame,
// return focus to dialog window if it's open.
function checkModal() {
	if (dialogWin.win && !dialogWin.win.closed) {
		dialogWin.win.focus()
	}
}

	function ControllaLista(pagina)
	{
	   var myindex = document.liste.lista.value;
	   if (myindex == '') {
		} else if (myindex == 'E') {
		   OpenPagina('lista.php?azione=elimina&pagina=' + pagina, 'LISTA', 300, 100);
		} else if (myindex == 'A') {
		   OpenPagina('lista.php?azione=aggiungi&pagina=' + pagina, 'LISTA', 300, 100);
		}
	}

	function Note(id)
	{
		   OpenPagina('note.php?id=' + id, 'LISTA', 300, 100);
	}



	function	SubmitForm(nomeform)
	{
		eval('document.' + nomeform + '.submit();');
	}

	function Aggiungi(nomeform, campo, codice, idordine, iva)
	{
	   if (campo != '') {
		   eval('document.' + nomeform + '.' + campo + '.value = Math.floor(document.' + nomeform + '.' + campo + '.value) + 1;');
		} else {
		   eval('document.' + nomeform + '.quantita.value = Math.floor(document.' + nomeform + '.quantita.value) + 1;');
		}
		return azione('variacarrello', codice, idordine, iva );
	}

	function Sottrai(nomeform, campo, codice, idordine, iva)
	{
	   if (campo != '') {
			if(eval('document.' + nomeform + '.' + campo + '.value') > 1 )
			{
			   eval('document.' + nomeform + '.' + campo + '.value = Math.floor(document.' + nomeform + '.' + campo + '.value) - 1;'); 
			}
		} else {
			if(eval('document.' + nomeform + '.quantita.value') > 1 )
			{
		      eval('document.' + nomeform + '.quantita.value = Math.floor(document.' + nomeform + '.quantita.value) - 1;');
			}
		}
		return azione('variacarrello', codice, idordine, iva );
	}
	function AggiungiSemplice(nomeform, campo)
	{
	   if (campo != '') {
		   eval('document.' + nomeform + '.' + campo + '.value = Math.floor(document.' + nomeform + '.' + campo + '.value) + 1;');
		} else {
		   eval('document.' + nomeform + '.quantita.value = Math.floor(document.' + nomeform + '.quantita.value) + 1;');
		}
		return true;
	}

	function SottraiSemplice(nomeform, campo)
	{
	   if (campo != '') {
			if(eval('document.' + nomeform + '.' + campo + '.value') > 1 )
			{
			   eval('document.' + nomeform + '.' + campo + '.value = Math.floor(document.' + nomeform + '.' + campo + '.value) - 1;'); 
			}
		} else {
			if(eval('document.' + nomeform + '.quantita.value') > 1 )
			{
		      eval('document.' + nomeform + '.quantita.value = Math.floor(document.' + nomeform + '.quantita.value) - 1;');
			}
		}
		return true;
	}
	
	function ControlloQuantita( q ) {
		if ( q <= 0 || q == '' 	) {
			alert( 'Quantità non valida!' );
			return false;
		}
		return true;
	}
	
	function Agglista(nomeform)
	{
	   var myindex = document.liste.lista.value;
		var nome = eval("document." + nomeform);
		nome.agglista.value = myindex;
		nome.azione.value = 'aggiuntalista';
		nome.submit();
	}
	
	function Ricarica(pagina)
	{
      parent.frames.prodotti.location = pagina;
	}

	function StopCarrello( )
	{
		location = "titolo.php?azione=mostracompra&chiudi=S";
		//var x = window.open( "titolo.php?azione=mostracompra", "wind", "top=2000, left=100" );
		//return false;
	}
	
	function StopCarrelloFromIframe( )
	{
		parent.document.frames.carrello.location = "titolo.php?azione=mostracompra&chiudi=S";
		//var x = window.open( "titolo.php?azione=mostracompra", "wind", "top=2000, left=100" );
	//	return false;
	}
	
	
	function StartCarrelloFromIframe( )
	{
		// parent.document.frames.carrello.location = "titolo.php";
	}

	function Cambiato(relink)
	{	
		if(relink != "")
		{
			if(relink == "X")
			{
				Ricarica('titolo.php?azione=puliziacarrello');
			} else {
				Ricarica(relink);
			}
		}
	}
	
	function azione( azione, codice, idordine, iva )
	// azioni eseguite dentro il carrello
   {
      document.carrello.azione.value = azione;
      document.carrello.codice.value = codice;
      document.carrello.idordine.value = idordine;
      document.carrello.iva.value = iva;
	   if( azione == "variacarrello" )
		{
         if ( codice.toUpperCase() == "ARTFL" )
	      {
			    var s;
	          s = document.qta.przartfl.value;
				 s = s.replace( ',', '.' );
				 document.carrello.przartfl.value = s;
	          document.carrello.desartfl.value = document.qta.desartfl.value; 
	      }
		   document.carrello.quantita.value = eval( 'document.qta.quantita' + idordine + '.value' );
		   
		}
		document.carrello.submit();
		return false;
	}
	
	function TrasferisciDati()
	// Passa dati dalla finestra dei Comuni a quella della Registrazione
	{
		parent.document.accesso.comune1.value = document.comuni.comune1.value;
		// alert(opener.parent.frames['prodotti'].accesso.comune1.value);
		parent.document.accesso.provincia1.value = document.comuni.provincia.value;
		// alert(opener.parent.frames['prodotti'].accesso.provincia1.value);
		parent.document.accesso.cap.value = document.comuni.cap.value;
		// alert(opener.parent.frames['prodotti'].accesso.cap.value);
		parent.document.accesso.comune.value = document.comuni.comune.value;
		// alert(opener.parent.frames['prodotti'].accesso.comune.value);
		parent.document.accesso.provincia.value = document.comuni.provincia.value;
		// alert(opener.parent.frames['prodotti'].accesso.provincia.value);
		//window.close();
	}
	
	var salvaconsegna = new Array(100);
	
	
	function Urgente()
	{
		// Valore checkbox urgente
		var ckurgente;
		ckurgente = document.consegna.urgente;
		// Numero di checkbox generati
		var n;
		n = document.consegna.fasciaconsegna.length;
		// Ciclo per abilita/disabilita
		for (i = 0; i <= n-1; i++)
		{
			if(ckurgente.checked)
			{
			   salvaconsegna[i] = document.consegna.fasciaconsegna[i].disabled;
				document.consegna.fasciaconsegna[i].disabled = true;
			} else {
				document.consegna.fasciaconsegna[i].disabled = salvaconsegna[i];
			}	
		}
	}	
function launch_support_1_0()
{
	var s;
	s =  escape( location.toString() );
	var request_url_1_0 = "http://www2.soscartucce.it/phplive/request.php?l=soscartucce&#x=1&deptid=0&page=www2"+ s.substring( 12 ) ;
	alert( request_url_1_0 );
	newwin = window.open( request_url_1_0, "chat1", 'scrollbars=no,menubar=no,resizable=0,location=no,screenX=50,screenY=100,width=450,height=350' ) ;
	newwin.focus() ;
}

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
	if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip;
