/*  Prototype Milenyum Kursc JavaScript framework
 *  (c) 2007 Kursat CELIK <kursatcelik@gmail.com>
 *
 *  
/*--------------------------------------------------------------------------*/


function $(id) {
  return document.getElementById(id);
}
function $s(o) {
  return o.options[o.selectedIndex].value;
}

function $cb(f, name) {
	var o =  f.elements;
	var SeciliSay = 0;
	var i = 0;	
	var secilen = ""  

  for (i=0;i<o.length;i++) {		
		if(o[i].type=="checkbox" && o[i].name == name){
			if (o[i].checked) {
				if (SeciliSay>0){
					secilen += ",";	 
				} 
				SeciliSay++;  
				secilen += o[i].value;
			}
		}
	}
	this.secililer = secilen;
	this.count = SeciliSay;
  return this;
}

function $f(o, r) {
 o.innerHTML = r;
}

function GetWindowWidth(){
	var width=0;
	if(typeof window.innerWidth=="number")
		width=window.innerWidth;
	else
	{
		if(document.documentElement&&document.documentElement.clientWidth)
			width=document.documentElement.clientWidth;
		else{
			if(document.body&&document.body.clientWidth)
				width=document.body.clientWidth;
		}
	}
	if(!width||width<100)
		width=100;
	
	return width;
}

function GetWindowHeight()
{
	var height=0;
	if(typeof window.innerHeight=="number")
		height=window.innerHeight;
	else{
		if(document.documentElement&&document.documentElement.clientHeight)
			height=document.documentElement.clientHeight;
		else{
			if(document.body&&document.body.clientHeight)
				height=document.body.clientHeight;
		}
	}
	if(!height||height<100)height=100;
	
	return height;
}


function show(obj) {
    obj.style.visibility = 'visible';
    obj.style.display = 'block';
}

function hide(obj) {
    obj.style.display = 'none';
}

function center(obj, parent) {
 var height, width;
 if (!parent) {
   height = GetWindowHeight();
   width = GetWindowWidth();
 } else {
   var oldparentvis = parent.style.visibility;
   var oldparentdisp = parent.style.display;
   parent.style.visibility = 'hidden';
   parent.style.display = '';
   height = parent.offsetHeight;
   width = parent.offsetWidth;
   parent.style.visibility = oldparentvis;
   parent.style.display = oldparentdisp;
 }
 var oldvis = obj.style.visibility;
 var olddisp = obj.style.display;
 obj.style.visibility = 'hidden';
 obj.style.display = '';
 px(obj, 'top', (height / 2) - (obj.offsetHeight / 2));
 px(obj, 'left', (width / 2) - (obj.offsetWidth / 2));
 obj.style.visibility = oldvis;
 obj.style.display = olddisp;
}

function px(obj, attr, n) {
 obj['style'][attr] = n + 'px';
}


function GetXmlHttp()  {
	var xmlhttp=false;
			/*@cc_on @*/
			/*@if (@_jscript_version >= 5)
			// JScript gives us Conditional compilation, we can cope with old IE versions.
			// and security blocked creation of the objects.
			 try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			 } catch (e) {
				try {
				 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (E) {
				 xmlhttp = false;
				}
			 }
			@end @*/
			if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
				xmlhttp = new XMLHttpRequest();
			}
	return xmlhttp;
} 

function AjaxGeldi(r, panel) {
  var o = $(panel)
	o.innerHTML = r;
	//o.innerHTML = r;
	//alert(r)
	//$f(o, r);
}


function Ajax(url, panel) {	
	AjaxGetir(url, AjaxGeldi, panel);
	
}

function AjaxGetir(url, callback, ekparam) {
	if(typeof url == "undefined" || typeof callback == "undefined")
		return false;   

	var request = GetXmlHttp();
	request.open("GET", url, true);
	request.onreadystatechange = function()
	{
		if (request.readyState == 4)
		{
			callback(request.responseText, ekparam);
		}
	}

  request.send(null);
  return true;
}

