// $Rev$
// $Author$ $Date$

function fngetQueryVar(key)
{
  var ary = document.location.search.substring(1).split("&");

  for ( var i=0; i<ary.length; i++ )
  {
    if ( ary[i].split("=")[0].toUpperCase() == key.toUpperCase() )
       return ary[i].split("=")[1];
  }

  return("")
}

if (top.location != self.location)
{
  top.location = self.location;
}

function fnInitSync()
{
  if(fngetQueryVar('country') && fngetQueryVar('language'))
  {
    fnDoQuery(fngetQueryVar('country'), fngetQueryVar('language'));
  }else{
    fnDoHost();
  }
}

function fnDoQuery(tmpCountry, tmpLanguage)
{
  var_hostname = document.location.hostname.replace(/^www\./,"").toLowerCase();
  var ary = var_hostname.split(".");
  tmpService    = ary.slice(0, ary.length - 2).join('.');
  tmpLanguage   = tmpLanguage.toLowerCase();
  tmpCountry    = tmpCountry.toLowerCase();

  switch(var_hostname)
  {
    case 'profile.tele2.cz':
      self.frames['fraMain'].location="http://www.radiokomunikace.cz/webmailoznam";
    break;

    case 'reg.tele2.cz':
      self.frames['fraMain'].location="http://www.radiokomunikace.cz/webmailoznam";
    break;

    case 'capdev-f1.swip.net':
      self.frames['fraMain'].location="http://capdev-f1.swip.net:36000/" + tmpCountry + "/" + tmpLanguage + "/v2/login_01.php" + location.search;
    break;

    default:
      switch(tmpService)
      {
        case 'admin':		// generic
	case 'admintool':	// se
	case 'admintool.adsl':	// no
          self.frames['fraMain'].location="https://safe.tele2.com/-site-" + var_hostname + "/" + tmpCountry + "/" + tmpLanguage + "/admin/logon.php" + location.search;
        break;

        case 'reg':			// generic
	case 'regminasidor':		// se
	case 'reg.minesider.adsl':	// no
          self.frames['fraMain'].location="https://safe.tele2.com/-site-" + var_hostname + "/" + tmpCountry + "/" + tmpLanguage + "/v2/00_01_trio.php" + location.search;
        break;

        case 'profile':			// generic
	case 'minasidor':		// se
	case 'monprofil':		// fr
	case 'minesider.adsl':		// no
          self.frames['fraMain'].location="https://safe.tele2.com/-site-" + var_hostname + "/" + tmpCountry + "/" + tmpLanguage + "/v2/login_01.php" + location.search;
        break;
    }
  }
}

function fnDoHost()
{
  var_hostname = document.location.hostname.replace(/^www\./,"").toLowerCase();
  var ary = var_hostname.split(".");
  tmpService = ary.slice(0, ary.length - 2).join('.');
  tmpCountry = ary[ary.length - 1];
 
  switch(tmpCountry)
  {
    case 'ch':
      tmpLanguage = 'deu';
    break;

    case 'it':
      tmpLanguage = 'ita';
    break;

    case 'cz':
      tmpLanguage = 'cze';
    break;

    case 'de':
      tmpLanguage = 'deu';
    break;

    case 'lt':
      tmpLanguage = 'lit';
    break;

    case 'nl':
      tmpLanguage = 'dut';
    break;

    case 'at':
      tmpLanguage = 'deu';
    break;

    case 'pl':
      tmpLanguage = 'pol';
    break;

    case 'be':
      tmpLanguage = 'dut';
    break;

    case 'dk':
      tmpLanguage = 'dan';
    break;

    case 'lu':
      tmpLanguage = 'fra';
    break;

    case 'se':
      tmpLanguage = 'swe';
    break;

    case 'no':
      tmpLanguage = 'nor';
    break;

    default:
      tmpLanguage = 'eng';

  }

  if(tmpCountry == 'net') tmpCountry = 'gb';

  switch(var_hostname)
  {
    case 'profile.tele2.cz':
      self.frames['fraMain'].location="http://www.radiokomunikace.cz/webmailoznam";
    break;

    case 'reg.tele2.cz':
      self.frames['fraMain'].location="http://www.radiokomunikace.cz/webmailoznam";
    break;

    case 'capdev-f1.swip.net':
      self.frames['fraMain'].location="http://capdev-f1.swip.net:36000/" + tmpCountry + "/" + tmpLanguage + "/v2/login_01.php" + location.search;
    break;

    default:
      switch(tmpService)
      {
        case 'admin':			// generic
	case 'admintool':		// se
	case 'admintool.adsl':		// no
          self.frames['fraMain'].location="https://safe.tele2.com/-site-" + var_hostname + "/" + tmpCountry + "/" + tmpLanguage + "/admin/logon.php" + location.search;
        break;

        case 'reg':			// generic
	case 'regminasidor':		// se
	case 'reg.minesider.adsl':	// no
          self.frames['fraMain'].location="https://safe.tele2.com/-site-" + var_hostname + "/" + tmpCountry + "/" + tmpLanguage + "/v2/00_01_trio.php" + location.search;
        break;

        case 'profile':			// generic
	case 'minasidor':		// se
	case 'monprofil':		// fr
	case 'minesider.adsl':		// no
          self.frames['fraMain'].location="https://safe.tele2.com/-site-" + var_hostname + "/" + tmpCountry + "/" + tmpLanguage + "/v2/login_01.php" + location.search;
        break;
    }
  }
}

