	function getXmlHttpObject() {
		var xmlHttp = null;
		try 
		{
		//Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
		}
		catch(e) 
		{
			// Internet Explorer
			try
			{
			xmlHttp = new ActiveXObject("Msxm12.XMLHTTP");
			}
			catch(e)
			{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
	return xmlHttp;
	}

	/* 
		listFilm()
		
		str parametresi dolu ise girilen harflere uygun olan liste
		str bos veya tanımsız ise tüm film listeyi gösterir
	*/
	
	function listFilm(str) {

		var xmlHttp = getXmlHttpObject();

		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		}
		
		var url;
		url="list_film.asp";
		
		if(str!= "" || str!= null) 
		{
			url=url+"?q="+str;
		}
		
		xmlHttp.onreadystatechange=function(){
			if (xmlHttp.readyState==1) 
			{
				document.getElementById("search-result").innerHTML="<img src='assets/images/loader.gif' />";
			}
			
			if (xmlHttp.readyState==4)
			{ 
				document.getElementById("search-result").innerHTML=xmlHttp.responseText;
				vaToolTipInit();
			}		
		}
		
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
	}

	/* 
		listOperation()
		
		Listenecek filmin isminemi yılınamı gibi seçenekler göndererek listelenmesi sağlar
	*/
	
	function listOrderBy(orderName,orderBy) {

		var xmlHttp = getXmlHttpObject();

		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		}
		
		var url;
		url="list_orderby.asp";
		
		url=url+"?orderName="+orderName+"&orderBy="+orderBy;
		
		xmlHttp.onreadystatechange=function(){
			if (xmlHttp.readyState==1) 
			{
				document.getElementById("search-result").innerHTML="<img src='assets/images/loader.gif' />";
			}
			
			if (xmlHttp.readyState==4)
			{ 
				document.getElementById("search-result").innerHTML=xmlHttp.responseText;
				vaToolTipInit();
			}		
		}
		
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
	}

	/* 
		openAddManuelFilmInformationWindow()

		Manuel olarak bilgileri girilecek film alanının bilgilerinin
		oldugu pencereyi acar
	*/
	
	function openAddManuelFilmInformationWindow() 
	{
	
		operationWindow = document.getElementById("operations-window");

		if(operationWindow.style.display=="none") 
		{
			operationWindow.style.display="block";
		}

		strHtml = "<table class=\"template1\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		strHtml +="<tr>";
		strHtml +="<th scope=\"row\">Filmin İsmi</th>";
		strHtml +="<td><input class=\"textField\" id=\"film_ismi\" type=\"text\"/></td>";
		strHtml +="</tr>";
		strHtml +="<tr>";
		strHtml +="<th scope=\"row\">Imdb Adresi</th>";
		strHtml +="<td><input class=\"textField\" id=\"imdb_adresi\" type=\"text\"/></td>";
		strHtml +="</tr>";
		strHtml +="<tr>";
		strHtml +="<th scope=\"row\">Yayın Tarihi</th>";
		strHtml +="<td><input class=\"textField\" id=\"cikis_tarihi\" type=\"text\"/></td>";
		strHtml +="</tr>";
		strHtml +="<tr>";
		strHtml +="<th scope=\"row\">Ekleyen Kişi</th>";
		strHtml +="<td><input class=\"textField\" id=\"kim_ekledi\" type=\"text\"/></td>";
		strHtml +="</tr>";
		strHtml +="<tr>";
		strHtml +="<th scope=\"row\">Kayıt Türü</th>";
		strHtml +="<td><input class=\"textField\" id=\"kayit_turu\" type=\"text\"/></td>";
		strHtml +="</tr>";
		strHtml +="<tr>";
		strHtml +="<th scope=\"row\">&nbsp;</th>";
		strHtml +="<td><input class=\"submit\" type=\"button\" value=\"Ekle\" onclick=\"addManuelFilmInformation();\"/> <input class=\"submit\" type=\"button\" value=\"Kapat\" onclick=\"document.getElementById('operations-window').style.display='none'\"/></td>";
		strHtml +="</tr>";
		strHtml +="</table>";
		operationWindow.innerHTML = strHtml;

	}

	/* 

		addManuelFilmInformation()
		
		Film Bilgilerini Manuel Olarak Veritabanına Ekler 
	
	*/
	function addManuelFilmInformation() {
		
		var xmlHttp = getXmlHttpObject();

		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 
		
		var film_ismi = escape(document.getElementById("film_ismi").value);
		var imdb_adresi = escape(document.getElementById("imdb_adresi").value);
		var cikis_tarihi = escape(document.getElementById("cikis_tarihi").value);
		var kim_ekledi = escape(document.getElementById("kim_ekledi").value);
		var kayit_turu = escape(document.getElementById("kayit_turu").value);
		
		var url="add_manuel_film_information.asp";
		url+="?film_ismi="+film_ismi;
		url+="&imdb_adresi="+imdb_adresi;
		url+="&cikis_tarihi="+cikis_tarihi;
		url+="&kim_ekledi="+kim_ekledi;		
		url+="&kayit_turu="+kayit_turu;		

		xmlHttp.onreadystatechange=function() {
			if (xmlHttp.readyState==1) {
				document.getElementById("search-result").innerHTML="<img src='assets/images/loader.gif' />";
			}
			
			if (xmlHttp.readyState==4)
			{ 
				document.getElementById("search-result").innerHTML=xmlHttp.responseText;		
				document.getElementById("film_ismi").value = "";
				document.getElementById("imdb_adresi").value = "";
				document.getElementById("cikis_tarihi").value = "";
				document.getElementById("kim_ekledi").value = "";
				document.getElementById("kayit_turu").value = "";
				document.getElementById("operation-status").innerHTML = "Film başarı ile eklendi...";
				listFilm("");
			}
		
		};
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
		
	}

	/* 
		deleteFilm()
		
		Filmi Siler 
	
	*/
	
	function deleteFilm(film_id) {

		var xmlHttp = getXmlHttpObject();

		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 

		var sil = confirm("Silmek istediğine eminmisin?");
		var film_id = film_id;

		if (sil) {
			var url="delete_film.asp";
			url=url+"?film_id="+film_id;
			xmlHttp.onreadystatechange=function() {

				if (xmlHttp.readyState==1) {
					document.getElementById("search-result").innerHTML="<img src='assets/images/loader.gif' />";
				}
	
				if (xmlHttp.readyState==4)
				{ 
					document.getElementById("search-result").innerHTML=xmlHttp.responseText;
					document.getElementById("operation-status").innerHTML = "Film başarı ile silindi...";						
					listFilm("");
				}

			}
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
	}
	
	/* 
		getFilmInformationFromDbForManuelUpdate()
		
		Veritabanından film bilgilerini çeker ve güncellenebilecek alanlar olarak ekranda gösterir 
		
	*/
	
	function getFilmInformationFromDbForManuelUpdate(film_id) {

		var xmlHttp = getXmlHttpObject();

		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 

		location.href = "#top";
		document.getElementById("film-update").style.display = "block";
		var film_id = film_id;
		var url="get_film_information_from_db_for_update.asp";
		url+="?film_id="+film_id;
		xmlHttp.onreadystatechange=function() 
		{
			if (xmlHttp.readyState==1) {
				document.getElementById("film-update").innerHTML="<img src='assets/images/loader.gif' />";
			}
			
			if (xmlHttp.readyState==4)
			{ 
				document.getElementById("film-update").innerHTML=xmlHttp.responseText;
			}			
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
	}	

	/* 

		filmInformationManuelUpdate()
		
		Manuel olarak girilen film bilgilerini günceller 
	
	*/
	function filmInformationManuelUpdate() {

		var xmlHttp = getXmlHttpObject();

		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 
		
		var film_id = escape(document.getElementById("g_film_id").value);
		var film_ismi = escape(document.getElementById("g_film_ismi").value);
		var imdb_adresi = escape(document.getElementById("g_imdb_adresi").value);
		var cikis_tarihi = escape(document.getElementById("g_cikis_tarihi").value);
		var kim_ekledi = escape(document.getElementById("g_kim_ekledi").value);
		var kayit_turu = escape(document.getElementById("g_kayit_turu").value);

		var url="film_information_manuel_update.asp";
		url+="?film_id="+film_id;			
		url+="&film_ismi="+film_ismi;
		url+="&imdb_adresi="+imdb_adresi;
		url+="&cikis_tarihi="+cikis_tarihi;
		url+="&kim_ekledi="+kim_ekledi;		
		url+="&kayit_turu="+kayit_turu;
		
		xmlHttp.onreadystatechange=function() 
		{
			if (xmlHttp.readyState==1) {
				document.getElementById("film-update").innerHTML="<img src='assets/images/loader.gif' />";
			}
			
			if (xmlHttp.readyState==4)
			{ 
				//setTimeout("listFilm('')",1000);
				document.getElementById("film-update").style.display = "none";
				document.getElementById("operation-status").innerHTML = "Film başarı ile güncellendi...";
				listFilm('');
			}			
		}

		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
		
	}

	/* 
		openAddImdbLinkWindow()
		
		Film Bilgilerini Imdb üzerinden almak için gerekli olan url yi girilecek pencereyi açar

	*/

	function openAddImdbLinkWindow() 
	{	
		operationWindow = document.getElementById("operations-window");

		if(operationWindow.style.display=="none") 
		{
			operationWindow.style.display="block";
		}

		strHtml = "<div id=\"add-imdb-link-window\">";
		strHtml +="<label>Imdb Adresi <input class=\"textField\" id=\"i_imdb_adresi\" type=\"text\"/></label> <input onclick=\"getFilmInformationFromImdbForManuelUpdate()\" id=\"imdb_adresi\" type=\"button\" value=\"Filmin Imdb Bilgileri Al\" class=\"submit\"/>";
		strHtml +="<p>Imdb'e adresini doğru girerseniz filmi eklemek için gerekli bilgiler imdb.com adresinden alınacaktır.</p>";
		strHtml +="<div id=\"add-imdb-link-window-inner\">";
		strHtml +="</div>";
		strHtml +="</div>";
		operationWindow.innerHTML = strHtml;		
	}

	/* 
	
		updateFilmInformationFromImdb()
		
		Film bilgilerini imdb sitesi üzerindeki sayfası üzerinden string parse
		yöntemini kullanarak günceller 
	
	*/

	function updateFilmInformationFromImdb(film_id,imdb_address) {

		var xmlHttp = getXmlHttpObject();

		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		}
		
		xmlHttp.onreadystatechange=function(){

			if (xmlHttp.readyState==1) {
				document.getElementById("search-result").innerHTML="<img src='assets/images/loader.gif' />";
			}
		
			if (xmlHttp.readyState==4)
			{ 
				listFilm("");
				document.getElementById("operation-status").innerHTML ="Film son bilgileri IMDB sitesi üzerinden başarı ile güncellendi.";
			}
		
		};
		
		url = "update_film_information_from_imdb.asp";
		url += "?film_id="+film_id;
		url += "&imdb_address="+imdb_address;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
	}

	/* 
	
		getFilmInformationFromImdbForManuelUpdate()
		
		Film bilgilerini imdb sitesi üzerindeki sayfası üzerinden string parse
		yöntemini kullanarak alır ve bir pencere içinde gösterir
	
	*/

		function getFilmInformationFromImdbForManuelUpdate() {

		var xmlHttp = getXmlHttpObject();

		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		}
		
		imdb_address = document.getElementById("i_imdb_adresi").value;
		
		if(imdb_address=="" || imdb_address==null) {
			document.getElementById("operation-status").innerHTML ="Bu alanı boş geçemezsiniz.";
			return;
		}
		
		if(imdb_address.indexOf("http://www.imdb.com/")== -1) 
		{
			document.getElementById("operation-status").innerHTML ="Imdb adresini doğru girdiğinizden emin olun.";
			return;
		}	

		url = "get_film_information_from_imdb_for_update.asp";
		url += "?imdb_address="+imdb_address;

		xmlHttp.onreadystatechange=function(){

			if (xmlHttp.readyState==1) {
				document.getElementById("search-result").innerHTML="<img src='assets/images/loader.gif' />";
			}
		
			if (xmlHttp.readyState==4)
			{ 
				document.getElementById("search-result").innerHTML = xmlHttp.responseText;
			}
		
		}
		
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
	}

	/* 
	
		addImdbFilmInformation()
		
		Imdb üzerinden string parse yöntemi ile alınan bilgileri veritabanına ekler.	
	*/

	function addImdbFilmInformation() {

		var xmlHttp = getXmlHttpObject();

		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 
		
		var film_src = escape(document.getElementById("i_film_poster").src);
		var film_ismi = escape(document.getElementById("i_film_ismi").value);
		var imdb_adresi = escape(document.getElementById("i_imdb_adresi").value);		
		var cikis_tarihi = escape(document.getElementById("i_cikis_tarihi").value);
		var kayit_turu = escape(document.getElementById("i_kayit_turu").value);
		var imdb_rating = escape(document.getElementById("i_imdb_rating").value);
		var film_turu = escape(document.getElementById("i_film_turu").value);
		var yonetmen = escape(document.getElementById("i_yonetmen").value);

		var url="add_imdb_film_information.asp";
		url+="?film_src="+film_src;
		url+="&film_ismi="+film_ismi;
		url+="&imdb_adresi="+imdb_adresi;
		url+="&cikis_tarihi="+cikis_tarihi;
		url+="&kayit_turu="+kayit_turu;		
		url+="&imdb_rating="+imdb_rating;		
		url+="&film_turu="+film_turu;		
		url+="&yonetmen="+yonetmen;		

		xmlHttp.onreadystatechange=function(){

			if (xmlHttp.readyState==1) {
				document.getElementById("search-result").innerHTML="<img src='assets/images/loader.gif' />";
			}
		
			if (xmlHttp.readyState==4)
			{ 
				document.getElementById("operation-status").innerHTML = "Film başarı ile eklendi...";
				document.getElementById("add-imdb-link-window").style.display = "none";
				listFilm("");
			}
		
		}

		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
		
	}

	function loginSite() {

		var username=document.getElementById("username").value;
		var password=document.getElementById("password").value;
		var memberArea=document.getElementById("member-area");

		/* Kullanıcı Adı ve Şifre Alanlarının boş olup olmadıkları kontrol ediliyor */

		if (username == "" || username == "Kullanıcı Adı" || password == "" || password == "Şifre") 
		{
			/* Kullanıcı Adı ve Şifre Alanı kontrol edildi ve hata bulunduysa
			ikinci defa giriş yapıldığında hata mesajı verildiyse tekrar
			kontrole sokma */

			if(document.getElementById("login-error") == null)
			{
				loginError = document.createElement("div");
				loginError.setAttribute("class","error");
				loginError.setAttribute("id","login-error");
				loginError.innerHTML = "Kullanıcı adı veya şifre bölümünü boş geçemezseniz!";
				memberArea.appendChild(loginError);
				return;
			}
		}

		else 
		{
			/* Daha önce üye giriş yapmaya çalışmış ve başarısız olmuş ve hata mesajı alanı ile karşılaşmışsa
			hata ekranını kaldır */

			if(document.getElementById("login-error") != null)
			{
				memberArea.removeChild(loginError);
			}

			var xmlHttp = getXmlHttpObject();
		
			if (xmlHttp==null)
			{
				alert ("Your browser does not support AJAX!");
				return;
			} 
		
			var url ="login.asp";
			url +="?username="+username;
			url +="&password="+password;

			xmlHttp.onreadystatechange = function() {
	
				if (xmlHttp.readyState==1) {
					document.getElementById("member-area").innerHTML="<img src='assets/images/loader.gif' />";
				}
			
				if (xmlHttp.readyState==4)
				{ 
					document.getElementById("member-area").innerHTML= xmlHttp.responseText;
					listFilm('');
					isLogin();
				}
	
			}
			xmlHttp.open("GET",url,true);		
			xmlHttp.send(null)
		}
	
	}
	
	/*
	
	isLogin()
	
	Üye girişi başarılı olmuşmu olmamışmı kontrol eder eğer başarıysa navigasyon bölümünü aktif hale getirir. 
	
	*/
	
	function isLogin() {
		var xmlHttp = getXmlHttpObject();
		
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 
		
		url = "inc/header.asp"
	
		xmlHttp.onreadystatechange = function() {

			if (xmlHttp.readyState==1) {
				document.getElementById("header").innerHTML="<img src='assets/images/loader.gif' />";
			}
		
			if (xmlHttp.readyState==4)
			{ 
				document.getElementById("header").innerHTML= xmlHttp.responseText;
			}

		}

		xmlHttp.open("GET",url,true);	
		xmlHttp.send(null)



	}
	
	function logout() {

		var xmlHttp = getXmlHttpObject();
		
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 
	
		var url ="logout.asp";
	
		xmlHttp.onreadystatechange = function() {

			if (xmlHttp.readyState==1) {
				document.getElementById("member-area").innerHTML="<img src='assets/images/loader.gif' />";
			}
		
			if (xmlHttp.readyState==4)
			{ 
				listFilm('');
				isLogin()
			}

		}

		xmlHttp.open("GET",url,true);	
		xmlHttp.send(null)

		}
	


