function ConfirmarBorrado(direccion,titular){
	if (confirm(titular)){
		window.location = direccion
	}	
}
function abrir(theURL,winName,features) { 
  window.open(theURL,winName,features);
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var titulares=new Array();

titulares['d']='Amnesty International';
titulares['e']='Amnistía Internacional';
titulares['f']='Amnesty International';
titulares['a']='Amnesty International';
titulares['i']='Amnesty International';
titulares['t']='Uluslararası Af Örgütü';

function changeLang(lang)
{
	changeImg('homechoose', lang, 'gif');
	changeImg('homesigning', lang);	
	changeImg('homeright', lang);
	changeImg('ti_language', lang, 'gif');	
	changeImg('ti_version', lang, 'gif');
	changeImg('logo', lang, 'gif');
	changeImg('bo_enter', lang);
	
	var auxtema=titulares['i'];
	if(lang!=''){
		auxtema=titulares[lang];
	}
	document.title=auxtema;
	
}

function changeImg(name, lang, ext)
{
	if(!ext) ext='jpg';
	var img = document.images[name];
	if (img) img.src='Img/' + name + (lang!='' ? '_' + lang : '') + '.' + ext;
}

var boenterin=false;
function entereonmouseover()
{
	var img = document.images['bo_enter'];
	if ((boenterin)||(!img)) return;
	boenterin = true;
	img.src= img.src.replace(/\.jpg/gi, "_il.jpg");
	img.onmouseout=entereonmouseout;	
}

function entereonmouseout()
{
	var img = document.images['bo_enter'];
	if ((!boenterin)||(!img)) return;
	img.src= img.src.replace(/_il\.jpg/gi, ".jpg");
	boenterin = false;
	

}

function changeonmouseover(name)
{
	var cadena= name;
	cadena=name.substring(name.lastIndexOf('/'),name.lastIndexOf('.'));
	var img = document.images['bo_enter'];
	if (img) img.src='Img/' + cadena + '_il' + '.' + 'jpg';

}
function changeonmouseout(name)
{
	var cadena= name;
	cadena=name.substring(name.lastIndexOf('/'),name.lastIndexOf('_'));
	var img = document.images['bo_enter'];
	if (img) img.src='Img/' + cadena  + '.' + 'jpg';

}
function restoreLang()
{
	changeLang(getLang());
}

function setLang(lang)
{
	changeLang(lang);
}

function getLang(lang)
{
	var langs = document.forms['langselect']['idioma'];
	for(var i=0; i<langs.length; i++)
	{
		if(langs[i].checked) return langs[i].value;
	}
}

equivoc=0;
function emilio(contcorreo){
        //compruebo el emilio
                var correo=contcorreo;
                var fallo_correo = 0;
                var pos = correo.indexOf("@");
                
                if (pos == -1){
                        fallo_correo = 1;
                }
        
        //compruebo q tenga al menos 1 carácter antes y después de le arroba y el punto
                if ((pos == 0)||(pos == correo.length-1)) {
                        fallo_correo = 1;
                }
                
                var pos2 = correo.lastIndexOf(".");
                if((pos2 < pos+1)||(pos2 == correo.length-1)){
                        fallo_correo = 1;        
                }

				if(correo.length>5){
					for (i=0; i<correo.length; i++){
							if (correo.charAt(i)==" ") {
							fallo_correo = 1;
							}
					}
				}
                
               return fallo_correo;
}

function validar(nombreform){
	equivoc=0;
	if(nombreform=='form1'){
		var nombre=eval("document."+nombreform+".firstname.value");
		var correo=eval("document."+nombreform+".email.value");
		document.getElementById("textofirstname").style.color='black';
		document.getElementById("textoemail").style.color='black';
		if(nombre==""){
			equivoc=1;
			document.getElementById("textofirstname").style.color='red';
		}
		//valido correo
		if(emilio(correo)==1){
			equivoc=1;
			document.getElementById("textoemail").style.color='red';
		}
	}
	if(nombreform=='form2'){
		document.getElementById("textofirstname").style.color='black';
		document.getElementById("textoemail").style.color='black';
		document.getElementById("textoemail2").style.color='black';
		document.getElementById("textofirstname2").style.color='black';
		document.getElementById("textoemail3").style.color='black';
		document.getElementById("textofirstname3").style.color='black';
		
		nombre=eval("document."+nombreform+".firstname.value");
		correo=eval("document."+nombreform+".email.value");
		
		if(nombre==""){
			equivoc=1;
			document.getElementById("textofirstname").style.color='red';
		}
		//valido correo
		if(emilio(correo)==1){
			equivoc=1;
			document.getElementById("textoemail").style.color='red';
		}
		
		
		nombre=eval("document."+nombreform+".name2.value");
		correo=eval("document."+nombreform+".email2.value");
		if((nombre!="")||(correo!="")){
			if(emilio(eval("document."+nombreform+".email2.value"))==1){
				equivoc=1;
				document.getElementById("textoemail2").style.color='red';
			}
			if(nombre==""){
				equivoc=1;
				document.getElementById("textofirstname2").style.color='red';
			}
		}
		
		nombre=eval("document."+nombreform+".name3.value");
		correo=eval("document."+nombreform+".email3.value");
		if((nombre!="")||(correo!="")){
			if(emilio(eval("document."+nombreform+".email3.value"))==1){
				equivoc=1;
				document.getElementById("textoemail3").style.color='red';
			}
			if(nombre==""){
				equivoc=1;
				document.getElementById("textofirstname3").style.color='red';
			}
		}
	}

	if (equivoc==0){
		eval("document."+nombreform+".submit()");
	}
}