// JavaScript Document
function makeObj() {
    var obj;
    var brw_type = navigator.appName;
    if(brw_type == "Microsoft Internet Explorer"){
        obj = new ActiveXObject("Microsoft.XMLHTTP");
		//obj.overrideMimeType('text/xml; charset=iso-8859-9');
    }else{
        obj = new XMLHttpRequest();
		//obj.overrideMimeType('text/xml; charset=iso-8859-9');
    }
    return obj;
}

var http = makeObj();
var place;
var form;

function sendForm(spanid,formid,URL)
{
	form = document.getElementById(formid);
	place = document.getElementById(spanid);
	//document.getElementById("Loading").style.display = "";
	place.innerHTML = "<table width=100% border=0 cellpadding=0 cellspacing=0 class=ctext><tr><td><div align=center><img src=images/spinner.gif width=32 height=32 /><br />Yükleniyor</div></td></tr></table>"
	var postRequest = new String("");

	var n,v;
	
	for(var i=0;i<form.elements.length;i++)
	{
		n = form.elements[i].name;
		v = form.elements[i].value;
		postRequest += escape(n) + '=' + escape(v) + '&';
	}

	http.open("POST",URL,true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=iso-8859-9");
	http.send(postRequest);
	http.onreadystatechange = contentResponse;
	
	return false;
}

function contentCall(spanid,URL) {
	//document.getElementById("Loading").style.display = "";
	place = document.getElementById(spanid);
	place.innerHTML = "<table width=100% border=0 cellpadding=0 cellspacing=0 class=ctext><tr><td><div align=center><img src=images/spinner.gif width=32 height=32 /><br />Yükleniyor</div></td></tr></table>"
    http.open("GET", URL);
    http.onreadystatechange = contentResponse;
    http.send(null);
}

function contentResponse() {
    if(http.readyState == 4){
		//document.getElementById("Loading").style.display = "none";
        place.innerHTML = http.responseText;
		//alert(http.responseText);
		
		var scripts = place.getElementsByTagName('script'); 
        for (var xx =0; xx < scripts.length; xx++) { 
			var cCode = scripts[xx].text;
			
			if (window.execScript) //IE için
				window.execScript(cCode);
				//alert(scripts[xx].text);
			else
				eval.call(window, cCode);//diğerleri için 
		
        }
    }
}

function getField(table,column,id) {
	place = document.getElementById(column+id);
	place.innerHTML = "Loading..."
    http.open('get', '_FieldData.asp?prc=1&table=' + table + '&column=' + column + '&id=' + id);
    http.onreadystatechange = contentResponse;
    http.send(null);
}

function updateField(table,column,id,data) {
	place = document.getElementById(column+id);
	place.innerHTML = "Loading..."
    http.open('get', '_FieldData.asp?prc=2&table=' + table + '&column=' + column + '&id=' + id + '&data=' + data);
    http.onreadystatechange = contentResponse;
    http.send(null);
}

function getArea(table,column,id) {
	place = document.getElementById(column+id);
	place.innerHTML = "Loading..."
    http.open('get', '_AreaData.asp?prc=1&table=' + table + '&column=' + column + '&id=' + id);
    http.onreadystatechange = contentResponse;
    http.send(null);
}

function updateArea(table,column,id,data) {
	place = document.getElementById(column+id);
	place.innerHTML = "Loading..."
    http.open('get', '_AreaData.asp?prc=2&table=' + table + '&column=' + column + '&id=' + id + '&data=' + data);
    http.onreadystatechange = contentResponse;
    http.send(null);
}

function getList(table,column,id,list_t,list_c) {
	place = document.getElementById(column+id);
	place.innerHTML = "Loading..."
    http.open('get', '_ListData.asp?prc=1&table=' + table + '&column=' + column + '&id=' + id + '&list_t=' + list_t + '&list_c=' + list_c);
    http.onreadystatechange = contentResponse;
    http.send(null);
}

function updateList(table,column,id,list_t,list_c,data) {
	place = document.getElementById(column+id);
	place.innerHTML = "Loading..."
    http.open('get', '_ListData.asp?prc=2&table=' + table + '&column=' + column + '&id=' + id + '&list_t=' + list_t + '&list_c=' + list_c + '&data=' + data);
    http.onreadystatechange = contentResponse;
    http.send(null);
}

function get_Date(table,column,id) {
	place = document.getElementById(column+id);
	place.innerHTML = "Loading..."
    http.open('get', '_DateData.asp?prc=1&table=' + table + '&column=' + column + '&id=' + id);
    http.onreadystatechange = contentResponse;
    http.send(null);
}

function update_Date(table,column,id,data) {
	place = document.getElementById(column+id);
	place.innerHTML = "Loading..."
    http.open('get', '_DateData.asp?prc=2&table=' + table + '&column=' + column + '&id=' + id + '&data=' + data);
    http.onreadystatechange = contentResponse;
    http.send(null);
}

function startUpload(){
      //document.getElementById("Loading").style.display = "";
      return true;
}

function stopUpload(success){
      if(success=="OK"){
	  	document.getElementById("newrecord").reset();
	  }
      //document.getElementById("Loading").style.display = "none";  
      return true;   
}

function Goster(tr_id) {
	document.getElementById(tr_id).style.display = "";
	arti="arti"+tr_id;
	eksi="eksi"+tr_id;
	document.getElementById(arti).style.display = "none";
	document.getElementById(eksi).style.display = "";
}
function Sakla(tr_id) {
	document.getElementById(tr_id).style.display = "none";
	arti="arti"+tr_id;
	eksi="eksi"+tr_id;
	document.getElementById(arti).style.display = "";
	document.getElementById(eksi).style.display = "none";
}

function ShowHide(elm_id) {
	var strDurum = document.getElementById(elm_id).style.display;
	
	if(strDurum=="none"){
		document.getElementById(elm_id).style.display = "";
		plus="plus_"+elm_id;
		minus="minus_"+elm_id;
		document.getElementById(plus).style.display = "none";
		document.getElementById(minus).style.display = "";
	}
	
	if(strDurum==""){
		document.getElementById(elm_id).style.display = "none";
		plus="plus_"+elm_id;
		minus="minus_"+elm_id;
		document.getElementById(plus).style.display = "";
		document.getElementById(minus).style.display = "none";
	}
}

function pollCheck() {
	var strAns = 0;
	for (var i=0; i < document.poll.poll_answer.length; i++)
	   {
	   if (document.poll.poll_answer[i].checked)
		  {
		  strAns = document.poll.poll_answer[i].value;
		  }
	   }

	if (strAns==0)  {
		alert("Lütfen bir alan seçin...");
		return false;
	} else {
		strChecked = "modules/poll.asp?res=1&ans=" + strAns ;
		contentCall('gmo_poll',strChecked);
		return false;
	}
}
