sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
	
	
function popup(url_pagina,w,h,sw_scroll) {

	//alert(url_pagina);
	  /*w = 500;
	  h = 400;*/
	  l = (screen.width - w) / 2;
	  t = (screen.height - h) / 2;
	  
	  wnd = window.open(url_pagina,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+sw_scroll+", resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
	  wnd.focus();		

}


function toggleDisplay(fO){

	var ns4 = (document.layers);
	var ie4 = (document.all && !document.getElementById);
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);
	
	
	if(ie5 || ns6){
		if (document.getElementById(fO).style.display=="none") {
		document.getElementById(fO).style.display="inline";
		}else{
		document.getElementById(fO).style.display="none";
		}
	}
	
	if(ie4){
		if (document.all[fO].style.display=="none") {
		document.all[fO].style.display="inline";
		}else{
		document.all[fO].style.display="none";
		}
	}	
}



function showFiglioManager (fO,img) {
	var ns4 = (document.layers);
	var ie4 = (document.all && !document.getElementById);
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);
	var num = document.getElementsByTagName('div');
 
	//alert(img);
	
	
	eval('document.'+img+'.src = "../img/freccia_giu.gif"') ;
	
	xx = fO.split("_") ;
	
	//alert (xx[0]) ;
	
	if (xx[0] == "menu") { 
		for (var i=0;i<num.length;i++) { 
			idx = num[i].id ;
			
			 
			arr = idx.split("_") ;
			 		//alert(arr[0]+"|"+arr[1]+"|"+idProd);	 
			if (arr[0] == "menu") { 	//alert(arr[0]+"|"+arr[1]+"|"+idProd);	 	 
 				if(ie5 || ns6){ 
 					document.getElementById(idx).style.display="none";
 				}
 				if(ie4){
 					document.all[idx].style.display="none";
 				} 
			} 		
		}

	}
		if(ie5 || ns6){
			document.getElementById(fO).style.display="inline";
		}
 		if(ie4){
 			document.all[fO].style.display="inline";
 		}
  
	
 	 

}

function showFiglio (codice,imgName) {
			
	altro_el = document.getElementById(codice).style; 
	spanName = document.getElementById(imgName).style;
	
	if(altro_el.display == "") {
		altro_el.display = "none" ;
		spanName.backgroundImage = "url(img/bot_down.gif)" ;
		spanName.backgroundRepeat = "no-repeat" ;
	}else {
		altro_el.display = "" ;
		spanName.backgroundImage = "url(img/bot_up.gif)" ;
		spanName.backgroundRepeat = "no-repeat" ;
	}
}

function riporta_data(data,campo){
 
 Arr = data.split("-")
 
 datavisYYYY  = Arr[0] ; 
 datavisMM  = Arr[1] ; 
 datavisGG  = Arr[2] ; 
 
 if(datavisMM.length == 1) datavisMM = "0" + datavisMM ;
 if(datavisGG.length == 1) datavisGG = "0" + datavisGG ;

 datavis = datavisGG + "-" + datavisMM + "-" + datavisYYYY ;
 data = datavisYYYY + datavisMM + datavisGG ;


 if(campo == "data") {
	window.opener.document.form.data.value=data ;
	window.opener.document.form.data_vis.value=datavis ;
}



self.close();	
}



function checkFormCatalogo () {
		var swKO = 0 ;
		var msg = "" ;
 
 
		// sezione valida email
		var x = document.form.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		msg += 'Indirizzo email inesatto.\n';
		swKO = 1 ;	
		} 
	
		if (document.form.email.value == "" ) {
		msg += 'Manca l\' email.\n';
		swKO = 1 ;
		} 

	
		if (document.form.sw_prod.value == 0 ) {
		msg += 'seleziona uno o piu\' prodotti.\n';
		swKO = 1 ;
		}
		
		
		var the_box1 = document.form.accetto[1].checked;
		
		 
		if (the_box1 == true) {
		msg += 'Devi accettare la clausola .\n' ;
		swKO = 1 ;
		}	
		
		if (swKO == 1) {
			alert(msg) ;
			return false ;	
		}  	
}

function checkFormContatto () {
		var swKO = 0 ;
		var msg = "" ;
 
 
		// sezione valida email
		var x = document.form.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		msg += 'Indirizzo email inesatto.\n';
		swKO = 1 ;	
		} 

		// sezione campi obbligatori
		if (document.form.nome.value == "" ) {
		msg += 'Manca il nome.\n';
		swKO = 1 ;
		}
		if (document.form.cognome.value == "" ) {
		msg += 'Manca il cognome.\n';
		swKO = 1 ;
		} 		
		
		if (document.form.email.value == "" ) {
		msg += 'Manca l\' email.\n';
		swKO = 1 ;
		} 
		if (document.form.messaggio.value == "" ) {
		msg += 'Manca il messaggio.\n';
		swKO = 1 ;
		}
		/*if (document.form.tel.value == "" ) {
		msg += 'Manca il telefono.\n';
		swKO = 1 ;
		}*/
 
		var the_box1 = document.form.accetto[1].checked;
		
		 
		if (the_box1 == true) {
		msg += 'Devi accettare la clausola .\n' ;
		swKO = 1 ;
		}	
				 			
		if (swKO == 1) {
			alert(msg) ;
			return false ;	
		}  	
}



