// -- functions for error modal and processing modal

var ae_cb = null;

function $( id ) { return document.getElementById(id); }
//-- end [ $ ]


function modal_click( state ) 
{ var status;
  
  if ( ( state == null ) || ( state == 'show' ) )
    { status = 'block'
      centerdiv( $('modal_modal'), 240 );    	
      // 200 = 50 (blockH) +10*2 (margin) +20*2 (padding) + 36 (title img H) + 3*1 (title margin) +3+6 (title padding) + 2*2 (border) +20*2 (wrap margin)
    }  
  else
    { status = 'none' }
  
  $('modal_overlay').style.display = $('modal_modal').style.display = status;
  
  if( status == 'none') 
	{ $(returnTo).focus(); }
  
  return false;

}//-- end [ modal_click ]


function clickswitch( )
 { modal_click('close');   }
//-- end [ clickswitch ]


function $q( id )
{ return document.getElementById( id );  }
//-- end [ $q ]


function modal_processing() 
{   
	centerdiv( $('process_modal'), 116 );	// 116 = 50 (imgH) +10*2 (padding) +20*2 (margin) + 3*2 (border)
	var status = 'block';
	$('modal_overlay').style.display = $('process_modal').style.display = status;
	
}
//-- end [ modal_processing ]




__getBrowserSize = function()
{
	var bodyWidth = document.documentElement.clientWidth;
	var bodyHeight = document.documentElement.clientHeight;
	
	var bodyWidth, bodyHeight; 
	
	if (self.innerHeight)
	{ // all except Explorer 
	   bodyWidth = self.innerWidth; 
	   bodyHeight = self.innerHeight; 
	}  
	else if (document.documentElement && document.documentElement.clientHeight) 
	{  // Explorer 6 Strict Mode 		 
	   bodyWidth = document.documentElement.clientWidth; 
	   bodyHeight = document.documentElement.clientHeight; 
	}
	else if (document.body) 
	{ // other Explorers 		 
	   bodyWidth = document.body.clientWidth; 
	   bodyHeight = document.body.clientHeight; 
	} 
	return [bodyWidth,bodyHeight];		
	
}


function centerdiv( divid, tmpH )
{
    var brSize = this.__getBrowserSize();
	var bodyWidth = brSize[0];
	var bodyHeight = brSize[1];

	var tmpWidth = divid.style.width;
	//var tmpHeight = divid.style.height;
	var tmpHeight = tmpH;

   	//this.divs_content.style.left = Math.ceil((bodyWidth - tmpWidth) / 2) + 'px';;
   	//divid.style.top = (Math.ceil((bodyHeight - tmpHeight) / 2) +  topOffset) + 'px';
   	divid.style.top = ( Math.ceil((bodyHeight-tmpHeight) / 2) ) + 'px';

}



