	




/* if(document.insert.date_to.value.search(/^(\d\d).(\d\d).(\d\d)$/) == -1){ 
*/
function checkInsert(){

	/*TODO: check date_from< date_to*/
   errstring = "";
   $('input').removeClass("fielderror");
   
   if(document.insert.date_from.value == ""){
   	  $('#date_from').addClass("fielderror");
	  errstring="Reisebegin\n";
	 }
   if(document.insert.date_to.value == ""){
   	  $('#date_to').addClass("fielderror");
	  errstring= errstring + "Reiseende\n";
   }
   if(document.insert.firstname.value == ""){
	  $('#firstname').addClass("fielderror");
	  errstring= errstring + "Vornamen\n";
	 }
	
   if(document.insert.email.value.indexOf('@') == -1){
	  $('#email').addClass("fielderror");
	  errstring= errstring + "Email\n";
	 }
	 
	/* todo check leerstring*/
   if(document.insert.zipcode.value == ""){
	  $('#zipcode').addClass("fielderror");
	  errstring= errstring + "Postleitzahl\n";
	 }
	/* todo check leerstring*/
   if(document.insert.age.value == ""){
	 $('#age').addClass("fielderror");
	 errstring= errstring + "Alter\n";
	}
   if(errstring != ""){
   		showAlarm("Bitte fuellen Sie noch folgende Felder aus:"  + errstring);
		return false;
	 	}
}

	
function showAlarm(message){
	$('#alarm').show("slow");
	$('#alarmtext').html(message);
}
	
function hideAlarm(){
	$('#alarm').hide("slow");
	$('#alarmtext').html(message);
}			

function timeAfterTime(){
    var ID=window.setInterval('CheckStr2()',500)
    var ID=window.setInterval('CheckStr()',500)
}
    
function CheckStr(userInput){

	StrLen = window.document.insert.description.value.length;
	if (StrLen > 2000 ){
		window.document.insert.description.value = window.document.insert.description.value.substring(0,2000);
		StrLeft = 0;
		alert("bitte nicht mehr als 2000 Zeichen eingeben")
	}
	else{
		StrLeft = 2000 - StrLen;
	}
	
	document.insert.Len.value = StrLeft;
}

function CheckStr2(userInput){

	StrLen = window.document.insert.properties.value.length;
	if (StrLen > 2000 )
	{
	window.document.insert.properties.value = window.document.insert.properties.value.substring(0,2000);
	StrLeft = 0;
	alert("bitte nicht mehr als 2000 Zeichen eingeben")
	}
	else
	{
	StrLeft = 2000- StrLen;
	}
	document.insert.Len2.value = StrLeft;
	}

function warnDelete(){
		warnDelete = confirm("Achtung! Das Loeschen der Anzeige kann nicht rueckgaengig gemacht werden!\nWollen Sie Ihr Inserat wirklich Loeschen?");
		
		if (warnDelete == false) return false;
}
	
function openPopup(url,name,arguments) {
		//ClosePopUp()             /* erstmal bisher geoeffnetes Popup zumachen */
		newWindow = window.open(url, name, "location=no,menubar=no,toolbar=no,status=no");
		newWindow.resizeTo(650, 500);
		newWindow.locationbar.visible=false;
		newWindow.focus();
}




