/* -------------

  FSL JAVASCRIPT 

  -------------- */


/* MENU */

if ( document.images )
{
	/* MAIN MENU */

	home_on     = new Image ( 103, 35 );  home_off     = new Image ( 103, 35 );  home_sel     = new Image ( 103, 35 );
	products_on = new Image ( 103, 35 );  products_off = new Image ( 103, 35 );  products_sel = new Image ( 103, 35 );
	download_on = new Image ( 103, 35 );  download_off = new Image ( 103, 35 );  download_sel = new Image ( 103, 35 );
	donate_on   = new Image ( 103, 35 );  donate_off   = new Image ( 103, 35 );  donate_sel   = new Image ( 103, 35 );
	forum_on    = new Image ( 103, 35 );  forum_off    = new Image ( 103, 35 );  forum_sel    = new Image ( 103, 35 );
	more_on     = new Image ( 103, 35 );  more_off     = new Image ( 103, 35 );  more_sel     = new Image ( 103, 35 );

	home_on.src     = "http://www.webalice.it/guido.ts/menubar/home_on.png";      home_off.src     = "http://www.webalice.it/guido.ts/menubar/home_off.png";      home_sel.src     = "http://www.webalice.it/guido.ts/menubar/home_sel.png";
	products_on.src = "http://www.webalice.it/guido.ts/menubar/products_on.png";  products_off.src = "http://www.webalice.it/guido.ts/menubar/products_off.png";  products_sel.src = "http://www.webalice.it/guido.ts/menubar/products_sel.png";
	download_on.src = "http://www.webalice.it/guido.ts/menubar/download_on.png";  download_off.src = "http://www.webalice.it/guido.ts/menubar/download_off.png";  download_sel.src = "http://www.webalice.it/guido.ts/menubar/download_sel.png";
	donate_on.src   = "http://www.webalice.it/guido.ts/menubar/donate_on.png";    donate_off.src   = "http://www.webalice.it/guido.ts/menubar/donate_off.png";    donate_sel.src   = "http://www.webalice.it/guido.ts/menubar/donate_sel.png";
	forum_on.src    = "http://www.webalice.it/guido.ts/menubar/forum_on.png";     forum_off.src    = "http://www.webalice.it/guido.ts/menubar/forum_off.png";     forum_sel.src    = "http://www.webalice.it/guido.ts/menubar/forum_sel.png";
	more_on.src     = "http://www.webalice.it/guido.ts/menubar/more_on.png";      more_off.src     = "http://www.webalice.it/guido.ts/menubar/more_off.png";      more_sel.src     = "http://www.webalice.it/guido.ts/menubar/more_sel.png";

	/*HOME SUBMENU */
	
	welcome_on  = new Image ( 84, 16 );  welcome_off  = new Image ( 84, 16 );
	news_on     = new Image ( 50, 16 );  news_off     = new Image ( 50, 16 );
	contacts_on = new Image ( 79, 16 );  contacts_off = new Image ( 79, 16 );
	awards_on   = new Image ( 70, 16 );  awards_off   = new Image ( 70, 16 );
	site_map_on = new Image ( 79, 16 );  site_map_off = new Image ( 79, 16 );

	welcome_on.src  = "http://www.webalice.it/guido.ts/menubar/welcome_on.png";   welcome_off.src  = "http://www.webalice.it/guido.ts/menubar/welcome_off.png";
	news_on.src     = "http://www.webalice.it/guido.ts/menubar/news_on.png";      news_off.src     = "http://www.webalice.it/guido.ts/menubar/news_off.png";
	contacts_on.src = "http://www.webalice.it/guido.ts/menubar/contacts_on.png";  contacts_off.src = "http://www.webalice.it/guido.ts/menubar/contacts_off.png";
	awards_on.src   = "http://www.webalice.it/guido.ts/menubar/awards_on.png";    awards_off.src   = "http://www.webalice.it/guido.ts/menubar/awards_off.png";
	site_map_on.src = "http://www.webalice.it/guido.ts/menubar/site_map_on.png";  site_map_off.src = "http://www.webalice.it/guido.ts/menubar/site_map_off.png";

	/*PRODUCTS SUBMENU */
	
	productsb_on    = new Image (  78, 16 );  productsb_off    = new Image (  78, 16 );
	underdev_on     = new Image ( 178, 16 );  underdev_off     = new Image ( 178, 16 );
	discontinued_on = new Image ( 115, 16 );  discontinued_off = new Image ( 115, 16 );

	productsb_on.src    = "http://www.webalice.it/guido.ts/menubar/productsbtn_on.png";   productsb_off.src    = "http://www.webalice.it/guido.ts/menubar/productsbtn_off.png";
	underdev_on.src     = "http://www.webalice.it/guido.ts/menubar/underdev_on.png";      underdev_off.src     = "http://www.webalice.it/guido.ts/menubar/underdev_off.png";
	discontinued_on.src = "http://www.webalice.it/guido.ts/menubar/discontinued_on.png";  discontinued_off.src = "http://www.webalice.it/guido.ts/menubar/discontinued_off.png";

	/*DOWNLOAD SUBMENU */
	
	downloadb_on = new Image (  88, 16 );  downloadb_off = new Image (  88, 16 );
	old_on       = new Image ( 115, 16 );  old_off       = new Image ( 115, 16 );
	userlogin_on = new Image ( 103, 16 );  userlogin_off = new Image ( 103, 16 );

	downloadb_on.src = "http://www.webalice.it/guido.ts/menubar/downloadbtn_on.png";  downloadb_off.src  = "http://www.webalice.it/guido.ts/menubar/downloadbtn_off.png";
	old_on.src       = "http://www.webalice.it/guido.ts/menubar/old_on.png";          old_off.src        = "http://www.webalice.it/guido.ts/menubar/old_off.png";
	userlogin_on.src = "http://www.webalice.it/guido.ts/menubar/userlogin_on.png";    userlogin_off.src  = "http://www.webalice.it/guido.ts/menubar/userlogin_off.png";

	/*DONATE SUBMENU */
	
	donateb_on    = new Image (  63, 16 );  donateb_off    = new Image (  63, 16 );
	privileged_on = new Image ( 145, 16 );  privileged_off = new Image ( 145, 16 );

	donateb_on.src    = "http://www.webalice.it/guido.ts/menubar/donatebtn_on.png";   donateb_off.src    = "http://www.webalice.it/guido.ts/menubar/donatebtn_off.png";
	privileged_on.src = "http://www.webalice.it/guido.ts/menubar/privileged_on.png";  privileged_off.src = "http://www.webalice.it/guido.ts/menubar/privileged_off.png";

	/*FORUMS SUBMENU */
	
	blog_on   = new Image ( 93, 16 );  blog_off   = new Image ( 93, 16 );
	forumb_on = new Image ( 55, 16 );  forumb_off = new Image ( 55, 16 );

	blog_on.src   = "http://www.webalice.it/guido.ts/menubar/blog_on.png";      blog_off.src   = "http://www.webalice.it/guido.ts/menubar/blog_off.png";
	forumb_on.src = "http://www.webalice.it/guido.ts/menubar/forumbtn_on.png";  forumb_off.src = "http://www.webalice.it/guido.ts/menubar/forumbtn_off.png";

	/*FORUMS SUBMENU */
	
	paper_on    = new Image ( 119, 16 );  paper_off    = new Image ( 119, 16 );
	contests_on = new Image (  77, 16 );  contests_off = new Image (  77, 16 );
	links_on    = new Image (  46, 16 );  links_off    = new Image (  46, 16 );
	other_on    = new Image (  51, 16 );  other_off    = new Image (  51, 16 );

	paper_on.src    = "http://www.webalice.it/guido.ts/menubar/paper_on.png";     paper_off.src    = "http://www.webalice.it/guido.ts/menubar/paper_off.png";
	contests_on.src = "http://www.webalice.it/guido.ts/menubar/contests_on.png";  contests_off.src = "http://www.webalice.it/guido.ts/menubar/contests_off.png";
	links_on.src    = "http://www.webalice.it/guido.ts/menubar/links_on.png";     links_off.src    = "http://www.webalice.it/guido.ts/menubar/links_off.png";
	other_on.src    = "http://www.webalice.it/guido.ts/menubar/other_on.png";     other_off.src    = "http://www.webalice.it/guido.ts/menubar/other_off.png";
}

