
function write_SubTable (i, link, ref_count, gets, self)
{
	document.getElementById("TOP_MEN1").className="";
	document.getElementById("TOP_MEN2").className="";
	document.getElementById("TOP_MEN3").className="";
	document.getElementById("TOP_MEN4").className="";
	document.getElementById("TOP_MEN5").className="";
	switch(i)
	{
		case "suche"	:	document.getElementById("TOP_MEN1").className="menTopSelectedTable";
							document.getElementById("SUB_TABLE").innerHTML=	 '	<table class="menSubTable">'
												+'		<tr>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a class="whiteLink" href="'+link+'suchen/immobilien.php" title="Immobilie suchen - Immobilien finden">Immobilien suchen</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a class="whiteLink" href="'+link+'suchwunsch/immobilien.php" title="Immobilien-Suchwunsch eintragen">kostenlos Suchwunsch eintragen</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a class="whiteLink" href="'+link+'suchwunsch/abmeldung.php" title="Immobilien-Suchwunsch abmelden">Suchwunsch abmelden</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a class="whiteLink" href="'+link+'info/faq.php" title="Immobilien FAQ">Oft gestellte Fragen</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+self+'?SHOWPIC=REF_'+ref_count+'&'+gets+'" class="whiteLink" title="Referenzen" rel="nofollow">Referenzen</a>'
												+'			</td>'
												+'		</tr>'
												+'	</table>';
							break;
		case "inser"	:	document.getElementById("TOP_MEN2").className="menTopSelectedTable";
							document.getElementById("SUB_TABLE").innerHTML=	 '	<table class="menSubTable">'
												+'		<tr>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a class="whiteLink" href="'+link+'inserieren/immobilien.php" title="Immobilie inserieren - Immobilien verkaufen / vermieten">Immobilien inserieren</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a class="whiteLink" href="'+link+'info/faq.php" title="Immobilien FAQ">Oft gestellte Fragen</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+self+'?SHOWPIC=REF'+ref_count+'&'+gets+'" class="whiteLink" title="Referenzen" rel="nofollow">Referenzen</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+link+'inserieren/immobilien-inserieren-demo.php" class="whiteLink" title="Immobilien inserieren Demo">Inserieren Demonstration</a>'
												+'			</td>'
												+'		</tr>'
												+'	</table>';
							break;
		case "abobe"	:	document.getElementById("TOP_MEN3").className="menTopSelectedTable";
							document.getElementById("SUB_TABLE").innerHTML=	 '	<table class="menSubTable">'
												+'		<tr>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+link+'abo/index.php" class="whiteLink" title="Immobilien - Kontaktdatenabo bestellen">Kontaktdaten-Abo bestellen</a>'
												+'			</td>'												
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+link+'info/faq.php" class="whiteLink" title="Immobilien FAQ">Oft gestellte Fragen</a>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+self+'?SHOWPIC=REF_'+ref_count+'&'+gets+'" class="whiteLink" title="Referenzen" rel="nofollow">Referenzen</a>'
												+'			</td>'
												+'		</tr>'
												+'	</table>';
							break;
		case "kodie"	:	document.getElementById("TOP_MEN4").className="menTopSelectedTable";
							document.getElementById("SUB_TABLE").innerHTML=	 '	<table class="menSubTable">'
												+'		<tr>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+link+'inserieren/immobilien.php" class="whiteLink" title="Immobilie inserieren - Immobilien verkaufen / vermieten">Immobilien inserieren</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+link+'suchwunsch/immobilien.php" class="whiteLink" title="Immobilien-Suchwunsch eintragen">Suchwunsch eintragen</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a class="whiteLink" href="'+link+'suchwunsch/abmeldung.php" title="Immobilien-Suchwunsch abmelden">Suchwunsch abmelden</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+link+'info/ombudsmann.php" class="whiteLink" title="Immobilien Ombudsmann">Ombudsmann</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+link+'info/faq.php" class="whiteLink" title="Immobilien FAQ">Oft gestellte Fragen</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="http://www.wohnbaufoerderung.info" class="whiteLink" title="Wohnbauf&ouml;rderung" target="_blank">Wohnbauf&ouml;rderung</a>'
												+'			</td>'
												+'		</tr>'
												+'	</table>';
							break;
		case "koimp"	:	document.getElementById("TOP_MEN5").className="menTopSelectedTable";
							document.getElementById("SUB_TABLE").innerHTML=	 '	<table class="menSubTable">'
												+'		<tr>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+link+'info/wuensche_anregungen.php" class="whiteLink" title="W&uuml;nsche und Anregungen">W&uuml;nsche und Anregungen</a>'
												+'			</td>'	
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+self+'?SHOWPIC=REF_'+ref_count+'&'+gets+'" class="whiteLink" title="Referenzen" rel="nofollow">Referenzen</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+link+'info/faq.php" class="whiteLink" title="Immobilien FAQ">Oft gestellte Fragen</a>'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+link+'lexikon/immobilien-lexikon.php" class="whiteLink" title="Immobilienlexikon">Immobilienlexikon</a>'
												+'			</td>'											
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+link+'info/agb.php" class="whiteLink" title="Allgemeine Gesch&auml;ftsbedingungen">AGB</a>'
												+'			</td>'
												+'			</td>'											
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">&nbsp;&nbsp;<a href="'+link+'info/referenzschreiben.php" class="whiteLink" title="Referenzschreiben verfassen">Referenzschreiben verfassen</a>'
												+'			</td>'
												+'		</tr>'
												+'	</table>';
							break;
		default	:			document.getElementById("SUB_TABLE").innerHTML=	 '	<table class="menSubTable">'
												+'		<tr>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">test klein'
												+'			</td>'
												+'			<td nowrap="nowrap" cellpadding="0" cellspacing="0">test klein'
												+'			</td>'
												+'		</tr>'
												+'	</table>';
							break;
	}
	
}

