
function banner_bk(id, url) 
{
         
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 (url+"/phpAdsNew/adjs.php?n=" + phpAds_random);

     document.write ("&amp;what=zone:"+id+"&amp;target=_top");
 
         
     document.write ("&amp;exclude=" + document.phpAds_used);
     if (document.referrer)
     document.write ("&amp;referer=" + escape(document.referrer));
     document.write ("'><" + "/script>");
}

function banner2(id, url) 
{ 
    /*
    var m3_u = (location.protocol=='https:'?'https://www.tarracofrade.com/openads/www/delivery/ajs.php':'http://www.tarracofrade.com/openads/www/delivery/ajs.php');
    
    var m3_r = Math.floor(Math.random()*99999999999);
    if (!document.MAX_used) document.MAX_used = ',';
    document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
    document.write ("?zoneid="+id);
    document.write ('&amp;cb=' + m3_r);
    if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
    document.write ("&amp;loc=" + escape(window.location));
    if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
    if (document.context) document.write ("&context=" + escape(document.context));
    if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
    document.write ("'><\/scr"+"ipt>");*/

   var m3_u = url+'/openads2/www/delivery/ajs.php';
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid="+id);
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
   
}


function banner(id,url)
{
 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://www.tarracofrade.com/openads2/adjs.php?n=" + phpAds_random);
    document.write ("&amp;what=zone:"+id);
    document.write ("&amp;exclude=" + document.phpAds_used);
    if (document.referrer)
       document.write ("&amp;referer=" + escape(document.referrer));
    document.write ("'><" + "/script>");
}

function displayComments (newsId)
{   
    var aleatorio = Math.random()  
	new Ajax.Updater({ success: 'comments', failure: 'comments' }, 'http://www.tarracofrade.com/index.php', {
					 method: 'get',
					 evalScripts: true,
					 encoding: 'iso-8859-1',
     				 parameters: {command: 'view_comments', news_id: newsId, aleator: aleatorio}	 
                    }); 
}

function deleteContentName ()
{   
    var contentName = document.getElementById('nlname').value;
    
    if (contentName=='Nom i cognoms' || contentName=='Nombre y apellidos') {
     document.getElementById('nlname').value='';
    }       
	}
	
function deleteContentEmail ()
{   
    var contentEmail = document.getElementById('nlemail').value;
    
     if (contentEmail=='Email') {
     document.getElementById('nlemail').value='';
    }		
	}
	
function deleteSearch ()
{   

    var search = document.getElementById('cerca').value;
    
     if (search=='Cercar not\xEDcies' || search=='Buscar noticias') {
     document.getElementById('cerca').value='';
    }		
}

// Incrustar video  
function add_video2(url, root_video,width,height)
{
    var text="<object width=\""+width+"\" height=\""+height+"\">"
            +"<param name=\"movie\" value=\""+url+"\"/>"
            +"<param name=\"wmode\" value=\"transparent\"/>"
            +"<embed src=\""+url+"\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\""+width+"\" height=\""+height+"\"/>"
            +"</object>";

    $(root_video).update(text);
   
}

function add_video(url,root_video,width,height)
{

 if(navigator.appName=="Microsoft Internet Explorer")
    {
        var text="<embed src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" autoplay=\"false\" wmode=\"transparent\">"
        +"<param name=\"cache\" value=\"true\">"
        +"<param name=\"type\" value=\"video/quicktime\">"
        +"<param name=\"bgcolor\" value=\"#FFFFFF\">"
        +"<param name=\"controller\" value=\"true\">"
        +"<param name=\"showcontrols\" value=\"1\"/>"
        +"<param name=\"enablejavascript\" value=\"TRUE\">"
        +"<param name=\"showdisplay\" value=\"1\">"
        +"<param name=\"wmode\" value=\"transparent\"/>"
        +"<param name=\"qtnext1\" value=\"javascript:GAMIndexAds.endMovie(GAMIndexAds.oCurrentMovie);\">"
        +"</embed>";
    
    } else {
        var text="<object width=\""+width+"\" height=\""+height+"\">"
            +"<param name=\"movie\" value=\""+url+"\"/>"
            +"<param name=\"wmode\" value=\"transparent\"/>"
            +"<embed src=\""+url+"\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\""+width+"\" height=\""+height+"\"/>"
            +"</object>";
    }
    $(root_video).update(text);
}


