

/*******************************************************************************
**
**  Metodo per eseguire la ricerca con il bottone di ricerca
**
**/

function cercaSulSito( oggetto )
{
	oggetto.form.submit();
}


/*******************************************************************************
**
**  Metodo per aprire le pop-up del modulo sondaggio.
**
**/


function openFullscreen(page) {
var yes = 1;
var no = 0;

var menubar = no;      // The File, Edit, View Menus
var scrollbars = no;   // Horizontal and vertical scrollbars
var locationbar = no;  // The location box with the site URL
var directories = no;  // the "What's New", "What Cool" links
var resizable = no;    // Can the window be resized?
var statusbar = no;    // Status bar (with "Document: Done")
var toolbar = no;      // Back, Forward, Home, Stop toolbar

//windowprops = "width=" + (screen.width-10) + ",height=" + (screen.height-50) + ",top=0,left=0";
 windowprops = "width=724, height=484";

windowprops += (menubar ? ",menubars" : "") +
(scrollbars ? ",scrollbars" : "") +
(locationbar ? ",location" : "") +
(directories ? ",directories" : "") +
(resizable ? ",resizable" : "") +
(statusbar ? ",status" : "") +
(toolbar ? ",toolbar" : "");

window.open(page, 'fullPopup', windowprops);
}




/*******************************************************************************
**
**  Metodo per inserire i title in tutti i link _blank.
**
**/



function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors .length; i++) {
	var anchor = anchors[i];
	if (anchor.getAttribute("href") && anchor.getAttribute("target") == "_blank") {
		anchor.title = (anchor.title != "") ? anchor.title+" (Questo link si apre in una nuova finestra)" : "Questo link si apre in una nuova finestra";
		}
	}
}

if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", externalLinks, false );
else if ( typeof window.attachEvent != "undefined" )
    window.attachEvent( "onload", externalLinks );
else {
    if ( window.onload != null ) {
        var oldOnload = window.onload;
        window.onload = function ( e ) {
            oldOnload( e );
            externalLinks();
        };
    }
    else
        window.onload = externalLinks;
}




/*******************************************************************************
**
**  JQUERY alek4u
**
**/

$(function() {
	$("a[rel='lightbox']").lightBox();
});

$(document).ready(function(){
	$(".carouselcontainer").easySlider();

	$("img.nodownload").click(function(e){
		if($("#nodownloavviso").length!=0){
			closeAvviso(e)
		} else{
			openAvviso(e)
		}
	})

    $("#loginnav a").click(function(){
         $("#loginnav a").removeClass("on");
         $(this).addClass("on");
    })
    $("#login input").focus(function () {
         $(this).css('color', '#000000');
         $(this).attr('value', '');
    });
    $("#login input").blur(function() {
          if($(this).attr('value')==""){
              $(this).css('color', '#afafaf');
              $(this).attr('value', $(this).attr('id'));
          }
    });

    paginatore();

});

function closeAvviso(e){
	$("#nodownloavviso").fadeOut("slow", function(){
		$("#nodownloavviso").remove()
		if (e!=null) {openAvviso(e)}
	});
};

function paginatore(){
    $(".paginatore ul li:first-child").addClass("first-child");
    $(".paginatore ul li:last-child").addClass("last-child");
    $(".paginatore").append("<div class=\"closer\"></div>")
    $(".paginatore").after("<div style=\"clear:both;\"></div>")
}

function openAvviso(e){
		var textAvviso="Per visualizzare il pdf delle tue vecchie bollette basta attivare il servizio <strong>Bolletta on Line</strong>.<br />In pochi click tanti vantaggi per controllare le tue forniture."
		divAvviso=document.createElement('div');
		divAvviso.id='nodownloavviso';
		divAvviso.innerHTML="<a href=\"javascript:closeAvviso()\" id=\"closeAvviso\">X</a></strong>"+textAvviso;
		divAvviso.style.position = "absolute";
		divAvviso.style.display = "none";
		divAvviso.style.left = e.pageX+"px";
		divAvviso.style.top = e.pageY+"px";
		document.getElementById('container').appendChild(divAvviso); 
		$("#nodownloavviso").fadeIn('slow');
}