﻿// JavaScript Document
window.ajx = (window.ActiveXObject) ? function(){return new ActiveXObject("Microsoft.XMLHTTP");}:function(){return new XMLHttpRequest();};
window.domParser = (window.ActiveXObject) ? function(){return new ActiveXObject;}:function(){return document.implementation.createDocument("","",null);}
document.write('<link href="scripts/ajax.css" rel="stylesheet" type="text/css" />');
function l(e,a,t){e.innerHTML=a.responseText;}
function e(e,a,t){e.innerHTML="eror loading:" +a.status;}
function ld(id,title,url,f,nf){	
    var a=ajx();
	var e=document.getElementById(id);
	a.onreadystatechange=function(){
		if(a.readyState==4){
			if(a.status==200){
				e.removeChild(document.getElementById("loading_" + e.id));
				if(typeof f=="function"){f(e,a);}else{l(e,a);}
			}
			else{
				if(typeof nf=="function"){nf(e,a);}else{e.innerHTML="eror loading:" +a.status;}
			}
		}
	}
	a.open("GET",url);
	oLoading = document.createElement("table");
	oLoading.insertRow(0);
	oLoading.rows[0].insertCell(0);
	oLoading.rows[0].cells[0].style.verticalAlign = "middle";
    oLoading.rows[0].cells[0].style.textAlign = "center";
	oLoading.id = "loading_" + e.id;
	oLoading.style.position = "absolute";
	oLoading.style.top = "0px";
	oLoading.style.left = "0px";
	oLoading.style.width = "100%";
	oLoading.style.height = "100%";
	oLoading.style.backgroundColor = "white";
	oLoading.style.opacity = "0.5";
	oLoading.style.filter = "alpha(opacity=50)";
	oImg = document.createElement("img");
	oImg.src="images/ajax-loader.gif";
	oImg.align = "center";
	oLoading.rows[0].cells[0].appendChild(oImg);
	oLoading.rows[0].cells[0].innerHTML += "&nbsp;YÜKLENİYOR...";
	e.appendChild(oLoading);
	a.send(null);
}
function fadein(oElement,x,y,interval){
	var oElement = document.getElementById(oElement);
	oElement.style.filter = "alpha(opacity=" + x +")";
	oElement.style.opacity = (x/100);
	x += 10;
	if (x<y) setTimeout("fadein('glassDiv',"+x+","+y+","+interval+")",interval);
	}
function fadeout(oElement,x,y,interval,rm){
	var oElement = document.getElementById(oElement);
	oElement.style.filter = "alpha(opacity=" + x +")";
	oElement.style.opacity = (x/100);
	x -= 10;
	if (x>y) setTimeout("fadeout('glassDiv',"+x+","+y+","+interval+","+rm+")",interval);
	else if (rm) oElement.parentNode.removeChild(oElement);
	}

function openInnerWindow(w,h,url){
	var oElement = document.createElement("table");
	oElement.insertRow(0);
	oElement.rows[0].insertCell(0);
	oElement.rows[0].cells[0].appendChild(document.createElement("center"));
	document.body.appendChild(oElement);
	oElement.style.height = document.documentElement.scrollHeight + "px";
	oElement.id="glassDiv";
	fadein("glassDiv",30,90,1);
	oElement = document.createElement("table");
	oElement.insertRow(0);
	oElement.rows[0].insertCell(0);
	oElement.rows[0].cells[0].appendChild(document.createElement("center"));
	oElement.id="glassDivBg";
	var oInnerElement = document.createElement("div")
	oInnerElement.id = "innerDiv";
	oInnerElement.innerHTML = "";
	with (oInnerElement.style){
		position = "relative";
		top = document.documentElement.scrollTop + "px";
		//width = "700px";
		//height = "600px";
		}
	var oCenterElement = oElement.rows[0].cells[0].childNodes[0];
	oCenterElement.appendChild(oInnerElement);
	document.body.appendChild(oElement);
	ld("innerDiv",null,url);
	}
function closeInnerWindow(){
	var oElement = document.getElementById("glassDivBg");
	if (oElement) {
		document.body.removeChild(oElement);
	    fadeout("glassDiv",50,0,1,true);
		}
	}