function loadVideos()
{

    var videos=$$('.urlvideo');
    if ($('video-width')!=null && $('video-height')!=null)
    {
        var width=$F('video-width');
        var height=$F('video-height');
    }

    for (i=0; i<videos.length;i++)
    {
        add_video(videos[i].value,'root_video_'+videos[i].id.substring(10),width,height);
    }
}

function loadAudios()
{
    var videos=$$('.urlaudios');
    for (i=0; i<videos.length;i++)
    {
        add_audio(videos[i].value,'root_audio_'+videos[i].id.substring(10))
    }

}
/* Incrustar audio */
function add_audio(url, root_audio)
{
    if(navigator.appName=="Microsoft Internet Explorer")
    {
      var text="<embed src=\""+url+"\"width=\"200\" height=\"30\" autoplay=\"false\" cache=\"true\" type=\"video/quicktime\">"
        +"<param name=\"enablejavascript\" value=\"TRUE\">"
        +"</embed>";
    }
    else
    {
        var text="<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0\" id=\"movie\" height=\"30\" width=\"200\">"
        +"<param name=\"src\" value=\""+url+"\">"
        +"<param name=\"autoplay\" value=\"false\">"
        +"<param name=\"cache\" value=\"TRUE\">"
        +"<param name=\"type\" value=\"video/quicktime\">"
        +"<param name=\"bgcolor\" value=\"#FFFFFF\">"
        +"<param name=\"controller\" value=\"TRUE\">"
        +"<param name=\"enablejavascript\" value=\"TRUE\">"
        +"<param name=\"qtnext1\" value=\"javascript:GAMIndexAds.endMovie(GAMIndexAds.oCurrentMovie);\">"
        +"<object type=\"video/quicktime\" data=\""+url+"\" height=\"30\" width=\"200\" class=\"iesucks\">"
        +"<param name=\"autoplay\" value=\"false\"/>"
        +"<param name=\"controller\" value=\"true\"/>"
        +"</object>"
        +"</object>";
    }
    $(root_audio).update(text);
/*     document.getElementById(root_audio).innerHTML=text;
     document.getElementById(link).style.display='none';
     document.getElementById(link_close).style.display='block';
     */
}



function validaNewsletter(lang) {
    var e=true;
    
    if (lang=='ca') {
        e=validateEmail('nlemail', 'error-newsletter','msg-newsletter','L\'adre\xE7a indicada no \xE9s correcta', 'Si us plau, indiqui el seu e-mail'); 
    }else{
        e=validateEmail('nlemail', 'error-newsletter','msg-newsletter','La direcci\xF3n indicada no es correcta', 'Por favor, indique su email');
    }  
   
    if (e!=false) e=true;
        
    if (e) {
        document.getElementById('newsletter').submit();
    }                 
} 

function validateEmail(id,msgArea,msg,alertText)
{
    // check the first email address ( the exclamation means "not" )
    field = document.getElementById (id);
    if(!check_email(field.value)){
        showMsg (msgArea,msg,alertText,true);
        // change the color of text field
        field.style.borderColor = "red";
        field.focus(); 
        // make sure the form is not submitted
        return false;
    }
    else {
        return true;
    }
}



function showMsg (msgArea, msg, msgText,isError)
{
    displayArea = document.getElementById (msgArea);
    displayElement =  document.getElementById (msg);
    displayArea.style.display = "";
    if (isError) {
        displayArea.style.backgroundColor="#f0eef2";
    }
    else {
        displayArea.style.backgroundColor="#f0eef2";    
    }
    if (!isDOMCompliant) {
        alert (msgText);
    }
    else {
        
        changeElementText (displayElement,msgText);
        //document.location.href="#top";    
    }
}

function changeElementText (node,text) 
{
    while (node.hasChildNodes()) {
        node.removeChild(node.lastChild);
    }
    var textNode = document.createTextNode(text);
    node.appendChild(textNode );
}

function isDOMCompliant ()
{
        return (document.getElementsByTagName && document.createElement);
}

