// para agregar eventos 
// Creamos la funcion para añadir eventos eventos
function nuevo_evento(elemento, evento, funcion) {
      if (elemento.addEventListener) 
            elemento.addEventListener(evento, funcion, false);
    	else 
            elemento.attachEvent("on"+evento, funcion);
}



// Abrir vetnas en XHMTL "strict"
function openTargetBlank(e){
   var className = 'external';
   if (!e) var e = window.event;
   var clickedObj = e.target ? e.target : e.srcElement;
   
   if(clickedObj.nodeName == 'A' )
    {
      r=new RegExp("(^| )"+className+"($| )");
      if(r.test(clickedObj.className)){
         window.open(clickedObj.href);
         return false;
   
      }
    }
}
   
document.onclick = openTargetBlank;




function poll_voto(campo){
	var total_rad,valido;
	
	valido=false;
	total_rad=campo.poll.length;
	
		for(num_rad=0;num_rad<total_rad;num_rad++){
			if(campo.poll[num_rad].checked)
				valido=true
		}
	
		if(!valido){
			alert("Debes seleccionar una opciï¿½n..!")
			return false;
		}
		else
			return true;
	}
	
//funcion para aceptar solo datos numericos en el onkeypress {onkeypress="return solo_numeros(event)"}
// script de:http://www.forosdelweb.com/showpost.php?p=1284132&postcount=232
function solo_numeros(e) {
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla==8) return true; //Tecla de retroceso (para poder borrar)
    if (tecla==0) return true; //Tecla de retroceso (para poder borrar)
	 patron =/^[0-9]$/; // Reg excprecion
    te = String.fromCharCode(tecla);
    return patron.test(te); 
} 


function maximaLongitud(texto,maxlong) {
  var tecla, in_value, out_value;

  if (texto.value.length > maxlong) {
    in_value = texto.value;
    out_value = in_value.substring(0,maxlong);
    texto.value = out_value;
    return false;
  }
  return true;
} 


// para preguntar antes de eliminar
// onclick="return false,eliminar_link(' esta foto')";
function eliminar_link(txt){
	if(confirm("¿Seguro que desea "+txt+"?"))
	  	return true;
	else
	   	return false;
	   }
	   
// para nueva vetana
// onclick="return false, popup(this,740,248,'_blank')	   
function popup(objeto,w,h,targt){
	width_pop=w;
	heigth_pop=h;
	left_pop=(screen.width/2)-(width_pop/2);
	top_pop=(screen.height/2)-(heigth_pop/2);
	window.open(objeto.href,targt,"width="+width_pop+",height="+heigth_pop+", left="+left_pop+", top="+top_pop+" ,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no");
	return false;		
	}
	
function bank_win(objeto){
	window.open(objeto.href,"_blank","");
	return false;		
	}

function notHomeLiks(){
    if($("#notScroll").length){
        
        
        indicNot=0;
        
        for(i=0;i<notTitulos.length;i++){
            $("#not"+i).attr("dat",i);
            $("#not"+i).click(function(){
                indicNot=$(this).attr("dat");
                changeNot(indicNot);
                return false;
            });
        }

        $("#notFleLeft").click(function(){
            indicNot--;
            if(indicNot<0)
               indicNot=notTitulos.length-1;
            changeNot(indicNot);
            return false;
        });
        $("#notFleRigh").click(function(){
            indicNot++;
            if(indicNot>=notTitulos.length)
                indicNot=0;
            changeNot(indicNot);
            return false;
        });

    }
}


function changeNot(idNot){
        var posPothosX=new Array(0,440,880,0,440,880);
        var posPothosY=new Array(0,0,0,255,255,255);

        
    $("#notBtnNav #notDesc h4").hide();
        $("#notBtnNav #notDesc h4").html(notTitulos[idNot]);
        $("#notBtnNav #notDesc h4").show("normal");
    $("#notBtnNav #notDesc p").hide();
        $("#notBtnNav #notDesc p").html(notResumen[idNot]);
        $("#notBtnNav #notDesc p").show("normal");

    $("#notScroll").animate({
       scrollLeft:posPothosX[idNot],
       scrollTop:posPothosY[idNot]
      }, 1000);

      if(notChageTime!=null)
        clearInterval(notChageTime);
      
      notChageTime=setInterval(function (){
            indicNot++;
            if(indicNot>=notTitulos.length)
                indicNot=0;
            changeNot(indicNot);
      },10000);
}




$(document).ready(function () {
    if(notChageTime==null && $("#notScroll").length)
        changeNot(0);


$("#foot").html($("#foot").html()+'<div id="linksDerech" style="position: fixed;display:none"></div>');
$("#linksDerech").html('<a class="f" href="http://www.facebook.com/Chivas"></a><a class="t" href="http://twitter.com/chivas/"></a><a class="r" href="http://www.redchivas.com/"></a>');
acomodarCuadroDerechaBnt=function(){
    if($(window).width()>1115){
        $("#linksDerech").css('left',$(window).width() - $("#linksDerech").width());
        $("#linksDerech").css('top',($(window).height() - $("#linksDerech").height())/2 );
        $("#linksDerech").show();
    }else
        $("#linksDerech").hidde();
}
acomodarCuadroDerechaBnt();

$(window).scroll(function() {
    acomodarCuadroDerechaBnt();
});

});

var notChageTime=null;