
var mycars = new Array();
var k;

for(k=0; k<=48; k++){
	mycars[k] = new Array();
}

mycars[0][0]="Wybierz model";
mycars[1][0]="Wszystkie";
mycars[2][0]="Wszystkie";
mycars[3][0]="Wszystkie";
mycars[4][0]="Wszystkie";
mycars[5][0]="Wszystkie";
mycars[6][0]="Wszystkie";
mycars[7][0]="Wszystkie";
mycars[8][0]="Wszystkie";
mycars[9][0]="Wszystkie";
mycars[10][0]="Wszystkie";









function Model(){
	var opt=document.c.marka.options[document.c.marka.selectedIndex].value;
	var i;
		
	for(i=0; i<document.c.model.length; i++){
		document.c.model.remove(i);
	}
	
	for(i=0; i<mycars[opt].length; i++){
		document.c.model[i]=new Option(mycars[opt][i], mycars[opt][i], false);
	}



}



function zmien(mr, gt){
	
	var oRequest = new XMLHttpRequest();
	var sURL  = "/ajax/cz123.php?marka=" + mr + "&gt=" + gt;

	oRequest.open("GET",sURL,false);
	oRequest.setRequestHeader("User-Agent", navigator.userAgent);
	oRequest.send(null)

	if (oRequest.status==200){
		
		document.getElementById('czescid').innerHTML = oRequest.responseText;
		//alert(oRequest.responseText);
	}else{
		alert("Wystąpił problem z pobieraniem danych");
	}

}


function zmienPR(mr, gt, pr){
	
	var oRequest = new XMLHttpRequest();
	var sURL  = "/ajax/cz1234.php?marka=" + mr + "&gt=" + gt + "&cid=" + pr;
	oRequest.open("GET",sURL,false);
	oRequest.setRequestHeader("User-Agent", navigator.userAgent);
	oRequest.send(null)

	if (oRequest.status==200){
		
		document.getElementById('producentid').innerHTML = oRequest.responseText;
		//alert(oRequest.responseText);
	}else{
		alert("Wystąpił problem z pobieraniem danych");
	}

}



function SubmitCheckBT(){
	var opt=document.b.wid.options[document.b.wid.selectedIndex].value;
	var retVal;

	if(opt=='0'){
		retVal=false;
		alert("Proszę wybrać województwo!");
	}else{
		retVal=true;
	}
	
	return retVal;
}



function SubmitCheck01(){
	var opt=document.c.wid.options[document.c.wid.selectedIndex].value;
	var retVal;

	if(opt=='0'){
		retVal=false;
		alert("Proszę wybrać województwo!");
	}else{
		retVal=true;
	}
	
	return retVal;
}


function SubmitCheck02(){
	var optMarka=document.c.marka.options[document.c.marka.selectedIndex].value;
	var optRp=document.c.rp.options[document.c.rp.selectedIndex].value;	
	var retVal=true;
	var msg='';
	
	if(optMarka=='0'){
		retVal=false;
		msg = "Proszę wybrać markę samochodu!\n";
	}
	
	if(optRp=='0'){
		retVal=false;
		msg = msg + "Proszę wybrać rok produkcji!\n";
	}
	
	if(retVal==false){
		alert(msg);
	}
	
	
	return retVal;
}



function SubmitCheck03(){
	var optGt=document.c.gt.options[document.c.gt.selectedIndex].value;
	//var optPr=document.c.pr.options[document.c.pr.selectedIndex].value;	
	var optCz=document.c.cz.options[document.c.cz.selectedIndex].value;	
	
	var retVal=true;
	var msg="NIE WYBRANO WSZYSTKICH OPCJI:\n\n";
	
	if(optGt=='0'){
		retVal=false;
		msg = msg + "- Proszę wybrać grupę towarową!\n";
	}
	
	if(optCz=='0'){
		retVal=false;
		msg = msg + "- Proszę wybrać część!\n";
	}	
	
	//if(optPr=='0'){
	//	retVal=false;
	//	msg = msg + "- Proszę wybrać producenta!\n";
	//}
	
	
	if(retVal==false){
		alert(msg);
	}
	
	
	return retVal;
}