function validaRecomendar(lang)
{

    var n=true;
    var e2=true;    
    var m=true;
    
    if (lang=='ca') {
        n=validateField('nom1','msgerror','message','Si us plau, indiqueu el vostre nom', 'Si us plau, indiqueu el vostre nom');
        e2=validateEmail('email2', 'msgerror','message','L\'adre\xE7a indicada no \xE9s correcta', 'Si us plau, indiqueu el vostre e-mail'); 
    }else{
        n=validateField('nom1','msgerror','message','Por favor, indique su nombre', 'Por favor, indique su nombre');
        e2=validateEmail('email2', 'msgerror','message','La direcci\xF3n indicada no es correcta', 'Por favor, indique su email'); 
    }         
    
    if (n!=false) n=true;
    if (e2!=false) e2=true;
 
    
    if (n && e2) 
    {
        document.getElementById('formenviar').submit();
    }                 
}



function validaEnviarEs()
{
    var n=true;
    var e2=true;    
    var m=true;
    
    n=validateField('name','msgerror','message','Por favor, indique su nombre', 'Por favor, indique su nombre');
    e2=validateEmail('email2', 'msgerror','message','La direcci\363n de correo indicada no es v\xE1lida', 'Por favor, indique su direcci\363n de correo');
    m=validateTextarea('comment', 'msgerror','message','Por favor, escriba un mensaje', 'Por favor, escriba un mensaje');    
    
    if (n!=false) n=true;
    if (e2!=false) e2=true;
    if (m!=false) m=true;
 
    
    if (n && e2 && m) 
    {
        document.getElementById('formsend').submit();
    }                 
}

function validaComentarioEs()
{
    var n=true;
    var e=true;    
    
    n=validateField('name','msgerror','message','Por favor, indique su nombre', 'Por favor, indique su nombre');
    e=validateEmail('email','msgerror','message','La direcci\xF3n indicada no es correcta', 'Por favor, indique su email'); 
    
    if (n!=false) n=true;
    if (e!=false) e=true;
 
    
    if (n && e) 
    {
        document.getElementById('formsend').submit();
    }                 
}

function validaComentarioCa()
{   
    var n=true;
    var e=true;    
    
    n=validateField('name','msgerror','message','Si us plau, indiqueu el vostre nom', 'Si us plau, indiqueu el vostre nom');
    e=validateEmail('email','msgerror','message','L\'adre\xE7a indicada no \xE9s correcta', 'L\'adre\xE7a indicada no \xE9s correcta'); 
    
    if (n!=false) n=true;
    if (e!=false) e=true;
 
    
    if (n && e) 
    {
        document.getElementById('formsend').submit();
    }                 
}



function validateField(id,msgArea,msg,alertText,isError)
{
    field = document.getElementById(id);
    if(!check_field(field.value)){
        showMsg(msgArea, msg, alertText,isError);
        // change the color of text field
        field.style.borderColor = "red";
        field.focus();
        // make sure the form is not submitted
        return false;
    }
    else {
        return true;
    }
}


function validateTextarea(id,msgArea,msg,alertText,isError)
{
    field = document.getElementById(id);
    if(!check_texta(field.value)){
    showMsg(msgArea, msg, alertText,isError);
    // change the color of text field
    field.style.borderColor = "red";
    field.focus();
    // make sure the form is not submitted
    return false;
    }
    else {
        return true;
    }
}

function check_field (f)
{
    var field = trim(f);
    if (field.length == 0) {
        return false;
    }
    else {
        return true;
    }
} 

function check_texta(f)
{
    if (f) {
        var field = trim(f);
        if (field.length == 0) {
            return false;
        } else {
            return true;
        }
    } else {
        return false;
    }
}

function trim(str)
{
    return str.replace(/^\s*|\s*$/g,"");
}

function check_email (emailAddress) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    return re.test(emailAddress);
}


/** Funcions autoexecutables 
*
*/

