﻿// Archivo JScript

function cambiaFecha(dia, mes, ano)
{
	var inputDia = document.getElementById("CalendarioDiaPost");
	inputDia.value = dia;
	var inputMes = document.getElementById("CalendarioMesPost");
	inputMes.value = mes;
	var inputAno = document.getElementById("CalendarioAnoPost");
	inputAno.value = ano;
	var form = document.getElementById("formulario");
	form.submit();
}


function ShowConcurso(id)
{
	// alert("Mostramos Concurso id:"+id);
	window.location.href = "/concursos?id=" + id;
}

function ShowPupupSubart(id)
{
    if(PopupID )
    {
        HidePupupSubart(PopupID)
    }
    document.getElementById("Popup_Subart_" + id).style.display = "block";
    PopupIDName = "Popup_Subart_" + id;
    init_flotante();
    PopupID = id;
}

function HidePupupSubart(id)
{
    document.getElementById("Popup_Subart_" + id).style.display = "none";
}


var PopupIDName ="";
var PopupID;

function init_flotante()
{
	var IE = document.all?true:false; 
	if (!IE) document.captureEvents(Event.MOUSEMOVE); 
	var ObjActivo = false; 

	if( IE ) 
	{ 	
	        
		    recoloca_flotante();
    		window.onscroll = function(){
			    recoloca_flotante();
	        }
    	
	}else{	
		popupInter=setInterval("recoloca_flotante()",1);
	}
}

function recoloca_flotante(){

	obj = document.getElementById(PopupIDName); 
	alto = document.body.clientHeight;
	alto_flot=619;
	posy = (alto-alto_flot)/2;
    var IE = document.all?true:false; 
	
	if (IE) 
	{
	    posy += document.documentElement.clientHeight /2;
	}
	
    movetop = ((document.body.scrollTop)?document.body.scrollTop:document.documentElement.scrollTop) + posy;       
    obj.style.top = movetop + 'px'; 
    //correción explorer
    scrolltop = document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop;
    if(obj.offsetHeight>document.documentElement.clientHeight){
       obj.style.top=0;
    }
	
}


function writeFlash(url,w,h){
	
    url=url+'.swf';

	var peli;
		  peli='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width='+w+' height='+h+'>';
          peli+='<param name="movie" value='+url+'>';
		  if (document.all)
          peli+='<param name="quality" value="high">';
		  peli+='<param name="wmode" value="transparent">';
          peli+='<embed src='+url+' quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width='+w+' height='+h+'></embed>';
		  peli+='</object>';

    document.write(peli);
}

function externalLinks() 
{ 

     if (!document.getElementsByTagName) return; 
     
     var anchors = document.getElementsByTagName("a"); 
     
     for (var i=0; i<anchors.length; i++) 
     { 
       var anchor = anchors[i]; 
       
       if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")  
       {
            anchor.target = "_blank"; 
       } 
       else if (anchor.getAttribute("href") && anchor.getAttribute("href").indexOf("http://") == 0)  
       {       
            var start = window.location.href.split('/');
            
            if(start.length >1)
            {
                
                var text = start[0] + "/" + start[1] + "/" + start[2];
                
                if (anchor.getAttribute("href") && anchor.getAttribute("href").indexOf(text) != 0)  
                {
                    anchor.target = "_blank"; 
                }
            }
            
       }
   
 } 
 
 if(LoginErrorMsg!= "")
 {
    alert(LoginErrorMsg);
 }
 
 if(TextoConfirmacionSuscripcion!= "")
 {
    ConfirmacionSuscripcion();
 }
 
}
 
var LoginErrorMsg = "";
var TextoConfirmacionSuscripcion= "";

window.onload = externalLinks;
