function checkq(id){
		if (document.getElementById("q"+id).value==""){
			alert("Per aggiungere un prodotto al carrello è necessario specificare la quantità desiderata");		
			document.getElementById("q"+id).focus()
			return false;	
		}else{
			var str = document.getElementById("q"+id).value
			if(str.match(/\D/)){
				alert("Indicare la quantità desiderata con caratteri numerici");	
				document.getElementById("q"+id).focus()
				return false;			
			}else{
				if(parseInt(document.getElementById("q"+id).value) < parseInt(document.getElementById("qminima"+id).value)){
					alert("La quantità minima acquistabile per questo prodotto è di " + document.getElementById("qminima"+id).value +" unità" );	
					document.getElementById("q"+id).value=document.getElementById("qminima"+id).value
					document.getElementById("q"+id).focus()
					return false;						
			    }else if(parseInt(document.getElementById("q"+id).value) > parseInt(document.getElementById("qmassima"+id).value)){
					alert("La quantità massima acquistabile per questo prodotto è di " + document.getElementById("qmassima"+id).value +" unità" );	
					document.getElementById("q"+id).value=document.getElementById("qmassima"+id).value
					document.getElementById("q"+id).focus()
					return false;						
			    }{					
					return true;			
				}
			}						
		}
}

function showimg(arg_img_tipo,arg_img_name, idprodotto){
		if (arg_img_name==''){
			arg_img_name= 'files/foto/' + arg_img_tipo + '.jpg'}
		else{
			var now = new Date();
			arg_img_name='files/foto/' + arg_img_name + '?t=' + now.getTime()
		}
		document.getElementById(arg_img_tipo+idprodotto).src = arg_img_name;
	}	
	
	function showimgdett(arg_img_tipo,arg_img_name, idprodotto,width,height){
		if (arg_img_name==''){
			arg_img_name= 'files/foto/' + arg_img_tipo + '.jpg'}
		else{
			var now = new Date();
			arg_img_name='files/foto/' + arg_img_name + '?t=' + now.getTime()
		}
		document.getElementById(arg_img_tipo+idprodotto).src = arg_img_name;
		document.getElementById(arg_img_tipo+idprodotto).width = width;
		document.getElementById(arg_img_tipo+idprodotto).height = height;
	}	
	

	
	function showbanner(arg_img_tipo,arg_img_name, idprodotto){
		if (arg_img_name==''){
			arg_img_name= 'files/banners/' + arg_img_tipo + '.gif'}
		else{
			var now = new Date();
			arg_img_name='files/banners/' + arg_img_name + '?t=' + now.getTime()
		}
		document.getElementById(arg_img_tipo+idprodotto).src = arg_img_name;
	}	
	
function openwin(url, name, attr) {	
		window.open(url, name, attr)
	}
	
	

	
	
	function URLEncode(arg)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = arg
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	
	return encoded;
};


    function goToUrl(arg, id, idc)
    {
        if(arg!="")
        {             
           location.href= "spot_count.asp?s=" + URLEncode(arg) 
        }
        else
        {                
           location.href="dettaglio_prodotto.asp?id=" + id + "&idc=" +idc    
        }    
    }
	



