//--------------------------------------------------------------------------------------------------------------------
var nah_xmlhttp;

function NAH_GetXmlHttp()
{
  nah_xmlhttp = null;
  if (window.XMLHttpRequest)
  {
    // Code for IE7, Firefox, Mozilla, etc.
    nah_xmlhttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject)
  {
    // Code for IE5, IE6, IE7
    nah_xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
  }

  if (nah_xmlhttp==null)
  {
    alert( "Your browser does not support XMLHTTP." );
  }
}

//--------------------------------------------------------------------------------------------------------------------
function NAH_ExternalUrl( theUrl )
{
  NAH_GetXmlHttp();

  var url = '/page/redirect/url/' + encodeURIComponent( encodeURIComponent( theUrl ) );
  nah_xmlhttp.onreadystatechange = null;
  nah_xmlhttp.open( 'HEAD', url, true );
  nah_xmlhttp.send( null );
}

//--------------------------------------------------------------------------------------------------------------------
function nah_to_lower_case_no_accents( theString )
{
  function remove_accent( theChr )
  {
    switch (theChr)
    {
      case 'à': case 'á': case 'â': case 'ã': case 'ä': case 'å':
  return 'a';
      case 'æ':
  return 'ae';
      case 'ç':
  return 'c';
      case 'è': case 'é': case 'ê': case 'ë': case 'ě': case 'ę':
  return 'e';
      case 'ð':
  return 'd';
      case 'ì': case 'í': case 'î': case 'ï':
  return 'i';
      case 'ł':
  return 'l';
      case 'ñ': case 'ń': case 'ň':
  return 'n';
      case 'ò': case 'ó': case 'ô': case 'õ': case 'ö': case 'ø':
  return 'o';
      case 'ù': case 'ú': case 'û': case 'ü':
  return 'u';
      case 'ş': case 'š':
  return 's';
      case 'ý': case 'ÿ':
  return 'y';
      case 'ž':
  return 'z';
      case 'þ':
  return 'th';
      case 'ß':
  return 'ss';
      default:
  return theChr;
    }
  }

  return theString.toLowerCase().replace( /./g, remove_accent );
}

//--------------------------------------------------------------------------------------------------------------------
function nah_filter_init_field( theFilterId, theFilterInitValue )
{
  var index = -1;

  if (document.getElementById( theFilterId ))
  {
    if (theFilterInitValue!='')  document.getElementById( theFilterId ).style.color = '#444444';

    document.getElementById( theFilterId ).style.width   = document.getElementById( theFilterId ).parentNode.offsetWidth;
    document.getElementById( theFilterId ).style.display = '';
    document.getElementById( theFilterId ).value         = theFilterInitValue;
    index = document.getElementById( theFilterId ).parentNode.cellIndex;
  }

  return index;
}

//--------------------------------------------------------------------------------------------------------------------
var bg;

//--------------------------------------------------------------------------------------------------------------------
function setPointer1(theRow)
{
  if (typeof(theRow.style)=='undefined' ||
      typeof(theRow.cells)=='undefined')
  {
    return false;
  }

  var row_cells_cnt = theRow.cells.length;
  for (var c = 0; c < row_cells_cnt; c++)
  {
    bg                      = theRow.cells[c].bgColor ;
    theRow.cells[c].bgColor = '#CCFFCC';
  }

  return true;
}

//-----------------------------------------------------------------------------
function setPointer2(theRow)
{

  var row_cells_cnt = theRow.cells.length;
  for (var c=0; c<row_cells_cnt; c++)
  {
    theRow.cells[c].bgColor = bg;
  }

  return true;
}

