function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function YY_checkform() { 
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'||o.type=='file'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('La información que introdujo está incompleta o contiene errores <br>The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
  document.MM_returnValue = (s=='');
  
}
function paisdesarrollo(combin)
{
	//var paisesvisa="AFGHANISTAN,ALBANIA,ANGOLA,ANTIGUA/BARBUDA,ARMENIA,AZERBAIJAN,BAHRAIN,BANGLADESH,BELARUS,BOLIVIA,BOSNIA/HERZEGOVINA,BRAZIL,BULGARIA,CAMEROON,CENTRAL AFRICAN REPUBLIC,CHINA,COLOMBIA,CONGO, DEM. REP.,CONGO, REP., CÔTE D'IVOIRE,CROATIA HRVATSKA,CUBA,DOMINICA,DOMINICAN REPUBLIC,ECUADOR,EGYPT,EL SALVADOR,ESTONIA,ETHIOPIA,GEORGIA,GUATEMALA,GUINEA, GUINEA-BISSAU,GUYANA,HAITI,HONDURAS,INDIA,INDONESIA,IRAN,IRAQ,JAMAICA,KOREA NORTH,LEBANON,LIBERIA,LIBYA,MALAYSIA,MOROCCO,NEPAL,NICARAGUA,OMAN,PAKISTAN,PANAMA,PARAGUAY,PERU,PHILIPPINES,ROMANIA,SOUTH AFRICA,SUDAN,SYRIA,TAIWAN,THAILAND,TOGO,TRINIDAD/TOBAGO,TUNISIA,TURKEY,UKRAINE,UNITED ARAB EMIRATES,VIETNAM,YUGOSLAVIA,ZAMBIA,ZIMBABWE";
	
	var paisesvisa="Afganistan,Albania,Angola,Antigua and Barbuda,Armenia,Azerbaijan,Bahrain,Bangladesh,Belarus,Bolivia,Bosnia and Herzegovina,Brazil,Bulgaria,Cameroon,China,Colombia,Congo,Republica Democratica del Congo,Croatia Hrvatska,Cuba,Dominica,Ecuador,Egipto,El Salvador,Estonia,Etiopia,Georgia,Guatemala,Guinea,Guinea-Bissau,Guyana,Haiti,Honduras,India,Indonesia,Iran,Iraq,Jamaica,Korea,Democratic People's Republic of,Libano,Liberia,Libia,Malasia,Morocco,Nepal,Nicaragua,Oman,Pakistan,Panama,Paraguay,Peru,Filipinas,Rumania,Sudan,Siria,Taiwan,Tailandia,Togo,Trinidad y tobago,tunisia,Turkey,Ucrania,united arab emirates,Vietnam,Yugoslavia,Zambia,Zimbawe";
//alert(combin.value);
valor=combin.value.split("-");
codigo=valor[0];
//alert(codigo);
document.getElementById('codigonacionalidad').value=codigo;

if (paisesvisa.match(valor[1])==valor[1]){
		document.getElementById('visa').style.display='inline';
		document.getElementById('tramivisa').value=1;
		document.getElementById('visavigente').style.display='inline';
		
		
		}else{
		document.getElementById('visa').style.display='none';
		document.getElementById('tramivisa').value=0;
		document.getElementById('visavigente').style.display='none';
		
		}
}