function playNews(i){
	i = (i>4) ? 0 : i;
	var oTable = document.getElementById("list");
	var oLink = oTable.getElementsByTagName("a")[i];
////	if(window.event){
		oLink.fireEvent("onmouseover",event);
////	}
////	else{
//		oLink.onmouseover(oLink.onmouseover);
//	}
	setTimeout("playNews("+(i+1)+")",5000);
}
function loadMainNews(e,a,t){
	var xd = a.responseXML.documentElement;
	if (xd.getElementsByTagName("code")[0].childNodes[0].nodeValue == 0){
		var ohaberList = xd.getElementsByTagName("news");
		var oTable = document.getElementById("list");
		for (var i=0;i<ohaberList.length;i++){
			oLink = document.createElement("a");
			oLink.innerHTML = ohaberList[i].getElementsByTagName("title")[0].childNodes[0].nodeValue;
			oLink.title = ohaberList[i].getElementsByTagName("title")[0].childNodes[0].nodeValue;
			oLink.name = i;
			oLink.id = ohaberList[i].getAttribute("id");
			oLink.onmouseover = function (event){
				var oElement = (window.event) ? window.event.srcElement:event.target;
				var oTable = document.getElementById("preview");
				oTable.rows[0].cells[0].innerHTML = ohaberList[oElement.name].getElementsByTagName("image")[0].childNodes[0].nodeValue;
				oTable.rows[1].cells[0].innerHTML = ohaberList[oElement.name].getElementsByTagName("date")[0].childNodes[0].nodeValue; 	
				oTable.rows[2].cells[0].innerHTML = ohaberList[oElement.name].getElementsByTagName("summary")[0].childNodes[0].nodeValue;
				oTable = oTable.parentNode.parentNode.parentNode.parentNode;
				oH1 = document.createElement("h1");
				oH1.innerHTML = ohaberList[oElement.name].getElementsByTagName("title")[0].childNodes[0].nodeValue;
				oTable.rows[0].cells[0].innerHTML = "";
				oTable.rows[0].cells[0].appendChild(oH1); 
				};
			oLink.onclick = function(event){
				var oElement = (window.event) ? window.event.srcElement:event.target;
				openInnerWindow(null,null,'php_xml/haber.php?haber_id='+oElement.id);
				//alert("clicked");
				};
			oLink.href = "javascript:";
			oTable.rows[0].cells[i].appendChild(oLink);
			}
		oTable = document.getElementById("preview");
		oTable.rows[0].cells[0].innerHTML = ohaberList[0].getElementsByTagName("image")[0].childNodes[0].nodeValue;
		oTable.rows[1].cells[0].innerHTML = ohaberList[0].getElementsByTagName("date")[0].childNodes[0].nodeValue; 	
		oTable.rows[2].cells[0].innerHTML = ohaberList[0].getElementsByTagName("summary")[0].childNodes[0].nodeValue;
		oTable = oTable.parentNode.parentNode.parentNode.parentNode;
		oH1 = document.createElement("h1");
		oH1.innerHTML = ohaberList[0].getElementsByTagName("title")[0].childNodes[0].nodeValue;
		oTable.rows[0].cells[0].appendChild(oH1); 
		playNews(0);
		} 		
	}
function loadLig(e,a,t){
	e.innerHTML = a.responseText;
	}
function doSubmit(oForm){
	if(oForm.elements[1].value="") alert("Lig Seçiniz");
	openInnerWindow(null,null,'php_xml/yapimasamasi.php');
//	if(oForm.elements[1].checked){}
//	else if(oForm.elements[2].checked){openInnerWindow(null,null,'php_xml/topluSonuclar.php?lig_id='+oForm.elements[0].value)}
//	else if(oForm.elements[3].checked){openInnerWindow(null,null,'php_xml/haftalikProgram.php?lig_id='+oForm.elements[0].value)}
//	else if(oForm.elements[4].checked){openInnerWindow(null,null,'php_xml/fikstur.php?lig_id='+oForm.elements[0].value)}
}
