function setFocus(id)
{
  document.getElementById(id).focus();
}
function AtualizaPai(id,valor)
{
    window.opener.document.getElementById(id).value = valor;
}
function abrirJanela(strUrl, strNomeJanela, strWidth, strHeight)
{ 
				// 544,432
				/*WIDTH = 544;
				HEIGHT = 30;*/
			var WIDTH = strWidth;
			var HEIGHT = strHeight;
				//alert(WIDTH + ' - '+ HEIGHT);
			var	x = (screen.width - WIDTH)/2;
	        var y = (screen.height - HEIGHT)/2;
	       
	        var windowprops = "dependent=yes, toolbar=no, menubar=no, statusbar=no, scrollbars=auto, resizable=no, titlebar=no, copyhistory=yes, maximized=yes, width=" + WIDTH + ",height=" + HEIGHT +",top=" + y + ",left=" + x +"";
	        var janela = window.open(strUrl, strNomeJanela, windowprops);							
			//janela.resizeTo(WIDTH, HEIGHT);	
			janela.resizeTo(WIDTH + 10, HEIGHT + 35);	
			janela.focus();
} 

var timerID
function startClock(){
   //alert('Start..1');
   timerID = window.setTimeout("showClock()", 2000); // 1-second interval
  // alert('Start..');
}
function startClockC(campo){
   //alert('Start..'+campo);
   timerID = window.setTimeout("showClockC('"+campo+"')", 2000); // 1-second interval
  // alert('Start..');
}

function stopClock(){
   window.clearTimeout(timerID);
   //alert('Fim');
}
function showClockC(campo){
   // This function actually displays the time. 
	
	//alert('Oi..'+window.document.forms[0].hdnPop);
	
	var ObjId = eval('window.document.forms[0].'+campo); 
	
	//alert(ObjId.value);
	
	if (ObjId != null) 
	{	
		if(ObjId.value == '1')
		{
			stopClock();
			window.document.forms[0].submit();	
		}	
		else
		{
			timerID = window.setTimeout("showClockC('"+campo+"')", 1500); // repeat call	
		}
	}
	else
	{
		stopClock();
	} 	
}

function showClock(){
   // This function actually displays the time. 
	
	//alert('Oi..');
	
	var ObjId = eval('window.document.forms[0].ctl00_hdnTime'); 
	
	if (ObjId != null) 
	{	
		if(ObjId.value == '1')
		{
			stopClock();
			window.document.forms[0].submit();	
		}	
		else
		{
			timerID = window.setTimeout("showClock()", 1500); // repeat call	
		}
	}
	else
	{
		stopClock();
	} 
}

function FechaPop()
{
    if ( window.opener == null )
    {
    
        window.open('Default.aspx','_self');
        
    }
    else
    { 
        var ObjId=eval('window.opener.document.forms[0].hdnTime'); 
        if (ObjId != null) 
        {	
            ObjId.value = '1';	
        } 
        else 
        {             
            ObjId = window.opener.document.getElementById('ctl00_hdnTime'); 
                
            if ( ObjId != null ) 
            {                 
                ObjId.value = '1'; 
            } 
        } 
    } 
    window.close();
    
}
function AlinhaJanela(WIDTH,HEIGHT)
{
	var	x = (screen.width - WIDTH)/2;
	var y = (screen.height - HEIGHT)/2;				
	window.moveTo(x,y);
	window.resizeTo(WIDTH+10,HEIGHT+35);
}



    function OpenALTShow ( Objeto, event, OpenALTAlinhamento )
    {
        var divs = Objeto.getElementsByTagName("div");

        if ( divs != null && divs.length > 0 )                 
        {
            divs[0].style.display = "block";
            var Ajuste = 10;
            
            if ( OpenALTAlinhamento == 1 )
            {
                Ajuste = ((Number(divs[0].style.width.replace('px', '')) / 2)) * -1;
            }
            else if ( OpenALTAlinhamento == 2 )
            {
                Ajuste = ((Number(divs[0].style.width.replace('px', ''))) + 10) * -1;
            }                
            
            divs[0].style.left = (event.clientX + Ajuste ) + "px"; 
            divs[0].style.top = (event.clientY - 4) + "px";
            
        }
    }

    function OpenALTHidden ( Objeto )
    {
        var divs = Objeto.getElementsByTagName("div");

        if ( divs != null && divs.length > 0 )                 
        {
            divs[0].style.display = "none";                    
        }
    }
