function reload_menu(catx,query,codx) {
//	alert('reload_menu');
// 	top.document.getElementById('menuframe').src = 'navmenu.php?catx=' + catx + '&amp;query=' + query; 
	if (codx == '') {
		top.frames['menuframe'].location.replace( '../navmenu.php?catx=' + catx + '&amp;query=' + query); 
	}
//  	top.frames['menuframe'].location.reload(true);  		
}

function reload_novita(dnov) {
	if (dnov != '') {
		top.frames['menuframe'].location.replace( '../novmenu.php'); 
	}
}

function addorder(frm,cod,k,allqta,allprz,descr,host) {
	qta_sel = frm.qta.value;
	if (qta_sel < 1) {
		alert('Quantity must be greater than 0');
		return false;
	}
	prz_sel = 0;
 	qta = allqta.split('|');
	prz = allprz.split('|');
  	n = prz.push(9999999);
	n = qta.push(9999999);	

 	for (j = n-1; j > -1 ; j--) {
		prz_sel = prz[j];
		if (parseInt(qta_sel) >= parseInt(qta[j]))  {
			break;
		} 
	} 
	prz_tot = (qta_sel * prz_sel);
	s = 'addtocart.php?ord=' + escape(cod + '|' + descr + '|' + qta_sel + '|' + prz_sel);
	s = s + '&allqta=' + escape(allqta); 
	s = s + '&allprz=' + escape(allprz); 
	if (window.opener && !window.opener.closed) {
		xhr_request(s,host);
		mycart = window.opener.top.document.getElementById('icocart');
		mycart.src = 'img_sito/ICO_carrello-pieno.gif';
	} else {
		top.xhr_request(s,host);
		top.cartfull();
	}
	if (window.opener && !window.opener.closed) {
//		window.close();
	}
	return false;
}

function toDollarsAndCents(n) {
	var s = "" + Math.round(n * 100) / 100
	var i = s.indexOf('.')
	if (i < 0) return s + ".00"
	var t = s.substring(0, i + 1) + s.substring(i + 1, i + 3)
	if (i + 2 == s.length) t += "0"
	return t
}

var mypop;
function dopop(url,name,parms) {
// 	if (false == mypop.closed) {
// 		mypop.close();
// 	}
	wleft = 240;
	wtop = 20;
	if (parms.indexOf('width=') == -1) {
 		wleft = (screen.width - 620) / 2;
 		wtop = (screen.width - 460) / 4;
		parms=parms + ',width=620,height=460,left='+wleft+',top='+wtop;
	} else {
 		wleft = (screen.width  / 8) * 5;
 		wtop = screen.height  / 4;
		parms=parms + ',left=' + wleft +',top='+wtop ;
	}
//	parms=parms + ',left=' + wleft +',top='+wtop ;
	parms = parms +',resizable=yes';
//	alert(parms);
	mypop = window.open(url,name,parms);
}

function setCookie(NameOfCookie, value, expiredays, path, domain, secure)
{
  //the first lines in the function converts the number of days to a valid date.

  var ExpireDate = new Date();
  ExpireDate.setTime(ExpireDate.getTime() + (expiredays*24*3600*1000));

  //The next line stores the cookie, simple by assigning
  //the values to the document.cookie-object
  //Note the date is converted to Greenwich Meantime using
  //the 'toGMTstring()'-function

  document.cookie = NameOfCookie +"="+ escape(value) + 
  ((expiredays == null)? "": ";expires="+ ExpireDate.toGMTString()) +
  ((path == null)? "": (";path=" + path)) +
  ((domain == null) ? "" : (";domain=" + domain)) +
  ((secure == true) ? ";secure" : "");
}

function docook(s) {
//	alert('cook'+s);
	setCookie('DifBack',s);
}

function positionat(hash) {
      s = location.href + '#' + hash;;
	parent.infoframe.location.href = s ;
        var zot = document.getElementById(hash);
}

