/***************************************************************
*  Copyright notice
*
*  (c) 2007 Dominik Danninger <ddanninger@may.co.at>
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
 * Plugin 'MAY Newsletter subscribe' for the 'nsl' extension.
 *
 * @author	Dominik Danninger <ddanninger@may.co.at>
 * @package	TYPO3
 * @subpackage	tx_nsl
 */

    /**
	 * The selectAll Method - Select all Checkbox Items in form
	 *
	 * @param	string		form: The Form name
	 * @param	string		name: The Checkbox Name
	 * @return	The content that is displayed on the website
	 */

      function selectAll(form,name) {
         var formel = document.forms[form];
         for (i = 0; i < formel.elements.length; i++) {
             if (formel.elements[i].type == "checkbox" && formel.elements[i].name == name) {
               formel.elements[i].checked = true;
             }
         }
      }



    /**
	 * The deselectAll Method - Deselect all Checkbox Items in form
	 *
	 * @param	string		form: The Form name
	 * @param	string		name: The Checkbox Name
	 * @return	The content that is displayed on the website
	 */

      function deselectAll(form,name) {
         var formel = document.forms[form];
         for (i = 0; i < formel.elements.length; i++) {
             if (formel.elements[i].type == "checkbox" && formel.elements[i].name == name) {
               formel.elements[i].checked = false;
             }
         }
      }

      function validate(form,name,text) {
         var formel = document.forms[form];
         for (i = 0; i < formel.elements.length; i++) {
            if (formel.elements[i].name == name) {
                formel.elements[i].parentNode.parentNode.style.color = '#990000';
                formel.elements[i].parentNode.innerHTML += '<br />- '+text;
                formel.elements[i].style.border = '1px solid #990000';
                return true;
            }
         }
         return false;
      }

      function PostSelect(form,name,value,type) {
          var e = document.forms[form].elements[name];
          if (type == "radio") {
                for (var i = 0; i < e.length; ++i) {
                    if (e[i].value != value)
                        e[i].checked = false;
                    else
                        e[i].checked = true;
                }
          }
          else if (type == "select") {
               for (var i = 0; i < e.length; ++i) {
                    if (e[i].value != value)
                        e[i].selected = false;
                    else
                        e[i].selected = true;
               }
          }
      }