var runJS = false;
var baseSRC;
var picsArray = new Array();
var currentPic;
var backNavi = false;
var forwardNavi = false;
var isPicInfo = false;

function initPics(basePath) {
	
	document.getElementById("PIC_IMG_LINK").setAttribute("href", "javascript:showPics()");
	document.getElementById("PIC_TXT_LINK").setAttribute("href", "javascript:showPics()");
	baseSRC = basePath;
	runJS = true;
}


function fillPicsArray(value) {
	picsArray.push(value);
}

function showPics() {
	if(runJS == true) {
		currentPic = 0;
		backNavi = false;
		forwardNavi = false;
		isPicInfo = false;
		setInseratnr();
		document.getElementById("DIV_FADE_OBJEKTTAFEL").style.display = 'block';
		document.getElementById("DIV_OBJEKTTAFEL").style.display = 'block';
		navigate(0);
	}	
}

function closePics() {
	if(runJS == true) {
		document.getElementById("DIV_FADE_OBJEKTTAFEL").style.display = 'none';
		document.getElementById("DIV_OBJEKTTAFEL").style.display = 'none';
		cleanNavigation();
	}
}

function setInseratnr() {
	if(runJS == true) {
		var nr = document.getElementById("sourceInseratnrColumn").firstChild.nodeValue;
		document.getElementById("targetInseratnrColumn").firstChild.nodeValue = "Bilder zu Objekt "+nr;
	}
}

function navigate(pic) {
	if(runJS == true) {
		currentPic = currentPic + pic;
		source = baseSRC + picsArray[currentPic];
		document.getElementById("OT_BIGSIZE_PIC").setAttribute("src", source);
		createNavigation();
	}
}

function createNavigation() {
	if(runJS == true) {
		if(backNavi == false && currentPic > 0)
		{
			
			var back_link = document.createElement("a");
			var back_txt = document.createTextNode("voriges Bild");
			
			back_link.setAttribute("href", "javascript:navigate(-1)");
			back_link.setAttribute("title", "voriges Bild");
			back_link.setAttribute("class", "stdLink");
			back_link.setAttribute("className", "stdLink");
			back_link.appendChild(back_txt);
			
			document.getElementById("backLink").appendChild(back_link);
			backNavi = true;
			
		}
		
		if(backNavi == true && currentPic == 0)
		{
			var toDel = document.getElementById("backLink").firstChild;
			document.getElementById("backLink").removeChild(toDel);
			backNavi = false;
		}
		
		if(forwardNavi == false && currentPic < picsArray.length)
		{		
			var forward_link = document.createElement("a");	
			var forward_txt = document.createTextNode("nächstes Bild");
		
			forward_link.setAttribute("href", "javascript:navigate(1)");
			forward_link.setAttribute("title", "nächstes Bild");
			forward_link.setAttribute("class", "stdLink");
			forward_link.setAttribute("className", "stdLink");
			forward_link.appendChild(forward_txt);
		
			document.getElementById("forwardLink").appendChild(forward_link);
			forwardNavi = true;
		}
		
		if(forwardNavi == true && currentPic+1 == picsArray.length)
		{
			var toDel = document.getElementById("forwardLink").firstChild;
			document.getElementById("forwardLink").removeChild(toDel);
			forwardNavi = false;
		}
		
		var showPicNumber = currentPic + 1;
		if(isPicInfo == false)
		{
			var picInfo_txt = document.createTextNode("Bild "+showPicNumber+" von "+picsArray.length);
			document.getElementById("picInfo").appendChild(picInfo_txt);
			isPicInfo = true;
		}
		else
		{
			document.getElementById("picInfo").firstChild.nodeValue = "Bild "+showPicNumber+" von "+picsArray.length;
		}
	}
}


