//Smoothscroll
$(function(){
    $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                return false;
            }
        }
    });
});

//Validierung Formularfelder
$( function() {
			$( '#testform' ).ipValidate( {

				required : { //required is a class
					rule : function() {
						return $( this ).val() == '' ? false : true;
					},
					onError : function() {
						$( this ).css( 'border', '2px solid #e35f05' );
					},
					onValid : function() {
						$( this ).css( 'border', '2px solid #dbdbdb' );
					}
				},


				nonzero : { //nonzero is a class

					rule : function() {
						return $( this ).val() == 0 ? false : true;
					},
					onError : function() {
						$( this ).css( 'border', '2px solid #e35f05' );
					},
					onValid : function() {
						$( this ).css( 'border', '2px solid #dbdbdb' );
					}
				},

				postOptions : {  //postOptions is a class

					rule : function() {
						//return $( 'input[type=checkbox]:checked' ).length < 1 ? false : true;
                                                return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($( this ).val()));
					},
					onError : function() {
						$( this ).css( 'border', '2px solid #e35f05' );
					},
					onValid : function() {
						$( this ).css( 'border', '2px solid #dbdbdb' );
					}
				},

				submitHandler : function() {
					
                                        document.testform.submit();

					return false;
				}
			});
		});

//Validierung Formularfelder
$( function() {
			$( '#partnerform' ).ipValidate( {

				required : { //required is a class
					rule : function() {
						return $( this ).val() == 'Firma' || $( this ).val() == 'Telefon' || $( this ).val() == 'Geschäftsführer'
                                                     || $( this ).val() == 'PLZ'  || $( this ).val() == 'Ort'
                                                       || $( this ).val() == 'Name, Vorname'  || $( this ).val() == 'Strasse'? false : true;
					},
					onError : function() {
						$( this ).css( 'border', '2px solid #e35f05' );
					},
					onValid : function() {
						$( this ).css( 'border', '2px solid #dbdbdb' );
					}
				},


				nonzero : { //nonzero is a class

					rule : function() {
						return $( this ).val() == 0 ? false : true;
					},
					onError : function() {
						$( this ).css( 'border', '2px solid #e35f05' );
					},
					onValid : function() {
						$( this ).css( 'border', '2px solid #dbdbdb' );
					}
				},

				postOptions : {  //postOptions is a class

					rule : function() {
						//return $( 'input[type=checkbox]:checked' ).length < 1 ? false : true;
                                                
                                                return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($( this ).val()));
					},
					onError : function() {
						$( this ).css( 'border', '2px solid #e35f05' );
					},
					onValid : function() {
						$( this ).css( 'border', '2px solid #dbdbdb' );
					}
				},

				submitHandler : function() {

                                        document.partnerform.submit();

					return false;
				}
			});
		});
