function closeAlert( AlertObject ) {
	Element = document.getElementById( AlertObject );
	
	$( Element ).slideUp();
}

function switchPayment( IDElement, IDValue, NameElement, NameValue ) {
	
	/**
	 * Changing the value inside of the hidden field for posting
	 */
	var IDObject = document.getElementById( IDElement );
	if ( IDObject ) {
		IDObject.value = IDValue;
	}
	
	/**
	 * Changing the layout of the chosen paymentmethod
	 */
	var PaymentmethodHolder = document.getElementById( 'Paymentmethods' );
	
	if ( PaymentmethodHolder ) {
		/**
		 * Setting all default
		 */
		var Paymentmethods = getChilds( PaymentmethodHolder );

		if ( Paymentmethods != false ) {
			for( i = 0; i < Paymentmethods.length; i++ ) {
				var Child = Paymentmethods[ i ];
				Child.className = 'PaymentMethod';
			}
		}
		
		/**
		 * Changing color of the active element
		 */
		var ActiveElement = document.getElementById( NameElement + IDValue );
		if ( ActiveElement ) {
			ActiveElement.className = 'ActivePayment';
		}
		
		/**
		 * Changing the value which show the chosen payment method
		 */
		var NameObject = document.getElementById( NameElement );
		
		if( NameObject ) {
			NameObject.innerHTML = NameValue
		} else {
			alert( 'Name object could not be set with value ' + NameValue );
		}
	}	
}

function getChilds( PaymentmethodHolder ) {
	/**
	 * If the ID excists 
	 */
	if ( PaymentmethodHolder ) {

		/* Getting all chulds inside the Element of ID */
		var Childs = new Array();
		
		for ( var i = 0; i < PaymentmethodHolder.childNodes.length; i++) {
			var Child = PaymentmethodHolder.childNodes[ i ];
			if ( Child.tagName == "DIV" ) {
				Childs.push(Child);
			}
		}

		/* If there are childs, then it is workable, and we give them back */
		if( Childs.length ) {
			return Childs;
		} else {
			return false;
		}
	}
}
