// JavaScript Document
<!--opens and centers new window automatically

<!-- 

var w = 517, h = 365;

if (document.all || document.layers) {
   w = screen.availWidth;
   h = screen.availHeight;
}

var popW = 517, popH = 365;

var leftPos = (w-popW)/2, topPos = (h-popH)/2;
       
function launchWindow(launchURL, cprodotto, name) {
	if( cprodotto != '' )
	{
		aggiungiAlCarrello(cprodotto);
	}
	window.open(launchURL,name,'width=517,height=365,top=' + topPos + ',left=' + leftPos + ',screenX=5,screeny=5,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
}
function closewindow()
{
	window.close();
}


var nomeCookie='carrello';
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	//alert(document.cookie);
	
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		
		var pos = document.cookie.indexOf(" ", i);
		if(pos<0)
			pos=document.cookie.indexOf(";", i);
		if(pos<0)
			break;
		i = pos + 1;
	}
	
	//alert("GetCookie return null");
	return null;
}

function SetCookie (name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	
	
	//var path = (argc > 3) ? argv[3] : null;
	//var domain = (argc > 4) ? argv[4] : null;
	//var secure = (argc > 5) ? argv[5] : false;
	var path ="/";
	var domain =null;
	var secure=false;
	
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

function DeleteCookie(name) {
	var exp = new Date();
	FixCookieDate (exp); 
	exp.setTime (exp.getTime() - 1); 
	var cval = GetCookie (name);
	if (cval != null)
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function settaIlCarrello(oggetto) {
	var thenewdate = new Date ();
	thenewdate.setTime(thenewdate.getTime() + (365 * 24 * 3600 * 1000));
	SetCookie(nomeCookie,oggetto,thenewdate); 
}

//-->

<!-- end open window script -->
