var XmlHttp;
var httpObject;
var objNode;

function homeExchange(){				
	this.loadFile;
	this.sendmethod="GET";
	this.cacheClear;
	this.loaderDiv;
	this.ContentArea;
	this.fillType;
	this.tur
	//this.root="http://tekstilbank.magiclick.net/portal";
	this.root="http://10.0.2.185/portal";
	//this.root="http://212.109.224.140/portal";
	//this.root="http://localhost/tekstilmenu";
	HE=this;
	//this.myOrientArr = myOrientArr;
}
	

/*** XML TANIMLA ***/
homeExchange.prototype.exchangeBuild = function(){
	
	document.getElementById(this.loaderDiv).style.display="block";
	document.getElementById(this.ContentArea).style.display="none";

	this.CreateXmlHttp();
	if(XmlHttp){
		XmlHttp.onreadystatechange = HE.HandleResponse;
		var clearCache="";					
		if (HE.cacheClear){clearCache="?" + Math.random()* 1000;}
		XmlHttp.open(HE.sendmethod, HE.loadFile + clearCache,  true);
		XmlHttp.send(null);		
	}
			
}
			
homeExchange.prototype.CreateXmlHttp = function(){
	try{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e){
		try{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc){
			XmlHttp = null;
		}
	}
	if(!XmlHttp && typeof XMLHttpRequest != "undefined"){
		XmlHttp = new XMLHttpRequest();
	}
}

homeExchange.prototype.HandleResponse = function(){				
	if(XmlHttp.readyState == 4){
		if(XmlHttp.status == 200 || XmlHttp.status == 304){
			objNode = XmlHttp.responseXML.documentElement;
			document.getElementById(HE.loaderDiv).style.display="none";
			document.getElementById(HE.ContentArea).style.display="";
			if (HE.tur=="currency"){
				HE.dataGosterCurrency();
			}
			else{
				HE.dataGosterImkb();
			}	
		}
		else{
			alert("Hata oluştu.Lütfen yeniden deneyiniz." );
		}
	}
}


/*** CURRENCY XML INNERHTML ***/

homeExchange.prototype.dataGosterCurrency = function  () {
	XMLExchangeCurrency = objNode.getElementsByTagName("exchange");
	var XMLCurrencyDate = XMLExchangeCurrency[0].getAttribute("currencydate");
	var XMLCurrencyDttm = XMLExchangeCurrency[0].getAttribute("dttm");
	
	var XMLCurrency = objNode.getElementsByTagName("currency");
	var XMLCurrencyCode="";
	var XMLCurrencyBuy="";
	var XMLCurrencySell="";
	
	var strText='<table cellpadding="0" cellspacing="0" border="0" class="currency">';
		strText = strText+'<tr><td colspan="3" class="dttm" valign="top" align="right">';
		strText = strText+'<img src="/portal/_i/clock.gif" border="0" class="clock" align="absmiddle">';
		strText = strText+XMLCurrencyDttm+'</td></tr>';
		strText = strText+'<tr><td class="topHeadNoUnder" valign="top" align="right">&nbsp;</td>';
		strText = strText+'<td class="topHead" valign="top" align="right">'+"Alış"+'</td>';
		strText = strText+'<td class="topHead" valign="top" align="right">'+"Satış"+'</td></tr>';
		
	for(i=0; i<XMLCurrency.length; i++){
		
		XMLCurrencyCode = XMLCurrency[i].getAttribute("code");
		XMLCurrencyBuy = XMLCurrency[i].getAttribute("buy");
		XMLCurrencySell = XMLCurrency[i].getAttribute("sell");
		
		if(i%2==0){
			strText = strText+'<tr><td  class="satirRenk" colspan="3" align="right">';
		}else{
			strText = strText+'<tr><td colspan="3" align="right">';
		}
			strText = strText+'<table cellpadding="0" cellspacing="0" border="0" class="detay">';
			strText = strText+'<tr><td class="leftHead">'+XMLCurrencyCode+'</td>';
			strText = strText+'<td>'+XMLCurrencyBuy+'</td>';
			strText = strText+'<td>'+XMLCurrencySell+'</td>';
			strText = strText+'</tr>';
			strText = strText+'</table></td></tr>';
		
	}
	
	strText =strText+'</table>';
	document.getElementById("piyasaBilgiArea").innerHTML = strText;	
}



/*** IMKB XML INNERHTML ***/
homeExchange.prototype.dataGosterImkb = function  () {
	XMLExchangeImkb = objNode.getElementsByTagName("imkb");
	var XMLDttm = XMLExchangeImkb[0].getAttribute("dttm");
	
	var XMLStock = objNode.getElementsByTagName("stock");
	var XMLImkbCode="";
	var XMLImkbCloseprice="";
	var XMLImkbChange="";
	
	var strText='<table cellpadding="0" cellspacing="0" border="0" id="imkb">';
		strText = strText+'<tr><td class="topEndeks" valign="top">'+"Endeks"+'</td>';
		strText = strText+'<td class="topDeger_Degisim" valign="top" align="right">'+"Son Değer"+'</td>';
		strText = strText+'<td class="topDeger_Degisim" valign="top" align="right">'+"Değişim(%)"+'</td></tr>';
		
	for(i=0; i<XMLStock.length; i++){
		
		XMLImkbCode = XMLStock[i].getAttribute("code");
		XMLImkbCloseprice = XMLStock[i].getAttribute("closeprice");
		XMLImkbChange = XMLStock[i].getAttribute("change");
		
		if(i%2==0){
			strText = strText+'<tr><td  class="satirRenk" colspan="3" >';
		}else{
			strText = strText+'<tr><td colspan="3">';
		}
			strText = strText+'<table cellpadding="0" cellspacing="0" border="0" class="detay">';
			strText = strText+'<tr><td class="leftHead" >'+XMLImkbCode+'</td>';
			strText = strText+'<td class="imkbCont" align="right">'+XMLImkbCloseprice+'</td>';
			strText = strText+'<td class="imkbCont" align="right">'+XMLImkbChange+'</td>';
			strText = strText+'</tr>';
			strText = strText+'</table></td></tr>';
		
	}
	
	strText =strText+'</table>';
	document.getElementById("piyasaBilgiArea").innerHTML = strText;	
}



