// JavaScript Document
/* dati statici della popup del carrello */
var winShopSyles = 'scrollbars=yes,width=650,height=600';
var winShopName = 'DEHONINANE_POPACQUISTA';
var winShopAbbSyles = 'scrollbars=yes,width=650,height=600';
var winShopAbbName = 'DEHONINANE_POPABBONA';

// Apre la finestra col carrello
function openCartWindow(){
    shoppage = window.open('/shop/shop_controller.php', winShopName, winShopSyles);
    shoppage.focus();
}

function openAbbCartWindow(pars){
    shoppage = window.open('/shop_abbonamenti/carrello.php'+pars, winShopAbbName, winShopAbbSyles);
    shoppage.focus();
} //openAbbCartWindow

function replaceString(oldS,newS,fullS) {
	// Replaces oldS with newS in the string fullS
	for (var i=0; i<fullS.length; i++) {
		if (fullS.substring(i,i+oldS.length) == oldS) {
			fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length);
			i += newS.length;
		}
	}
	return fullS;
} // replaceString



// scrive la form per l'acquisto direttamente nella popup ed al termine del caricamento fa il submit;
// in questo modo si evitano le corse critiche
// OBSOLETA nel carrello non popup
function addItemInCart2(codice, titolo, euro, peso) {
	//alert(titolo);

    shoppage = window.open('', winShopName, winShopSyles);
	titolo = replaceString("&","&amp;",titolo); // ariQuoto l'ampersand
    shoppage.document.open();
	shoppage.document.writeln("<html><body onLoad='document.forms[\"AddTheItem\"].submit();'>");
	shoppage.document.writeln("<form name='AddTheItem' method='post' action='/shop/shop_controller.php'>");
	//shoppage.document.writeln("<!--input type='submit' name='submit' value='submit'-->");
	shoppage.document.writeln("<input type='hidden' name='Cmd' value='Add'>");
	shoppage.document.writeln("<input type='hidden' name='ItemId' value=\""+codice+"\">");
	//document.writeln("<input type='HIDDEN' name='NextPage' value='".getSelfPage().getPrevQuery()."&openCart=1'>");
	shoppage.document.writeln("<input type='hidden' name='D_DESCRIZIONE' value=\""+titolo+"\">");
	shoppage.document.writeln("<input type='hidden' name='P_EURO' value=\""+euro+"\">");
	shoppage.document.writeln("<input type='hidden' name='P_PESO' value=\""+peso+"\">");
	shoppage.document.writeln("</form>");
	shoppage.document.writeln("</body></html>");
    shoppage.document.close();
    shoppage.focus();
} //addItemInCart2


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function zoom(imgURL,w,h) { //v2.0

	var theURL = '/php/zoom.php?IMG='+imgURL;
	var winName = '';
	var features = 'width='+w+',height='+h+', status=no';
	//alert(imgURL);
	window.open(theURL,winName,features);
} // zoom


function segnalaAmico($ean13) {
    var htmlUrl = 'cat_segnala.php?EAN13='+$ean13;
    var features = 'width=500,height=650';
    //alert(htmlUrl);
    var myWin = window.open(htmlUrl,'SEGNALA',features);
    myWin.focus();
    return(false);
} // segnalaAmico

