function buAdresiKullan(id){
	$('#adres_bilgileri').html('<img src="images/loading.gif">'); 
	$.post('motor.php',	{id : id, islem : 'bu_adresi_kullan'},
		function(ajaxCevap){
			$('#adres_bilgileri').html(ajaxCevap) 
		}
	);
	return false;
}


function adresiSil(id){
	$('#kayitli_adreslerim').html('<img src="images/loading.gif">'); 
	$.post('motor.php',	{id : id, islem : 'adresi_sil'},
		function(ajaxCevap){
			$('#kayitli_adreslerim').html(ajaxCevap) 
		}
	);
	return false;
}

function adresiKaydet(){
	ad_soyad = document.teslimat_bilgileri.ad_soyad.value;
	sabit_telefon = document.teslimat_bilgileri.sabit_telefon.value;
	cep_telefon = document.teslimat_bilgileri.cep_telefon.value;
	adres = document.teslimat_bilgileri.adres.value;
	diger_ilce_mahalle = document.teslimat_bilgileri.diger_ilce_mahalle.value;
	
	for(i=0; i<document.teslimat_bilgileri.il.length; i++){
		if(document.teslimat_bilgileri.il[i].selected == true)
			sehir_id = document.teslimat_bilgileri.il[i].value;
	}
	
	for(i=0; i<document.teslimat_bilgileri.ilce.length; i++){
		if(document.teslimat_bilgileri.ilce[i].selected == true)
			ilce_id = document.teslimat_bilgileri.ilce[i].value;
	}
	
	for(i=0; i<document.teslimat_bilgileri.semt.length; i++){
		if(document.teslimat_bilgileri.semt[i].selected == true)
			semt_id = document.teslimat_bilgileri.semt[i].value;
	}
	
	
	$.post('motor.php',{ad_soyad : ad_soyad, sabit_telefon : sabit_telefon, cep_telefon : cep_telefon, adres : adres,
		  il : sehir_id, ilce : ilce_id, semt : semt_id, diger : diger_ilce_mahalle, islem : 'adres_kaydet'},
		function(ajaxCevap){
			$('#kayitli_adreslerim').html(ajaxCevap) 
		}
	);
	return false;
	
}

function ilceAyikla(){
	for(i=0; i<document.teslimat_bilgileri.il.length; i++){
		if(document.teslimat_bilgileri.il[i].selected == true)
			sehir_id = document.teslimat_bilgileri.il[i].value;
	}
	
	$.post('motor.php',{sehir_id : sehir_id, islem : 'il_ayikla'},
		function(ajaxCevap){
			$('#il').html(ajaxCevap) 
		}
	);
	
	$.post('motor.php',{id: sehir_id, islem : 'ilce_ayikla'},
		function(ajaxCevap){
			$('#ilce').html(ajaxCevap) 
		}
	);
	return false;
	
}

function semtAyikla(id){
	
	for(i=0; i<document.teslimat_bilgileri.il.length; i++){
		if(document.teslimat_bilgileri.il[i].selected == true)
			sehir_id = document.teslimat_bilgileri.il[i].value;
	}
	for(i=0; i<document.teslimat_bilgileri.ilce.length; i++){
		if(document.teslimat_bilgileri.ilce[i].selected == true)
			ilce_id = document.teslimat_bilgileri.ilce[i].value;
	}
	
	$.post('motor.php',{sehir_id : sehir_id, islem : 'il_ayikla'},
		function(ajaxCevap){
			$('#il').html(ajaxCevap) 
		}
	);
	
	$.post('motor.php',{id: sehir_id, ilce_id : ilce_id, islem : 'ilce_ayikla'},
	function(ajaxCevap){
		$('#ilce').html(ajaxCevap) 
	}
	);
	
	$.post('motor.php',{sehir_id: sehir_id, ilce_id : ilce_id, islem : 'semt_ayikla'},
		function(ajaxCevap){
			$('#semt').html(ajaxCevap) 
		}
	);
	return false;
	
}

