// JavaScript Document
function slide_photogallery(){
var slideShowSpeed = 4000

			var crossFadeDuration = 3
			
			var Pic = new Array()
			
			Pic[0] = 'images/messico.jpg'
			Pic[1] = 'images/sestriere.jpg'
			//Pic[2] = '03.gif'
			
			var t
			var j = 0
			var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

		  
function runSlideShow(){
    
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[j].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   j = j + 1
   if (j > (p-1)) j=0
   //t = setTimeout('runSlideShow()', slideShowSpeed)
}
t = setTimeout('runSlideShow()', slideShowSpeed)
}

defaultStatus = "Bagno Look s.p.a.    - IL PARTNER IDEALE PER IL TUO LAVORO"

function VerificaForm(FORM){
if(FORM.azienda.value==""){
alert("Inserire Ragione Sociale");
FORM.azienda.focus();
return false;
}
if(FORM.lavora.value==""){
alert("Inserire nome e cognome");
FORM.azienda.focus();
return false;
}
if(FORM.indirizzo.value==""){
alert("Inserire Indirizzo");
FORM.indirizzo.focus();
return false;
}
if(FORM.citta.value==""){
alert("Inserire la Citt&agrave;");
FORM.citta.focus();
return false;
}
if(FORM.telefono.value==""){
alert("Inserire il numero di telefono");
FORM.telefono.focus();
return false;
}
if(FORM.email.value==""){
alert("Inserire email");
FORM.email.focus();
return false;
}else if(!FORM.email.value.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){
alert("Email errata");
FORM.email.focus();
return false;
}
if(FORM.messaggio.value=="" || FORM.messaggio.value=="Scriva qui il suo messaggio" ){
alert("Attenzione scrivi il tuo messaggio");
FORM.messaggio.focus();
return false;
}
}


function mail(user) 
{ 
	document.location.href = "mailto:" + user + "@bagnolook.com"; 
}

function scopri(menuId)
{
	if(document.getElementById(menuId).style.display == "none")
	{
		document.getElementById(menuId).style.display = "block";
	}
	else if(document.getElementById(menuId).style.display == "block")
	{
		document.getElementById(menuId).style.display = "none";
	}
	else
	{
		document.getElementById(menuId).style.display = "none";
	}
}
 
var myRequest = null;
 
