//Popup Function
function openWindow(address,windowName,width,height)
{
	var newWindow = window.open(address,windowName,"scrollbars=1,width="+width+",height="+height+",status=0,location=0,top=100,left=100")
}

//Ajax Functions
var loadingText = "<div style='width:100%' align='center'><img src='images/loading.gif' width='180' /><br/><br/>Yükleniyor...</div>";
function showError(e)
{
	alert(e);
}

function $(id)
{
	return document.getElementById(id)
}

function showDocument(data,targetContainer)
{
	$(targetContainer).innerHTML = data.responseText;
	var scripts = $(targetContainer).getElementsByTagName('SCRIPT'); 
	for (var i = 0; i < scripts.length; i++)
	{
		var s = document.createElement('script');
		s.text = scripts[i].text;
		document.body.appendChild(s);
	}
}

function makeAjax(address,param,method,whichContainer)
{
	$(whichContainer).innerHTML = loadingText;
	var addurl = '';
	if(param)
	{
		addurl = '?' + param;
		p = param;
	}
	var u = address + addurl;
	var m = method;
	var request = getHTTPObject();
	request.open(m,u,true);	
	if(m=='post' || m=='POST')
	{
		request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		request.send(p);
	}
	else
		request.send(null);
	
	request.onreadystatechange = function()
	{
		if(request.readyState==4)
		{
			try {
				if(request.status==200)
					showDocument(request,whichContainer);
				else
					alert('Error Report: abort['+abort+']status[' + request.status + '] readyState['+request.readyState+']')
			} catch(e) {
				alert(e)
			}
		}
	}
}

function getHTTPObject()
{
	var xhr = false;
	if(window.XMLHttpRequest) {
		var xhr = new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		try {
			var xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				var xhr = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				xhr = false;
			}
		}
	}
	return xhr;
}

//Scroller Div
var scrollStep=1,timerTop="",timerBottom="";
function scrollDivTop(id)
{
  clearTimeout(timerBottom) 
  $(id).scrollTop -= scrollStep
  timerTop = setTimeout("scrollDivTop('"+id+"')",10)
}

function scrollDivBottom(id)
{
  clearTimeout(timerTop)
  $(id).scrollTop += scrollStep
  timerBottom = setTimeout("scrollDivBottom('"+id+"')",10)
}

function stopMe()
{
  clearTimeout(timerBottom)
  clearTimeout(timerTop)
}

function jumpBox(selectionBox)
{ 
	var URL = selectionBox.value; 
	window.location.href = URL; 
} 