// JavaScript Document
var bulundum="";
var disdata;
var mydizi = new Array();
function importXML(burada)
{
	bulundum=burada;
	
	if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.onload = menucreateRootTable;
	}
	else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.onreadystatechange = function () {if (xmlDoc.readyState == 4) menucreateRootTable()};
 	}
	else
	{
		alert('Kullandığınız İnternet Gezgini Bu Siteyi Desteklemiyor.');
		return;
	}
	xmlDoc.load("/menu.xml");
}

//
function menucreateRootTable()
{	
	menudiziyap();
	var x = xmlDoc.getElementsByTagName('MENU');
	var newEl = document.createElement('<TABLE border=0 cellspacing=0 cellpadding=0></TABLE>');
	newEl.tabload="";
	newEl.setAttribute("width","175");
	var tmp = document.createElement('<TBODY border=0></TBODY>');
	newEl.appendChild(tmp);

	for (i=0;i<x[0].childNodes.length;i++)
	{
		var row = document.createElement('<TR></TR>');
		//row.style.background = "url(/images/bg_nav.gif)";
		//row.style.background = "url(/images/bg_nav.gif)";
		//var container = document.createElement('<TD>');
		//if(x[0].childNodes[i].childNodes[0]!=null){
		//	container.innerHTML='<img src="/images/nav/icon_nav.gif" width="7" height="7" />';		
		//}
		//container.setAttribute("align","center");
		//container.setAttribute("width","15");
		//row.appendChild(container);
		var container = document.createElement('<TD></TD>');		
		var theData = document.createTextNode(x[0].childNodes[i].getAttribute("TEXT"));
		container.appendChild(theData);
		if(x[0].childNodes[i].getAttribute("TEXT")==mydizi[0]){
			container.style.color="#936cb0";
		}
		container.className="nav2";
		container.style.height="20px";
		container.style.cursor="pointer";
		container.i=i
		container.onmouseover = function(){
			this.renk=this.style.color;
			this.style.color="#936cb0";
		}
		container.onmouseout = function(){
			this.style.color=this.renk;
		}
		
		container.onclick = function(){
			if(this.parentNode.parentNode.parentNode.tabload!="" && this.parentNode.parentNode.parentNode.tabload!=null){
				gelen = this.parentNode.parentNode.parentNode.tabload;
				gelenx=gelen.replace("table","");
				document.getElementById(gelenx).removeChild(document.getElementById(gelen));	
			}
			
			if(x[0].childNodes[this.i].childNodes[0]!=null){
				//this.parentNode.parentNode.appendChild(row);
				if(this.parentNode.parentNode.parentNode.tabload!="table"+"menu"+this.i){
					this.parentNode.parentNode.parentNode.tabload="table"+"menu"+this.i;
					menucreateTable(x[0].childNodes[this.i],"menu"+this.i,"160");
				}else
					this.parentNode.parentNode.parentNode.tabload="";
			}
			if(x[0].childNodes[this.i].getAttribute("LINK")!="#"){
				location.href=x[0].childNodes[this.i].getAttribute("LINK");
			}
		}
		row.appendChild(container);
		tmp.appendChild(row);	

		if(x[0].childNodes[i].childNodes[0]!=null){
			var row = document.createElement('<TR></TR>');
			//var container = document.createElement('<TD bgcolor="#F5F5F5"></TD>');
			//row.appendChild(container);
			var container = document.createElement('<TD  bgcolor="#F5F5F5"></TD>');
			container.i=i
			container.id="menu"+i
			if(menuyerbul(x[0].childNodes[i].getAttribute("TEXT"))){
				disdata=i;
				//disdata.push(x[0].childNodes[i]);
			}
			tmp.appendChild(row);
			row.appendChild(container);			
			tmp.appendChild(row);
			
		}
		var row = document.createElement('<TR></TR>');
		var container = document.createElement('<TD align="center" colspan="2" height="1" bgcolor="#e0d7c2">&nbsp;</TD>');	
		container.i=i
		row.appendChild(container);
		tmp.appendChild(row);
		
	}
	
	document.getElementById('mymenu').appendChild(newEl);
	
	if(disdata!=null){
		//alert(document.getElementById("menu"+disdata));
		tmp.parentNode.tabload="table"+"menu"+disdata;			
		menucreateTable(x[0].childNodes[disdata],"menu"+disdata,"160");
	}
	
	//document.getElementById('mymenuz').value = document.getElementById('mymenu').innerHTML
}
//
function menucreateTable(x,mytd,genis)
{//burada kaldım......................
	disdata=null;
	var newEl = document.createElement('<TABLE border=0 cellspacing=0 cellpadding=0></TABLE>');
	newEl.id="table"+mytd;
	newEl.setAttribute("width",genis);
	var tmp = document.createElement('<TBODY border=0></TBODY>');
	newEl.appendChild(tmp);
	
	for (i=0;i<x.childNodes.length;i++)
	{
		var row = document.createElement('<TR></TR>');
		var container = document.createElement('<TD align="center" width="15">');
		if(x.childNodes[i].childNodes[0]!=null){
			container.innerHTML='<img src="/images/nav/icon_nav3.gif" width="7" height="7" />';	
		}	
		else{
			container.innerHTML='<img src="/images/nav/icon_nav4.gif" width="3" height="5" />';	
		}
		 
		row.appendChild(container);
		var container = document.createElement('<TD></TD>');		
		var theData = document.createTextNode(x.childNodes[i].getAttribute("TEXT"));
		if(x.childNodes[i].getAttribute("TEXT")==mydizi[0]){
			container.style.color="#936cb0";
		}
		container.appendChild(theData);
		container.i=i
		container.style.height="19px";
		container.className="nav2";
		container.style.padding="0";
		container.style.cursor="pointer";
		container.onmouseover = function(){
			this.renk=this.style.color;
			this.style.color="#936cb0";
		}
		container.onmouseout = function(){
			this.style.color=this.renk;
		}
		
		container.onclick = function(){
			//alert(this.parentNode.parentNode.parentNode.parentNode.i)
			if(this.parentNode.parentNode.parentNode.tabload!="" && this.parentNode.parentNode.parentNode.tabload!=null){
				gelen = this.parentNode.parentNode.parentNode.tabload;
				gelenx=gelen.replace("table","");
				document.getElementById(gelenx).removeChild(document.getElementById(gelen));	
			}
			
			if(x.childNodes[this.i].childNodes[0]!=null){
				//this.parentNode.parentNode.appendChild(row);
				if(this.parentNode.parentNode.parentNode.tabload!="table"+mytd+"menu"+this.i){
					this.parentNode.parentNode.parentNode.tabload="table"+mytd+"menu"+this.i;
					menucreateTable(x.childNodes[this.i],mytd+"menu"+this.i,"135");
				}else
					this.parentNode.parentNode.parentNode.tabload="";			
			}
			if(x.childNodes[this.i].getAttribute("LINK")!="#"){
				if(x.childNodes[this.i].getAttribute("TARGET")!="")
					newpage(x.childNodes[this.i].getAttribute("LINK"));
				else
					location.href=x.childNodes[this.i].getAttribute("LINK")+((x.childNodes[this.i].getAttribute("LINK")=="under.aspx")?"?id="+x.childNodes[this.i].getAttribute("TEXT"):"");
			}
		}
		row.appendChild(container);
		tmp.appendChild(row);		
		
		if(x.childNodes[i].childNodes[0]!=null){
			var row = document.createElement('<TR></TR>');
			var container = document.createElement('<TD bgcolor="#F5F5F5"></TD>');
			row.appendChild(container);
			var container = document.createElement('<TD bgcolor="#F5F5F5"></TD>');
			container.i=i
			container.id=mytd+"menu"+i
			row.appendChild(container);
			tmp.appendChild(row);
			if(menuyerbul(x.childNodes[i].getAttribute("TEXT"))){
				disdata=i;
			}
			
		}else{		
			var row = document.createElement('<TR></TR>');
			var container = document.createElement('<TD colspan="2" height="1">&nbsp;</TD>');
			container.i=i
			row.style.background = "url(/images/bg_cizgi_yatay.gif)";
			row.appendChild(container);
			tmp.appendChild(row);
		}
	}
	
	var row = document.createElement('<TR></TR>');
	var container = document.createElement('<TD colspan="2" height="10">&nbsp;</TD>');
	row.appendChild(container);
	tmp.appendChild(row);
	
	document.getElementById(mytd).appendChild(newEl);
	
	if(disdata!=null){
		tmp.parentNode.tabload="table"+mytd+"menu"+disdata;	
		menucreateTable(x.childNodes[disdata],mytd+"menu"+disdata,"135");
	}
	
}
//

