/*  (C) 1995-2010 Nautica Editrice Srl - All rights reserved  */

if (!window.language) var language = 'italian';
if (!window.hit_count) var hit_count = 'pagineazzurre';

var MONTHS = new Array (12);
var WEEKDAYS = new Array (7);

if (language == 'english') {
	MONTHS[0] = "January";
	MONTHS[1] = "February";
	MONTHS[2] = "March";
	MONTHS[3] = "April";
	MONTHS[4] = "May";
	MONTHS[5] = "June";
	MONTHS[6] = "July";
	MONTHS[7] = "August";
	MONTHS[8] = "September";
	MONTHS[9] = "October";
	MONTHS[10] = "November";
	MONTHS[11] = "December";

	WEEKDAYS[0] = "Sunday";
	WEEKDAYS[1] = "Monday";
	WEEKDAYS[2] = "Tuesday";
	WEEKDAYS[3] = "Wednesday";
	WEEKDAYS[4] = "Thursday";
	WEEKDAYS[5] = "Friday";
	WEEKDAYS[6] = "Saturday";
}
else {
	MONTHS[0] = "Gennaio";
	MONTHS[1] = "Febbraio";
	MONTHS[2] = "Marzo";
	MONTHS[3] = "Aprile";
	MONTHS[4] = "Maggio";
	MONTHS[5] = "Giugno";
	MONTHS[6] = "Luglio";
	MONTHS[7] = "Agosto";
	MONTHS[8] = "Settembre";
	MONTHS[9] = "Ottobre";
	MONTHS[10] = "Novembre";
	MONTHS[11] = "Dicembre";

	WEEKDAYS[0] = "Domenica";
	WEEKDAYS[1] = "Lunedi";
	WEEKDAYS[2] = "Martedi";
	WEEKDAYS[3] = "Mercoledi";
	WEEKDAYS[4] = "Giovedi";
	WEEKDAYS[5] = "Venerdi";
	WEEKDAYS[6] = "Sabato";
}

function startClock () {
	if (!document.getElementById ('clock')) return;
	var now = new Date ();
	var y = now.getFullYear ();
	var m = zeroPad (now.getMonth ());
	var d = zeroPad (now.getDate ());
	var h = zeroPad (now.getHours ());
	var i = zeroPad (now.getMinutes ());
	var s = zeroPad (now.getSeconds ());
	document.getElementById ('clock').innerHTML = y + '/' + m + '/' + d + ' ' + h + ':' + i + ':' + s;
	t = setTimeout ('startClock()', 500);
}

function displayClock () {
	if (!document.getElementById ('clock')) return;
	var now = new Date ();
	var y = now.getFullYear ();
	var m = MONTHS[now.getMonth ()];
	var d = now.getDate ();
	var w = WEEKDAYS[now.getDay ()];
	var h = zeroPad (now.getHours ());
	var i = zeroPad (now.getMinutes ());
	var s = zeroPad (now.getSeconds ());
	var z = zeroPad (Math.abs (now.getTimezoneOffset () / 60));
	document.getElementById ('clock').innerHTML = w + ', ' + d + ' ' + m + ' '+ y + ' ' + h + ':' + i + ':' + s + ' GMT +' + z + '00';
	t = setTimeout ('displayClock()', 500);
}

function zeroPad (n) {
	return (n < 10) ? '0' + n : n;
}

function randomnumber (start, total) {
	return Math.round (Math.random() * (total - 1) + start);
}

function sleep (msec) {
	var now = new Date ();
	var timeout = now.getTime () + msec;
	do {
		now = new Date ();
	}
	while (now.getTime () < timeout);
	return timeout;
}

function trackLink (link) {
	if (!document.images) return true;
	if (!document.getElementById ("trackout")) return true;
	var uri = link.name;
	if (!uri.length) {
		uri = link.href;
		uri = uri.replace ("http://", "");
		uri = uri.split ("/", 1);
	}
	uri = "/nol/track.php?" + uri + "_" + hit_count + "_" + Math.random ();
	document.getElementById ("trackout").src = uri;
	sleep (500);
	return true;
}


function tooltip (elementID, txt) {
	return document.all ? document.all[elementID].innerHTML = txt : document.getElementById (elementID).innerHTML = txt;
}



function mouse_over (elementID) {
	var obj = document.all ? document.all[elementID] : document.getElementById (elementID);
	if (obj) {
		obj.style.color = '#FFFFFF';
		obj.style.background = '#99CCFF';
		return true;
	}
	return false;
}



function mouse_out (elementID) {
	var obj = document.all ? document.all[elementID] : document.getElementById (elementID);
	if (obj) {
		obj.style.color = '#3366CC';
		obj.style.background = '#FFFFFF';
		return true;
	}
	return false;
}