/*	function ImdbBilgileriniAl2() {
		document.getElementById("imdb").style.display ="none";

		xmlHttp = getXmlHttpObject();
		if (xmlHttp==null)
		{
		alert ("Your browser does not support AJAX!");
		return;
		}
		
		xmlHttp.onreadystatechange=function(){

			if (xmlHttp.readyState==1) {
				document.getElementById("search-result").innerHTML="<img src='assets/images/loader.gif' />";
			}
		
			if (xmlHttp.readyState==4)
			{ 
				document.getElementById("search-result").innerHTML = xmlHttp.responseText;
			}
		
		};
		
		imdb_address = document.getElementById("filmin_imdb_adresi").value;
		
		if(imdb_address=="" || imdb_address==null) {
			document.getElementById("operation-status").innerHTML ="Bu alanı boş geçemezsiniz.";
			return;
		}
		
		if(imdb_address.indexOf("http://www.imdb.com/")== -1) 
		{
			document.getElementById("operation-status").innerHTML ="Imdb adresini doğru girdiğinizden emin olun.";
			return;
		}	

		url = "imdb_bilgilerini_al.asp";
		url += "?imdb_address="+imdb_address;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
	}

	function ImdbIcindeFilmiAra() {

		xmlHttp = getXmlHttpObject();
		if (xmlHttp==null)
		{
		alert ("Your browser does not support AJAX!");
		return;
		}
		
		xmlHttp.onreadystatechange=function(){

			if (xmlHttp.readyState==1) {
				document.getElementById("search-result").innerHTML="<img src='assets/images/loader.gif' />";
			}
		
			if (xmlHttp.readyState==4)
			{ 
				document.getElementById("imdb").innerHTML = xmlHttp.responseText;
			}
		
		};
		
		imdb_search_word = document.getElementById("imdb_search_word").value;

		if(imdb_search_word=="" || imdb_search_word==null) {
			document.getElementById("imdb").innerHTML ="Bu alanı boş geçemezsiniz.";
			return;
		}
		
		url = "imdb_icinde_ara.asp";
		url += "?imdb_search_word="+imdb_search_word;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
	}
*/
