///////////
var url = "";
var url_adres='';
var http=GetXmlHttpObject();
var	adres = window.location.href;
var tr = adres.split('/');
	if(tr[2]=='localhost')
	{
		 url='http://'+tr[2] + '/' +tr[3];
	}
	else if(tr[2]=='online-hukuk.org')
	{
		 url='http://' + tr[2];
	}
url_adres = url;
url = url+"/ajax.html";

function GetXmlHttpObject()
{
	var http=null;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
	            http = new XMLHttpRequest();
	            if (http.overrideMimeType) {
	                http.overrideMimeType('text/xml');
	                // See note below about this line
	            }
	        }   
	        else if (window.ActiveXObject) { // IE
	            try {
	                http = new ActiveXObject("Msxml2.XMLHTTP");
	            } 
	            catch (e) {
	                try {
	                    http = new ActiveXObject("Microsoft.XMLHTTP");
	                } 
	                catch (e) {}
	            }
	        } 
	return http;
	
	/*try
	  {
	  // Firefox, Opera 8.0+, Safari
	  http=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
	    {
	    http=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	  catch (e)
	    {
	    http=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	  }*/

}


function giris()
{
	document.getElementById('ana').value = window.location;
	var	adres = window.location;	
	var tr = adres.split("/");
	if(tr[2]=='localhost')
	{
		 url='http://'+tr[2] + '/' +tr[3];
	}
	else if(tr[2]=='online-hukuk.org')
	{
		 url='http://' + tr[2];
	}
	 url_adres=url;
	url=url+"/ajax.html";
}
//////////////////////////////
function bolum_arama()
{
	var arama = document.getElementById("bolum").value;
    if(http.readyState!=4)
    {
		http.abort();
	}	
    http.open('POST', url, true);
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
    http.onreadystatechange=ajax_cvp_goster;    
    http.send("sayfa=bolum_arama&bolum=" + arama);
}

function mail_kontrol_soru_cevap()
{
	var mail = document.getElementById("mail").value;
	//alert(mail);
	document.getElementById("div_id_input").value="mail_kontrol"
    if(http.readyState!=4)
    {
		http.abort();
	}	
	//alert(url);
    http.open('POST', url, true);
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
    http.onreadystatechange=ajax_cvp_goster;    
    http.send("sayfa=mail_kontrol_soru_cevap&mail=" + mail);
}


function ajax_cvp_goster()
{
	div_id = document.getElementById("div_id_input").value;
	//alert(div_id);
	var yazi='İstek Üzerinde Çalışılıyor.';
	if(http.readyState==4)
    {
        yazi=http.responseText;
    }
	document.getElementById(div_id).innerHTML=yazi;
}

function alt_bolum_goster(id)
{
	div_=document.getElementById('div_' + id);
	resim = document.getElementById('img_'+id);
	if(div_.style['display']!='block')
	{
		
	   if(http.readyState!=4)
		{
			http.abort();
		}	
		
		//alert(url);
		
		http.open('POST', url, true);
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
		http.onreadystatechange= function() {
			yazi='<img src="' + url_adres + '/theme/onlinehukuk/images/loading.gif" style="float:left;">';
			if(http.readyState==4)
			{
				yazi = http.responseText;			
				
			}
			
			div_.innerHTML=yazi;
			div_.style.display='block'; 
			resim.src= url_adres + '/theme/onlinehukuk/images/acilir_alt.jpg';
		}    
		http.send("sayfa=alt_bolumler&bolum_id=" + id); 
	}
	else
	{
		div_.style.display='none';
		resim.src= url_adres + '/theme/onlinehukuk/images/acilir.jpg';
	}
	

}



function sepete_ekle(id)
{
	if(id.length==0)
	{
		alert("Sepete eklenecek ürün bildirilmemiş.");
		return;
	}
	document.getElementById("div_id_input").value='div_sepet';
    if(http.readyState!=4)
    {
		http.abort();
	}	
	//alert(url);
    http.open('POST', url, true);
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
    http.onreadystatechange=ajax_cvp_goster;    
    http.send("sayfa=sepet&eylem=ekle&id=" + id);
}
function sepet_sil(id)
{
	if(id.length==0)
	{
		alert("Sepetten silinecek ürün bildirilmemiş.");
		return;
	}
	document.getElementById("div_id_input").value='div_sepet';
    if(http.readyState!=4)
    {
		http.abort();
	}	
	//alert(url);
    http.open('POST', url, true);
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
    http.onreadystatechange=ajax_cvp_goster;    
    http.send("sayfa=sepet&eylem=sil&id=" + id);
}

