
function webdynFormDisplay( id ) {
    if(id != 'optionAnfrage'){
	if( jQuery( '#' + id ).is(":hidden") ) {
		jQuery( '#' + id ).fadeIn('fast');
		jQuery( '#' + id + 'Point' ).addClass( 'showpointTop' );
	} else {
		jQuery(  '#' + id ).hide();
		jQuery(  '#' + id + 'Point' ).removeClass( 'showpointTop' );
	}
    }
}

function setValStr( tmp_key ) {
	
	 tmp_key=tmp_key.replace(/\u00fc/g, "ue");
	 tmp_key=tmp_key.replace(/\u00f6/g, "oe");
	 tmp_key=tmp_key.replace(/\u00e4/g, "ae");
	 tmp_key=tmp_key.replace(/\u00dc/g, "Ue");
	 tmp_key=tmp_key.replace(/\u00d6/g, "Oe");
	 tmp_key=tmp_key.replace(/\u00c4/g, "Ae");
	 tmp_key=tmp_key.replace(/\u00df/g, "ss");
	 tmp_key=tmp_key.replace(/ü/g, "ue");
	 tmp_key=tmp_key.replace(/ö/g, "oe");
	 tmp_key=tmp_key.replace(/ä/g, "ae");
	 tmp_key=tmp_key.replace(/Ü/g, "Ue");
	 tmp_key=tmp_key.replace(/Ö/g, "Oe");
	 tmp_key=tmp_key.replace(/Ä/g, "Ae");
	 tmp_key=tmp_key.replace(/ß/g, "ss");

	return tmp_key;
}

function validSpezialStr( tmp_key ) {
	var err = false;
	if( tmp_key.indexOf('*') >= 1 ) err = true;
	if( tmp_key.indexOf(';') >= 1 ) err = true;
	if( tmp_key.indexOf('#') >= 1 ) err = true;
	if( tmp_key.indexOf('~') >= 1 ) err = true;
	if( tmp_key.indexOf('}') >= 1 ) err = true;
	if( tmp_key.indexOf(']') >= 1 ) err = true;
	if( tmp_key.indexOf('[') >= 1 ) err = true;
	if( tmp_key.indexOf('/') >= 1 ) err = true;
	if( tmp_key.indexOf('{') >= 1 ) err = true;
	if( tmp_key.indexOf('&') >= 1 ) err = true;
	if( tmp_key.indexOf('%') >= 1 ) err = true;
	if( tmp_key.indexOf('$') >= 1 ) err = true;
	if( tmp_key.indexOf('§') >= 1 ) err = true;
	if( tmp_key.indexOf('"') >= 1 ) err = true;
	
	return err;
}

function validSpezialInt( tmp_key ) {
	var err = false;
	if( tmp_key.indexOf('1') >= 1 ) err = true;
	if( tmp_key.indexOf('2') >= 1 ) err = true;
	if( tmp_key.indexOf('3') >= 1 ) err = true;
	if( tmp_key.indexOf('4') >= 1 ) err = true;
	if( tmp_key.indexOf('5') >= 1 ) err = true;
	if( tmp_key.indexOf('6') >= 1 ) err = true;
	if( tmp_key.indexOf("7") >= 1 ) err = true;
	if( tmp_key.indexOf('8') >= 1 ) err = true;
	if( tmp_key.indexOf('9') >= 1 ) err = true;
	if( tmp_key.indexOf('0') >= 1 ) err = true;
	return err;
}
function is_int(value){
  if((parseFloat(value) == parseInt(value)) && !isNaN(value)){
      return true;
  } else {
      return false;
  }
}
function validSpezialABC( tmp_key ) {
	var err = 0;
	tmp_key = tmp_key.toLowerCase();
	if( tmp_key.indexOf('a') >= 1 ) err = err +1;
	if( tmp_key.indexOf('b') >= 1 ) err = err +1;
	if( tmp_key.indexOf('c') >= 1 ) err = err +1;
	if( tmp_key.indexOf('d') >= 1 ) err = err +1;
	if( tmp_key.indexOf('e') >= 1 ) err = err +1;
	if( tmp_key.indexOf('f') >= 1 ) err = err +1;
	if( tmp_key.indexOf("g") >= 1 ) err = err +1;
	if( tmp_key.indexOf('h') >= 1 ) err = err +1;
	if( tmp_key.indexOf('i') >= 1 ) err = err +1;
	if( tmp_key.indexOf('j') >= 1 ) err = err +1;
	
	if( tmp_key.indexOf('k') >= 1 ) err = err +1;
	if( tmp_key.indexOf('l') >= 1 ) err = err +1;
	if( tmp_key.indexOf('m') >= 1 ) err = err +1;
	if( tmp_key.indexOf('n') >= 1 ) err = err +1;
	if( tmp_key.indexOf('o') >= 1 ) err = err +1;
	if( tmp_key.indexOf('p') >= 1 ) err = err +1;
	if( tmp_key.indexOf("q") >= 1 ) err = err +1;
	if( tmp_key.indexOf('r') >= 1 ) err = err +1;
	if( tmp_key.indexOf('s') >= 1 ) err = err +1;
	if( tmp_key.indexOf('t') >= 1 ) err = err +1;
	
	if( tmp_key.indexOf('u') >= 1 ) err = err +1;
	if( tmp_key.indexOf('v') >= 1 ) err = err +1;
	if( tmp_key.indexOf('w') >= 1 ) err = err +1;
	if( tmp_key.indexOf('x') >= 1 ) err = err +1;
	if( tmp_key.indexOf('y') >= 1 ) err = err +1;
	if( tmp_key.indexOf('z') >= 1 ) err = err +1;

	return err;
}

