function abreFechaPop( pop )
{
	var e = document.getElementById( pop ) ;
	if ( document.all )
	{
		var displayReal=e.currentStyle.display;
	}
	else 
	{
		var cs=document.defaultView.getComputedStyle(e, null);
		var displayReal=cs.getPropertyValue('display');
	}
	
	if ( displayReal == 'block' ) 
	{
		document.getElementById( 'bkgPop' ).style.display = 'none' ;
		document.getElementById( 'frm' ).style.display = 'none' ;
		document.getElementById( pop ).style.display = 'none' ;
	}
	else 
	{
		resizePop() ;
		document.getElementById( 'bkgPop' ).style.display = 'block' ;
		document.getElementById( 'frm' ).style.display = 'block' ;
		document.getElementById( pop ).style.display = 'block' ;
	}
}

function resizePop() 
{
	if (!document.all) 
	{
		document.getElementById('bkgPop').style.height = window.innerHeight + 'px';
		document.getElementById('frm').style.height = window.innerHeight + 'px';
		if (window.innerHeight < document.body.clientHeight) 
		{
			document.getElementById('bkgPop').style.height = document.body.clientHeight + 'px';
			document.getElementById('frm').style.height = document.body.clientHeight + 'px';
		}
	} 
	else 
	{		
		if (document.documentElement.clientHeight < document.body.clientHeight) 
		{
			document.getElementById('bkgPop').style.height = document.body.clientHeight + 'px';
			document.getElementById('frm').style.height = document.body.clientHeight + 'px';
		}
		else 
		{
			document.getElementById('bkgPop').style.height = document.documentElement.clientHeight + 'px';
			document.getElementById('frm').style.height = document.documentElement.clientHeight + 'px';
		}
	}
}

function esqueciSenha( idForm )
{
	var oErro = document.getElementById( 'erro-esqueci' ) ;
	while( oErro.firstChild ) oErro.removeChild( oErro.firstChild ) ;

	var oForm = document.getElementById( idForm ) ;
	oForm.submit() ;
}

function esqueciSenhaRetorno( status, message )
{
	if ( status == 'ERRO' )
	{
		var oErro = document.getElementById( 'erro-esqueci' ) ;
		
		while( oErro.firstChild ) oErro.removeChild( oErro.firstChild ) ;
		
		oErro.appendChild( document.createTextNode( message ) ) ;
	}
	else
	{
		var oEmail = document.getElementById( 'passSentEmail' ) ;
		oEmail.innerHtml = message ;

		abreFechaPop( 'sendPass' ) ;
		abreFechaPop( 'passSent' ) ;
	}
}

function mostraCupom( url )
{
	cupomPop.location = url ;
	
	abreFechaPop( 'print' ) ;
}

function abreEnvio( idCupom )
{
	var oForm = document.getElementById( 'frm-envia' ) ;
	oForm.id.value = idCupom ;
	
	abreFechaPop( 'sendMail' ) ;
}

function enviaCupon( idForm )
{
	var oErro = document.getElementById( 'erro-envia' ) ;
	while( oErro.firstChild ) oErro.removeChild( oErro.firstChild ) ;

	var oForm = document.getElementById( idForm ) ;
	oForm.submit() ;
}

function enviaCuponRetorno( status, message )
{
	if ( status == 'ERRO' )
	{
		var oErro = document.getElementById( 'erro-envia' ) ;
		
		while( oErro.firstChild ) oErro.removeChild( oErro.firstChild ) ;
		
		oErro.appendChild( document.createTextNode( message ) ) ;
	}
	else
	{
		abreFechaPop('sendMail') ;
		abreFechaPop('mailSent') ;
	}
}

function autoTab( oFrom, oToId )
{
	var oTo = document.getElementById( oToId ) ;
	if ( oFrom.value.length == oFrom.maxLength ) oTo.focus() ;
}

function numeros( e )
{
	var unicode = e.charCode ? e.charCode : e.keyCode ;
	
	if ( unicode!=8 && unicode!=9 && unicode!= 37 && unicode != 39 ) // backspace, tab, <-, ->
	{
		if ( unicode < 48 || unicode > 57 ) // if not a number
			return false ;// disable key press
	}
	return true ;
}