function button_on ( imgId )
{
	if ( document.images )
	{
		butOn = eval ( imgId + "_on.src" );
		document.getElementById(imgId).src = butOn;
	}
}


function button_off ( imgId )
{
	if ( document.images )
	{
		butOff = eval ( imgId + "_off.src" );
	    document.getElementById(imgId).src = butOff;
	}
}

function button_sel ( imgId )
{
	if ( document.images )
	{
		butSel = eval ( imgId + "_sel.src" );
	    document.getElementById(imgId).src = butSel;
	}
}


/* LAST MODIFIED */

function lastMod(date) {
	var x = date || new Date (document.lastModified);
	Modif = new Date(x.toGMTString());
	Year = takeYear(Modif);
	Month = Modif.getMonth();
	Day = Modif.getDate();
	Mod = (Date.UTC(Year,Month,Day,0,0,0))/86400000;
	x = new Date();
	today = new Date(x.toGMTString());
	Year2 = takeYear(today);
	Month2 = today.getMonth();
	Day2 = today.getDate();
	now = (Date.UTC(Year2,Month2,Day2,0,0,0))/86400000;
	daysago = now - Mod;
	if (daysago < 0) return '';
	unit = 'days';
	if (daysago > 730) {
		daysago = Math.floor(daysago/365);
		unit = 'years';
	}
	else if (daysago > 60) {
		daysago = Math.floor(daysago/30);
		unit = 'months';
	}
	else if (daysago > 14) {
		daysago = Math.floor(daysago/7);
		unit = 'weeks'
	}
	var towrite = '';
	if (daysago == 0) towrite += 'today';
	else if (daysago == 1) towrite += 'yesterday';
	else towrite += daysago + ' ' + unit + ' ago';
	return towrite;
}

function takeYear(theDate) {
	var x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}