function yerbul(gelen){
	if(gelen!=""){
		var x = xmlDoc.getElementsByTagName('DATA');
		//alert(document.getElementById('durumbildir'));
		for (i=0;i<x.length;i++)
		{		
			if(x[i].getAttribute("TEXT")==gelen){
				myxml=x[i];
				var sayfaadi=myxml.getAttribute("TEXT");
				if(myxml.parentNode.getAttribute("TEXT")!=null){
					sayfaadi=myxml.parentNode.getAttribute("TEXT")+" / "+sayfaadi;
					if(myxml.parentNode.parentNode.getAttribute("TEXT")!=null){
						sayfaadi=myxml.parentNode.parentNode.getAttribute("TEXT")+" / "+sayfaadi;
					}
				}					
				document.getElementById('durumbildir').innerText=sayfaadi+ " - " +myxml.getAttribute("DATE");				
			}			
		}	
	}	
}


function menudiziyap(){
	var x = xmlDoc.getElementsByTagName('DATA');
	var mygelen = document.getElementById("thispage").innerHTML;
	var sayfaadi = "";	
	for (i=0;i<x.length;i++)
	{
		if(x[i].getAttribute("LINK").toLowerCase()==mygelen){
			var myxml=x[i];
			mydizi.push(myxml.getAttribute("TEXT"));
			if(myxml.parentNode.getAttribute("TEXT")!=null){
				mydizi.push(myxml.parentNode.getAttribute("TEXT"))
				if(myxml.parentNode.parentNode.getAttribute("TEXT")!=null){
					mydizi.push(myxml.parentNode.parentNode.getAttribute("TEXT"))
				}
			}			
		}		
	}
}

function menuyerbul(gelen){
	for (var i = 0; i < mydizi.length; i++) {		
		if(gelen==mydizi[i]){
			//alert(gelen);
			return true;
		}		
	}
	return false;		
}

function newpage(x){
	sayfa = window.open(x);
	sayfa.focus();
}