
function deleteNewsletEmail (){   
    var contentEmail = document.getElementById('nlemail').value;
    
     if (contentEmail=='e-mail') {
     document.getElementById('nlemail').value='';
    }		
	}
	
function banner(zone){
    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.colosalcenter.com/openx/adjs.php?n=" + phpAds_random);
    document.write ("&amp;what=zone:"+zone);
    document.write ("&amp;exclude=" + document.phpAds_used);
    if (document.referrer)
       document.write ("&amp;referer=" + escape(document.referrer));
    document.write ("'><" + "/script>");

}

function validaContact(lang)
{
    var n=true;
    var e2=true;
    
     if (lang=='ca') {
     
      n=validateCheckbox('avis','msgerror','message','Heu d\'acceptar l\'av\xEDs legal');
      e2=validateEmail('cemail', 'msgerror','message','L\'adre\xE7a indicada no \xE9s correcta', 'Si us plau, indiqueu el vostre e-mail'); 

          }else{
       n=validateCheckbox('aviso','msgerror','message','Debe aceptar el aviso legal');
       e2=validateEmail('cemail', '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) 
    {
        $('contact-form').submit();
    }
}

function validateCheckbox(id,msgArea,msg,alertText)
{
    field = $(id);
    
    if(field.checked!=true)
    {
         showMsg (msgArea,msg,alertText,true);
        // change the color of text field
       field.addClassName('fieldError');
        field.focus();
        // make sure the form is not submitted
        return false;
    }
    else 
    {
        field.removeClassName('fieldError');
        $(msgArea).hide();
        return true;
    }
}

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 = "#900000";
        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="#d0d0d0";
    }
    else {
        displayArea.style.backgroundColor="#d0d0d0";    
    }
    if (!isDOMCompliant) {
        alert (msgText);
    }
    else {    
        changeElementText (displayElement,msgText);    
    }
}

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


// Incrustar video  
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 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; 
        } 
}

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", "");
                    }
                }
            }
        } 
    }      


function load(){
    addEvent(window, 'load', startList);
    addEvent(window, 'load', loadVideos);
}
    
load()