function SpecOnOff(){
	
	if(document.c.typ.options[document.c.typ.selectedIndex].value == 1){
		 document.getElementById('specc').style.display = 'inline';		
		WyswietlSpecjalizacje();
	
	}else if(document.c.typ.options[document.c.typ.selectedIndex].value == 3){
		document.getElementById('specc').style.display = 'inline';	
		WyswietlMarki();
	}else{
		document.getElementById('specc').style.display = 'none';	
		WyswietlMiasta();
	}
	
}



function SubmitCheckWarsztat(){
	
	var optGt=document.c.widd.options[document.c.widd.selectedIndex].value;
	var optPr=document.c.typ.options[document.c.typ.selectedIndex].value;
	
	var retVal=true;
	var msg="NIE WYBRANO WSZYSTKICH OPCJI:\n\n";
	
	if(optGt=='0'){
		retVal=false;
		msg = msg + "- Proszę wybrać województwo!\n";
	}
		
	if(optPr=='0'){
		retVal=false;
		msg = msg + "- Proszę typ działalności!\n";
	}
	
	
	if(retVal==false){
		alert(msg);
	}
	
	
	return retVal;


}





function WyswietlMiasta() {
	
	var req = mint.Request();
	req.AddParam("typ", $k("typ").value);
	req.AddParam("wid", $k("widd").value);
	req.AddParam("spec", $k("spec").value);
	req.method = "post";
	
	req.OnLoading = function() {
		$k('wmiasto').innerHTML = '<p style="margin-top: 5px">Wczytuję miasta ...</p>';
	};
	
	req.OnSuccess = function() {

		//$k("contener_"+id).removeChild($k("select_"+id));
		//var a = $k("contener_"+id).innerHTML;
		
		$k('wmiasto').innerHTML = this.responseText;
	};
	
	req.Send("/ajax/wm.php");
	
}



function WyswietlMarki() {
	
	var req = mint.Request();
	req.AddParam("typ", $k("typ").value);
	req.AddParam("wid", $k("widd").value);
	req.AddParam("mod", "marks");
	req.method = "post";
	
	req.OnLoading = function() {
		$k('wmarka').innerHTML = '<p style="margin-top: 5px">Wczytuję marki ...</p>';
	};
	
	req.OnSuccess = function() {

		//$k("contener_"+id).removeChild($k("select_"+id));
		//var a = $k("contener_"+id).innerHTML;
		
		$k('wmarka').innerHTML = this.responseText;
		WyswietlMiasta();

	};
	
	req.Send("/ajax/wm.php");
	
}



function WyswietlSpecjalizacje(){
	var req = mint.Request();
	req.AddParam("mod", "spec");
	req.method = "post";
	
	req.OnLoading = function() {
		$k('wmarka').innerHTML = '<p style="margin-top: 5px">Wczytuję specjalizacje ...</p>';
	};
	
	req.OnSuccess = function() {

		//$k("contener_"+id).removeChild($k("select_"+id));
		//var a = $k("contener_"+id).innerHTML;
		
		$k('wmarka').innerHTML = this.responseText;
		WyswietlMiasta();

	};
	
	req.Send("/ajax/wm.php");
		
}




function WojChange(){
	var optPr=document.c.typ.options[document.c.typ.selectedIndex].value;

	if(optPr=='1'){
		WyswietlSpecjalizacje();
	}
	
	if(optPr=='3'){
		WyswietlMarki();
	}

	WyswietlMiasta();
}



function CommentAdd() {
	
	
	document.getElementById('CButton22').style.display = 'none';
		
	var req = mint.Request();
	req.AddParam("nick", $k("nick").value);
	req.AddParam("email", $k("email").value);
	req.AddParam("comment", $k("comment").value);
	req.AddParam("aid", $k("aid").value);
	req.AddParam("uid", $k("uid").value);
	req.AddParam("mod", "addc");
	req.method = "post";
	
	req.OnLoading = function() {
		$k('CButton').innerHTML = '<p style="margin-left: 25px; margin-bottom: 5px; margin-top: 5px; color: #1A306C; font-size: 12px"><img src="/img/loading.gif" border="0" />Dodaję komentarz ...</p>';
	};
	
	req.OnSuccess = function() {		
		$k('comments').innerHTML = this.responseText;
	};
	
	req.Send("/ajax/ac.php");
	
}