var html = "<div id=\"banner_intersitial\">";
html +="        <div id=\"capcalera_intersitial\">";
html +="            <img src=\"/resources/img/logo-lamalla_03.jpg\" alt=\"lamalla.cat\">";
html +="            <a class=\"linknormal\" href=\"javascript:void(0)\" onclick=\"hide_banner_intersitial()\" class=\"linknormal\">Entrar a lamalla.cat ></a>";
html +="        </div>";
html +="        <div id=\"contingut_intersitial\">";
html +="            <p>";

var html2 = "       </p>";
html2 +="       </div>";
html2 +="   </div>";



function show_banner_intersitial(time, views, cookieName, zoneid)
{
    semafor = false;

    // Leemos la cookie para recuperar el numero de visitas que el usuario a tenido durante un dia a la portada
    num = getCookie(cookieName);

    // Si el numero de visitas es menor al limite mostramos la publicidad
    if (num<views)
    {
        semafor = true;

        var jhtml = "<iframe id='aef8399b' name='aef8399b' src='http://publicitat.xal.cat/adframe.php?n=aef8399b&amp;what=zone:"+zoneid+"' framespacing='0' frameborder='no' scrolling='no' width='800' height='600'><a href='http://publicitat.xal.cat/adclick.php?n=aef8399b' target='_blank'><img src='http://publicitat.xal.cat/adview.php?what=zone:"+zoneid+"&amp;n=aef8399b' border='0' alt=''></a></iframe> <script language='JavaScript' type='text/javascript'><!-- if (typeof phpAds_adg == 'undefined') { document.write('<scr'+'ipt language=\"JavaScript\" type=\"text/javascript\" src=\"http://publicitat.xal.cat/adg.js\"></scr'+'ipt>'); } //--></script>;";
        //var jhtml = " if (!document.phpAds_used) document.phpAds_used = ','; phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11); document.write (\"<\" + \"script language='JavaScript' type='text/javascript' src='\"); document.write (\"http://publicitat.xal.cat/adjs.php?n=\" + phpAds_random); document.write (\"&amp;what=zone:64\"); document.write (\"&amp;exclude=\" + document.phpAds_used); if (document.referrer) document.write (\"&amp;referer=\" + escape(document.referrer)); document.write (\"'><\" + \"/script>\"); ";
        
        // Imprimimos el banner
        document.write(html);
        document.write(jhtml);
        //eval(jhtml);
        document.write(html2);

        // Convertimos el contador a numerico y sumamos uno al contador
        num = (num*1) + 1;

        // Actualizamos la cookie con el nuevo valor
        setCookie(cookieName,num, 1);

        // Mostramos el banner durante el tiempo indicado en  la variable 'time' (milisigundos).
        // Al transcurrir el tiempo estipulado ejecutamos  la funcion "hide_banner_intersitial()"

        setTimeout("hide_banner_intersitial()", time);
    }
    else
    {
        // Mostramos el contenido de la portada despues de 1/2 segundo
        setTimeout("show_content()",500);
    }
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
      {
      c_start=document.cookie.indexOf(c_name + "=")
      if (c_start!=-1)
        {
        c_start=c_start + c_name.length+1
        c_end=document.cookie.indexOf(";",c_start)
        if (c_end==-1) c_end=document.cookie.length
        return unescape(document.cookie.substring(c_start,c_end))
        }
      }
    return 0
}


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())
}

/* Ocultamos la capa con la portada de vilaweb */
function hide_content(views, cookieName)
{
    // Si el numero de visitas es menor al limite mostramos la publicidad
    if (semafor)
    {
        document.getElementById('wrapper').style.display= "none";
    }
}


/* Mostarmos la capa con la portada de vilaweb */
function show_content()
{
    document.getElementById('wrapper').style.display= "";
}


/* Recargamos la pagina con  un valor de request per mostrar la portada sense el banner*/
function hide_banner_intersitial()
{
    document.getElementById('banner_intersitial').style.display= "none";
    document.getElementById('wrapper').style.display= "";
}


