
function senden(seite) {
  document.getElementById('OFFSET').value = seite;
  sendForm();
}

function show_details(anzeige, sitepos){
	document.getElementById('DETAILS').value	= anzeige;
	document.getElementById('SITEPOS').value	= sitepos;
	document.forms[0].action= 'detailanzeige.php';
	document.forms[0].submit();
}

function sendForm(){
  document.forms['detail'].target = '_self'; 
  document.forms['detail'].submit();
}

function gotoSuche(){
	document.forms['detail'].target = '_self'; 
	document.forms['detail'].action  = 'index.php';
    document.forms['detail'].submit();
    
}
function gotoTreffer(){
	document.forms['detail'].target = '_self'; 
    document.forms['detail'].action  = 'ergebnisse.php';
    document.forms['detail'].submit();
}

function get_cookie( cookieName ){
    strValue = false;    
    if( strCookie = document.cookie ){
            if( arrCookie = strCookie.match( new RegExp( cookieName + '=([^;]*)', 'g'))){
                    strValue=RegExp.$1;
                }
        }
    return(strValue);
}

function setAnzahl(){
	if (get_cookie('anz'))
		anz =  get_cookie('anz')
		else
			anz = 0; 
    if (document.getElementById('anzahl'))
			document.getElementById('anzahl').innerHTML = '<strong>'+anz+'</strong>';  
    }
    
    
function OpenGarage(anzeigeID){
	if (anzeigeID != 0){						
		document.getElementById('ANZEIGE_ID').value	= anzeigeID;
		document.forms['garage'].action= 'garage.php';
		document.forms['garage'].target = 'parken'
		document.forms['garage'].onsubmit = window.open('about:blank','parken','height=180,width=350');
		document.forms['garage'].submit();
		window.setTimeout("setAnzahl()",4500);	
		}else {
			document.forms['detail'].action= 'parken.php';
			document.forms['detail'].target = '_self'; 
			document.forms['detail'].submit();
	}
}


function anfrageSenden(){
	document.getElementById('SUBMITANFRAGE').value	= 1;
	document.forms['detail'].submit();
}

function Suchanfrage(what){
	document.getElementById('SUCHANFRAGE').value	= what;
	gotoSuche(); 

}

$(document).ready(function() {
	if ($('#ANZEIGE_MARKE_ID').val() == 0) {
		$('#ANZEIGE_MARKE_ID').val('1014');
	}
	getModelle();		
	
	function getModelle(){
		$('select#ANZEIGE_MODELL_ID').val(''); 
		$.ajax ({
			url: "/ajax/get_modelle.php?ANZEIGE_MARKE_ID="+$('#ANZEIGE_MARKE_ID').val()+"&SPRACHE="+$('#SPRACHE').val()+"&LAND="+$('#LAND').val(),
			type: "GET",
			cache: false,
			success: function handleResponseModell(reqCode){
				$('#ANZEIGE_MODELL_ID').html(reqCode); 
				if ($('#m_id').val() > 1) {
					$('#ANZEIGE_MODELL_ID').val($('#m_id').val());
				}
			}
		});
	}
	
	$('select').change(function() {
		if ($(this).attr('id') == 'ANZEIGE_MARKE_ID'){				
			getModelle(); 
		}			
	});
});

