/*return crossbrowser ID of given ressource*/

function $( ID )
{
 if ( document.getElementById )
  return document.getElementById(ID);
 if ( document.layers )
  return document.layers[ID];
 if ( document.all )
  return document.all[ID];
 return null;
}

function E( error )
{
 $( 'js_errors' ).innerHTML        = error;
 $( 'js_errors' ).style.visibility = 'visible';
 $( 'js_errors' ).style.display    = 'block';
}

function check_internet_explorer()
{
 var msie = navigator.appVersion.indexOf( 'MSIE' );
 if ( msie > 0 )
 {
  var vers = parseFloat( navigator.appVersion.substr( msie + 5, 3 ) );
  if ( vers < 7 )
  {
   var message = '';
   message += 'Ihr Browser ( IE' + vers + ' ) ist veraltet!';
   message += ' Installieren Sie bitte einen aktuellen Browser, wie z.B.';
   message += ' <a style="color:#FF0000;" href="http://www.firefox-browser.de/windows.php" target="_blank">Firefox</a>';
   message += ' oder <a style="color:#FF0000;" href="http://www.microsoft.com/germany/windows/products/winfamily/ie/default.mspx">Internet Explorer 7</a>.';
   E( message );
  }
 }
}

function getHostName()
{
 return ( window.location.hostname ) ? window.location.hostname : window.location.host;
}

function decode( s )
{
 var res = "";
 for ( var i = 0; i < s.length; i++ )
 {
  var ch = s.charCodeAt(i) ;
  res += String.fromCharCode( ( ch & 0xF0 ) + ( ( ch & 0x0C ) >> 2 ) + ( ( ch & 0x03 ) << 2 ) );
 }
 return res;
}

/*display ID or not*/
function visible( ID, status )
{
 if ( typeof ( ID ) == "string" )
 {
  if ( $( ID ) == null ){ return false; }
  if ( status == null ){ status = ( $( ID ).style.display != "block" ); }
  $( ID ).style.display    = ( status == true ) ? "block" : "none";
  $( ID ).style.visibility = ( status == true ) ? "visible" : "hidden";
 }
 else
 {
  if ( ID == null ){ return false; }
  if ( status == null ){ status = ( ID.style.display != "block" ); }
  ID.style.display    = ( status == true ) ? "block"   : "none";
  ID.style.visibility = ( status == true ) ? "visible" : "hidden";
 }
};

/*display loading icon*/
function loading( status )
{
 var o = $( "loading" );
 if ( o.style.zIndex < 1000 ) o.style.zIndex = 1000;
 if ( status )
 {
  ++o.style.zIndex;
  visible( "loading", true );
 }
 else
 {
  if ( --o.style.zIndex <= 1000 ) { visible( "loading", false ); }
 }
};

CONST =
{
 EOL:    String.fromCharCode(0x0A),
 SQUOTE: String.fromCharCode(0x27),
 DQUOTE: String.fromCharCode(0x22),
 BACKSL: String.fromCharCode(0x5C)
};


