function aggiungiCarrelloConTaglia(pdid)
{
	var comboValue;
	var selIndex = document.frmAddToCart.cboTaglie.selectedIndex;
	comboValue = document.frmAddToCart.cboTaglie.options[selIndex].value;
	var qtyValue;
	qtyValue = document.frmAddToCart.txtQty.value;
	if (qtyValue <= 0)
		alert ('La quantitą deve essere maggiore di 0');
	else if (comboValue == 'Scegli la taglia')
		alert ('Scegli la taglia');
	else
		window.location.href='carrello.php?action=add&p='+pdid+'&t='+comboValue+'&q='+qtyValue;
}

function aggiungiCarrelloNoTaglia(pdid)
{
	var qtyValue;
	qtyValue = document.frmAddToCart.txtQty.value;
	if (qtyValue <= 0)
		alert ('La quantitą deve essere maggiore di 0');
	else
		window.location.href='carrello.php?action=add&p='+pdid+'&q='+qtyValue;
}


function checkAddUserForm()
{
	with (window.document.frmRegistra) {
		if (isEmpty(txtUserName, 'Inserisci il nome utente')) {
			return;
		} else if (isEmpty(txtPass, 'Inserisci la password')) {
			return;
		} else if (isEmpty(txtFirstName, 'Inserisci il nome')) {
			return;			
		} else if (isEmpty(txtLastName, 'Inserisci il cognome')) {
			return;
		} else if (isEmpty(txtCodFisc, 'Inserisci il codice fiscale')) {
			return;			
		} else if (isEmpty(txtAddress1, 'Inserisci un indirizzo')) {
			return;			
		} else if (isEmpty(txtCity, 'Inserisci la cittą')) {
			return;
		} else if (isEmpty(txtAddress2, 'Inserisci la provincia')) {
			return;			
		} else if (isEmpty(txtPostalCode, 'Inserisci il CAP')) {
			return;
		} else if (isEmpty(txtEmail, 'Inserisci una email')) {
			return;			
		} else if (isEmpty(txtPhone, 'Inserisci il telefono')) {
			return;
		} else if (isEmpty(txtCell, 'Inserisci il cellulare')) {
			return;			
		} else {
			submit();
		}
	}
}

function checkModifyUserForm()
{
	with (window.document.frmModifica) {
		if (isEmpty(txtUserName, 'Inserisci il nome utente')) {
			return;
		} else if (isEmpty(txtFirstName, 'Inserisci il nome')) {
			return;			
		} else if (isEmpty(txtLastName, 'Inserisci il cognome')) {
			return;
		} else if (isEmpty(txtCodFisc, 'Inserisci il codice fiscale')) {
			return;			
		} else if (isEmpty(txtAddress1, 'Inserisci un indirizzo')) {
			return;			
		} else if (isEmpty(txtCity, 'Inserisci la cittą')) {
			return;
		} else if (isEmpty(txtAddress2, 'Inserisci la provincia')) {
			return;			
		} else if (isEmpty(txtPostalCode, 'Inserisci il CAP')) {
			return;
		} else if (isEmpty(txtEmail, 'Inserisci una email')) {
			return;			
		} else if (isEmpty(txtPhone, 'Inserisci il telefono')) {
			return;
		} else if (isEmpty(txtCell, 'Inserisci il cellulare')) {
			return;			
		} else {
			submit();
		}
	}
}


/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

/*
Make sure that textBox only contain number
*/
function checkNumber(textBox)
{
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	
	textBox.value = trim(textBox.value);
/*	if (textBox.value.length == 0) {
		textBox.value = 0;		
	} else {
		textBox.value = parseInt(textBox.value);
	}*/
}

/*
	Check if a form element is empty.
	If it is display an alert box and focus
	on the element
*/
function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}

function checkSegnala()
{
	theForm = window.document.frmSegnala;
		
	if (isEmpty(theForm.txtTuoNome, 'Inserisci il tuo nome')) {
		return;
	} else if (isEmpty(theForm.txtTuaEmail, 'Inserisci la tua email')) {
		return;
	} else if (isEmpty(theForm.txtNomeAmico, 'Inserisci il nome del tuo amico')) {
		return;
	} else if (isEmpty(theForm.txtEmailAmico, 'Inserisci la mail del tuo amico')) {
		return;		
	} else {
		theForm.submit();
	}
}

function checkContattaci()
{
	theForm = window.document.frmContattaci;
		
	if (isEmpty(theForm.txtNome, 'Inserisci il tuo nome')) {
		return;
	} else if (isEmpty(theForm.txtEmail, 'Inserisci la tua email')) {
		return;
	} else if (isEmpty(theForm.mtxTesto, 'Inserisci il testo')) {
		return;
	} else {
		theForm.submit();
	}
}


PositionX = 100;
PositionY = 100;
defaultWidth  = 820;
defaultHeight = 820;
var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}