function CreateXmlHttpReq(handler) {
  var xmlhttp = null;
  try {
    xmlhttp = new XMLHttpRequest();
  } catch(e) {
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  xmlhttp.onreadystatechange = handler;
  return xmlhttp;
}
 
function myHandler() {
    if (myRequest.readyState == 4 && myRequest.status == 200) {
        e = document.getElementById("shopping_cart_totalprice");
        e.innerHTML = myRequest.responseText;
    }
}
function doRedirect() 
{ 
	location.href = "../index.php";
} 
function aggiungi_carrello(id_articolo,action,compro,sc1,sc2,sc3,netto) {
	if(action=="aggiungi" && compro=="" || compro=="0")
		alert("inserisci la quantita da aggiungere al carrello");
	else{
    	myRequest = CreateXmlHttpReq(myHandler);
    	myRequest.open("POST","funzioni.php?compro="+compro+"&action="+action+"&id_articolo="+id_articolo+"&sc1="+sc1+"&sc2="+sc2+"&sc3="+sc3+"&netto="+netto+"&rand="+Math.random());
    	myRequest.send(null);
		if(action=="esci")
		{
					window.setTimeout("doRedirect()", 100);	
		}
	}
}

function sel_cliente(codice,li)
{
	if(codice.value!="" || codice=="new")
	{	
	//alert(codice.value);
		if(codice=="new")
			cod=codice;
		else if(codice.value==undefined && parseInt(codice)!="NaN")
			cod=codice;
		else
			cod=codice.value.substr(codice,7);
    	myRequest = CreateXmlHttpReq(myHandler2);
    	myRequest.open("POST","funzioni.php?sel_cliente=1&codice_cliente="+cod+"&rand="+Math.random());
    	myRequest.send(null);
	}
}

function myHandler2() {
    if (myRequest.readyState == 4 && myRequest.status == 200) {
        e = document.getElementById("anagrafica_clienti");
        e.innerHTML = myRequest.responseText;
    }
}

function prezzo_netto(sc1,sc2,sc3,netto)
{
	if (document.getElementById(sc1).style.display!="none"){
		document.getElementById(sc1).style.display = "none";
		document.getElementById(sc1).style.width = "0px";
		document.getElementById(netto).style.display = "inline";
		document.getElementById(netto).style.width = "80px";
	}
	else
	{
		document.getElementById(sc1).style.display = "inline";
		document.getElementById(netto).style.display = "none";
		document.getElementById(sc1).style.width = "20px";
		document.getElementById(netto).style.width = "0px";
	}
	if (document.getElementById(sc2).style.display!="none")
	{
		document.getElementById(sc2).style.display = "none";
		document.getElementById(sc2).style.width = "0px";
	}
	else
	{
		document.getElementById(sc2).style.display = "inline";
		document.getElementById(sc2).style.width = "20px";
	}
	if (document.getElementById(sc3).style.display!="none")
	{
		document.getElementById(sc3).style.display = "none";
		document.getElementById(sc3).style.width = "0px";
	}
	else
	{
		document.getElementById(sc3).style.display = "inline";
		document.getElementById(sc3).style.width = "20px";
	}
		
}

function myHandler_cat(id) {
    if (myRequest.readyState == 4 && myRequest.status == 200) {
        e = document.getElementById(id);
        e.innerHTML = myRequest.responseText;
    }
}

function sel_categoria(categoria,id)
{
	if(categoria!="")
	{	
    	myRequest = CreateXmlHttpReq(function() {myHandler_cat(id)});
    	myRequest.open("POST","funzioni.php?action=nuovo_prodotto&sel_categoria=1&categoria="+categoria+"&rand="+Math.random());
		//alert("funzioni.php?action=nuovo_prodotto&sel_categoria=1&categoria="+categoria+"&rand="+Math.random());
    	myRequest.send(null);
	}
}

function stampa(page) {
	
     //Nasconde le celle indesiderate
        document.getElementById("elenco_princ").style.display = "None";
        document.getElementById("header").style.display = "None";
        document.getElementById("footer").style.display = "None";
		document.getElementById("stampa").style.display = "None";
     //Imposta la parte da stampare a tutto schermo
        document.getElementById("centrale_princ").style.width = "100%";
     //Lancia la funzione di stampa
        window.print();
		location.href = "index.php?action="+page;
		window.setTimeout(location.href, 100);
		
     //Ripristina la parte da stampare alle dimensioni originali
        //stampa.style.width = "450px";
     //Ripristina l'impostazione iniziale delle celle indesiderate
       /* intestazione.style.display = "";
        sinistro.style.display = "";
        destro.style.display = "";*/
  }
  
function colora(rif,colore)
{
	rif.style.background = "#"+colore;
}

function VerificaFormPromo(FORM){
if(FORM.codice.value==""){
alert("Inserire Codice");
FORM.codice.focus();
return false;
}
if(FORM.descrizione.value==""){
alert("Inserire descrizione");
FORM.descrizione.focus();
return false;
}
if(FORM.indirizzo.value==""){
alert("Inserire Indirizzo");
FORM.indirizzo.focus();
return false;
}
if(FORM.prezzo.value==""){
alert("Inserire prezzo");
FORM.prezzo.focus();
return false;
}
if(FORM.file1.value==""){
	if(FORM.images.value==""){
alert("Caricare una foto o mettere il codice");
FORM.file1.focus();
return false;
	}
}
}

function VerificaFormUtenti(FORM){
if(FORM.userCodice.value==""){
alert("Inserire Codice Agente");
FORM.userCodice.focus();
return false;
}
if(FORM.userbagno.value==""){
alert("Inserire Username");
FORM.userbagno.focus();
return false;
}
if(FORM.mailbagno.value==""){
alert("Inserire email");
FORM.mailbagno.focus();
return false;
}else if(!FORM.mailbagno.value.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){
alert("Email errata");
FORM.mailbagno.focus();
return false;
}
if(FORM.capo.value==""){
alert("Inserire il capoarea");
FORM.capo.focus();
return false;
}
}

function VerificaFormNuovoProdotto(FORM){
if(FORM.codice.value==""){
alert("Inserire Codice");
FORM.codice.focus();
return false;
}
if(FORM.descrizione.value==""){
alert("Inserire descrizione");
FORM.descrizione.focus();
return false;
}
if(FORM.prezzo.value==""){
alert("Inserire prezzo");
FORM.prezzo.focus();
return false;
}
if(FORM.qta.value==""){
alert("Inserire quantità");
FORM.qta.focus();
return false;
}
}

function VerificaFormNuovoSottocategoria(FORM){
if(FORM.descrizione_ita.value==""){
alert("Inserire descrizione italiano");
FORM.descrizione_ita.focus();
return false;
}
if(FORM.descrizione_ing.value==""){
alert("Inserire descrizione inglese");
FORM.descrizione_ing.focus();
return false;
}
if(FORM.file1.value==""){
alert("Inserire immagine");
FORM.file1.focus();
return false;
}
if(FORM.codice.value==""){
alert("Inserire Codice");
FORM.codice.focus();
return false;
}
if(FORM.descrizione.value==""){
alert("Inserire descrizione");
FORM.descrizione.focus();
return false;
}
if(FORM.prezzo.value==""){
alert("Inserire prezzo");
FORM.prezzo.focus();
return false;
}
if(FORM.qta.value==""){
alert("Inserire quantità");
FORM.qta.focus();
return false;
}
}


function annulla_overflow()
{
    var id=document.getElementById('pagine_catalogo');
    
    if(id.style.overflow=='auto')
        id.style.overflow = 'visible';
    else
        id.style.overflow = 'auto';
    //alert(id.style.overflow);
}

function myHandler_carrello_modificabile(id) {
    if (myRequest.readyState == 4 && myRequest.status == 200) {
        e = document.getElementById('carrello_modificabile');
        //if(myRequest.responseText=='')
            //alert(myRequest.responseText);
            //$('#carrllo_modificabile').docwrite(myRequest.responseText);
        e.innerHTML = myRequest.responseText;
        e.style.visibility='visible';
        myRequest = CreateXmlHttpReq(function() {myHandler()});
        myRequest.open("POST","funzioni.php?action=refresh&rand="+Math.random());
        myRequest.send(null);
    }
    else{
       // document.getElementById('carrello_modificabile').style.visibility='hidden';
        document.getElementById('carrello_modificabile').innerHTML='<center><h2>Attendere.....</h2></center>';
    }
}

function aggiorna_carrello_modificabile(value,id,campo)
{	
    	myRequest = CreateXmlHttpReq(function() {myHandler_carrello_modificabile(id)});
    	myRequest.open("POST","funzioni.php?carrello_modificabile=1&id="+id+"&value="+value+"&campo="+campo+"&rand="+Math.random());
        //alert("funzioni.php?action=carrello_modificabile&id="+id+"&value="+value+"&campo="+campo+"&rand="+Math.random());
    	myRequest.send(null);
        
}