function today () {
	var now = new Date();
	var year = now.getYear();
	var month = now.getMonth() + 1;
	var day = now.getDate();
	var hour = now.getHours();
	var minute = now.getMinutes();
	var second = now.getSeconds()
	var output = (year < 1900) ? (year + 1900) + "/" : year + "/";
	output += (month < 10) ? "0" + month + "/" : month + "/";
	output += (day < 10) ? "0" + day + " " : day + " ";
	output += (hour < 10) ? "0" + hour + ":" : hour + ":";
	output += (minute < 10) ? "0" + minute + ":" : minute + ":";
	output += (second < 10) ? "0" + second : second;
	return output;
}



function reference () {
	var now = new Date();
	var year = now.getYear(); 
	var month = now.getMonth() + 1;
	var day = now.getDate();
	var hour = now.getHours();
	var minute = now.getMinutes();
	var second = now.getSeconds()
	year = (year > 1900) ? year - 2000 : year;
	year = (year > 99) ? year - 100 : year;
	var output = (year <10) ? "0" + year : year;
	output += (month < 10) ? "0" + month : month;
	output += (day < 10) ? "0" + day  : day;
	output += (hour < 10) ? "0" + hour : hour;
	output += (minute < 10) ? "0" + minute : minute;
	output += (second < 10) ? "0" + second : second;
	return output;
}



function emailaddress (mailbox, domain, tld) {
	return mailbox + unescape ('%40') + domain + unescape ('%2E') + tld;
}



function mailto (mailbox, domain, tld, refid, anchor) {
	var email = emailaddress (mailbox, domain, tld);
	if (!refid.length) {
		var subject = "Pagine Azzurre Online";
	}
	else {
		var subject = "Pagine Azzurre Online ref. " + refid;
	}
	document.write ('<a href=\"mailto:' + email + '?subject=' + subject + '\">'); 
	if (anchor.length > 0) {
		document.write (anchor + '</a>');
	}
	else {
		document.write (email + '</a>');
	}
}



function randomnumber (start, total) {
	return Math.round (Math.random() * (total - 1) + start);
}



function disabletext () {
	if (document.all) {
		document.onselectstart = function () { return false; };
	}
	else {
		document.onmousedown = function () { return false; };
	}
}



function radio_value (theRadio) {
	var n_buttons = theRadio.length;
	if (n_buttons) {
		for (var i = 0; i < n_buttons; i++) {
			if (theRadio[i].checked) return theRadio[i].value;
		}
	}
	else if (theRadio.checked) return theRadio.value;
	return null;
}



function pop_show (parent, child) {

	if (pop_offset == undefined) var pop_offset = 4;

	var P = document.getElementById (parent);
	var C = document.getElementById (child);

	var top  = (C['pop_display'] == 'bottom') ? P.offsetHeight + pop_offset : 0;
	var left = (C['pop_display'] == 'right') ? P.offsetWidth + pop_offset : 0;

	for (; P; P = P.offsetParent) {
		top += P.offsetTop;
		left += P.offsetLeft;
	}

	C.style.top = top + 'px';
	C.style.left = left + 'px';
	C.style.position = 'absolute';
	C.style.visibility = 'visible';
}



function pop_on () {
	P = document.getElementById (this['pop_parent']);
	C = document.getElementById (this['pop_child' ]);
	pop_show (P.id, C.id);
	clearTimeout (C['pop_timeout']);
}



function pop_off () {
	if (pop_delay == undefined) var pop_delay = 60;
	C = document.getElementById (this['pop_child']);
	C['pop_timeout'] = setTimeout ("document.getElementById ('" + C.id + "').style.visibility = 'hidden'", pop_delay);
}



function pop_click () {
	P = document.getElementById (this['pop_parent']);
	C = document.getElementById (this['pop_child']);
	if (C.style.visibility != 'visible') {
		pop_show (P.id, C.id);
	}
	else {
		C.style.visibility = 'hidden';
	}
	return false;
}



function pop_up (parent, child, display, mode, cursor) {

	if (display == undefined) var display = 'bottom';	//  'bottom' or 'right'
	if (mode == undefined) var mode = 'hover';		//  'hover' or 'click'
	if (cursor == undefined) var cursor = 'pointer';	//  CSS cursor type

	P = document.getElementById (parent);
	C = document.getElementById (child);

	P['pop_parent']  = P.id;
	C['pop_parent']  = P.id;
	P['pop_child']   = C.id;
	C['pop_child']   = C.id;
	P['pop_display'] = display;
	C['pop_display'] = display;

	P.style.cursor = cursor;
	C.style.position = 'absolute';
	C.style.visibility = 'hidden';

	if (mode == 'click') {
		P.onclick     = pop_click;
		P.onmouseout  = pop_off;
		C.onmouseover = pop_on;
		C.onmouseout  = pop_off;
	}
	else {
		P.onmouseover = pop_on;
		P.onmouseout  = pop_off;
		C.onmouseover = pop_on;
		C.onmouseout  = pop_off;
	}

}

window.onload = function () {
	displayClock ();
}


