if (typeof(ACTIVEX) === 'undefined') ACTIVEX = 1;


function openGalleryJoin(joinURL)
{
  if (window.opener)
  {
    // hurray walk back all parents we find
    if (window.opener.parent)
    {
      if (window.opener.parent.parent)
      {
        if (window.opener.parent.parent.parent)
        {
          window.opener.parent.parent.parent.location.href = joinURL;
        }
        else
        {
          window.opener.parent.parent.location.href = joinURL;
        }
      }
      else
      {
        window.opener.parent.location.href = joinURL;
      }
    }
    else
    {
      window.opener.location.href = joinURL;
    }

    window.close();
  }
  else
  {
    window.document.location.href = joinURL;
  }
}

function writeit(text, id) //v1.1
{
  if (document.getElementById) {
    x = document.getElementById(id);
    if (x) {
      x.innerHTML = '';
      x.innerHTML = text;
    }
  }
  else if (document.all) {
    x = document.all[id];
    if (x) {
      x.innerHTML = text;
    }
  }
  else if (document.layers) {
    x = document.layers[id];
    if (x) {
      x.document.open();
      x.document.write(text);
      x.document.close();
    }
  }
} // ---------------------------------------------------------------------------------- END WRITEIT


function productChangeHelpText(destHLP, destL1, destL3, attach) //v1.0
{
  if (document && document.forms['problem']) {
    var f = document.forms['problem'];
    if (f.elements['product']) {

      var i = f.elements['product'].selectedIndex;
      var t = f.elements['product'].options[i].text;

      for (i = 0; i < productHelpTexts.length; i+= 4) {
        if (t.indexOf(productHelpTexts[i]) != -1) {

          if (attach) writeit(productHelpTexts[i + 1], destHLP);
          else        writeit(productHelpDefault     , destHLP);

          writeit(productHelpTexts[i + 2], destL1);
          writeit(productHelpTexts[i + 3], destL3);

          break;
        }
      }
    }
  }
} // ------------------------------------------------------------------------ productChangeHelpText


function openAfendisCancel(query) //v1.0
{
  var p = "dependent=0,directories=0,height=400,hotkeys=0,left=0,location=0,menubar=0,titlebar=0,"+
          "personalbar=0,resizable=1,scrollbars=1,status=0,toolbar=0,top=0,width=800";
  var u = "https://admin.thrixxx.at/customer-support/afendis/cancellation.php?"+query;
  var w = window.open(u, "AFENDISCANCEL", p);
} // ---------------------------------------------------------------------------- openAfendisCancel


function checkUpdateManager(text) //v1.3
{
  var found = false;

  if (document) {
    if (typeof(document.UpdateManager) != 'undefined') {
      if (document.UpdateManager.Installed) {
        found = true;
      }
    }
  }

  if (found) {
    var x = 0;

  	if (document.getElementById) {
  		x = document.getElementById("box");
  		x.innerHTML = text;
  	}
  	else if (document.all) {
  		x = document.all["box"];
  		x.innerHTML = text;
  	}
  	else if (document.layers) {
  		x = document.layers["box"];
  		x.document.open();
  		x.document.write("<p>"+text+"</p>");
  		x.document.close();
  	}
  }
} // --------------------------------------------------------------------------- checkUpdateManager


function popUp(page, width, height) //v1.1
{
  var p = "dependent=0,directories=0,height="+height+",hotkeys=0,left=0,location=0,menubar=0,"+
          "personalbar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,top=0,width="+width;
  var w = window.open(page, "THRIXXXPOPUP", p);
} // ------------------------------------------------------------------------------------ END POPUP


function openBetaAGR(add) //v1.1
{
  var p = "dependent=0,directories=0,hotkeys=0,location=0,menubar=0,personalbar=0,resizable=1,"+
          "scrollbars=1,status=0,titlebar=0,toolbar=0,left=0,top=0,width=500,height=400";
  var w = window.open("betatest_agreement.php?"+add, "BetaTestAgreement", p);
  if (w) {
    w.focus();
  }
} // ------------------------------------------------------------------------------ END OPENBETAAGR


function toggleInput(name) //v1.1
{
  if (document.getElementById) {
    var h = document.getElementById(name);
    var s = document.getElementById("i_"+name);

    if (h && s && s.style.display == "none") {
      h.style.display = "none";
      s.style.display = "inline";
    }
    else {
      h.style.display = "inline";
      s.style.display = "none";
    }
  }
} // ------------------------------------------------------------------------------ END TOGGLEINPUT


function displayInput(form, name, val) //v1.1
{
  if (document && document.forms[form]) {
    var h = document.forms[form].elements[name];
    var s = document.forms[form].elements["i_"+name];

    if (h && s && h.selectedIndex && h.options && h.options[h.selectedIndex]) {
      var o = h.options[h.selectedIndex];

      if (o.value == val) {
        document.getElementById(     form+"_"+name).style.display = "none";
        document.getElementById("i_"+form+"_"+name).style.display = "inline";
      }
      else {
        document.getElementById(     form+"_"+name).style.display = "inline";
        document.getElementById("i_"+form+"_"+name).style.display = "none";
      }
    }
  }
} // ----------------------------------------------------------------------------- END DISPLAYINPUT


function startDownload(dlUrl) //v1.1
{
  if (dlUrl && dlUrl.length) {
    document.location.href = dlUrl;
  }
} // ---------------------------------------------------------------------------- END STARTDOWNLOAD