function urun_sil_sepet(id)
{
	document.getElementById("id").value=id;
	document.getElementById("eylem").value="sil";
	alert(id);
	form=document.getElementById("genel_form").submit();
}

function siparis_tamamla()
{
	 document.getElementById('eylem').value='tamamla';
	 document.getElementById('genel_form').submit();
}

function bolum_sil(id)
{
	var saat= zmn.getHours() + '' + zmn.getMinutes() + '' + zmn.getSeconds();
    var url = "ajax.php?sayfa=bolum_silme&bolum=" + id + "&zmn=" + saat;
    http.open('GET', url, true);
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
    http.onreadystatechange=ajax_cvp_goster;    
    http.send(null);
}

function goster(id)
{
	document.getElementById(id).style.display='block';
}
function gizle(id)
{
	document.getElementById(id).style.display='none';
}


function sepet_sayfasi(url)
{
	sayfa=window.open(url,'Sepet','width=600px,height=400px,menubar=no, toolbar=no, location=no,status=no, left=150, top=150, scrollbars=yes, resizable=yes');
}

function sayfalama(id)
{
	var adres = document.URL;
	var form = document.getElementById("form");
	var page = document.getElementById("page");
	form.setAttribute("action", adres);
	page.value = id;
	form.submit();
}

function soru_menu(eylem)
{
	document.getElementById("eylem").value=eylem;
	document.getElementById('form').submit();
}

function soru_goster(soru_id)
{
	document.getElementById("eylem").value='goster';
	document.getElementById("soru_id").value=soru_id;
	document.getElementById('form').submit();
}


function yazdir(id)
{
	if(id==undefined)
	{
		alert("boş");
		return;
	}
	window.open('yazdir.php?id='+id,'yazdir','');
}

function yorumlari_goster()
{
	var yorum_liste=document.getElementById("yorumlar");
	var arkadasina_gonder=document.getElementById("arkadasina_gonder");
	var yorumla=document.getElementById("yorumla");
	
	yorum_liste.style.display="block";
	arkadasina_gonder.style.display='none';
	yorumla.style.display='none';
	
	makale_event_change_classname("yorum_liste");
	
}

