function updateQuantity(f, oname, action){
    var merker = 0;
    for (var i = 0; i < f.length; i++){
        var str = f.elements[i].name;
        if (str == oname){
            merker = i;
            break;
        }
    }
    var neu = parseInt(f.elements[merker].value) + action;
    if ((neu > 0 && neu < 10))
        f.elements[merker].value = neu;
}


// An onkeypress event on an inputTextfield can call this function and pass the event 
// as parameter as well as the encapsulating form and the target command, that needs 
// to be called to submit the form.
// The entered key in the textfield triggeres the onkeypress event. That ascii code of 
// that key can be retrieved via event.keyCode or event.CharCode or event.which depending on browser
function checkAndSubmitOnEnterKey(evt, form, target) { 
	var keycode; 
	if (evt) ; 
	else 
		if (window.event) evt = window.event; 
		else 
			if (event) evt = event; 
			else return true; 
	if (evt.charCode) keycode = evt.charCode; 
	else 
		if (evt.keyCode) keycode = evt.keyCode;  //character code is contained in IE's keyCode property
		else 
			if (evt.which) keycode = evt.which; //character code is contained in NN4's which property
			else keycode = 0; 
	if (keycode == 13) { 				//if character code of pressed key is equal to ascii 13 (if ENTER key)
		chkEmailField(form,target);		//call a validation function before submitting
		//alternatively submit directly:
		//document.getElementById(form+':'+target).onclick(null);
		return false; 
	} 
	else return true; 
}



/**********************************************************************************************************
 ***********************************    External Code    **************************************************
 ******************************************************************************************************** */

/**
 * Various form validation methods.
 *
 * @author Moxiecode
 * @copyright Copyright Â© 2004-2007, Moxiecode Systems AB, All rights reserved.
 */

/**
	// String validation:

	if (!Validator.isEmail('myemail'))
		alert('Invalid email.');

	// Form validation:

	var f = document.forms['myform'];

	if (!Validator.isEmail(f.myemail))
		alert('Invalid email.');
*/
var Validator = {
	isEmail : function(s) {
		return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
	},

	isAbsUrl : function(s) {
		return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
	},

	isSize : function(s) {
		return this.test(s, '^[0-9]+(px|%)?$');
	},

	isId : function(s) {
		return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
	},

	isEmpty : function(s) {
		var nl, i;

		if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
			return true;

		if (s.type == 'checkbox' && !s.checked)
			return true;

		if (s.type == 'radio') {
			for (i=0, nl = s.form.elements; i<nl.length; i++) {
				if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
					return false;
			}

			return true;
		}

		return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
	},

	isNumber : function(s, d) {
		return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
	},
	
	isDigit : function(s) {
		var p = '[0-9]';
		return s == '' || new RegExp(p).test(s);
	},

	test : function(s, p) {
		s = s.nodeType == 1 ? s.value : s;

		return s == '' || new RegExp(p).test(s);
	}
};
/*********************************************************************************************************
 ***********************************  End Of External Code    ********************************************
 ******************************************************************************************************* */


/*********************  Validation Check für den E-card Formular *************************************/
function chkEcardForm(form, target){	
	var arrayIndex=0;		
	var tempArray=new Array(9);		
	var alertText="";	
	
	if (this.document.getElementById(form+':receiverFirstName').value==""){		
	tempArray[arrayIndex]="Bitte geben Sie den Vornamen des EmpfÃ¤ngers ein.";
	arrayIndex++;  
	}	
	if (this.document.getElementById(form+':senderFirstName').value==""){		
	tempArray[arrayIndex]="Bitte geben Sie Ihren Vornamen ein.";
	arrayIndex++;  
	}	
	if (this.document.getElementById(form+':senderLastName').value==""){
	tempArray[arrayIndex]="Bitte geben Sie Ihren Nachnamen ein.";
	arrayIndex++;  
	}		
	if (this.document.getElementById(form+':senderLastName').value==""){
	tempArray[arrayIndex]="Bitte geben Sie den Nachnamen des EmpfÃ¤ngers ein.";
	arrayIndex++;  
	}
    if (this.document.getElementById(form+':receiverEmail').value==""){
	tempArray[arrayIndex]="Bitte geben Sie eine EmpfÃ¤nger-Emailadresse ein.";
	arrayIndex++;
	}
    if (!Validator.isEmail(this.document.getElementById(form+':receiverEmail').value)){
	tempArray[arrayIndex]="Bitte geben Sie eine gÃ¼ltige EmpfÃ¤nger-Emailadresse an.";
	arrayIndex++;  
	}
    if (this.document.getElementById(form+':senderEmail').value==""){
	tempArray[arrayIndex]="Bitte geben Sie eine Absender-Emailadresse ein.";
	arrayIndex++;
	}
    if (!Validator.isEmail(this.document.getElementById(form+':senderEmail').value)){
	tempArray[arrayIndex]="Bitte geben Sie eine gÃ¼ltige Absender-Emailadresse an.";
	arrayIndex++;  
	}

    if (this.document.getElementById(form+':captcha').value==""){
     tempArray[arrayIndex]="Bitte geben Sie einen Sicherheitscode an.";
     arrayIndex++;
     }

      if (arrayIndex != 0) {
		var i=0;
		for (i=0; i<arrayIndex; i++) {
			alertText=alertText+"\n "+tempArray[i]	
		}
		alert("Bitte geben Sie alle mit (*) gekennzeichneten Felder ein: \n\n"+alertText);  
  	}  	
	else {
		//This is an emulation of the action link on the hidden form being clicked and submitted.
		document.getElementById(form+':'+target).onclick(null);  		
	} 	
  	 	
}