function cleanNavigation() {
	
	if(runJS == true) {
		if(document.getElementById("backLink").hasChildNodes())
		{
			var toDel = document.getElementById("backLink").firstChild;
			document.getElementById("backLink").removeChild(toDel);
			backNavi = false;
		}
		
		if(document.getElementById("forwardLink").hasChildNodes())
		{
			var toDel = document.getElementById("forwardLink").firstChild;
			document.getElementById("forwardLink").removeChild(toDel);
			forwardNavi = false;
		}
		
		if(document.getElementById("picInfo").hasChildNodes())
		{		
			var toDel = document.getElementById("picInfo").firstChild;
			document.getElementById("picInfo").removeChild(toDel);
			isPicInfo = false;
		}
	}
}


function generateOptions(bland) {

	getDistricts(bland);
	
	otyp = document.forms[0].elements[0].value;
	
	getSize(otyp);
}

function getDistricts(bland) {
	
	optionValues = new Array();
	
	optionValues.push(new Option('alle Bezirke', '0', false, true));
	
	switch(bland)
	{
		case "W":	optionValues.push(new Option("1. Innere Stadt", "1010"));
					optionValues.push(new Option("2. Leopoldstadt", "1020"));
					optionValues.push(new Option("3. Landstraße", "1030"));
					optionValues.push(new Option("4. Wieden", "1040"));
					optionValues.push(new Option("5. Margareten", "1050"));
					optionValues.push(new Option("6. Mariahilf", "1060"));
					optionValues.push(new Option("7. Neubau", "1070"));
					optionValues.push(new Option("8. Josefstadt", "1080"));
					optionValues.push(new Option("9. Alsergrund", "1090"));
					optionValues.push(new Option("10. Favoriten", "1100"));
					optionValues.push(new Option("11. Simmering", "1110"));
					optionValues.push(new Option("12. Meidling", "1120"));
					optionValues.push(new Option("13. Hietzing", "1130"));
					optionValues.push(new Option("14. Penzing", "1140"));
					optionValues.push(new Option("15. Rudolfsheim-Fünfhausen", "1150"));
					optionValues.push(new Option("16. Ottakring", "1160"));
					optionValues.push(new Option("17. Hernals", "1170"));
					optionValues.push(new Option("18. Währing", "1180"));
					optionValues.push(new Option("19. Döbling", "1190"));
					optionValues.push(new Option("20. Brigittenau", "1200"));
					optionValues.push(new Option("21. Floridsdorf", "1210"));
					optionValues.push(new Option("22. Donaustadt", "1220"));
					optionValues.push(new Option("23. Liesing", "1230"));
					
					break;
					
		case "NO": 	
					optionValues.push(new Option("Amstetten", "20"));
					optionValues.push(new Option("Baden", "21"));
					optionValues.push(new Option("Bruck an der Leitha", "22"));
					optionValues.push(new Option("Gänserndorf", "23"));
					optionValues.push(new Option("Gmünd", "24"));
					optionValues.push(new Option("Hollabrunn", "25"));
					optionValues.push(new Option("Horn", "26"));
					optionValues.push(new Option("Korneuburg", "27"));
					optionValues.push(new Option("Krems Land", "28"));
					optionValues.push(new Option("Krems Stadt", "29"));
					optionValues.push(new Option("Lilienfeld", "30"));
					optionValues.push(new Option("Melk", "31"));
					optionValues.push(new Option("Mistelbach", "32"));
					optionValues.push(new Option("Mödling", "33"));
					optionValues.push(new Option("Neunkirchen", "34"));
					optionValues.push(new Option("Scheibbs", "35"));
					optionValues.push(new Option("St. Pölten Land", "36"));
					optionValues.push(new Option("St. Pölten Stadt", "37"));
					optionValues.push(new Option("Tulln", "38"));
					optionValues.push(new Option("Waidhofen an der Thaya", "39"));
					optionValues.push(new Option("Waidhofen an der Ybbs", "40"));
					optionValues.push(new Option("Wiener Neustadt Land", "41"));
					optionValues.push(new Option("Wiener Neustadt Stadt", "42"));
					optionValues.push(new Option("Zwettl", "43"));
					optionValues.push(new Option("Wien-Umgebung", "101"));					
					break;
		case "B":	
					optionValues.push(new Option("Eisenstadt Stadt", "1"));
					optionValues.push(new Option("Eisenstadt-Umgebung", "2"));
					optionValues.push(new Option("Güssing", "3"));
					optionValues.push(new Option("Jennersdorf", "4"));
					optionValues.push(new Option("Mattersburg", "5"));
					optionValues.push(new Option("Neusiedl am See", "6"));
					optionValues.push(new Option("Oberpullendorf", "7"));
					optionValues.push(new Option("Oberwart", "8"));
					optionValues.push(new Option("Rust Stadt", "9"));
					break;
		case "K":	
					optionValues.push(new Option("Feldkirchen", "10"));
					optionValues.push(new Option("Hermagor", "11"));
					optionValues.push(new Option("Klagenfurt Land", "12"));
					optionValues.push(new Option("Klagenfurt Stadt", "13"));
					optionValues.push(new Option("Spittal an der Drau", "14"));
					optionValues.push(new Option("St. Veit an der Glan", "15"));
					optionValues.push(new Option("Villach Land", "16"));
					optionValues.push(new Option("Villach Stadt", "17"));
					optionValues.push(new Option("Völkermarkt", "18"));
					optionValues.push(new Option("Wolfsberg", "19"));
					break;
		case "OO":	
					optionValues.push(new Option("Braunau am Inn", "44"));
					optionValues.push(new Option("Eferding", "45"));
					optionValues.push(new Option("Freistadt", "46"));
					optionValues.push(new Option("Gmunden", "47"));
					optionValues.push(new Option("Grieskirchen", "48"));
					optionValues.push(new Option("Kirchdorf an der Krems", "49"));
					optionValues.push(new Option("Linz Land", "50"));
					optionValues.push(new Option("Linz Stadt", "51"));
					optionValues.push(new Option("Perg", "52"));
					optionValues.push(new Option("Ried im Innkreis", "53"));
					optionValues.push(new Option("Rohrbach", "54"));
					optionValues.push(new Option("Schärding", "55"));
					optionValues.push(new Option("Steyr Land", "56"));
					optionValues.push(new Option("Steyr Stadt", "57"));
					optionValues.push(new Option("Urfahr-Umgebung", "58"));
					optionValues.push(new Option("Vöcklabruck", "59"));
					optionValues.push(new Option("Wels Land", "60"));
					optionValues.push(new Option("Wels Stadt", "61"));
					break;
		case "ST":	
					optionValues.push(new Option("Bruck an der Mur", "68"));
					optionValues.push(new Option("Deutschlandsberg", "69"));
					optionValues.push(new Option("Feldbach", "70"));
					optionValues.push(new Option("Fürstenfeld", "71"));
					optionValues.push(new Option("Graz Stadt", "72"));
					optionValues.push(new Option("Graz-Umgebung", "73"));
					optionValues.push(new Option("Hartberg", "74"));
					optionValues.push(new Option("Judenburg", "75"));
					optionValues.push(new Option("Knittelfeld", "76"));
					optionValues.push(new Option("Leibnitz", "77"));
					optionValues.push(new Option("Leoben", "78"));
					optionValues.push(new Option("Liezen", "79"));
					optionValues.push(new Option("Murau", "80"));
					optionValues.push(new Option("Mürzzuschlag", "81"));
					optionValues.push(new Option("Radkersburg", "82"));
					optionValues.push(new Option("Voitsberg", "83"));
					optionValues.push(new Option("Weiz", "84"));
					break;
		case "S":	
					optionValues.push(new Option("Hallein", "62"));
					optionValues.push(new Option("Salzburg Stadt", "63"));
					optionValues.push(new Option("Salzburg-Umgebung", "64"));
					optionValues.push(new Option("St. Johann im Pongau", "65"));
					optionValues.push(new Option("Tamsweg", "66"));
					optionValues.push(new Option("Zell am See", "67"));
					break;
		case "T":	
					optionValues.push(new Option("Imst", "85"));
					optionValues.push(new Option("Innsbruck Land", "86"));
					optionValues.push(new Option("Innsbruck Stadt", "87"));
					optionValues.push(new Option("Kitzbühel", "88"));
					optionValues.push(new Option("Kufstein", "89"));
					optionValues.push(new Option("Landeck", "90"));
					optionValues.push(new Option("Lienz", "91"));
					optionValues.push(new Option("Reutte", "92"));
					optionValues.push(new Option("Schwaz", "93"));
					break;
		case "V":	
					optionValues.push(new Option("Bludenz", "94"));
					optionValues.push(new Option("Bregenz", "95"));
					optionValues.push(new Option("Dornbirn", "96"));
					optionValues.push(new Option("Feldkirch", "97"));
					break;

					
	}
	
		
	for(i=0; document.forms[0].elements[2].options.length = 0; i++)
	{
		document.forms[0].elements[2].options[i] = null;
	}
	
	
	for(i=0; i<optionValues.length; i++)
	{
		document.forms[0].elements[2].options[i] = optionValues[i];
	}
	
}