function yorumla()
{
	var yorum_liste=document.getElementById("yorumlar");
	var arkadasina_gonder=document.getElementById("arkadasina_gonder");
	var yorumla=document.getElementById("yorumla");
	
	yorum_liste.style.display="none";
	arkadasina_gonder.style.display='none';
	yorumla.style.display='block';
	
	makale_event_change_classname("yorumla");
}
function yorum_kaydet()
{
	
	return false;
}
function arkadasa_gonder()
{
	var yorum_liste=document.getElementById("yorumlar");
	var arkadasina_gonder=document.getElementById("arkadasina_gonder");
	var yorumla=document.getElementById("yorumla");
	
	yorum_liste.style.display="none";
	arkadasina_gonder.style.display='block';
	yorumla.style.display='none';
	
	makale_event_change_classname("arkadasa_gonder");
}
function arkadasina_tavsiye_et()
{
	var mail_adresiniz=document.getElementById("mail_adresiniz").value;
	if(mail_adresiniz.length==0||mail_adresiniz==' ')
	{
		alert("Mail adresinizi yazınız.");
		return false;
	}
	var adiniz=document.getElementById("adiniz").value;
	if(adiniz.length==0||adiniz==' ')
	{
		alert("Adınızı yazınız.");
		return false;
	}
	var arkadasinizin_adi=document.getElementById("arkadasinizin_adi").value;
	if(arkadasinizin_adi.length==0||arkadasinizin_adi==' ')
	{
		alert("Arkadaşınızın yazınız.");
		return false;
	}
	var arkadasinizin_maili=document.getElementById("arkadasinizin_maili").value;
	if(arkadasinizin_maili.length==0||arkadasinizin_maili==' ')
	{
		alert("Arkadaşınızın mail adresinizi yazınız. Yoksa tavsiyeniz gönderilemez.");
		return false;
	}
	var arkadasina_mesaj=document.getElementById("arkadasina_mesaj").value;
	if(arkadasina_mesaj.length==0||arkadasina_mesaj==' ')
	{
		alert("Bu makale ile ilgili Arkadaşınıza göndereceğiniz yorumunuz yok mu?");
		return false;
	}
	var makale_id=document.getElementById("makale_id").value;
	if(makale_id.length==0||makale_id==' ')
	{
		alert("Makale bilgisi alınamadı lütfen sayfayı YENİLEYİNİZ.");
		return false;
	}
	if(http.readyState!=4)
    {
		http.abort();
	}	
	//alert(url);
    http.open('POST', url, true);
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
    http.onreadystatechange=function(){
		yazi='Mesajınız arkadaşınıza gönderilmeye çalışılıyor.';
		if(http.readyState==4)
	    {
	        yazi=http.responseText;
	    }
		document.getElementById("arkadasina_gonder_uyari").innerHTML=yazi;
    };    
    http.send("sayfa=arkadasina_gonder&mail_adresiniz=" + mail_adresiniz + "&adiniz=" + adiniz + "&arkadasinizin_adi=" + arkadasinizin_adi + "&arkadasinizin_maili=" + arkadasinizin_maili + "&arkadasina_mesaj=" + arkadasina_mesaj + "&makale_id=" + makale_id);
	return false;
}
function yorum_kaydet()
{
	var adi_soyadi=document.getElementById("adi_soyadi").value;
	if(adi_soyadi.length==0||adi_soyadi==' ')
	{
		alert("Adını ve Soyadınızı yazınız.");
		return false;
	}
	var mail_adresi=document.getElementById("mail_adresi").value;
	if(mail_adresi.length==0||mail_adresi==' ')
	{
		alert("Gerekli görüldüğünde sizinle irtibata geçilebilmesi için mail adresinizi yazınız.");
		return false;
	}
	var yorum=document.getElementById("yorum").value;
	if(yorum.length==0||yorum==' ')
	{
		alert("Yorumunuzu yazmadan yorum kayıt edemeyiz. Lütfen yorumunuzu yazınız.");
		return false;
	}
	var makale_id=document.getElementById("makale_id").value;
	if(makale_id.length==0||makale_id==' ')
	{
		alert("Makale bilgisi alınamadı lütfen sayfayı YENİLEYİNİZ.");
		return false;
	}
	if(http.readyState!=4)
    {
		http.abort();
	}	
	//alert(url);
    http.open('POST', url, true);
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
    http.onreadystatechange=function(){
		yazi='Yorumunuz kayıt ediliyor.';
		if(http.readyState==4)
	    {
	        yazi=http.responseText;
	    }
		document.getElementById("yorum_kayit_uyari").innerHTML=yazi;
    };    
    http.send("sayfa=yorum_kaydet&mail_adresi=" + mail_adresi + "&adi_soyadi=" + adi_soyadi + "&yorum=" + yorum + "&makale_id=" + makale_id);
	return false;
}
function makale_event_change_classname(section)
{
	var yorum_liste_a=document.getElementById("a_yorumlar");
	var arkadasina_gonder_a=document.getElementById("a_arkadasina_gonder");
	var yorumla_a=document.getElementById("a_yorumla");
	
	yorum_liste_a.className="";
	arkadasina_gonder_a.className="";
	yorumla_a.className="";

	switch(section)
	{
		case 'yorum_liste':
			yorum_liste_a.className="secili";
		break;
		case 'arkadasa_gonder':
			arkadasina_gonder_a.className="secili";
		break;
		case 'yorumla':
			yorumla_a.className="secili";
		break;
		
	}

}
function makale_yorumlari_hepsi(url)
{
	if(url.length>0)
	{
		window.open(url, "makale_yorumlari","width=350,height=600,scrollbars=yes");
	}
}