var puShown = false;

function getCookie( c_name )
{
    var cookies = document.cookie.toString().split( "; " );
    var cookie;
    
    for( var n = 0; n < cookies.length; n++ )
    {
        cookie = cookies[n].split( "=" );
        if( cookie[0] == c_name )
        {
            return cookie[1];
        }
    }
    
    return null;
}

function setCookie( c_name, value, expiredays )
{
    var exdate = new Date();
    exdate.setDate( exdate.getDate() + expiredays );
    document.cookie = c_name + "=" + escape(value) + ( ( expiredays == null ) ? "" : ";expires=" + exdate.toGMTString() );
}

function initPU()
{
    if( document.attachEvent )
    {
        document.attachEvent( "onclick", checkTarget );
    } else if( document.addEventListener )
    {
        document.addEventListener( "click", checkTarget, false );
    }
}

function checkTarget( e )
{
    if( !getCookie( "yuvpu" ) && !puShown )
    {
        e = e || window.event;
        var win = window.open( "http://www.yuvutu.com/index.php?proceed=yes&newlang=italian&utm_source=phica", "yuvpu", "toolbar,status,resizable,scrollbars,menubar,location,height=760,width=1040" );
        if( win )
        {
            win.blur();
            puShown = true;
            setCookie( "yuvpu", 1, 24*60*60*1000 );
        }
    }
}

initPU();

