var ie4 = false; if(document.all) { ie4 = true; }
function getObject(id) { if (ie4) { return document.all[id]; } else { return document.getElementById(id); } }

if (readCookie('properties')){ 
	gg_strCookie = readCookie('properties').split("-");
	gg_strLang	= gg_strCookie[0];
}else{ 
	createCookie('properties','IT',2);
	gg_strLang	= 'IT';
}

function BrowserDetectLite() {
	var ua = navigator.userAgent.toLowerCase(); 
	this.ua = ua;

	// browser name
	this.isGecko     = (ua.indexOf('gecko') != -1);
	this.isMozilla   = (this.isGecko && ua.indexOf("gecko/") + 14 == ua.length);
	this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
	this.isIE        = ( (ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1) ); 
	this.isOpera     = (ua.indexOf("opera") != -1); 
	this.isFirefox     = (ua.indexOf("firefox") != -1); 
	this.isKonqueror = (ua.indexOf("konqueror") != -1); 
	this.isIcab      = (ua.indexOf("icab") != -1); 
	this.isAol       = (ua.indexOf("aol") != -1); 
	this.isWebtv     = (ua.indexOf("webtv") != -1); 
	this.isOmniweb   = (ua.indexOf("omniweb") != -1);
	this.isDreamcast   = (ua.indexOf("dreamcast") != -1);
	this.isSafari   	= (ua.indexOf("safari") != -1);
	
	// spoofing and compatible browsers
	this.isIECompatible = ( (ua.indexOf("msie") != -1) && !this.isIE);
	this.isNSCompatible = ( (ua.indexOf("mozilla") != -1) && !this.isNS && !this.isMozilla);
	
	// browser version
	this.versionMinor = parseFloat(navigator.appVersion); 
	
	// correct version number for NS6+ 
	if (this.isNS && this.isGecko) {
		this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
	}
	
	// correct version number for IE4+ 
	else if (this.isIE && this.versionMinor >= 4) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
	}
	
	// correct version number for Opera 
	else if (this.isOpera) {
		if (ua.indexOf('opera/') != -1) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
		}
		else {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
		}
	}
	
	// correct version number for Konqueror
	else if (this.isKonqueror) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
	}
	
	// correct version number for iCab 
	else if (this.isIcab) {
		if (ua.indexOf('icab/') != -1) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
		}
		else {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
		}
	}
	
	// correct version number for WebTV
	else if (this.isWebtv) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('webtv/') + 6 ) );
	}
	
	this.versionMajor = parseInt(this.versionMinor); 
	this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
	
	// platform
	this.isWin   = (ua.indexOf('win') != -1);
	this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1) );
	this.isMac   = (ua.indexOf('mac') != -1);
	this.isUnix  = (ua.indexOf('unix') != -1 || ua.indexOf('linux') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1);
	
	// specific browser shortcuts
	this.isNS4x = (this.isNS && this.versionMajor == 4);
	this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
	this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
	this.isNS4up = (this.isNS && this.versionMinor >= 4);
	this.isNS6x = (this.isNS && this.versionMajor == 6);
	this.isNS6up = (this.isNS && this.versionMajor >= 6);
	
	this.isIE4x = (this.isIE && this.versionMajor == 4);
	this.isIE4up = (this.isIE && this.versionMajor >= 4);
	this.isIE5x = (this.isIE && this.versionMajor == 5);
	this.isIE55 = (this.isIE && this.versionMinor == 5.5);
	this.isIE5up = (this.isIE && this.versionMajor >= 5);
	this.isIE6x = (this.isIE && this.versionMajor == 6);
	this.isIE6up = (this.isIE && this.versionMajor >= 6);
	
	this.isIE4xMac = (this.isIE4x && this.isMac);
		
}
var browser = new BrowserDetectLite();

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
 	for (var i=0; i<anchors.length; i++) {
  	var anchor = anchors[i];
   	if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}