function divleriAc(id){
	birim_secenek_eski = document.sepet.birim_secenek_eski.value;
	$('#adet'+birim_secenek_eski).html('');
	$('#toplam_fiyat'+birim_secenek_eski).html(''); 
	$.post('motor.php',	{id: id, islem : 'adet_divini_ac'},
		function(ajaxCevap){
			$('#adet'+id).html(ajaxCevap) 
		}
	);
	$.post('motor.php',	{id: id, islem : 'toplam_fiyat_divini_ac'},
		function(ajaxCevap){
			$('#toplam_fiyat'+id).html(ajaxCevap) 
		}
	);
	$.post('motor.php',	{id: id, islem : 'eski_id_divine_ayar_cek'},
		function(ajaxCevap){
			$('#eski_id').html(ajaxCevap) 
		}
	);
	return false;
}

function fiyatHesapla(id){
	for(i=0; i<document.sepet.adet.length; i++){
		if(document.sepet.adet[i].selected == true)
			adet = document.sepet.adet[i].value;
	}
	$.post('motor.php',	{id: id, adet : adet, islem : 'fiyat_hesapla'},
		function(ajaxCevap){
			$('#toplam_fiyat'+id).html(ajaxCevap) 
		}
	);
	return false;
}

function sepeteEkle(urun_id){
	
	for(i=0; i<document.sepet.adet.length; i++){
		if(document.sepet.adet[i].selected == true)
			adet = document.sepet.adet[i].value;
	}
	if(document.sepet.birim_secenek.length>1)
	{
		for(i=0; i<document.sepet.birim_secenek.length; i++){
			if(document.sepet.birim_secenek[i].checked == true)
				birim_secenek = document.sepet.birim_secenek[i].value;
		}
	}
	else
	{
		birim_secenek = document.sepet.birim_secenek.value;		
	}
	
	$.post('motor.php',	{adet : adet, birim_id : birim_secenek, urun_id : urun_id, islem : 'sepete_ekle'},
		function(ajaxCevap){
			$('#sepet_content').html(ajaxCevap) 
		}
	);
	return false;
}

function sepettenSil(id){
	
	$.post('motor.php',	{id : id, islem : 'sepetten_sil'},
		function(ajaxCevap){
			$('#sepet_content').html(ajaxCevap) 
		}
	);
	return false;
}

function sepettenCikar(id){
	$('#sepetim_content').html('<img src="images/loading.gif">'); 
	$.post('motor.php',	{id : id, islem : 'sepetten_cikar'},
		function(ajaxCevap){
			$('#sepetim_content').html(ajaxCevap) 
		}
	);
	$('#sepetim_bilgi_content').html('<img src="images/loading.gif">'); 
	$.post('motor.php',	{id : id, islem : 'sepetten_cikar2'},
		function(ajaxCevap){
			$('#sepetim_bilgi_content').html(ajaxCevap) 
		}
	);
	$('#satin_almaya_basla').html('<img src="images/loading.gif">'); 
	$.post('motor.php',	{id : id, islem : 'satin_almaya_basla'},
		function(ajaxCevap){
			$('#satin_almaya_basla').html(ajaxCevap) 
		}
	);
	return false;
}

function sepetiBosalt(){
	$('#sepetim_content').html('<img src="images/loading.gif">'); 
	$.post('motor.php',	{islem : 'sepeti_bosalt1'},
		function(ajaxCevap){
			$('#sepetim_content').html(ajaxCevap) 
		}
	);
	$('#sepetim_bilgi_content').html('<img src="images/loading.gif">'); 
	$.post('motor.php',	{islem : 'sepeti_bosalt2'},
		function(ajaxCevap){
			$('#sepetim_bilgi_content').html(ajaxCevap) 
		}
	);
	$('#satin_almaya_basla').html('<img src="images/loading.gif">'); 
	$.post('motor.php',	{ islem : 'sepeti_bosalt3'},
		function(ajaxCevap){
			$('#satin_almaya_basla').html(ajaxCevap) 
		}
	);
	return false;
}



function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}

function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}

var isIE = (navigator.appName == "Microsoft Internet Explorer");

function elementi_cek(element) {
	return document.getElementById(element);
}

function Toggle(element) {
	var e = elementi_cek(element);
	if (e.style.display == 'none')
		e.style.display = '';
	else
		e.style.display = 'none';
}

