/********************************************/
/******* SHOW HIDDEN ELEMENT**********/
/********************************************/
function show(item)
{
	var contenedor=document.getElementById(item)
		
	if(contenedor.style.display=='none')
	{
		contenedor.style.display='block'
	}
	else
	{
		contenedor.style.display='none'
	}
	
	resizeElements();
	
}
/********************************************/
/******* BUSCAR CONTROL TIPO INPUT **********/
/********************************************/
function findControl(ControlName)
{       
    var ret=null;
    var aControls = document.getElementsByTagName("input");
    if (aControls)
    {       
        for (var i=0; i< aControls.length ; i++)
        {
            if (aControls[i].id.lastIndexOf(ControlName) == 
                aControls[i].id.length - ControlName.length && 
                aControls[i].id.length != ControlName.length && 
                aControls[i].id.lastIndexOf(ControlName)  > 0 )
            {
                ret =aControls[i];
                break;
            }
        }
    }
    return ret;
} 
/********************************************/
/******* INTERCAMBIO DE IMAGENES ************/
/********************************************/
function swapImage(element,source) { 
    var img;
    img = document.getElementById(element);
    img.src=source;
}
/********************************************/
/******* RESIZE ELEMENTOS *******************/
/********************************************/
function resizeElements() {
    
    if (document.getElementById) {
        
        /*ASIGNAR ALTO DE CONTENIDO*/
        var windowHeight=getWindowHeight();        
        
        if (windowHeight>0) {
        
            var contentBody=document.getElementById('body');
            var contentSponsors=document.getElementById('sponsors');
                                   
            var bodyHeight=document.getElementById('body').offsetHeight;
            var sponsorsHeight=document.getElementById('sponsors').offsetHeight;                        
            var sponsorsMinHeight = 320
                                    
            /*alert ("bodyheight " + BodyHeight + " SponsorsHeight " + SponsorsHeight);*/
            /*alert(sponsorsHeight);*/
            
            if (bodyHeight>sponsorsHeight) {
                contentSponsors.style.height= bodyHeight + 'px';
            }
            else if (bodyHeight<sponsorsHeight) {
                    
                if (sponsorsMinHeight<bodyHeight){              
                    contentSponsors.style.height = bodyHeight + 'px';                      
                }else{
                    contentBody.style.height= sponsorsMinHeight + "px";
                }
                
            }                                   
        }               
    }
}

function getWindowHeight() {

    var windowHeight=0;
    if (typeof(window.innerHeight)=='number') {
        windowHeight=window.innerHeight;
    }
    else {
        if (document.documentElement&&document.documentElement.clientHeight) {
            windowHeight=document.documentElement.clientHeight;
        }
        else {
            if (document.body&&document.body.clientHeight) {
            windowHeight=document.body.clientHeight;
            }
        }
    }
    
    return windowHeight;

}
/********************************************/
/******* HANDLER SUMARIO ERRORES ************/
/********************************************/
function ShowSummaryErrors()
{
    if (!Page_IsValid)
    {    
        var s = "";
        var i;
        for (i=0; i<Page_Validators.length; i++) {
            if (!Page_Validators[i].isvalid && 
                 typeof(Page_Validators[i].errormessage) == "string") {
                s += "<li>" + Page_Validators[i].errormessage + "</li>";
            }
        }
        if (s != "")
        {
            document.getElementById('errores').innerHTML = s;
            document.getElementById('error').style.display = 'block';
            resizeElements();
        }
    }
}
/********************************************/
/******* CONTROL SECCIONES ******************/
/********************************************/
function showHideDiv(id)
{    
    var status = document.getElementById(id).style.display;
    
    if (status=='none' || status=='')
    {
        document.getElementById(id).style.display = 'block';
    }
    else
    {
        document.getElementById(id).style.display = 'none';
    }
}
/********************************************/
/******* EVENTOS WINDOW *********************/
/********************************************/
window.onload = function() {   
  resizeElements();  
}

window.onresize = function() {
  resizeElements();  
}