function validSpezialMail( tmp_key ) {
	var err = false;
	if( tmp_key.indexOf('@') >= 1 && tmp_key.indexOf('.') >= 1) err = true;
	return err;
}

function webdynAnfrage( thisisit ) {

	if( $(thisisit).attr('name') == 'E-Mail Adresse' && $(thisisit).attr('name') == $(thisisit).val() ) {
		$('#cntr_point_mail').addClass('poff'); 
		$(thisisit).addClass('errinput'); 
		return false;
	} else if( $(thisisit).attr('name') == 'Name' && $(thisisit).attr('name') == $(thisisit).val() ) {		
		$('#cntr_point_name').removeClass('pon');
		$('#cntr_point_name').removeClass('pon2');
		$(thisisit).addClass('errinput');
                $('#cntr_point_name').addClass('poff');
		return false;
	} else if( $(thisisit).attr('name') == 'Anmerkungen' && $(thisisit).attr('name') == $(thisisit).val() ) {
		$('#cntr_point_txt').addClass('poff'); 
		$(thisisit).addClass('errinput'); 
		return false;
	} else {
		
		if( $(thisisit).attr('name') == 'Name' || $(thisisit).attr('name') == 'Vorname' ) {
			if( validSpezialStr( $(thisisit).val() ) == false && validSpezialInt( $(thisisit).val() ) == false ) {
				if( $('#cntr_point_name').is('.pon2') )	{
                                    $(thisisit).removeClass('errinput'); $('#cntr_point_name').removeClass('pon2'); $('#cntr_point_name').addClass('pon2');
                                }else {
                                    $('#cntr_point_name').removeClass('pon'); $('#cntr_point_name').addClass('pon2');
                                }
				return true;
			} else {
				 $(thisisit).removeClass('errinput'); 
				$('#cntr_point_name').removeClass('pon2');
				$('#cntr_point_name').removeClass('pon');
				$('#cntr_point_name').addClass('poff'); 
				return false;
			}
		}
		
		else if( $(thisisit).attr('name') == 'E-Mail Adresse' ) {
			if( validSpezialStr( $(thisisit).val() ) == false &&  validSpezialMail( $(thisisit).val() ) == true  && validSpezialABC( $(thisisit).val() ) >= 4) {
				$('#cntr_point_mail').addClass('pon'); 
				$('#cntr_point_mail').css('background-position', '0 -644px');;
				$(thisisit).removeClass('errinput');				
				return true;
			} else {
				$('#cntr_point_mail').removeClass('pon');
				$('#cntr_point_mail').addClass('poff');
                                $('#cntr_point_mail').css('background-position', '0 -677px');
                                $(thisisit).addClass('errinput');
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Betreff' ) {
			if( validSpezialStr( $(thisisit).val() ) == false ) {
				$('#cntr_point_btr').addClass('pon'); 
				return true;
			} else {	
				$('#cntr_point_btr').removeClass('pon');
				$('#cntr_point_btr').addClass('poff'); 
				return false;
			}			
		}
		else if( $(thisisit).attr('name') == 'Telefon' ) {
			if( validSpezialStr( $(thisisit).val() ) == false && validSpezialABC( $(thisisit).val() ) <= 1 ) {
				$('#cntr_point_tel').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_tel').removeClass('pon');
				$('#cntr_point_tel').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Anmerkungen' ) {
			if( validSpezialStr( $(thisisit).val() ) == false ) {
				$('#cntr_point_txt').addClass('pon'); 
				$(thisisit).removeClass('errinput');					
				return true;
			} else {
				$('#cntr_point_txt').removeClass('pon');
				$('#cntr_point_txt').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Stra&szlig;e' ) {
			if(  validSpezialStr( $(thisisit).val() ) == false && validSpezialABC( $(thisisit).val() ) >= 4 ) {
				$('#cntr_point_adr').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_adr').removeClass('pon');
				$('#cntr_point_adr').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Nr.' ) {
			if(  validSpezialStr( $(thisisit).val() ) == false ) {
				$('#cntr_point_adr').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_adr').removeClass('pon');
				$('#cntr_point_adr').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Plz' ) {
			if(  validSpezialStr( $(thisisit).val() ) == false && validSpezialInt( $(thisisit).val() ) == true && validSpezialABC( $(thisisit).val() ) <= 2 ) {
				$('#cntr_point_adr2').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_adr2').removeClass('pon');
				$('#cntr_point_adr2').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Ort' ) {
			if(  validSpezialStr( $(thisisit).val() ) == false && validSpezialInt( $(thisisit).val() ) == false && validSpezialABC( $(thisisit).val() ) >= 4 ) {
				$('#cntr_point_adr2').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_adr2').removeClass('pon');
				$('#cntr_point_adr2').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Hersteller' ) {
			if(  validSpezialStr( $(thisisit).val() ) == false && validSpezialABC( $(thisisit).val() ) >= 1 ) {
				$('#cntr_point_hersteller').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_hersteller').removeClass('pon');
				$('#cntr_point_hersteller').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Modell' ) {
			if(  validSpezialStr( $(thisisit).val() ) == false ) {
				$('#cntr_point_modell').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_modell').removeClass('pon');
				$('#cntr_point_modell').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Erstzulassung (TT.MM.JJ)' ) {
//			var tmp = $(thisisit).val();
//			if(  tmp.length == 8 && validSpezialInt( $(thisisit).val() ) == true && validSpezialABC( $(thisisit).val() ) == 0 ) {
//				$('#cntr_point_erstzulassung').addClass('pon');
//				return true;
//			} else {
//				$('#cntr_point_erstzulassung').removeClass('pon');
//				$('#cntr_point_erstzulassung').addClass('poff');
//				return false;
//			}
		}
		else if( $(thisisit).attr('id') == 'key1' ) {
			var tmp = $(thisisit).val();
			if( validSpezialStr( $(thisisit).val() ) == false ) {
				$('#cntr_point_zu2').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_zu2').removeClass('pon');
				$('#cntr_point_zu2').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('id') == 'key2' ) {
			var tmp = $(thisisit).val();
			if( validSpezialStr( $(thisisit).val() ) == false ) {
				$('#cntr_point_zu3').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_zu3').removeClass('pon');
				$('#cntr_point_zu3').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Zylinderanzahl' ) {
			var tmp = $(thisisit).val();
			if( validSpezialStr( $(thisisit).val() ) == false  ) {
				$('#cntr_point_extra').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_extra').removeClass('pon');
				$('#cntr_point_extra').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Hubraum (cm3)' ) {
			var tmp = $(thisisit).val();
			if( validSpezialStr( $(thisisit).val() ) == false  ) {
				$('#cntr_point_extra').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_extra').removeClass('pon');
				$('#cntr_point_extra').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'KW' ) {
			var tmp = $(thisisit).val();
			if( validSpezialStr( $(thisisit).val() ) == false  ) {
				$('#cntr_point_extra').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_extra').removeClass('pon');
				$('#cntr_point_extra').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Abgas Euro Norm' ) {
			var tmp = $(thisisit).val();
			if( validSpezialStr( $(thisisit).val() ) == false  ) {
				$('#cntr_point_abgas').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_abgas').removeClass('pon');
				$('#cntr_point_abgas').addClass('poff'); 
				return false;
			}		
		}
		else if( $(thisisit).attr('name') == 'Woher kennen Sie uns?' ) {
			var tmp = $(thisisit).val();
			if( validSpezialStr( $(thisisit).val() ) == false  ) {
				$('#cntr_point_werbung').addClass('pon'); 
				return true;
			} else {
				$('#cntr_point_werbung').removeClass('pon');
				$('#cntr_point_werbung').addClass('poff'); 
				return false;
			}		
		}
		//else alert( $(thisisit).attr('name') );
	}
}

function webdynAnfrageBlur( thisisit ) {
	if($(thisisit).val() == '' ) { 
		$(thisisit).val( $(thisisit).attr('name') ); 
		$(thisisit).css('font-weight','normal');
                if($(thisisit).attr('name') == 'Name' || $(thisisit).attr('name') == ''){
                    $(thisisit).addClass('errinput');
                    $('#cntr_point_name').removeClass('pon');
                    $('#cntr_point_name').removeClass('pon2');
                    $('#cntr_point_name').css('background-position', '0 -677px');
                }
//                if($(thisisit).attr('name') == 'Ort' || $(thisisit).attr('name') == 'Plz'){
//                    $(thisisit).addClass('errinput');
//                     $('#cntr_point_adr2').css('background-position', '0 -677px');
//                     document.getElementById('cntr_point_adr4').innerHTML = "Diese Angabe ist wichtig, da der Standort des Umbaus (Berlin oder Freiburg) f&uuml;r das Angebot ma&szlig;geblich ist.";
//                }
                if( $(thisisit).attr('name') == 'E-Mail Adresse' ) {
                    $(thisisit).addClass('errinput');
                    $('#cntr_point_mail').css('background-position', '0 -677px');
                }
	}else{
                $(thisisit).removeClass('errinput');
                if($(thisisit).attr('name') == 'Name'){                    
                    if( validSpezialStr($(thisisit).val()) == false && is_int($(thisisit).val()) == false ) {
                        $('#cntr_point_name').css('background-position', '0 -644px');
                        $(thisisit).removeClass('errinput');
                    }else{
                        $('#cntr_point_name').css('background-position', '0 -677px');
                        $(thisisit).addClass('errinput');
                    }
                }
//                var plz = document.getElementById('plz').value;
//                var ort = document.getElementById('ort').value;
//                if($(thisisit).attr('name') == 'Ort' || $(thisisit).attr('name') == 'Plz'){
//                    document.getElementById('cntr_point_adr4').innerHTML = "Diese Angabe ist wichtig, da der Standort des Umbaus (Berlin oder Freiburg) f&uuml;r das Angebot ma&szlig;geblich ist.";
//                }
//                if( (plz != "" && plz != "Plz") && (ort != "" && ort != "Ort")){
//                    $('#cntr_point_adr2').css('background-position', '0 -644px');
//                    document.getElementById('cntr_point_adr4').innerHTML = "";
//                }
                if( $(thisisit).attr('name') == 'E-Mail Adresse' ) {
			if( validSpezialStr( $(thisisit).val() ) == false &&  validSpezialMail( $(thisisit).val() ) == true  && validSpezialABC( $(thisisit).val() ) >= 4) {
				$('#cntr_point_mail').addClass('pon');
				$('#cntr_point_mail').css('background-position', '0 -644px');
				$(thisisit).removeClass('errinput');
				return true;
			} else {
				$('#cntr_point_mail').removeClass('pon');
				$('#cntr_point_mail').addClass('poff');
                                $('#cntr_point_mail').css('background-position', '0 -677px');
                                $(thisisit).addClass('errinput');
				return false;
			}
		}
        }
}

function webdynAnfrageFocus( thisisit ) {
	if($(thisisit).val() == $(thisisit).attr('name') ) { 
		$(thisisit).val(''); 
		$(thisisit).css('font-weight','bold'); 
	}
}

function webdynAnfrageform( id , val ) {
	if( $( '#' + id ).val() == val ) $( '#' + id ).val('');
}
function autoCom( name , inputid ) {
$( '.ac_results' ).show();
}
