// Preis Switch

function preisSwitch(val) {
	if(val<'1500') {
		document.getElementById("kaufpreis").name="quicksearch#ObjPreise#kaufpreis#68#klgl";
		}
	else {
		document.getElementById("kaufpreis").name="quicksearch#ObjPreise#kaufpreis#68#grgl";
		}
	}	



//Formularausblender 

$(document).ready(function()
{
	$('form[name="submit_form"]').submit(function()
	{
		$('input[type="text"]').each(function()
		{
            if ($(this).val() == $(this).attr('defaultValue'))
				$(this).val('');
		});
	});
	
	$('input[type="text"]').focus(function()
	{
		if ($(this).val() == 'von' || $(this).val() == 'bis')
			$(this).val('');
	});
	
	$('input[type="text"]').blur(function()
	{
		if ($(this).val() == '')
			$(this).val($(this).attr('defaultValue'));
	});
});

//???

function enable(id){
for(i=1;i<7;i++){
if(document.getElementById('text'+i)){
document.getElementById('text'+i).style.visibility='hidden';
document.getElementById('text'+i).style.display='none';
if(document.getElementById('tab'+i)){
document.getElementById('tab'+i).className='tabbedtext';
		}
	}
}
document.getElementById('text'+id).style.visibility='visible';
document.getElementById('text'+id).style.display='block';
document.getElementById('tab'+id).className='tabbedtext_sel';
}


//Objektart/typswitch

function quickSearchChangeName(select)
{
    var index = select.options.selectedIndex;
    var value = select.options[index].value;
    
    //alert('name: ' + select.name + '\nindex: ' + index + '\nvalue:' + value);
    
    if (value == 'grundstueck' || 
        value == 'einzelhandel' || 
        value == 'hallen_lager_prod' || 
        value == 'wohnung' || 
        value == 'sonstige' || 
		value == 'haus' ||
        value == 'buero_praxen' ||
		value == 'zimmer' ||
		value == 'zinshaus_renditeobjekt'
		)
    {
        select.name = "quicksearch#ObjKategorie#objektart#11#id";
    }
    else
    {
        select.name = "quicksearch#ObjKategorie#objekttyp#12#id";
    }
}


//Popups

function OSG_mypopup(s,b,h,id,entry,optionen) {
	if (!optionen) {
		optionen = "location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=no,top=5,left=30";
	}
	var seite = "osg_popup.xhtml?art="+s+"&id="+id+"&entry="+entry;
	windowprops = "height="+h+",width="+b+","+optionen;
	var fensterle =	window.open(seite, "Popup", windowprops);
	fensterle.focus();
}


// Formularproof

function proof(){
	if(document.formular.vorname.value==""){
		alert("__OSG__LANGUAGE(Bitte geben Sie Ihren Vornamen an)");
		return false;
	}
	if(document.formular.name.value==""){
		alert("__OSG__LANGUAGE(Bitte geben Sie Ihren Namen an)");
		return false;
	}

	if(document.formular.wohnort_plz.value==""){
		alert("__OSG__LANGUAGE(Bitte geben Sie Ihre PLZ an)");
		return false;
	}
	if(document.formular.Ort.value==""){
		alert("__OSG__LANGUAGE(Bitte geben Sie Ihren Wohnort an)");
		return false;
	}
	if(document.formular.strasse.value==""){
		alert("__OSG__LANGUAGE(Bitte geben Sie Ihre Strasse an)");
		return false;
	}
	if(document.formular.telefon.value==""){
		alert("__OSG__LANGUAGE(Bitte geben Sie Ihre Telefonnummer an)");

		return false;
	}

		return true;

	}
	
	
// Listenstriche bei nicht vorhandenem Link ausblenden. Hier wird dann das komplette <li> gelöscht.

$(document).ready(function()
{
	$('li.extlink').each(function()
    {
		if ($(this).html() == '&nbsp;<i>|</i>&nbsp;')
        	$(this).remove();
    });
	
	$('ul#subnavigation').each(function()
    {
		var inhalt = $(this).html();
		
		if (jQuery.trim(inhalt) == '')
        	$(this).remove();
    });
	
});


// Flash Objektliste
$(document).ready(function(){
	
	var first = 0;
	var speed = 700;
	var pause = 3500;
	
		function removeFirst(){
			first = $('ul#listticker li:first').html();
			$('ul#listticker li:first')
			.animate({opacity: 0}, speed)
			.fadeOut('slow', function() {$(this).remove();});
			addLast(first);
		}
		
		function addLast(first){
			last = '<li style="display:none">'+first+'</li>';
			$('ul#listticker').append(last)
			$('ul#listticker li:last')
			.animate({opacity: 1}, speed)
			.fadeIn('slow')
		}
	
	interval = setInterval(removeFirst, pause);
});

// Menu ul Ausblender

$(document).ready(function() 
{
	$("ul#subnavi").each(function()
	{
		if (jQuery.trim($(this).html()) == '')
			$(this).remove();
	});
});


// iService Meldung

$(document).ready(function() 
{
	$("#iservice").each(function()
	{
		if (jQuery.trim($(this).html()) == '')
		{
			$(this).html('<p>Leider wurden keine passenden Objekte gefunden.</p><p><a href="javascript:history.back(1)">zurück</p>');
			$("p.textweg").empty();
		}
	});
});


// verkauft, vermietet und neu ordentlich auf Größe bringen
$(document).ready(function(){
$("div.divImgNeuRiesig").attr("style", "position: absolute; top: 100px; left: 10px;");
 });