function getPluginData(newurl, pass, debug, usrid) //v5.2
{
  // no activex? then skip timeout
  if (!ACTIVEX && !pass) pass = 1;

  if (typeof(debug) === 'undefined') debug = 0;
  if (typeof(usrid) === 'undefined') usrid = 0;

  switch (pass) {
  case 0:
    window.setTimeout("getPluginData('"+newurl+"', 1, "+debug+", "+usrid+")", 1000);
    break;

  case 1:
    if (debug) alert("Checking PLUGIN\n"+
                     "newurl: '"+newurl+"' ("+typeof(newurl)+")\n"+
                     "pass  : '"+pass  +"' ("+typeof(pass  )+")\n"+
                     "debug : '"+debug +"' ("+typeof(debug )+")\n"+
                     "usrid : '"+usrid +"' ("+typeof(usrid )+")\n"+
                     "typeof document: '"+typeof(document      )+"'\n"+
                     "typeof forms: '"+   typeof(document.forms)+"'\n"+
                     "typeof all: '"+     typeof(document.all  )+"'\n"+
                     "typeof skip: '"+    typeof(document.skip )+"'\n"+
                     "typeof getElementById: '"+  typeof(document.getElementById  )+"'\n"+
                     "typeof getElementByName: '"+typeof(document.getElementByName)+"'\n");

    if (ACTIVEX && typeof(document.Luder3D) === 'object') {

      var f = 0;
      if (document) {
        if (typeof(document.forms) === 'object') {
          if (document.forms["skip"]) {
            f = document.forms["skip"];
          }
          else {
            if (debug) alert("NO Form skip!");
          }
        }
        else {
          if (debug) alert("Form skip not accessible");
        }
      }

      if (newurl.indexOf("?") == -1) {
        newurl+= "?";
      }
      else if (newurl[newurl.length - 1] != "&") {
        newurl+= "&";
      }

      if (document.Luder3D.UID && document.Luder3D.UID.length) {
        if (debug) alert("UID found: "+document.Luder3D.UID+" ("+typeof(document.Luder3D.UID)+")");
        if (usrid) newurl+= "usrid="+escape(document.Luder3D.UID.toString())+"&";
        else       newurl+= "uid="+escape(document.Luder3D.UID.toString())+"&";
        if (f) f.elements["UID"].value = document.Luder3D.UID.toString();
      }
      if (document.Luder3D.Page && document.Luder3D.Page.length) {
        if (debug) alert("Page found: "+document.Luder3D.Page+" ("+typeof(document.Luder3D.Page)+")");
        newurl+= "wbst="+escape(document.Luder3D.Page.toString())+"&";
        if (f) f.elements["wbst"].value = document.Luder3D.Page.toString();
      }
      if (document.Luder3D.PageParameters && document.Luder3D.PageParameters.length) {
        if (debug) alert("PPrms found: "+document.Luder3D.PageParameters+" ("+typeof(document.Luder3D.PageParameters)+")");
        newurl+= "pprms="+escape(document.Luder3D.PageParameters.toString())+"&";
        if (f) f.elements["pprms"].value = document.Luder3D.PageParameters.toString();
      }
      if (document.Luder3D.Version && document.Luder3D.Version.length) {
        if (debug) alert("Version found: "+document.Luder3D.Version+" ("+typeof(document.Luder3D.Version)+")");
        newurl+= "plgV="+escape(document.Luder3D.Version.toString())+"&";
        if (f) f.elements["plgV"].value = document.Luder3D.Version.toString();
      }
    }
    else {
      if (debug) alert("Luder3D NOT FOUND");
    }

    if (typeof(document.location) === 'object') {
      document.location.href = newurl;
    }
    else {
      if (debug) alert("NO document.location!");
    }

    break;
  }
} // ---------------------------------------------------------------------------- END GETPLUGINDATA


function checkCancel() //v1.1
{
  var ok = true;

  if (document && document.forms["cancel"]) {
    var c = document.forms["cancel"].elements["creditc"];
    var a = document.forms["cancel"].elements["account"];

    if (ok && c.value && c.value.length) {                            // check creditcard number
      for (i = 0; i < c.value.length; i++) {
        if (c.value.charCodeAt(i) < 48 || c.value.charCodeAt(i) > 57) {
          alert(TTccc[0]);
          ok = false;
          break;
        }
      }
    }

    if (ok && a.value && a.value.length) {                            // check account number
      for (i = 0; i < a.value.length; i++) {
        if (a.value.charCodeAt(i) < 48 || a.value.charCodeAt(i) > 57) {
          alert(TTccc[1]);
          ok = false;
          break;
        }
      }
    }
  }

  if (ok) {
    ok = submitForm();
  }

  return ok;
} // ------------------------------------------------------------------------------ END CHECKCANCEL


function submitForm(idx) //v2.1
{
  var sf = "sub_form";
  var rf = "rst_form";
  var as = "aft_form";

  if (idx) {
    sf+= "_"+idx;
    rf+= "_"+idx;
    as+= "_"+idx;
  }

  if (document.getElementById) {
    if (document.getElementById(sf)) document.getElementById(sf).style.display = "none";
    if (document.getElementById(rf)) document.getElementById(rf).style.display = "none";
    if (document.getElementById(as)) document.getElementById(as).style.display = "inline";
  }

  return true;
} // ------------------------------------------------------------------------------- END SUBMITFORM