function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be attached");
  }
}

function trim (string) {
	return string.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}



function SuscripcionBoletin(){
	



if(document.getElementById("formulario-boletin")){

var boletin=document.getElementById("formulario-boletin");
var input_=boletin.getElementsByTagName("input")[1];

if(input_.getAttribute('rel')=='ingles'){
var msg="Enter your email address";
}
else{
var msg="Introduzca su Correo Electrónico";
}
//Enter your email address

input_.value=msg;

var value_=boletin.getElementsByTagName("input")[1].value;
var boton_=boletin.getElementsByTagName("button")[0];

input_.onblur=function(){
input_.value=trim(input_.value);
if(input_.value==""){
input_.value=msg;
}
}
input_.onfocus=function(){
if(input_.value==msg){
input_.value="";
}

}

document.getElementById("formulario-boletin").onsubmit=function(){

if(input_.value==msg || input_.value==""){
return false;
}

emailpat = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;

if(emailpat.test(input_.value)){

return true;
}
else{
if(input_.getAttribute('rel')=='ingles'){
alert("The e-mail address is not correct");
}
else{
alert("El formato del email no es correcto");
}
return false;
}
}


}

}


addEvent(window, 'load', SuscripcionBoletin);