function _(_id){
  return document.getElementById(_id);
}


function confirm_send(){
    _nombre=_('nombre').value;
    _email=_('email').value;
    _telefono=_('telefono').value;
    _apellido=_('apellido').value;
    _mensajes=_('mensajes').value;

    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    if(_nombre==""){
       alert("Para poder suscribirte necesitas escribir tu nombre");
       _('nombre').focus();
       return false;
    }else if(_apellido==""){
       alert("falta introducir tu apellido");
       _('apellido').focus();
       return false;
    }else if (pattern.test(_email)==false){
       alert("Tu email proporcionado es incorrecto");
       _('email').focus();
       return false;
    }else if(_telefono==""){
       alert("Para poder suscribirte necesitas escribir tu telefono");
       _('telefono').focus();
       return false;
    }else if(_mensajes==""){
       alert("falta introducir tu mensaje");
       _('mensajes').focus();
       return false;
    }else{
      alert("Sus datos se han enviado con �xito, gracias.");
      return true;
    }

}

function sendFriend(){
	__url=location.href.toString();
	var docTitle = document.title.toString();
	window.open('http://www.doctorweb.org/enviar/'+b64.encode(__url)+":"+b64.encode(docTitle),'win2','width=410,height=380,menubar=no,resizable=no,scrollbars=no,titlebar=no,directories=no,location=no');
	
}

function _(_e){
  return document.getElementById(_e);
}
function changeTabsEnf(e){
    var _divs=_('contentEnf');
    var nodes=_divs.childNodes.length;
    for(each=0;each<nodes;each++){
      _divsHidden=_divs.childNodes[each].id;
      _(_divsHidden).style.display='none';
    }
     _(e).style.display='block';
}

function IsNumeric(input){
  var RE = /^-?(0|INF|(0[1-7][0-7]*)|(0x[0-9a-fA-F]+)|((0|[1-9][0-9]*|(?=[\.,]))([\.,][0-9]+)?([eE]-?\d+)?))$/;
  return (RE.test(input));
}


function getPDF(){
  __u=document.location.href;
  RegExenfermedad=/enfermedades\-a\-z\/([a-zA-Z])\/(\w)/;
  RegExEmbarazo=/embarazo/;
  RegExSalud=/salud/;
  RegExHospital=/hospitales\/hospitales\-en\-mexico/;

  if(__u.match(RegExenfermedad)){
    __pa=__u.split('/');
    __art=__pa[__pa.length-2];
    if(__art.length==1 || __art.length==0){
        __art=__pa[__pa.length-1];
    }
    outPdf('enfermedad',__art);

  }else if(__u.match(RegExEmbarazo)){
    __pa=__u.split('/');
    __art=__pa[__pa.length-1];
    if(typeof __art=="undefined" || __art=="" ){
        __art=__pa[__pa.length-2];
    }
    outPdf('embarazo',__art,true);
  }else if(__u.match(RegExSalud)){
    __pa=__u.split('/');
    __art=__pa[__pa.length-1];
    if(typeof __art=="undefined" || __art=="" ){
        __art=__pa[__pa.length-2];
    }
    outPdf('salud',__art,true);
  } else if(__u.match(RegExHospital)){
    __pa=__u.split('/');
    __art=__pa[__pa.length-1];
    if(typeof __art=="undefined" || __art=="" || IsNumeric(__art)){
        __art=__pa[__pa.length-2];
    }
    outPdf('hospital',__art,true);
  }
  else{
    alert('Lo sentimos no puedes genera un pdf desde este link');
  }
 // alert($url);
}


function outPdf(type,article,ext){
    if(typeof ext=="undefined" || ext=="" ){
        ext='';
    }else{
        __url=location.href.toString();
        ext=':'+b64.encode(__url);
    }
    location.href='http://www.doctorweb.mx/generate/pdf/'+type+':'+article+ext;
}



function goPrint()
{
	getPDF();
	//$("#content div p").printArea([options]);
	//jQuery.jPrintArea("#content div p");
}
