/**
 * Projekt:
 * MediCMS - Content Management System
 *
 * Sämtliche in dieser Release enthaltenen Dateien
 * unterliegen Copyrights und dürfen nicht ohne deren Beachtung
 * (weiter-)verwendet werden.
 *
 **************************************************************************
 * Copyrights in Bezug auf Verwendung in MediCMS:
 * Für jede Datei, für die kein Copyright explizit angegeben ist, gilt das
 * Copyright des Packages, welches die Datei enthält.
 *
 **************************************************************************
 * CMS-Engine und Engineabhängige Module:
 *
 * Copyright 2003-2005
 *           Ingo Scholz
 *                hummel+lang (www.hummel-lang.de)
 * - Die Dateien dürfen in keiner Form verändert oder angepasst werden.
 * - Die wiederverwendung von Codeauszügen ist untersagt.
 *
 *
 **************************************************************************
 * Admin-Umgebung - Smarty - Komplirierende Template-Engine:
 *
 * Smarty - version 2.6.2
 * 2001-2004 ispi of Lincoln, Inc.
 *
 * http://smarty.php.net/
 *
 *
 **************************************************************************
 * Admin-Umgebung - HTMLAREA-Eingabefeld:
 *
 * Copyright (c) 2002, interactivetools.com, inc.
 * See htmlarea/license.txt for details.
 *
 *
 **************************************************************************
 * Login-JavaScript-MD5-Verschlüsselung:
 *
 * JavaScript implementation of the RSA Data Security, Inc. MD5 Message
 * Digest Algorithm, as defined in RFC 1321.
 * Version 1.1 Copyright (C) Paul Johnston 1999 - 2002.
 * Code also contributed by Greg Holt
 *
 * See http://pajhome.org.uk/site/legal.html for details.
 *
 */


function openLoadingScreen()
{
  parent.document.body.rows = '*,2';
}

function closeLoadingScreen()
{
  parent.document.body.rows = '2,*';
}


function f_filterResults(n_win, n_docel, n_body) {
  var n_result = n_win ? n_win : 0;
  if (n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel;
  return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function setScrollbarEntry()
{
  /*
	y=0;
  alert (window.pageYOffset);
  alert (document.body.scrollTop);
  alert (document.documentElement.scrollTop);
  if (window.pageYOffset) {
    y = window.pageYOffset;
    alert ("step 1: "+y);
  } else {
    //alert ("step 2 ok? ("+window.top.mainFrame.document.body.scrollTop+")");
    if (document.body && document.body.scrollTop)
    {
      y=document.body.scrollTop;
      alert ("step 2 ok: "+y);
    }
  }
  */
  
  y = f_filterResults (
    window.pageYOffset ? window.pageYOffset : 0,
    document.documentElement ? document.documentElement.scrollTop : 0,
    document.body ? document.body.scrollTop : 0
  );
  
	//alert ("offset: "+y);
	txForm['sb_o'].value = y;	
	openLoadingScreen();
}

sentPwdAlertBox = false;

function doChangeTxForm (formObj, exceptCtlName)
{
  cnt=0;
  //alert ("doChangeTX for "+ formObj.name);
  while (formObj[cnt])
  {
    if ( (formObj[cnt].name != exceptCtlName) && (formObj[cnt].name != 'tmpdummy') )
    {
      //alert ("cnt: "+cnt +" -> Name: "+formObj[cnt].name+" Title: "+formObj[cnt].title+" type:" + formObj[cnt].type + " val:" + formObj[cnt].value);
      if (formObj[cnt].type == 'checkbox')
      {
        //alert ("set chkBox ("+formObj[cnt].checked+")!");
        txForm[formObj[cnt].name].value = formObj[cnt].checked;
      } else if (formObj[cnt].type == 'password')
      {
        if (formObj[cnt].value != '')
        {
          if (!sentPwdAlertBox)
          {
            alert ("\n"+window.document.title+"\nSicherheitshinweis.               \n\n\nIhr Passwort wird nun über ein passives Skript           \n\nzuerst verschlüsselt und dann übertragen.      \n\n");
            sentPwdAlertBox = true;
          }
          txForm[formObj[cnt].name].value  = calcMD5( formObj[cnt].value );
        } else {
          //alert ("\n"+window.document.title+"\nSicherheitshinweis.               \n\nEs werden keine leeren Passwörter akzeptiert.        \n\n");
          //return (false);
          //txForm[formObj[cnt].name].value  = '';
        }
				
      } else if ((formObj[cnt].type != 'image') && (formObj[cnt].type != 'submit') && (formObj[cnt].type != 'button'))
      {
        //alert ("set!");

        if ((formObj[cnt].name == 'chg_co_pid') || (formObj[cnt].name == 'chg_mti_pid'))
        {
          if (formObj[cnt].value != '')
          {
            txForm[formObj[cnt].name].value = "  "+formObj[cnt].value+"  ";
          }
        } else {
          txForm[formObj[cnt].name].value = formObj[cnt].value;
        }
        if (formObj[cnt].type == 'hidden')
        {
          formObjName = formObj[cnt].name;

          if (formObjName == 'chg_co')
          {
            // contentObject-Änderung - also Daten sammeln.
            doChangeTxForm (document.chgCOstdFieldsForm, '');
            txForm['chg_co_c'].value = document.chgCOcontentForm.chgcocontent.value;
            //alert ("content: "+document.chgCOcontentForm.chgcocontent.value);

          }

          if (formObjName == 'chg_go')
          {
            // contentObject-Änderung - also Daten sammeln.
            doChangeTxForm (document.chgGOstdFieldsForm, '');
            txForm['chg_go_c'].value = document.chgGOcontentForm.chggocontent.value;
            //alert ("content: "+document.chgCOcontentForm.chg_co_content.value);

          }
        }

        //} else {
        //  txForm['n_co_c'].value = formObj[cnt].value;
        //}
      }
    }
    cnt++;
  }

}


function cTx(formObj)
{
  doChangeTxForm (formObj, '');


  if (document.newCOnameForm)
  {
    txForm['n_co_n'].value = document.newCOnameForm.n_co_n.value;
  }

  if (document.newGOnameForm)
  {
    txForm['n_go_n'].value = document.newGOnameForm.n_go_n.value;
  }

  //if (document.newCOcontentForm)
  //{
  //  //alert ("getting nameForm");
  //  doChangeTxForm (document.newCOnameForm, '');
  //  //alert ("getting contentForm");
  //  txForm['n_co_c'].value = document.newCOcontentForm.ncocontent.value;
  //}

  //if (document.newGOcontentForm)
  //{
  //  //alert ("getting nameForm");
  //  doChangeTxForm (document.newGOnameForm, '');
  //  //alert ("getting contentForm");
  //  txForm['n_go_c'].value = document.newGOcontentForm.ngocontent.value;
  //}

	setScrollbarEntry();
}

function mcTx(formObj, objValue)
{
	txForm[formObj].value = objValue;
  //if (document.newProductForm)
  //{
  //  doChangeTxForm (document.newProductForm, 'np');
  //}
	setScrollbarEntry();
}

function changeCheckbox(obj)
{
    alert ("Checkbox: name: "+obj.name+" value: "+obj.value+" -> checked: "+obj.checked);
    //if(this.blur)this.blur();
  //if (document.newProductForm)
  //{
  //  doChangeTxForm (document.newProductForm, 'np');
  //}
		setScrollbarEntry();
}