//-----------------------------------------------------------------------------
function view_html_mail( theUrl )
{
  window.open(theUrl,'html_mail','width=400,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

//-----------------------------------------------------------------------------
function view_help( theUrl )
{
  var help = window.open(theUrl,'help','width=400,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
  help.focus();
}

//-----------------------------------------------------------------------------
function view_auto_help( theUrl )
{
  window.open(theUrl,'help','width=400,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

//-----------------------------------------------------------------------------
function view_ranklist_details( theRlsId, theRrlId  )
{
  window.open('?page=rnk_lst_fll.php;rls_id='+theRlsId+';rrl_id='+theRrlId,'','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

//-----------------------------------------------------------------------------
function nah_http_redirect( theUrl )
{
  window.open(theUrl,'Redirect','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
}

//-----------------------------------------------------------------------------
function MM_showHideLayers( theId )
{
  document.getElementById( theId ).style.visibility='visible';
}


function land(ref, target)
{
  lowtarget=target.toLowerCase();
  if (lowtarget=="_self") {window.location=loc;}
  else {if (lowtarget=="_top") {top.location=loc;}
  else {if (lowtarget=="_blank") {window.open(loc);}
  else {if (lowtarget=="_parent") {parent.location=loc;}
  else {parent.frames[target].location=loc;};
 }}}
}

function jump(menu)
{
  ref=menu.choice.options[menu.choice.selectedIndex].value;
  splitc=ref.lastIndexOf("*");
  target="";
  if (splitc!=-1)
  {loc=ref.substring(0,splitc);
   target=ref.substring(splitc+1,1000);}
  else {loc=ref; target="_self";};
  if (ref != "") {land(loc,target);}
}

//-----------------------------------------------------------------------------
function UpperCase( theChar )
{
  var chr = theChar.charCodeAt(0);

  if (224<=chr && chr<=254)return String.fromCharCode(chr-(224-192));

  return theChar.toUpperCase();
}

//-----------------------------------------------------------------------------
function LowerCase( theChar )
{
  var chr = theChar.charCodeAt(0);

  if (192<=chr && chr<=222) return String.fromCharCode(chr+(224-192));

  return theChar.toLowerCase();
}

//-----------------------------------------------------------------------------
function PCase(STRING)
{
  var strReturn_Value = "";
  var iTemp = STRING.length;
  if(iTemp==0){
    return"";
  }
  var UcaseNext = false;
  strReturn_Value += UpperCase(STRING.charAt(iCounter));
  for(var iCounter=1;iCounter < iTemp;iCounter++){
     if(UcaseNext == true){
      strReturn_Value += UpperCase(STRING.charAt(iCounter));
    }
    else{
      strReturn_Value += LowerCase(STRING.charAt(iCounter));
    }
    var iChar = STRING.charCodeAt(iCounter);
    if(iChar == 32 || iChar == 45 || iChar == 46){
      UcaseNext = true;
    }
    else{
      UcaseNext = false
  }
    if(iChar == 99 || iChar == 67){
      if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109){
  UcaseNext = true;
      }
    }


  } //End For

  return strReturn_Value;
} //End Function

//-------------------------------------------------------------------------------------------------
function rot( t, u, v )
{
  return String.fromCharCode( ( ( t - u + v ) % ( v * 2 ) ) + u );
}

//-------------------------------------------------------------------------------------------------
function rot13( s )
{
  var b = [], c, i = s.length,   a = 'a'.charCodeAt(), z = a + 26,   A = 'A'.charCodeAt(), Z = A + 26;
  while(i--)
  {
    c = s.charCodeAt( i );
    if( c>=a && c<z ) { b[i] = rot( c, a, 13 );
    }
    else if( c>=A && c<Z )
    {
      b[i] = rot( c, A, 13 );
    }
    else { b[i] = s.charAt( i );
    }
  }  return b.join( '' );
}

//-------------------------------------------------------------------------------------------------
function rot5( s )
{
  var b = [], c, i = s.length,   a = '0'.charCodeAt(), z = a + 10;
  while(i--)
  {
    c = s.charCodeAt( i );
    if( c>=a && c<z )
    {
      b[i] = rot( c, a, 5 );
    }
    else
    {
      b[i] = s.charAt( i );
    }
  }  return b.join( '' );
}

//-------------------------------------------------------------------------------------------------
function rot135( s )
{
  return rot13( rot5( s ) );
}

//-------------------------------------------------------------------------------------------------
function nah_show_mail_address( theName, theDomain )
{
  document.write( rot13(theName) + "@" + rot13(theDomain) );
}

//-------------------------------------------------------------------------------------------------
function nah_show_mail( theContact, theName, theDomain )
{
  if (theContact)
  {
    document.write( "<a h"+"r"+"e"+"f="+"m"+"a"+"i"+"l"+"t"+"o:" + rot13(theName) + "@" + rot13(theDomain) + ">" + "\"" + rot13(theContact) + "\" &lt;" + rot13(theName) + "@" + rot13(theDomain) + "&gt;</a>" );
  }
  else
  {
    document.write( "<a h"+"r"+"e"+"f="+"m"+"a"+"i"+"l"+"t"+"o:" + rot13(theName) + "@" + rot13(theDomain) + ">" + rot13(theName) + "@" + rot13(theDomain) + "</a>" );
  }
}

//----------------------------------------------------------------------------------------------------------------------
function nah_w3c_validate( theFilename )
{
  var url = '/page/w3c_validate/path/' + theFilename;

  $('#w3c_validate').load(url);
}

//-------------------------------------------------------------------------------------------------
function nah_set_menu_height()
{
  var menu_height   = document.getElementById( 'menu' ).offsetHeight;
  var content_height = document.getElementById( 'content' ).offsetHeight;

  if (content_height>menu_height) document.getElementById( 'menu2' ).style.height = content_height + 'px';
}

//-------------------------------------------------------------------------------------------------

