<!--
	/***********************
	 * FUNZIONI MACROMEDIA *
	 ***********************/	
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

	/********************
	 * FUNZIONI WEBROOM *
	 ********************/	

	function FB_trim(chestring){
		var chestring = chestring.split(" ");
		chestring = chestring.join();
		return chestring;
	}

	function FB_isnumeric(chestring){
		if(FB_trim(chestring) == ""){
			return true;
		}
		return (chestring.match(/\d+/g));
	}

	function isInteger(s){
		var i;
		for (i = 0; i < s.length; i++){   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9")) && ((c != ".") && (c != ","))) return false;
		}
		// All characters are numbers.
		return true;
	}

	function stripCharsInBag(s, bag){
		var i;
		var returnString = "";
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
		for (i = 0; i < s.length; i++){   
			var c = s.charAt(i);
			if (bag.indexOf(c) == -1) returnString += c;
		}
		return returnString;
	}

	function daysInFebruary (year){
		// February has 29 days in any year evenly divisible by four,
		// EXCEPT for centurial years which are not also divisible by 400.
		return (((year % 4 == 0) && (((!(year % 100 == 0)) || (year % 400 == 0))))?29:28);
	}

	function DaysArray(n) {
		for (var i = 1; i <= n; i++){
			this[i] = 31;
			if (i==4 || i==6 || i==9 || i==11){
				this[i] = 30;
			}
			if (i==2){
				this[i] = 29;
			}
	   } 
	   return this;
	}

	function FB_isdata(chestring){

		if(FB_trim(chestring) == ""){
			return true;
		}
		if(chestring.length != 10){
			return false;
		}

		var dtCh= "/";
		var daysInMonth = DaysArray(12);
		var pos1=chestring.indexOf(dtCh);
		var pos2=chestring.indexOf(dtCh,pos1+1);
		var strDay=chestring.substring(0,pos1);
		var strMonth=chestring.substring(pos1+1,pos2);
		var strYear=chestring.substring(pos2+1);
		strYr=strYear;
		if (strDay.charAt(0)=="0" && strDay.length>1){
			strDay=strDay.substring(1);
		}
		if (strMonth.charAt(0)=="0" && strMonth.length>1){
			strMonth=strMonth.substring(1);
		}
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
		}
		month=parseInt(strMonth);
		day=parseInt(strDay);
		year=parseInt(strYr);
		if (pos1==-1 || pos2==-1){
			return false;
		}
		if (strMonth.length<1 || month<1 || month>12){
			return false;
		}
		if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			return false;
		}
		if (strYear.length != 4 || year==0){
			return false;
		}
		if (chestring.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(chestring, dtCh))==false){
			return false;
		}

		return true;
	}
	
	function emailCheck (emailStr) {
		if(FB_trim(emailStr) == ""){
			return true;
		}
		var checkTLD=0;
		var knownDomsPat=/ ^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|it|fr|co.uk|de)$/;
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';
		var word="(" + atom + "|" + quotedUser + ")";
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray=emailStr.match(emailPat);
		if (matchArray==null) {
			return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];
		for (i=0; i<user.length; i++) {
			if (user.charCodeAt(i)>127) {
				return false;
			}
		}
		for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i)>127) {
				return false;
			}
		}
		if (user.match(userPat)==null) {
			return false;
		}
		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) {
			for (var i=1;i<=4;i++) {
				if (IPArray>255) {
					return false;
				}
			}
			return true;
		}
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
			if (domArr[i].search(atomPat)==-1) {
				return false;
			}
		}
		if (checkTLD && domArr[domArr.length-1].length!=2 &&
			domArr[domArr.length-1].search(knownDomsPat)==-1) {
			return false;
		}
		if (len<2) {
			return false;
		}
		return true;
	}

	function FB_openBrowserWindow(cheUrl, cheName, cheWidth, cheHeight){
		cheName = window.open(cheUrl,cheName,"width=" + cheWidth + ",height=" + cheHeight + ",scrollbars=no,resizable=yes,top=10,left=10,location=0");
		cheName.resizeTo(cheWidth, cheHeight);
		cheName.focus();
	}

	function FB_changePopupSize(imgWidth,imgHeight,winWidth,winHeight){
		var wndW = (flagWndResize)?(parseInt(imgWidth)+28):winWidth;
		var wndH = (flagWndResize)?(parseInt(imgHeight)+32):winHeight;
		flagWndResize = (flagWndResize)?false:true;	
		window.resizeTo(wndW,wndH);
	}

	function FB_chooseItem(frmName,itemID, itemState){
		var cheInput = MM_findObj("item_"+itemID);
		cheInput.checked = !cheInput.checked;		
		var nowInp = document.forms[frmName].elements[cheInput.name];
		if(nowInp.length){
			for(var i=0; i<nowInp.length; i++){
				var cheCell = MM_findObj("td_"+nowInp[i].id);
				cheCell.className = ((itemState=="on") && (nowInp[i].id==("item_"+itemID)))?"selected_choice":((nowInp[i].checked)?"selected_choice":"choice");
			}
		}
		else{
			var cheCell = MM_findObj("td_"+nowInp.id);
			cheCell.className = ((itemState=="on") && (nowInp.id==("item_"+itemID)))?"selected_choice":((itemState=="on")?"selected_choice":((nowInp.checked)?"selected_choice":"choice"));	
		}
	}

	function FB_editOrder(cheUser,cheOrder, cheAction){
		var frmInProcess = document.forms["frm_ordine"];

		if(cheUser != "") frmInProcess.elements["id_user"].value = cheUser;
		if(cheOrder != "") frmInProcess.elements["id_ordine"].value = cheOrder;

		frmInProcess.action=cheAction;

		frmInProcess.submit();
	}

	function FB_deleteOrder(cheUser,cheOrder, cheAction){
		if(confirm("Procedendo, l'ordine "+cheOrder+" verrà cancellato.\n\nPremi [OK] per procedere, [Annulla] per annullare l'operazione."))
			FB_editOrder(cheUser,cheOrder, cheAction);
		else 
			return false;
	}

	function FB_CharPriceCounter(cheForm, cheField, cheLayer, chePrice){
		var frmInProcess = document.forms[cheForm].elements;
		var priceLayer = MM_findObj(cheLayer);
		var nowPrice = parseInt(frmInProcess[cheField].value.length)*chePrice;
		nowPrice = nowPrice.toFixed(2)
		priceLayer.innerHTML = nowPrice.replace(".",",");
	}
	
	function FB_shipCostCalc(cheForm, cheCountry, cheColli, cheDivPrezzo, cheFormSend, cheCountrySend, cheColliSend, chePrezzoSend){
		var frmInProcess = document.forms[cheForm].elements;
		var frmSend = document.forms[cheFormSend].elements;
		var frmCountry = frmInProcess[cheCountry].options[frmInProcess[cheCountry].selectedIndex].value;
		var frmColli = frmInProcess[cheColli].value;

		var msg = "";
		if(frmCountry == "")
			msg += "- È necessario specificare una nazione per la spedizione\n";
		if(frmColli.replace(/\s/g,"") == "")
			msg += "- È necessario specificare il numero di camicie desiderate\n";

		if(msg != ""){
			msg = "Impossibile calcolare i costi di spedizione.\nControlla i seguenti campi\n\n" + msg;
			alert(msg);
			return false;
		}

		var chePrezzo = frmCountry.substr(frmCountry.indexOf(">")+1);
		var cheColliPos = chePrezzo.indexOf("|"+frmColli+":");
		if(cheColliPos < 0){
			alert("numero di camicie non valido ("+frmColli+").\n\nPer favore inserire un quantitativo diverso");
			return false;
		}
		
		frmSend[cheCountrySend].value = frmCountry.substr(0,frmCountry.indexOf(">"));
		frmSend[cheColliSend].value = frmColli;

		chePrezzo = chePrezzo.substr(cheColliPos+2+(frmColli.length));
		chePrezzo = chePrezzo.substr(0,chePrezzo.indexOf("|"));
		chePrezzo = parseFloat(chePrezzo);
		chePrezzo = chePrezzo.toFixed(2);
		frmSend[chePrezzoSend].value = chePrezzo;

		var divPrezzo = MM_findObj(cheDivPrezzo);
		divPrezzo.innerHTML = chePrezzo+"&#8364;";

		return true;
	}

	function FB_payOrdine(cheForm, cheFormPP){
		var wndFormPP = window.open('about:blank','wndFormPP','width=800, height=600, top=10, left=10, scrollbars=yes');
		document.forms[cheFormPP].submit();
		wndFormPP.focus();
		document.forms[cheForm].submit();
	}

	function FB_reloadOpener(cheURL){
		if(window.opener)
			window.opener.location = cheURL;				
	}

	function FB_swapPrezzi(cheLayer){	
		var prezziLayer = MM_findObj(cheLayer);
		if(prezziLayer.style) prezziLayer = prezziLayer.style;
		prezziLayer.display = (prezziLayer.display == "block")?"none":"block";
	}

//-->