function getSize(otyp) {

	if(document.forms[0].elements[1].value != '')
	{
		
		optionValues = new Array();
	
		optionValues.push(new Option('alle Größen', '0-9999999', false, true));
	
		switch(otyp)
		{
			case 'OO00':	
			case 'OO01':
			case 'OO05':	optionValues.push(new Option('bis 60 m²', '0-60'));
							optionValues.push(new Option('61 bis 80 m²', '61-80'));
							optionValues.push(new Option('81 bis 100 m²', '81-100'));
							optionValues.push(new Option('101 bis 130 m²', '101-130'));
							optionValues.push(new Option('131 bis 160 m²', '131-160'));
							optionValues.push(new Option('größer als 160 m²', '161-9999999'));
							break;
			case 'OO02':
			case 'OO04':	optionValues.push(new Option('bis 80 m²', '0-80'));
							optionValues.push(new Option('81 bis 110 m²', '81-110'));
							optionValues.push(new Option('111 bis 160 m²', '111-160'));
							optionValues.push(new Option('161 bis 200 m²', '161-200'));
							optionValues.push(new Option('größer als 200 m²', '201-9999999'));
							break;
			case 'OO06':	
			case 'OO07':	optionValues.push(new Option('bis 400 m²', '0-400'));
							optionValues.push(new Option('401 bis 700 m²', '401-700'));
							optionValues.push(new Option('701 bis 900 m²', '701-900'));
							optionValues.push(new Option('901 bis 1200 m²', '901-1200'));
							optionValues.push(new Option('größer als 1200 m²', '1201-9999999'));
							break;
			case 'OO03':	optionValues.push(new Option('bis 25 m²', '0-25'));
							optionValues.push(new Option('26 bis 35 m²', '26-35'));
							optionValues.push(new Option('36 bis 50 m²', '36-50'));
							optionValues.push(new Option('größer als 50 m²', '51-9999999'));
							break;
			case 'OOHW':	break;		
			default:		break;	
			
		}
	
		for(i=0; document.forms[0].elements[3].options.length = 0; i++)
		{
			document.forms[0].elements[3].options[i] = null;
		}
		
		for(i=0; i<optionValues.length; i++)
		{
			document.forms[0].elements[3].options[i] = optionValues[i];
		}
	}
}

