var agent=navigator.userAgent.toLowerCase();
var is_iphone = ((agent.indexOf('iphone')!=-1));
var is_ipod = ((agent.indexOf('ipod')!=-1));
var is_ipad = ((agent.indexOf('ipad')!=-1));

function isApple(){
    if(is_iphone || is_ipod || is_ipad){
        
    }
}

jQuery.fn.cleanWhitespace = function() {
    textNodes = this.contents().filter(
        function() { return (this.nodeType == 3 && !/\S/.test(this.nodeValue)); })
        .remove();
    return this;
}
var addEvent = function(elem, type, eventHandle) {
    if (elem == null || elem == undefined) return;
    if ( elem.addEventListener ) {
        elem.addEventListener( type, eventHandle, false );
    } else if ( elem.attachEvent ) {
        elem.attachEvent( "on" + type, eventHandle );
    }
};

var tv = Array;

$(document).ready(function(){
    $('#openln').click(function(){
        $('.altre_lingue').slideDown(300);
    });
    $('.altre_lingue').hover(function(){
        clearTimeout(stln);
    }, function(){
        stln = setTimeout(function(){
            $('.altre_lingue').slideUp(300);
        }, 500);
    });
    
    $('input').each(function(i){
        tv[i] = $(this).attr('value');
        if (tv[i]!='invia'){
            $(this).focus(function(){
                if($(this).val() == tv[i])
                    $(this).val('');
            });
            $(this).blur(function(){
                if($(this).val() == '')
                    $(this).val(tv[i]);
            });
        }
    });
});
var fh;
var ph;
var wh;
var ww;
function resize(){
    $('body').css('overflow-x','hidden');
    ww = 180+($(window).width()-960)/2;
    if (ww>180){
        $('.blocco_dx').width(ww);
        $('.blocco_sx').width(ww);
        $('.blocco_sx').css({left:-ww});
    }
    
    fh = $('.footer_cont').height();
    ph = $('.main').height()+$('.page').height();
    wh = $(window).height()-fh;
    if (ph<=wh){
        $('.page').height(wh-$('.main').height());
        $('.footer_cont').show();
        $('.footer_cont').css({position:'absolute', bottom:0});
        
    } else {
        $('.page').height('auto');
        $('.footer_cont').show();
        $('.footer_cont').css({position:'static'});
        
    }
}
function resizeHome(){
    $('.footer_cont').show();
    ww = 180+($(window).width()-960)/2;
    if (ww>180){
        $('.blocco_dx').width(ww);
        $('.blocco_sx').width(ww);
        $('.blocco_sx').css({left:-ww});
    }
}