/*

FLY TO BASKET

*/

/************************************************************************************************************
(C) www.dhtmlgoodies.com, March 2006

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Version:
	1.0	Released	March. 3rd 2006

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/

var flyingSpeed = 25;

var url_to_php = './php/AJX.php' ;



var shopping_cart_div = false;
var flyingDiv = false;
var currentProductDiv = false;

var shopping_cart_x = false;
var shopping_cart_y = false;

var slide_xFactor = false;
var slide_yFactor = false;

var diffX = false;
var diffY = false;

var currentXPos = false;
var currentYPos = false;

var ajaxObjects = new Array();


function shoppingCart_getTopPos(inputObj)
{		
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
  }
  return returnValue;
}

function shoppingCart_getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}
	

function addToBasket(productId)
{
	if(!shopping_cart_div)shopping_cart_div = document.getElementById('shopping_cart');
	if(!flyingDiv){
		flyingDiv = document.createElement('DIV');
		flyingDiv.style.position = 'absolute';
		document.body.appendChild(flyingDiv);
	}
	
	shopping_cart_x = shoppingCart_getLeftPos(shopping_cart_div);
	shopping_cart_y = shoppingCart_getTopPos(shopping_cart_div);

	currentProductDiv = document.getElementById('slidingProduct' + productId);
	
	currentXPos = shoppingCart_getLeftPos(currentProductDiv);
	currentYPos = shoppingCart_getTopPos(currentProductDiv);
	
	diffX = shopping_cart_x - currentXPos;
	diffY = shopping_cart_y - currentYPos;
	

	
	var shoppingContentCopy = currentProductDiv.cloneNode(true);
	shoppingContentCopy.id='';
	flyingDiv.innerHTML = '';
	flyingDiv.style.left = currentXPos + 'px';
	flyingDiv.style.top = currentYPos + 'px';
	flyingDiv.appendChild(shoppingContentCopy);
	flyingDiv.style.display='block';
	flyingDiv.style.width = currentProductDiv.offsetWidth + 'px';
	flyToBasket(productId);
	
}


function flyToBasket(productId)
{
	var maxDiff = Math.max(Math.abs(diffX),Math.abs(diffY));
	var moveX = (diffX / maxDiff) * flyingSpeed;;
	var moveY = (diffY / maxDiff) * flyingSpeed;	
	
	currentXPos = currentXPos + moveX;
	currentYPos = currentYPos + moveY;
	
	flyingDiv.style.left = Math.round(currentXPos) + 'px';
	flyingDiv.style.top = Math.round(currentYPos) + 'px';	
	
	
	if(moveX>0 && currentXPos > shopping_cart_x){
		flyingDiv.style.display='none';		
	}
	if(moveX<0 && currentXPos < shopping_cart_x){
		flyingDiv.style.display='none';		
	}
		
	if(flyingDiv.style.display=='block') {
		setTimeout('flyToBasket("' + productId + '")',10);
	} else {
		ajaxAddProduct(productId);
	}
			
}





function ajaxRemoveProduct(productId)
{
	makeRequestIdSpan(url_to_php + '?action=delete&id_cart=' + productId,'shopping_cart') ;		
}

function ajaxAddProduct(productId)
{  
	makeRequestIdSpan(url_to_php + '?action=insert&id_catalogo=' + productId,'shopping_cart') ;	 
}
/*

FINE FLY TO BASKET

*/

/*
	------------------------------------------------------------------
	HTTP_REQUEST
*/	
 
	function makeRequestIdSpan(url,idSpan) {
		
		this.idSpan = idSpan ;
		http_request = checkHttpRequest() ;

	  http_request.onreadystatechange = alertContentsProdLista ;
		http_request.open('GET', url, true);
		http_request.send(true);
			
	}	
	
	function alertContentsProdLista() {
		
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				changeHtml () ;
			} else {
				alert('There was a problem with the request.');
			}
		} else {
			loading () ;	
		}
   }
    
	function loading () {
		var text =  "" ;
		text = "<img src=\"../img/spinner.gif\"><span class=\"text\">Loading ...</span>" ; 
		eval('document.getElementById(\''+this.idSpan+'\').innerHTML = text ;') ; 	
	}

	
	function changeHtml() {
		this.rispostaHtml = http_request.responseText ;
		eval('document.getElementById(\''+this.idSpan+'\').innerHTML = http_request.responseText;') ;
		
		
		// per LOGIN
		if(this.rispostaHtml == 'LOGIN OK'){ 
			location.href = "manager/" ;
		}
	}
    	
    	
    function checkHttpRequest() {
		http_request = false;
		
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			
			if (http_request.overrideMimeType) {
				http_request.overrideMimeType('text/xml');
				
			}
		} else if (window.ActiveXObject) { // IE
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		
		if (!http_request) {
		alert('Browser obsoleto.\n\nScarica un nuovo browser\nsiamo nel 2006 !!!!  ');
		return false;
		}
		
		return http_request ;
	}