var reg_telefon = /^[0-9 \/\+-]{0,30}$/;
var reg_mail = /^[0-9a-zA-Z_.-]+@[0-9a-zA-Z_.-]{2,}[.]{1,1}[a-zA-Z]{2,4}$/;
var reg_url = /^([0-9a-zA-Z_.-]{2,100}[.]{1,1}[a-zA-Z]{2,4}([\/]{1,1}[0-9a-zA-Z_.-\/])*)*$/;
//deaktiviert Preisüberprüfung, wenn "Preise auf Anfrage" ausgewählt wurde
var priceValidation = true;

//für optionale Preisfelder gilt: alles ist erlaubt (deshalb auskommentiert)
function validate(formname, name, value) {
	
	
	var name = name.substring(11);
	var alerttext = "";
	
	switch(name)
	{
		case "KO00":	alerttext = checkContactInformation(name, value);
						break;
		case "KO01":	alerttext = checkContactInformation(name, value);
						break;
		case "KO02":	alerttext = checkContactInformation(name, value);
						break;
		case "KO03":	alerttext = checkContactInformation(name, value);
						break;
		case "KO04":	alerttext = checkContactInformation(name, value);
						break;
		
		case "PLZ":		alerttext = checkLocationInformation(name, value);
						break;
		case "ORT":		alerttext = checkLocationInformation(name, value);
						break;
		case "STR":		alerttext = checkLocationInformation(name, value);
						break;
		case "HNR":		alerttext = checkLocationInformation(name, value);
						break;
		
		/*case "TEXT":	alerttext = checkDescriptionText(value);
						break;*/
		
		case "BA00":	if(isNaN(value) || value < 10)	alert("Ungültige Nutzfläche");
						break;
		case "BA01":	if(isNaN(value))				alert("Ungültige Anzahl der Räume");
						break;
						
		case "BA12":	if(isNaN(value))				alert("Ungültige Grundfläche");
						break;
		case "BA13":	if(isNaN(value))				alert("Ungültige Anzahl an Ebenen");
						break;
		
		
		case "BA19":	if(isNaN(value))	alert("Ungültige Anzahl der Straßenfronten");
						break;
						
						
		
		case "BA20":	if(priceValidation == true)
						{
							if(!value.match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/)){
								alert("Ungültige Nettomiete");
							}
							//if(isNaN(value))	alert("Ungültige Nettomiete");
						}
						break;		
		case "BA21":	if(priceValidation == true)
						{
							if(!value.match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/)){
								alert("Ungültige Bruttomiete");
							}
							//if(isNaN(value))	alert("Ungültige Bruttomiete");
						}
						break;
		/*						
		case "BA22":	if(isNaN(value))	alert("Ungültige Ablöse");
						break;		
		case "BA23":	if(isNaN(value))	alert("Ungültige Kaution");
						break;		
		*/
		case "BA24":	if(priceValidation == true)
						{
							if(!value.match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/)){
								alert("Ungültige Kaufpreis");
							}
							//if(isNaN(value))	alert("Ungültiger Kaufpreis");
						}
						break;
		case "BA25":	if(priceValidation == true)
						{
							if(!value.match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/)){
								alert("Ungültige Bruttomiete");
							}
							//if(isNaN(value))	alert("Ungültiger Genossenschaftsanteil");
						}
						break;
		/*
		case "BA26":	if(isNaN(value))	alert("Ungültiger Quadratmeterpreis");
						break;
		case "BA28":	if(isNaN(value))	alert("Ungültiger Baukostenzuschuss");
						break;
		*/
	}
	
	if(alerttext.length > 0)
		alert(alerttext);
	
}

