nn4=(document.layers)?true:false;
ie4=(document.all)?true:false;
ie5=navigator.appVersion.indexOf("MSIE 5")>0;

newWindow = null;
win = null;

function showDetails(src, name){
	if(window.screen){
		 aw=screen.availWidth;
		 ah=screen.availHeight;
	}else{
		 aw=800;
		 ah=600;
	}
	w=600;
	h=600;
	if(name=="w"){
		w=800;
		h=450;
	}
	settings=
	 "left=" + (aw-w)/2 + ","
	 +"top=" + (ah-h)/2 + ","
	 +"screenX=" + (aw-w)/2 + ","
	 +"screenY=" + (ah-h)/2 + ","
	 +"width=" + (w+20) + ","
	 +"height=" + (h+20) + ","
	 +"innerWidth=" + (w+20) + ","
	 +"innerHeight=" + (h+20) + ","
	 +"toolbar=no,"
	 +"location=no,"
	 +"directories=no,"
	 +"status=no,"
	 +"menubar=no,"
	 +"scrollbars=yes,"
	 +"resizable=no"
	win = window.open("", name, settings);
    win.location.href = src;
	win.focus();
}

function show(src, w, h, text){
	if(window.screen){
		 aw=screen.availWidth;
		 ah=screen.availHeight;
	}else{
		 aw=640;
		 ah=450;
	}
if(newWindow==null || newWindow.closed){
	 settings=
	 "left=" + (aw-w)/2 + ","
	 +"top=" + (ah-h)/2 + ","
	 +"screenX=" + (aw-w)/2 + ","
	 +"screenY=" + (ah-h)/2 + ","
	 +"width=" + (w+20) + ","
	 +"height=" + (h+20) + ","
	 +"innerWidth=" + (w+20) + ","
	 +"innerHeight=" + (h+20) + ","
	 +"toolbar=no,"
	 +"location=no,"
	 +"directories=no,"
	 +"status=no,"
	 +"menubar=no,"
	 +"scrollbars=no,"
	 +"resizable=no"
	newWindow = window.open("",'image',settings);
	}
	newWindow.document.open();
	newWindow.document.clear();
	newWindow.document.write(
	"<html><head><title>SPARE- "+ text +"</title>\n"
	+"<style><!--\n"
	+"body{background-repeat:no-repeat}\n"
	+"--></style>\n"
	+"</head>\n"
	+"<body rightmargin='10' bottommargin='10' marginwidth='10' marginheight='10'></body>\n"
	+"<img src=" +src+ " width="+w+" height="+h+" border='0'>\n"
	+"</html>"
	);
	newWindow.document.close();
	newWindow.focus();
}
function popup(){
		if(window.screen){
			 aw=screen.availWidth;
		}else{
			 aw=768;
		}
		document.getElementById("banner").style.top= 100;
		document.getElementById("banner").style.left= (aw-500)/2;
		var expdate = new Date();
		var visit;
		expdate.setTime(expdate.getTime() + (24 *3600 * 1000)); 
		if(!(visit = GetCookie("spare"))) visit = 0;
		visit++;
		SetCookie("spare", visit, expdate, "/", null, false);
		if(visit > 1){
			visitato = true;
			document.getElementById("banner").style.visibility = "hidden"; 
		}else{
			visitato = false;
			document.getElementById("banner").style.visibility = "visible";
		}
	
}
function closebanner(){
	 document.getElementById("banner").style.visibility = "hidden"; 
}

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;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	}
	return null;
}
function SetCookie (name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}

function ResetCounts() {
	var expdate = new Date();
	expdate.setTime(expdate.getTime() + (24* 3600 *1000)); 
	visit = 0;
	SetCookie("spare", visit, expdate , "/", null, false);
	leapto();
}