function nuevoAjax()
{
	var xmlhttp=false;
	 try {
	 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	 try {
	 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	 } catch (E) {
	 xmlhttp = false;
	 }
	 }	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	 xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function VerfCo(Objeto,Objeto2)
{
	contenedor=document.getElementById('coe');
	if(document.getElementById('correo2').value=='')
	{
		contenedor.innerHTML='';
		hdBoton('1');
	}
	if(document.getElementById('correo').value==document.getElementById('correo2').value && document.getElementById('correo2').value!='')
	{
		hdBoton('1');
		ajax=nuevoAjax();
		ajax.open("POST", 'correo.php', true);
		ajax.onreadystatechange=function()
			{
				if(ajax.readyState==4)
				{
					contenedor.innerHTML = ajax.responseText;
				}
			}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("correo2="+Objeto.value+"&addmem="+Objeto2);
	}
	if(document.getElementById('correo').value!=document.getElementById('correo2').value)
	{
		contenedor.innerHTML = 'The e-mail address doesn\'t match. The information may not be sent<br>Please check.';
		hdBoton('0');
	}
}
function hdBoton(quehago)
{
	if(quehago==0) //Si se trata de deshabilitar el boton
	{
		document.getElementById('BotonEnvia').disabled=true;
		document.getElementById('BotonEnvia').value='The email address does not match';
	}
	if(quehago==1) //Si se trata de habilitar el boton
	{
		document.getElementById('BotonEnvia').disabled=false;
		document.getElementById('BotonEnvia').value='Submit';
	}	
}
function mo(idin, accion)
{
	switch(accion)
	{
		case 1:
		document.getElementById(idin).style.display='inline';
		break;
		case 0:
		document.getElementById(idin).style.display='none';
		break;
	}
}
function sen(boton)
{
	document.getElementById('lo').style.display='inline';
	boton.value = 'Please wait';
	boton.disabled=true;	
	form1.submit();
}
function pv28 ()
{
	v28(document.getElementById('foquin').value, document.getElementById('foquin').id);
	v28(document.getElementById('BillToCompany').value, document.getElementById('BillToCompany').id);
	v28(document.getElementById('BillToStreet2').value, document.getElementById('BillToStreet2').id);
}
function v28(texto, caja)
{
texto=texto.toUpperCase();
texto=texto.replace(/(À|Á|Â|Ã|Ä|Å|Æ)/gi,'A');
texto=texto.replace(/(È|É|Ê|Ë)/gi,'E');
texto=texto.replace(/(Ì|Í|Î|Ï)/gi,'I');
texto=texto.replace(/(Ò|Ó|Ô|Ö)/gi,'O');
texto=texto.replace(/(Ù|Ú|Û|Ü)/gi,'U');
texto=texto.replace(/(Ñ)/gi,'N');
document.getElementById(caja).value = texto;
longitud = texto.length;
pollin = new Array();
for (i=0; i<longitud; i++)
	{
	pollin[i]=texto.charAt(i);
	 eKeyCode=texto.charCodeAt(i);
	 if ((eKeyCode < 48 || eKeyCode > 57) && (eKeyCode < 65 || eKeyCode > 90) && (eKeyCode < 96 ||  eKeyCode > 122) && (eKeyCode != 13) && (eKeyCode != 44)&& (eKeyCode != 45) && (eKeyCode != 46) && (eKeyCode != 47) && (eKeyCode != 8)  && (eKeyCode != 16) && (eKeyCode != 32))
	 	{
		pollin[i]='';
		} 		
	}
var textof='';
for (i=0;i<longitud;i++)
{
textof=textof+pollin[i];
}
document.getElementById(caja).value=textof;
}
function karga()
{
	if(document.getElementById('foquin')){document.getElementById('foquin').focus();}	
}
///////////////FUNCION DE BECAS
 function cumpAttach(attatch,marco,form){
	file = attatch.value;
	div = marco;
	campo = attatch.name;

	document.getElementById(marco).style.display='inline';
	 ext = file.split(".");
	
	 if(ext[1] == "doc" || ext[1] == "DOC" || ext[1] == "docx" || ext[1] == "DOCX" || ext[1] == "PDF" || ext[1] == "pdf" || ext[1] == "GIF" || ext[1] == "gif")
	 {
	document.getElementById(marco).innerHTML="  ";
    document.getElementById('t'+campo).value="true";

}
	 else
	 {
 
		 document.getElementById(marco).innerHTML="<br>File in wrong format.  Please select files with extensions(PDF, GIF or WORD). *The file was not uploaded to the server*";
		document.getElementById('t'+campo).value="false";
		 	 
	 }
	 
	 
	 if(form=='beca'){ //SI VENGO DEL FOMULARIO DE BECAS APLICO ESTA PARTE DEL CODIGO
	 if(campo="archivo1"){
		file1 = document.getElementById('t'+campo).value;}
		
		if(campo="archivo2"){
		file2 = document.getElementById('t'+campo).value;}
		
		if(campo="archivo3"){
		file3 = document.getElementById('t'+campo).value;}
		
		


				if(file1 =='true' && file2 =='true' )
				{
				document.getElementById('enviar').disabled=false;
				}
				if(file1 =='false' || file2 =='false' )
				{
				document.getElementById('enviar').disabled=true;
				}
				if(file3 == 'false')
				{
					 document.getElementById(marco).innerHTML="<br>File in wrong format.  Please select files with extensions(PDF, GIF or WORD). *The file was not uploaded to the server*";
				}

	}//TERMINA BECA
	
	if(form=='travel'){
		if(campo="archivo1"){
		file1 = document.getElementById('t'+campo).value;}
		
		if(campo="archivo2"){
		file2 = document.getElementById('t'+campo).value;}

				if(document.getElementById('tarchivo1').value=='true' && document.getElementById('tarchivo2').value=='true' && document.getElementById('tarchivo3').value=='true')
				{
				document.getElementById('enviar').disabled=false;
				}
	}//TERMINA TRAVEL
 }
 
 
 
 function muestracargo(combin,objeto)
{
	
valor=objeto.value;
//alert(combin.value);
document.getElementById('hiddencargo').value=combin.value;

	if (combin.value=='Otro'){
		document.getElementById('div_otro').style.display='inline';
	}else{
		document.getElementById('div_otro').style.display='none';
		}
	
	if (combin.value=='Prensa Nacional' || combin.value=='Prensa Internacional'){
		document.getElementById('div_prensa').style.display='inline';//muestra el otro cargo
	}else{
		document.getElementById('div_prensa').style.display='none';
		}

	
	if (combin.value=='Prensa Nacional' || combin.value=='Otro' || combin.value=='Prensa Internacional'){
			document.getElementById('cargootro').style.display='inline';
	}else{
		document.getElementById('cargootro').style.display='none';
		}
		
		
		
		
	if(valor=='no' || combin.value=='Prensa Internacional'){
		
		if(combin.value!='Prensa Internacional'){
		document.getElementById('div_visageneral').style.display='inline'; //OCULTO EL DIV DEL MENSAJE GENERAL	
		document.getElementById('div_visaprensa').style.display='none'; //OCULTO EL DIV DEL MENSAJE GENERAL	
		document.getElementById('radiovig').checked;
		}else{
		document.getElementById('div_visaprensa').style.display='inline'; //OCULTO EL DIV DEL MENSAJE GENERAL	
		document.getElementById('div_visageneral').style.display='none'; //OCULTO EL DIV DEL MENSAJE GENERAL	
		}
		document.getElementById('div_visavigente').style.display='inline';//DIV FORMULARIO 	
	}else{
		document.getElementById('div_visaprensa').style.display='none';//DIV PARA ETIKETA DE PRENSA
		document.getElementById('div_visageneral').style.display='none'; //OCULTO EL DIV DEL MENSAJE GENERAL
		document.getElementById('div_visavigente').style.display='none';//DIV FORMULARIO 
	}
	
	
	/*	if(valor=='no'){//if para todos los que requieren visa

			if(combin.value=='Prensa Internacional'){
			document.getElementById('div_visaprensa').style.display='inline';//DIV PARA ETIKETA DE PRENSA
			document.getElementById('div_visageneral').style.display='none';
			}else{
				document.getElementById('div_visageneral').style.display='inline';//DIV PARA ETIKETA GENERAL
				document.getElementById('div_visaprensa').style.display='none';
				}
			document.getElementById('div_visavigente').style.display='inline';//DIV FORMULARIO 
		}else{
				document.getElementById('div_visavigente').style.display='none';//DIV FORMULARIO 
		}*/
		
	
		
}


function vigenciavisa(objeto, objeto2)
{
//alert(objeto2.value);

	document.getElementById('hiddenvigencia').value=objeto.value; //TOMA EL VALOR DE SI O NO TIENE VISA VIGENTE
	
	if(objeto.value=='no'){
		
			document.getElementById('div_visavigente').style.display='inline';//DIV FORMULARIO 
			if(objeto2.value=='Prensa Internacional'){
				document.getElementById('div_visaprensa').style.display='inline';//DIV PARA ETIKETA DE PRENSA
				document.getElementById('div_visgeneral').style.display='none';
			}else{
				document.getElementById('div_visaprensa').style.display='none';//DIV PARA ETIKETA DE PRENSA
				document.getElementById('div_visageneral').style.display='inline';
				}
	}else{
	document.getElementById('div_visaprensa').style.display='none';//DIV PARA ETIKETA DE PRENSA
		document.getElementById('div_visageneral').style.display='none'; //OCULTO EL DIV DEL MENSAJE GENERAL
		document.getElementById('div_visavigente').style.display='none';//DIV FORMULARIO 
	}
		
		
		
		/*
	document.getElementById('div_visageneral').style.display='inline';//DIV PARA ETIKETA GENERAL
	document.getElementById('div_visavigente').style.display='inline';//DIV FORMULARIO 
	}else{
	document.getElementById('div_visageneral').style.display='none';//DIV PARA ETIKETA GENERAL
	document.getElementById('div_visavigente').style.display='none';//DIV FORMULARIO 
	document.getElementById('div_visaprensa').style.display='none';//DIV PARA ETIKETA DE PRENSA
	}*/
}