function checkPLZ(formularname) {
	var plz = document.forms[formularname].elements["BASISDATEN_PLZ"].value;
	var bland = document.forms[formularname].elements["BASISDATEN_BNDLAND"].value;
	
	var firstNumber = plz.substring(0, 1);
	var error = false;
	
	switch(firstNumber)
	{
		case "1":	if(bland != "W") 	error = true;
					break;
		case "2":
		case "3":	if(bland != "NO")	error = true;
				 	break;
		case "4":	if(bland != "OO")	error = true;
					break;
		case "5":	if(bland != "S")	error = true;
					break;
		case "6":	if(bland != "V" && bland != "T") 	error = true;
					break;
		case "7":	if(bland != "B")	error = true;
					break;

		case "8":	if(bland != "ST")	error = true;
					break;
		case "9":	if(bland != "K")	error = true;
					break;
			
		default:	break;
	}
	
	if(error)	confirm("Sind Ihre Eingaben korrekt?");
}

function completeValidation(otyp, formularname) {
	
	var errortext = "";
	var el = new Array();

	for(var i=0; i<document.forms[formularname].elements.length; i++)
	{
		var elementName = document.forms[formularname].elements[i].name;
		elementName = elementName.substring(11);
		el[elementName] = document.forms[formularname].elements[i].value;
	}


	//Kontaktinformationen überprüfen
	errortext += checkContactInformation("KO00", el["KO00"]);
	errortext += checkContactInformation("KO01", el["KO01"]);
	errortext += checkContactInformation("KO02", el["KO02"]);
	errortext += checkContactInformation("KO03", el["KO03"]);
	errortext += checkContactInformation("KO04", el["KO04"]);
	
	
	switch(otyp)
	{
		case "OO00":		if(isNaN(el["BA00"]) || el["BA00"] < 10)	errortext += "Ungültige Nutzfläche\n";
							if(isNaN(el["BA01"]))						errortext += "Ungültige Anzahl der Räume\n";
							
							if(el["BA11"].length == 0 
							|| el["BA11"].length > 2)					errortext += "Bitte wählen Sie einen Zustand aus!\n";	
							
							if(priceValidation == true)
							{
								if(!(el["BA20"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA20"] < 10)
								{
									if(!(el["BA21"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA21"] < 10)
																			errortext += "Bitte geben Sie entweder die Nettomiete oder die Bruttomiete an!\n";
								}
								
								if(!(el["BA20"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))	errortext += "Ungültige Nettomiete\n";
								if(!(el["BA21"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))	errortext += "Ungültige Bruttomiete\n";

								//if(isNaN(el["BA20"]))	errortext += "Ungültige Nettomiete\n";
								//if(isNaN(el["BA21"]))	errortext += "Ungültige Bruttomiete\n";
								//optionale Eingabefelder als Textfelder (alle Zeichen erlaubt)
								/*
								if(isNaN(el["BA22"]))						errortext += "Ungültige Ablöse\n";
								if(isNaN(el["BA23"]))						errortext += "Ungültige Kaution\n";
								if(isNaN(el["BA28"]))						errortext += "Ungültiger Baukostenzuschuss\n";
								*/
							}
							
							break;
							
		case "OO01":		if(isNaN(el["BA00"]) || el["BA00"] < 10)	errortext += "Ungültige Nutzfläche\n";
							if(isNaN(el["BA01"]))						errortext += "Ungültige Anzahl der Räume\n";
							if(el["BA11"].length == 0 
							|| el["BA11"].length > 2)					errortext += "Bitte wählen Sie einen Zustand aus!\n";	
							
							if(priceValidation == true)
							{
								if(!(el["BA24"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA24"] < 10)
								{
									
									if(!(el["BA25"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA25"] < 10)
																			errortext += "Bitte geben Sie entweder den Kaufpreis oder den Genossenschaftsanteil und Bruttomiete oder Nettomiete an!\n";			
									else
									{
										if(!(el["BA20"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA20"] < 10)
										{									
										
											if(!(el["BA21"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA21"] < 10)
																			errortext += "Bitte geben Sie entweder den Kaufpreis oder den Genossenschaftsanteil und Bruttomiete oder Nettomiete an!\n";
										}
									}
																			
								}
							
							
								if(!(el["BA20"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültige Nettomiete\n";
								if(!(el["BA21"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültige Bruttomiete\n";
								/*
								if(isNaN(el["BA22"]))						errortext += "Ungültige Ablöse\n";
								if(isNaN(el["BA23"]))						errortext += "Ungültige Kaution\n";
								*/
								if(!(el["BA24"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültiger Kaufpreis\n";
								if(!(el["BA25"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültiger Genossenschaftsanteil\n";
							}
							break;
							
		case "OO02":
		case "OO04":		
							if(isNaN(el["BA00"]) || el["BA00"] < 10)	errortext += "Ungültige Nutzfläche\n";
							if(isNaN(el["BA12"]))						errortext += "Ungültige Grundfläche\n";
							if(isNaN(el["BA13"]))						errortext += "Ungültige Anzahl an Ebenen\n";
							if(isNaN(el["BA01"]))						errortext += "Ungültige Anzahl der Räume\n";
							if(el["BA11"].length == 0 
							|| el["BA11"].length > 2)					errortext += "Bitte wählen Sie einen Zustand aus!\n";
							
							if(priceValidation == true)
							{
								if(!(el["BA24"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA24"] < 10)
								{
									if(!(el["BA20"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA20"] < 10)
									{
										if(!(el["BA21"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA21"] < 10){
																			errortext += "Bitte geben Sie entweder Kaufpreis, Brutto- oder Nettomiete an!\n";
										}
									}
								}
								
								if(!(el["BA20"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültige Nettomiete\n";
								if(!(el["BA21"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültige Bruttomiete\n";
								/*
								if(isNaN(el["BA22"]))						errortext += "Ungültige Ablöse\n";
								if(isNaN(el["BA23"]))						errortext += "Ungültige Kaution\n";
								*/
								if(!(el["BA24"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültiger Kaufpreis\n";
							}
							break;
		
		case "OO03":		if(isNaN(el["BA00"]) || el["BA00"] < 10)	errortext += "Ungültige Nutzfläche\n";
							if(el["BA11"].length == 0 
							|| el["BA11"].length > 2)					errortext += "Bitte wählen Sie einen Zustand aus!\n";	
							
							if(priceValidation == true)
							{
								if(!(el["BA20"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA20"] < 10)
								{
									if(!(el["BA21"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA21"] < 10)
																			errortext += "Bitte geben Sie entweder die Nettomiete oder die Bruttomiete an!\n";
								}
								/*
								if(isNaN(el["BA22"]))						errortext += "Ungültige Ablöse\n";
								if(isNaN(el["BA23"]))						errortext += "Ungültige Kaution\n";
								*/
							}
							break;
							
		case "OO05":		if(isNaN(el["BA00"]) || el["BA00"] < 10)	errortext += "Ungültige Nutzfläche\n";
							if(isNaN(el["BA01"]))						errortext += "Ungültige Anzahl der Räume\n";
							if(el["BA11"].length == 0 
							|| el["BA11"].length > 2)					errortext += "Bitte wählen Sie einen Zustand aus!\n";				
							
							if(priceValidation == true)
							{
								if(isNaN(el["BA24"]) || el["BA24"] < 10)
								{
									if(!(el["BA20"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA20"] < 10)
									{
										if(!(el["BA21"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA21"] < 10)
																			errortext += "Bitte geben Sie entweder Kaufpreis, Brutto- oder Nettomiete an!\n";
									}
								}
								
								if(!(el["BA20"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültige Nettomiete\n";
								if(!(el["BA21"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültige Bruttomiete\n";
								/*
								if(isNaN(el["BA22"]))						errortext += "Ungültige Ablöse\n";
								if(isNaN(el["BA23"]))						errortext += "Ungültige Kaution\n";
								*/
								if(!(el["BA24"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültiger Kaufpreis\n";
							}
							
							break;
		
		case "OO06":
		case "OO07":		if(isNaN(el["BA12"]) || el["BA12"] < 10)	errortext += "Ungültige Grundfläche\n";								
							if(isNaN(el["BA19"]))						errortext += "Ungültige Anzahl der Straßenfronten\n";
							
							if(priceValidation == true)
							{
								if(!(el["BA24"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA24"] < 10)
								{
									if(!(el["BA20"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA20"] < 10)
									{
										if(!(el["BA21"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/) || el["BA21"] < 10)
																			errortext += "Bitte geben Sie entweder Kaufpreis, Brutto- oder Nettomiete an!\n";
									}
								}
								
								if(!(el["BA20"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültige Nettomiete\n";
								if(!(el["BA21"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültige Bruttomiete\n";
								if(!(el["BA24"]).match(/^([0-9]{0,})([.,]{0,1})([0-9]{0,2})$/))						errortext += "Ungültiger Kaufpreis\n";
								//if(isNaN(el["BA26"]))						errortext += "Ungültiger Quadratmeterpreis\n";
							}
							break;
		
		
	}	
	
	errortext += checkLocationInformation("PLZ", el["PLZ"]);
	errortext += checkLocationInformation("ORT", el["ORT"]);
	errortext += checkLocationInformation("STR", el["STR"]);
	errortext += checkLocationInformation("HNR", el["HNR"]);
	errortext += checkLocationInformation("BNDLAND", el["BNDLAND"]);
	
	//errortext += checkDescriptionText(el["TEXT"]);
	
	errortext += isChecked('AGB', document.forms[formularname].elements['inserat_agb'].checked, true)
	
	
	if(errortext.length > 0)
	{
		alert(errortext);
		return false;
	}
	else
		return true;
}

function checkContactInformation(kokey, value) {
	
	var errortext = "";

	switch(kokey)
	{
		case "KO00":	if(!reg_mail.test(value))	errortext = "Ungültige E-Mail Adresse\n";
						break;
		case "KO01":	if(!reg_telefon.test(value)) 
						{
							alert("Ungültige Telefonnummer");
							//document.forms["BASISDATEN_FORM"].elements["BASISDATEN_KO01"].focus();
						}
						break;
		case "KO02":	if(!reg_telefon.test(value)) 	errortext = "Ungültige Mobilnummer\n";
						break;
		case "KO03":	if(!reg_telefon.test(value)) 	errortext = "Ungültige Faxnummer\n";
						break;
		case "KO04":	if(!reg_url.test(value))		errortext = "Ungültige Homepage\n";
						break;
	}
	
	return errortext;
}

function checkLocationInformation(lokey, value) {

	var errortext = "";
	
	switch(lokey)
	{
		case "PLZ":		if(isNaN(value) || value.length != 4)		errortext = "Ungültige Postleitzahl\n";
						break;
		case "ORT":		if(value.length < 2 || value.length > 100)	errortext = "Ungültiger Ort\n";
						break;
		case "STR":		if(value.length < 2 || value.length > 100)	errortext = "Ungültige Straße\n";
						break;
		case "HNR":		if(value.length < 1 || value.length > 100)	errortext = "Ungültige Hausnummer\n";
						break;
		case "BNDLAND":	if(value.length == 0 || value.length > 2)	errortext = "Bitte wählen Sie ein Bundesland aus!\n";
						break;	
	}
	
	return errortext;
}

function checkDescriptionText(value) {
	
	var errortext = "";
	
	if(value.length < 20)
	{
		errortext = "Ungültiger Text (mind. 20 Zeichen)\n";
	}
	return errortext;

}

function isChecked(type, status, silent) {

	var errortext = "";
	
	if(silent === undefined)
	{
		silent = false;
	}
	
	
	if(status == false)
	{
		switch(type)
		{
			case "DATEN":	errortext = "Bitte lesen Sie die Datenschutzbedingungen!\n"; break;
			case "AGB":		errortext = "Bitte lesen Sie die AGBs!\n"; break;
		}
		
		
		if(silent == true)
		{
			return errortext;
		}
		else
		{
			alert(errortext);
			return false;
		}
		
	}
	else
	{
		if(silent == true)
		{
			return errortext;
		}
		else
		{
			return true;
		}
	}
}

function getCheckedMessage(type, status)
{
	var errortext = "";
	
	alert(status);
	
	if(status == false)
	{
		switch(type)
		{
			case "DATEN":	errortext = "Bitte lesen Sie die Datenschutzbedingungen!"; break;
			case "AGB":		errortext = "Bitte lesen Sie die AGBs!"; break;
		}
		alert("Fehlerhaft");
		return errortext;
		
	}
	else
	{
		alert("FEhlerfrei");
		return errortext;
	}
}

function checkPriceValidation (noprice) {
	

	if(noprice == true)
		priceValidation = false;	
	else
		priceValidation = true;
		
}

function checkChoosenSelects (elName, maxNumber) {
	
	var anzOptions = elName.length;
	var selOptions = 0;
	
	for(var i=0; i<anzOptions; i++)
	{
		if(elName.options[i].selected == true)
		{
			selOptions ++;
		}
	}
	
	if(selOptions > maxNumber)
	{
		alert("Bitte wählen Sie maximal "+ maxNumber + " Einträge aus");
		return false;
	}
	else
	{	
		return true;
	}
		
}

function Social_Load() 
{ 
	var d=document; 
	if(d.images)
	{ 
		if(!d.Social) 
			d.Social=new Array();

		var i,j=d.Social.length,a=Social_Load.arguments; 
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0)
			{
				d.Social[j]=new Image; d.Social[j++].src=a[i];
			}
	}
}

Social_Load('http://www.social-bookmark-script.de/img/bookmarks/wong_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/webnews_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/icio_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/bookmrk_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/hardware_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/oneview_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/folkd_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/yigg_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/linkarena_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/bookmarksat_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/linksilo_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/readster_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/seekxl_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/favit_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/kledy_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/publishr_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/boni_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/power_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/favoriten_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/bookmarkscc_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/newsider_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/digg_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/del_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/facebook_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/reddit_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/jumptags_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/simpy_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/stumbleupon_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/slashdot_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/propeller_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/furl_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/yahoo_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/spurl_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/google_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/blinklist_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/blogmarks_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/diigo_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/technorati_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/newsvine_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/softigg_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/netvouz_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/what_trans_ani.gif','http://www.social-bookmark-script.de/load.gif')

function schnipp() 
{ 
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function schnupp(n, d) 
{ 
	var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=schnupp(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function schnapp() 
{ 
	 var i,j=0,x,a=schnapp.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	 if ((x=schnupp(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

tinyMCE.init
({
	mode : "textareas",
	cleanup_on_startup : true,
	invalid_elements : "h1,h2,h3,h4,h5,h6,a,font,div,img,script",
	plugins : "paste",
	paste_remove_styles : true
});