/*
		fine HTTP_REQUEST
		------------------------------------------------------------------
*/


/*

CLASSE AJAX

*/

// CLASSE AJAX

function ClassAJAX () {

	this.xmlhttp = null ;

	this.reset = function() {
		
		this.execute = false; //se true fatica come sappiamo....mette codice ottenuto da file php in id_span
  		this.element = null;	// è l'id dell'oggetto (l'id_span)
		this.elementObj = null;
		this.responseStatus = new Array(2);
		this.vars = Array () ;
		
		this.onFailed = function() { };
	};
	
	//	creo oggetto XHTMLHTTP compatibile col browser altrimenti setto 
	//	variabile booleana this.failed = true ;
	this.createAJAX = function() {
		
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}
	
		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};
	
	
	// metodo che mi ritorna il codice dall' url che passo come parametro
	this.runAJAX = function(urlstring) {
		
	
		if (this.failed) {
			//se ho avuto problemi in createAJAX vado in function onFailed()
			this.onFailed() ;
		} else {			
			
			if (this.element) {
				this.elementObj = document.getElementById(this.element);
			}
			
			if (this.xmlhttp) {
			
				var self = this ;
				
				this.xmlhttp.open("GET", urlstring, true);				
				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
			
						case 1:
							self.onLoading();
						break;
						
						case 2:
							self.onLoaded();
						break;
						
						case 3:
							self.onInteractive();
						break;
						
						case 4:
							
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;
							
							if (self.execute) {	//se devo fare l'innerHTML del contenuto dinamico nell'elemento
								self.changeHtml();
							}
							else {
								
								/*
									QUI CAZZI PER AUTOCOMPLETE etc ....
								*/
								if (self.elementObj) {
									
									elemNodeName = self.elementObj.nodeName;
									elemNodeName.toLowerCase();
									if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea") {
										//self.elementObj.value = self.response;
										showSuggest (self.response, '', self.vars) ;
																				
									} else {
										//self.elementObj.innerHTML = self.response;
										showSuggest (self.response, 'inner', self.vars) ; 
									}
								}
								
								if (self.responseStatus[0] == "200") {
									self.onCompletion();
								} else {
									self.onError();
								}
							}
							
						break;
					}
				} ;		
				this.xmlhttp.send(true);
			}
		}
		
	}
	
	this.changeHtml = function () {
		this.elementObj.innerHTML = this.response ; 
	};
	
	this.setElement = function(elementId) {
		this.element = elementId ;
	};
	
	this.setExecute = function(bool) {
		this.execute = bool ;
	};
	
	this.setVars = function (key,val) {
		this.vars[key] = val ;
	};

	this.onFailed = function () {
		alert ("onFailed") ;
	};
	
	this.onLoading = function () {
		//alert ("onLoading") ;
	};
	
	this.onLoaded = function () {
		//alert ("onLoaded") ;
	};
	
	this.onInteractive = function () {
		//alert ("onInteractive") ;
	};
	
	this.onCompletion = function () {
		//alert ("onCompletion") ;
	};
	
	this.onError = function () {
		//alert ("onError") ;
	};
	
	this.reset();
	this.createAJAX();
}
/*
 ---------------------------------
*/

function AXJAboutus(action,lang) {
		var ajaxObj = new ClassAJAX();
	
		ajaxObj.setExecute(true) ;	
		ajaxObj.setElement ('about_us') ;

		ajaxObj.runAJAX ('./php/AJX.php?action='+action) ;	
		
		// spegne
		document.getElementById('azienda').className = "meunSx" ;
		document.getElementById('vision').className = "meunSx" ;
		document.getElementById('porcellana').className = "meunSx" ;
		
		// accende
		eval('document.getElementById(\''+action+'\').className = "textB"');
		
		document.img.src = "../img/piuoriginali_"+lang+".jpg";
		//alert(document.img.src = "../img/piuoriginali_"+lang+".jpg");
		
		
}

function AXJEvento(idEvento) {
		var ajaxObj = new ClassAJAX();
	
		ajaxObj.setExecute(true) ;	
		ajaxObj.setElement ('evento_dett') ;

		ajaxObj.runAJAX ('./php/AJX.php?action=evento&id_evento='+idEvento) ;	
}
 

