var main_host;
var img_array = new Array();
var swap_img = "";
var debug = true;

$().ready(function() {

	hReplace();

	preloadImages();

	if($.trim($('#blocco4').html()) != '') {
		openModal();
	}

	main_host = $('base').attr('href');

	log('Campi restricted: '+$('.restricted').size());
	$('.restricted').bind('keypress', function(e) {
		return restricted(e, $(this).attr('rel'));
	});

	/**
	 * Gestione degli helptip.
	 */
	$('.helptip').hover(function() { showhelptip(this);}, function () {hidehelptip()});
	$('.helptip').bind('click', function() { return false; });

	$('.newwindow').each(function() {
		$(this).attr({'title' : $(this).attr('title')+' '+getLang('base', 'NEW_WINDOW')});
	});

	$('.newwindow').bind('click', function() {
		href = $(this).attr('href');
		height = $(window).height()-30;
		width = $(window).width()-30;
		window.open(href, '', 'width='+width+',height='+height);
		return false;
	});

	$('#audiorecaptcha').bind('click', function() {
		recaptchaAudio();
		return false;
	});

	$('#textrecaptcha').bind('click', function() {
		recaptchaText();
		return false;
	});

});

$(window).load(function() {
	$('.rollover').hover(function() { rolloverimg(this) },function() { rolloutimg(this) });
});






function openModal() {
	buttons  = {};
	buttons[getLang('base', 'CLOSE')] = function() {
																								 $('#blocco4').dialog('destroy');
																							 };
	$('#blocco4').dialog({
		title: getLang('base', 'COMUNICAZIONE_IMPORTANTE'),
		modal : true,
		overlay: {
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: buttons,
		close: function(event, ui) { $('#blocco4').dialog('destroy'); },
		position: new Array('center', 20, 'center', 0) ,
		heigth: '450px',
		width: '600px'
	});
}