(
function() {

/* Donat un lang, printa la data d'avui */
function printDate() 
{

    var lang=$('lang').value;

    Fecha = new Date();
    $('date').update(Fecha.getDate()+" "+getMonth(Fecha.getMonth(),lang)+' de '+Fecha.getFullYear());   
}


/* Donat un # de mes i un lang retorna el nom del mes */
function getMonth(id,lang) 
{
    var mes="";
    if(lang=='ca')
    {
    switch (id) {
        case 0 : mes="de gener"; break;
        case 1 : mes="de febrer"; break; 
        case 2 : mes="de mar\xe7"; break; 
        case 3 : mes="d'abril"; break; 
        case 4 : mes="de maig"; break; 
        case 5 : mes="de juny"; break; 
        case 6 : mes="de juliol"; break; 
        case 7 : mes="d'agost"; break; 
        case 8 : mes="de setembre"; break; 
        case 9 : mes="d'octubre"; break; 
        case 10 : mes="de novembre"; break;
        case 11 : mes="de desembre"; break; 
    }
    } else if(lang=='es')
    {
        switch (id) {
        case 0 : mes="de enero"; break;
        case 1 : mes="de febrero"; break; 
        case 2 : mes="de marzo"; break; 
        case 3 : mes="de abril"; break; 
        case 4 : mes="de mayo"; break; 
        case 5 : mes="de junio"; break; 
        case 6 : mes="de julio"; break; 
        case 7 : mes="de agost"; break; 
        case 8 : mes="de septiembre"; break; 
        case 9 : mes="de octubre"; break; 
        case 10 : mes="de noviembre"; break;
        case 11 : mes="de diciembre"; break; 
    }
    }
    return mes;
}




    function countdown_clock()
    {
         /*year=11;
         month=4;
         day=17;
         hour=23;
         minute=59;
         format=1;*/
         
         year=10;
         month=3;
         day=28;
         hour=23;
         minute=59;
         format=1;         

        /* text en catala */
         var rest="Falten ";
         var before=" dies per Diumenge de Rams";
         var current="Avui \xE9s Diumenge de Rams!";
         var lang=document.getElementById("lang").value;

        /* text en castella */        
         if (lang=='es')        
         {
            rest="Faltan ";
            before=" d\xEDas para el Domingo de Ramos";
            current="!Hoy es domingo de Ramos!";
         }

         
         var dies=countdown(year, month, day, hour, minute, format);
         
         if (dies==0)
         {
             $('count').update(current);
         }
         else
         {
            
            $('count').update(rest+dies+before);
         }

    }
      
function countdown(year, month, day, hour, minute, format)
{
         Today = new Date();
         Todays_Year = Today.getFullYear() - 2000;
         Todays_Month = Today.getMonth() + 1;                  
         
         //Convert both today's date and the target date into miliseconds.                           
         Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), 
                                 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();                                 
         Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();                  
         
         //Find their difference, and convert that into seconds.                  
         Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
         
         if(Time_Left < 0)
            Time_Left = 0;
         
         var days = Math.floor(Time_Left / (60 * 60 * 24));
         return days;
}


    /* Funci— de moviment de la marquesina */
    function execute(element,index,size) {

        return (function() {
            completed = false;
            if (index >= size) {
                index = 0;
                completed = true;
            }
            var call = execute (element,index+1,size);
            if (index > 0) {
    //            Effect.Fade(element[index-1]);
              element[index-1].style.display='none';
            }
        //    Effect.Appear(element[index],{delay:1});
        element[index].style.display='block';
            if (completed) {
//                Effect.Fade(element[size-1]);
            element[size-1].style.display='none';
            }
            setTimeout(call,6000,size);
        });
    }

    /* Executa la marquesina */
    function displayHeadlines() 
    {    
        var news = $$('#marquee h2');
        
        if (news.length>0)
        {
            var call = execute (news,0,news.length);
            setTimeout(call,100);    
        }
        
        
    }

    /* Inicialitza el menu per al ie6*/
    function startList(){
        if (document.all&&document.getElementById) {
            navRoot = document.getElementById("nav");
            for (i=0; i<navRoot.childNodes.length; i++) {
                node = navRoot.childNodes[i];
                if (node.nodeName=="LI") {
                    node.onmouseover=function() {
                        this.className+=" over";
                    }
                    node.onmouseout=function() {
                        this.className=this.className.replace(" over", "");
                    }
                }
            }
        }
    }

    addEvent(window, 'load', startList);
   
    function addEvent(obj, evType, fn){ 
    if (obj.addEventListener){ 
            obj.addEventListener(evType, fn, false); 
            return true; 
            } else if (obj.attachEvent){ 
            var r = obj.attachEvent("on"+evType, fn); 
            return r; 
            } else { 
            return false; 
        } 
    }
    

    // Funcions que s'executaran al carregar la pˆgina
    addEvent(window, 'load', countdown_clock);
    addEvent(window, 'load', printDate);
    addEvent(window, 'load', displayHeadlines);
    addEvent(window, 'load', startList);
    addEvent(window, 'load', loadVideos);
    addEvent(window, 'load', loadAudios);
}
)();




