function setLanguage(pp_strLang) {
	var ll_strAppo;
	var ll_strCurrUrl = window.location + '';
	var ll_strNewUrl	= ll_strCurrUrl;
	
	if (ll_strCurrUrl.indexOf('asp') == -1)
		ll_strNewUrl = ll_strCurrUrl + 'default.asp';
	else if (ll_strCurrUrl.indexOf('index.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('index.asp','default.asp');
	else if (ll_strCurrUrl.indexOf('default.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('default.asp','index.asp');
	else if (ll_strCurrUrl.indexOf('novita.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('novita.asp','news.asp');
	else if (ll_strCurrUrl.indexOf('news.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('news.asp','novita.asp');
	else if (ll_strCurrUrl.indexOf('novita_dettaglio.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('novita_dettaglio.asp','news_detail.asp');
	else if (ll_strCurrUrl.indexOf('news_detail.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('news_detail.asp','novita_dettaglio.asp');
	else if (ll_strCurrUrl.indexOf('benedettini_subiaco.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('benedettini_subiaco.asp','benedectines_subiaco.asp');
	else if (ll_strCurrUrl.indexOf('benedectines_subiaco.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('benedectines_subiaco.asp','benedettini_subiaco.asp');
	else if (ll_strCurrUrl.indexOf('benedettini_europa.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('benedettini_europa.asp','benedectines_europe.asp');
	else if (ll_strCurrUrl.indexOf('benedectines_europe.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('benedectines_europe.asp','benedettini_europa.asp');
	else if (ll_strCurrUrl.indexOf('benedettini_sudamerica.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('benedettini_sudamerica.asp','benedectines_samerica.asp');
	else if (ll_strCurrUrl.indexOf('benedectines_samerica.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('benedectines_samerica.asp','benedettini_sudamerica.asp');		
	else if (ll_strCurrUrl.indexOf('benedettini_nordamerica.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('benedettini_nordamerica.asp','benedectines_namerica.asp');
	else if (ll_strCurrUrl.indexOf('benedectines_namerica.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('benedectines_namerica.asp','benedettini_nordamerica.asp');
	else if (ll_strCurrUrl.indexOf('san_benedetto.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('san_benedetto.asp','saint_benedict.asp');
	else if (ll_strCurrUrl.indexOf('saint_benedict.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('saint_benedict.asp','san_benedetto.asp');

	else if (ll_strCurrUrl.indexOf('mondo_legenda.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('mondo_legenda.asp','world_leggenda.asp');
	else if (ll_strCurrUrl.indexOf('world_leggenda.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('world_leggenda.asp','mondo_legenda.asp');
	else if (ll_strCurrUrl.indexOf('mondo_africa.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('mondo_africa.asp','world_africa.asp');
	else if (ll_strCurrUrl.indexOf('world_africa.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('world_africa.asp','mondo_africa.asp');
	else if (ll_strCurrUrl.indexOf('mondo_nordamerica.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('mondo_nordamerica.asp','world_northamerica.asp');
	else if (ll_strCurrUrl.indexOf('world_northamerica.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('world_northamerica.asp','mondo_nordamerica.asp');
	else if (ll_strCurrUrl.indexOf('mondo_centroamerica.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('mondo_centroamerica.asp','world_centralamerica.asp');
	else if (ll_strCurrUrl.indexOf('world_centralamerica.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('world_centralamerica.asp','mondo_centroamerica.asp');
	else if (ll_strCurrUrl.indexOf('mondo_sudamerica.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('mondo_sudamerica.asp','world_southamerica.asp');
	else if (ll_strCurrUrl.indexOf('world_southamerica.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('world_southamerica.asp','mondo_sudamerica.asp');
	else if (ll_strCurrUrl.indexOf('mondo_asia.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('mondo_asia.asp','world_asia.asp');
	else if (ll_strCurrUrl.indexOf('world_asia.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('world_asia.asp','mondo_asia.asp');
	else if (ll_strCurrUrl.indexOf('mondo_europa.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('mondo_europa.asp','world_europe.asp');
	else if (ll_strCurrUrl.indexOf('world_europe.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('world_europe.asp','mondo_europa.asp');
	else if (ll_strCurrUrl.indexOf('mondo_pacifico.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('mondo_pacifico.asp','world_pacific.asp');
	else if (ll_strCurrUrl.indexOf('world_pacific.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('world_pacific.asp','mondo_pacifico.asp');
	else if (ll_strCurrUrl.indexOf('monasteri_storia.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('monasteri_storia.asp','monasteries_history.asp');
	else if (ll_strCurrUrl.indexOf('monasteries_history.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('monasteries_history.asp','monasteri_storia.asp');
	else if (ll_strCurrUrl.indexOf('monastero_santascolastica.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('monastero_santascolastica.asp','monastery_stscholastica.asp');
	else if (ll_strCurrUrl.indexOf('monastery_stscholastica.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('monastery_stscholastica.asp','monastero_santascolastica.asp');
	else if (ll_strCurrUrl.indexOf('monastero_sanbenedetto.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('monastero_sanbenedetto.asp','monastery_stbenedict.asp');
	else if (ll_strCurrUrl.indexOf('monastery_stbenedict.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('monastery_stbenedict.asp','monastero_sanbenedetto.asp');
	else if (ll_strCurrUrl.indexOf('biblioteca.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('biblioteca.asp','library.asp');
	else if (ll_strCurrUrl.indexOf('library.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('library.asp','biblioteca.asp');
	else if (ll_strCurrUrl.indexOf('museo.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('museo.asp','museum.asp');
	else if (ll_strCurrUrl.indexOf('museum.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('museum.asp','museo.asp');
	else if (ll_strCurrUrl.indexOf('monastero_notizie.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('monastero_notizie.asp','monasteries_information.asp');
	else if (ll_strCurrUrl.indexOf('monasteries_information.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('monasteries_information.asp','monastero_notizie.asp');
	else if (ll_strCurrUrl.indexOf('ospitalita.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('ospitalita.asp','hospitality.asp');
	else if (ll_strCurrUrl.indexOf('hospitality.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('hospitality.asp','ospitalita.asp');
	else if (ll_strCurrUrl.indexOf('ospitalita_prezzi.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('ospitalita_prezzi.asp','hospitality_prices.asp');
	else if (ll_strCurrUrl.indexOf('hospitality_prices.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('hospitality_prices.asp','ospitalita_prezzi.asp');
	else if (ll_strCurrUrl.indexOf('ospitalita_arrivare.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('ospitalita_arrivare.asp','hospitality_reach.asp');
	else if (ll_strCurrUrl.indexOf('hospitality_reach.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('hospitality_reach.asp','ospitalita_arrivare.asp');
	else if (ll_strCurrUrl.indexOf('ospitalita_offerte.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('ospitalita_offerte.asp','hospitality_offers.asp');
	else if (ll_strCurrUrl.indexOf('hospitality_offers.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('hospitality_offers.asp','ospitalita_offerte.asp');
	else if (ll_strCurrUrl.indexOf('prodotti.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('prodotti.asp','products.asp');
	else if (ll_strCurrUrl.indexOf('products.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('products.asp','prodotti.asp');
	else if (ll_strCurrUrl.indexOf('prodotto_dettaglio.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('prodotto_dettaglio.asp','product_detail.asp');
	else if (ll_strCurrUrl.indexOf('product_detail.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('product_detail.asp','prodotto_dettaglio.asp');
	else if (ll_strCurrUrl.indexOf('prodotti_carrello.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('prodotti_carrello.asp','products_cart.asp');
	else if (ll_strCurrUrl.indexOf('products_cart.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('products_cart.asp','prodotti_carrello.asp');
	else if (ll_strCurrUrl.indexOf('contatti.asp') >= 0)
			ll_strNewUrl = ll_strCurrUrl.replace('contatti.asp','contacts.asp');
	else if (ll_strCurrUrl.indexOf('contacts.asp') >= 0)
		ll_strNewUrl = ll_strCurrUrl.replace('contacts.asp','contatti.asp');
	window.location = ll_strNewUrl;					
	
}

function SetSubmenuOver(pp_strId1,pp_strId2){
	getObject(pp_strId1).className = getObject(pp_strId1).className + ' over';
	getObject(pp_strId2).className = getObject(pp_strId2).className + ' over';
}
function SetSubmenuOut(pp_strId1,pp_strId2){

	getObject(pp_strId1).className = getObject(pp_strId1).className.replace(' over','');
	getObject(pp_strId1).className = getObject(pp_strId1).className.replace('over','');

	getObject(pp_strId2).className = getObject(pp_strId2).className.replace(' over','');
	getObject(pp_strId2).className = getObject(pp_strId2).className.replace('over','');
}


function setImgDim(pp_objThis,pp_lngWidth,pp_lngHeight){

	var ll_lngHeightNew;
	var ll_lngWidthNew;
	var ll_lngHeight = pp_objThis.height;
	var ll_lngWidth = pp_objThis.width;					
	if (ll_lngWidth > pp_lngWidth){
		ll_lngHeight 	= Math.floor(ll_lngHeight * (pp_lngWidth / ll_lngWidth));		
		ll_lngWidth 	= pp_lngWidth;
	}
	if (ll_lngHeight > pp_lngHeight){
		ll_lngWidth 	= Math.floor(ll_lngWidth * (pp_lngHeight / ll_lngHeight));		
		ll_lngHeight 	= pp_lngHeight;
	}
	pp_objThis.height = ll_lngHeight;
	pp_objThis.width = ll_lngWidth;	
	pp_objThis.style.visibility = 'visible';
}

var gg_strPic 			= new Array() 

gg_strPic[0] 			= 'masthead2.jpg';
gg_strPic[1] 			= 'masthead3.jpg';
gg_strPic[2] 			= 'masthead4.jpg';
var gg_lngCurrentPic = 1;
var gg_lngMaxPic 		= 2;
var gg_strPath			= 'img/';


function preload() { 
	var tmp = null; 
   
   
   for (var j = 0; j < gg_strPic.length; j++) { 
   	tmp = gg_strPath + gg_strPic[j]; 
     	gg_strPic[j] = new Image(); 
     	gg_strPic[j].src = tmp; 
   } 
   
} 

function ChangeImage() {
	
	div1 = document.getElementById('payoffs');
//	div1.style.background = 'url(' + gg_strPic[gg_lngCurrentPic].src + ')';
	div1.style.background = 'transparent url(' + gg_strPic[gg_lngCurrentPic].src + ') 0 0 scroll no-repeat';
	div2 = document.getElementById('payoffs_img');
	div2.style.visibility = 'hidden';
	if (gg_lngCurrentPic < gg_lngMaxPic) {
		gg_lngCurrentPic = gg_lngCurrentPic + 1;
	}else{
		gg_lngCurrentPic = 0;
	}
//	div2.src = gg_strPic[gg_lngCurrentPic].src;
	setTimeout('ChangeImage1()', 3500);
	
}

function ChangeImage1() {
	div2 = document.getElementById('payoffs_img');
	div2.src = gg_strPic[gg_lngCurrentPic].src;
}	

function initImage() {

	imageId = 'payoffs_img';
	image = document.getElementById(imageId);
	setOpacity(image, 0);
	image.style.visibility = 'visible';
	fadeIn(imageId,0);
	
}
function fadeIn(objId,opacity) {

	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 5;
			setTimeout("fadeIn('"+objId+"',"+opacity+")", 50);
		}else{
			ChangeImage();
			setTimeout('initImage()', 3500);
		}
	}
	
}
function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}


function runSlideShow(){
   if (document.all){
      document.images.payoffs_img.style.zindex = "-1";
      document.images.payoffs_img.style.filter="blendTrans(duration=2)";
      document.images.payoffs_img.style.filter="blendTrans(duration=1)";
      document.images.payoffs_img.filters.blendTrans.Apply();
   }
   document.images.payoffs_img.src = gg_strPic[gg_lngCurrentPic].src
   if (document.all){
      
      document.images.payoffs_img.filters.blendTrans.Play()      
   }
	if (gg_lngCurrentPic < gg_lngMaxPic) {
		gg_lngCurrentPic = gg_lngCurrentPic + 1;
	}else{
		gg_lngCurrentPic = 0;
	}
   t = setTimeout('runSlideShow()', 4000)
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function forceNumericValueBasket(pp_objThis) {

	var ll_strValidchars = '0123456789';
	var ll_lngIndex = parseInt(pp_objThis.id.substring(3));

	var ll_strNewValue;
	ll_strNewValue = '';
	for (var i=0;i<pp_objThis.value.length;i++) {
		if (ll_strValidchars.indexOf(pp_objThis.value.charAt(i)) != -1)
			ll_strNewValue = ll_strNewValue + pp_objThis.value.charAt(i);
	}	
	
	pp_objThis.value = ll_strNewValue;
}

function checkQtaNotZero(pp_objThis) {

	if ((pp_objThis.value == '') || (parseInt(pp_objThis.value) == 0))
		pp_objThis.value = '1'
	
}
function setDefaultValue(pp_objThis) {

	if ((pp_objThis.value == '') || (parseInt(pp_objThis.value) == 0))
		pp_objThis.value = pp_objThis.alt;
	
}


function addToBasket(){
	var ll_lngNumArtBuy;
	var ll_dblTotBuy;
	var ll_strAppo;
	var ll_lngCont;
	
	var ll_dblProdPrice;
	var ll_lngProdQta;
	var ll_lngProdId;
	var ll_dblProdPriceTot;
	
	var ll_dblProdPriceOld;
	var ll_lngProdQtaOld;
	var ll_dblProdPriceTotOld;

	var ll_bolIsInBasket	= false;
	var ll_arrCookie 			= new Array();
	var ll_arrProd				= new Array();

	ll_lngNumArtBuy			= 0;
	ll_dblTotBuy				= 0;
		
	ll_strAppo = getObject('prod_price').innerHTML;
	ll_strAppo = ll_strAppo.replace('€ ',"");
	if (gg_strLang == "IT") {
		ll_strAppo = ll_strAppo.replace(".","");
		ll_strAppo = ll_strAppo.replace(",",".");
	}else{
		ll_strAppo = ll_strAppo.replace(",","");
	}	
	ll_dblProdPrice 		= parseFloat(ll_strAppo).toFixed(2);
	ll_lngProdQta				= parseInt(getObject('prod_qty').value);
	ll_lngProdId				= parseInt(getObject('prod_ident').value);
	ll_dblProdPriceTot	= parseFloat(ll_dblProdPrice*ll_lngProdQta).toFixed(2);

	if (readCookie('benedettinibasket')){
		ll_arrCookie 			= readCookie('benedettinibasket').split('-');
		ll_lngNumArtBuy 	=	parseInt(ll_arrCookie.shift());
		ll_dblTotBuy			= parseFloat(ll_arrCookie.shift()).toFixed(2);
		ll_lngCont = 0;
		while ((ll_lngCont < ll_arrCookie.length) && (!ll_bolIsInBasket)) {
			ll_arrProd = ll_arrCookie[ll_lngCont].split(',');
			if (ll_lngProdId == parseInt(ll_arrProd[0])){
				ll_lngProdQtaOld 			= parseInt(ll_arrProd[1]);
				ll_dblProdPriceTotOld	= parseFloat(ll_dblProdPrice*ll_lngProdQtaOld).toFixed(2);
				ll_lngNumArtBuy 	=	parseInt(ll_lngNumArtBuy - ll_lngProdQtaOld);
				ll_dblTotBuy			= (parseFloat(ll_dblTotBuy) - parseFloat(ll_dblProdPriceTotOld)).toFixed(2);
				ll_arrCookie.splice(ll_lngCont,1);
				ll_bolIsInBasket = true;
			}
			ll_lngCont = ll_lngCont + 1;
		}		
	}	
	ll_arrCookie[ll_arrCookie.length] = ll_lngProdId + ',' + ll_lngProdQta;	
	ll_lngNumArtBuy 	=	parseInt(ll_lngNumArtBuy + ll_lngProdQta);
	ll_dblTotBuy			= (parseFloat(ll_dblTotBuy) + parseFloat(ll_dblProdPriceTot)).toFixed(2);

	createCookie('benedettinibasket',ll_lngNumArtBuy + '-' + ll_dblTotBuy + '-' + ll_arrCookie.join('-'),2);
	
	if (gg_strLang == 'IT')
		window.location = 'prodotti_carrello.asp';
	else
		window.location = 'products_cart.asp';
	
}

function removeFromBasket(pp_lngProdIndex) { 

	var ll_lngNumArtBuy;
	var ll_dblTotBuy;
	var ll_strAppo;
	var ll_lngCont;
	
	var ll_dblProdPrice;
	var ll_lngProdQta;
	var ll_lngProdId;
	var ll_dblProdPriceTot;
	
	var ll_dblProdPriceOld;
	var ll_lngProdQtaOld;
	var ll_dblProdPriceTotOld;

	var ll_bolIsInBasket	= false;
	var ll_arrCookie 			= new Array();
	var ll_arrProd				= new Array();

	ll_lngNumArtBuy			= 0;
	ll_dblTotBuy				= 0;
		
	ll_strAppo = getObject('price' + pp_lngProdIndex).innerHTML;
	ll_strAppo = ll_strAppo.replace('€ ',"");
	if (gg_strLang == "IT") {
		ll_strAppo = ll_strAppo.replace(".","");
		ll_strAppo = ll_strAppo.replace(",",".");
	}else{
		ll_strAppo = ll_strAppo.replace(",","");
	}	
	ll_dblProdPrice 		= parseFloat(ll_strAppo).toFixed(2);
	ll_lngProdQta				= parseInt(getObject('qta' + pp_lngProdIndex).value);
	ll_lngProdId				= parseInt(getObject('prodid' + pp_lngProdIndex).value);
	ll_dblProdPriceTot	= parseFloat(ll_dblProdPrice*ll_lngProdQta).toFixed(2);

	if (readCookie('benedettinibasket')){
		ll_arrCookie 			= readCookie('benedettinibasket').split('-');
		ll_lngNumArtBuy 	=	parseInt(ll_arrCookie.shift());
		ll_dblTotBuy			= parseFloat(ll_arrCookie.shift()).toFixed(2);
		ll_lngCont = 0;
		while ((ll_lngCont < ll_arrCookie.length) && (!ll_bolIsInBasket)) {
			ll_arrProd = ll_arrCookie[ll_lngCont].split(',');
			if (ll_lngProdId == parseInt(ll_arrProd[0])){
				ll_lngProdQtaOld 			= parseInt(ll_arrProd[1]);
				ll_dblProdPriceTotOld	= parseFloat(ll_dblProdPrice*ll_lngProdQtaOld).toFixed(2);
//				ll_lngNumArtBuy 	=	parseInt(ll_lngNumArtBuy - ll_lngProdQtaOld);
//				ll_dblTotBuy			= (parseFloat(ll_dblTotBuy) - parseFloat(ll_dblProdPriceTotOld)).toFixed(2);
				ll_arrCookie.splice(ll_lngCont,1);
				ll_bolIsInBasket = true;
			}
			ll_lngCont = ll_lngCont + 1;
		}		
	}	

	if (ll_arrCookie.length == 0)
		createCookie('benedettinibasket','',2);
	else		
		createCookie('benedettinibasket',ll_lngNumArtBuy + '-' + ll_dblTotBuy + '-' + ll_arrCookie.join('-'),2);

	if (gg_strLang == 'IT')
		window.location = 'prodotti_carrello.asp';
	else
		window.location = 'products_cart.asp';

}

function updateBasket() { 

	var ll_lngNumArtBuy;
	var ll_dblTotBuy;
	var ll_strAppo;
	var ll_lngCont;
	
	var ll_dblProdPrice;
	var ll_lngProdQta;
	var ll_lngProdId;
	var ll_dblProdPriceTot;
	
	var ll_dblProdPriceOld;
	var ll_lngProdQtaOld;
	var ll_dblProdPriceTotOld;

	var ll_bolIsInBasket	= false;
	var ll_arrCookie 			= new Array();
	var ll_arrProd				= new Array();

	ll_lngNumArtBuy			= 0;
	ll_dblTotBuy				= 0;
	
	ll_lngCont	= 1;
	
	while (getObject('prodid' + ll_lngCont)) {
		ll_arrCookie[ll_lngCont-1] = getObject('prodid' + ll_lngCont).value + ',' + getObject('qta' + ll_lngCont).value;
		ll_lngCont = ll_lngCont + 1;
	}

	createCookie('benedettinibasket',ll_lngNumArtBuy + '-' + ll_dblTotBuy + '-' + ll_arrCookie.join('-'));

	if (gg_strLang == 'IT')
		window.location = 'prodotti_carrello.asp';
	else
		window.location = 'products_cart.asp';

}

function chkValidFormSendOrder() {
	
	
	if (getObject('firstname').value.length < 1) {
		if (gg_strLang == 'IT')
			alert('Tutti i campi sono obbligatori');
		else
			alert('All fields are mandatory');
		return false;
	}		
	
	if (getObject('lastname').value.length < 1) {
		if (gg_strLang == 'IT')
			alert('Tutti i campi sono obbligatori');
		else
			alert('All fields are mandatory');
		return false;
	}		
	if (getObject('email').value.length < 1) {
		if (gg_strLang == 'IT')
			alert('Tutti i campi sono obbligatori');
		else
			alert('All fields are mandatory');
		return false;
	}		
	
	if (!indirizzoEmailValido(getObject('email').value)) {
		if (gg_strLang == 'IT')
			alert('Inserire un indirizzo mail valido.');
		else
			alert('Insert a valid email address.');
		return false;
		}		
	if (getObject('address').value.length < 1) {
		if (gg_strLang == 'IT')
			alert('Tutti i campi sono obbligatori');
		else
			alert('All fields are mandatory');
		return false;
	}		
	if (getObject('zipcode').value.length < 1) {
		if (gg_strLang == 'IT')
			alert('Tutti i campi sono obbligatori');
		else
			alert('All fields are mandatory');
		return false;
	}		
	if (getObject('city').value.length < 1) {
		if (gg_strLang == 'IT')
			alert('Tutti i campi sono obbligatori');
		else
			alert('All fields are mandatory');
		return false;
	}		
	if (getObject('prov').value.length < 1) {
		if (gg_strLang == 'IT')
			alert('Tutti i campi sono obbligatori');
		else
			alert('All fields are mandatory');
		return false;
	}		
	if (getObject('country').value.length < 1) {
		if (gg_strLang == 'IT')
			alert('Tutti i campi sono obbligatori');
		else
			alert('All fields are mandatory');
		return false;
	}		
}

function chkValidMailForm() {
	
	if (getObject('email_address').value.length < 1) {
		if (gg_strLang == 'IT')
			alert('Inserire un indirizzo mail valido');
		else
			alert('Enter a valid email address');
		return false;
	}		
		
	if (!indirizzoEmailValido(getObject('email_address').value)) {
		if (gg_strLang == 'IT')
			alert('Inserire un indirizzo mail valido.');
		else
			alert('Enter a valid email address.');
		return false;
	}		
		
	if (getObject('your_message').value.length < 1) {
		if (gg_strLang == 'IT')
			alert('Inserire il messaggio.');
		else
			alert('Enter your message');
		return false;
	}		
	
	if (getObject('captcha_img_text').value.length < 1) {
		if (gg_strLang == 'IT')
			alert('Inserire il codice antispam.');
		else
			alert('Enter the valid antispam code.');
		return false;
	}		
}




function indirizzoEmailValido(indirizzo) {
  if (window.RegExp) {
    var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    var regnv = new RegExp(nonvalido);
    var regv = new RegExp(valido);
    if (!regnv.test(indirizzo) && regv.test(indirizzo))
      return true;
    return false;
	}
  else {
    if(indirizzo.indexOf("@") >= 0)
      return true;
    return false;
  	}
  };


