var imgArray;

function CambiaPagina(pagina)
{
	var appElement=document.getElementById('tblPaginazione_txtPaginaSel');
	appElement.value=pagina;
	document.forms[0].submit();
}

function MessaggioNonDisp()
{
	alert('Il prodotto selezionato non è al momento acquistabile');
}

function CambiaTipoRicerca(prova)
{
	var myDrop=document.getElementById('cstColonnaSin_dropTipoRicerca');
	myDrop.options.length=0;
	
	if (CampiRicerca[prova.selectedIndex]!='')
	{
		i=0
		while (CampiRicerca[prova.selectedIndex][i]!=null)
		{
			app=CampiRicerca[prova.selectedIndex][i].split("|");
			myDrop.options[i]=new Option(app[0], app[1]);
			i++
		}	
	}
	else
	{
		myDrop.options[0]=new Option("Titolo", "txtTitolo");
	}
}

function clickButton(e, buttonid)
{ 
    var bt = document.getElementById(buttonid); 
    if (typeof bt == 'object'){ 
        if(navigator.appName.indexOf("Netscape")>(-1)){ 
                if (e.keyCode == 13){ 
                    bt.click(); 
                    return false; 
                } 
        } 
        if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
                if (event.keyCode == 13)
                { 
                    bt.click(); 
                    return false; 
                } 
        } 
    } 
} 

function Acquista(ID_Prodotto)
{
	var myText=document.getElementById('txtProdHome');
	myText.value=ID_Prodotto;
}

function AcquistaEvidenza(ID_Prodotto)
{
	var myText=document.getElementById('cstColonnaDestra_txtProdEvidenza');
	myText.value=ID_Prodotto;
}

String.prototype.Trim=Trim;

function Trim() 
{ 
	return this.replace(/\s+$|^\s+/g,""); 
} 


function LoadImage()
{
	imgArray=new Array();
	var i,a=LoadImage.arguments; 
	
	for (i=0; i<a.length; i++)
	{
		imgArray[i]=new Image();
		imgArray[i].src="immagini\\"+a[i];
	}
}

function CambiaImmagine(imm, nome)
{
	var appImg=new Image();
	appImg.src=imm.src;
	var iApp=0;
	
	while (iApp<imgArray.length)
	{
		if(imgArray[iApp].src.indexOf(imm.name+'_'+nome)>0)
		{
			imm.src=imgArray[iApp].src;
			imgArray[iApp].src=appImg.src;
			break;
		}
		iApp=iApp+1;
	} 
}

function LunghezzaTesto(testo)
{
	return testo.replace(/\s+$|^\s+/g,"").length;
}

function ControllaEmail(Email)
{
	var appEmail=document.getElementById(Email);
	var filtro=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
	if ( LunghezzaTesto(appEmail.value)<1)
		errore="Devi inserire l'E-mail per effettuare l'accesso";
		
	if (errore.length>0)
	{
		alert(errore);
		return false;
	}
		
	if (filtro.test(appEmail.value))
		return true;
	else
	{
		alert("Controlla l'indirizzo e-mail inserito");
		return false;
	}
}
function ControllaLogin(Email, Psw)
{
	var appEmail=document.getElementById(Email);
	var appPsw=document.getElementById(Psw);
	var filtro=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	var errore='';
	
	if ( LunghezzaTesto(appEmail.value)<1)
		errore="Devi inserire l'E-mail per effettuare l'accesso";
		
	if ( LunghezzaTesto(appPsw.value)<6)
	{
		if (errore.length>0)
			errore+='\n';
		errore+="Devi inserire una Password formata da almeno 6 caratteri";
	}
	
	if (errore.length>0)
	{
		alert(errore);
		return false;
	}
		
	if (filtro.test(appEmail.value))
		return true;
	else
	{
		alert("Controlla l'indirizzo e-mail inserito");
		return false;
	}
}

function effettuaLogin()
{
	alert("Per inserire l'articolo nella Wish List devi effettuare il Login"); 
	document.ReturnValue=false;
}




