function nothing() {}

var ts;
var ajax, a_target;
ajax=null;
a_target=null;

function ajax_set_target(new_id)
	{
	a_target=new_id;
	}

function state_Change()
	{
	if (ajax.readyState==4)
		{
		if (ajax.status==200)
			{
			document.getElementById(a_target).innerHTML=ajax.responseText;

			var s = document.getElementById(a_target);
			var sc = s.getElementsByTagName('SCRIPT');

			for (i=0; i<sc.length; i++)
				{
				eval(sc[i].innerHTML);
				}
			}
		else
			{
			document.getElementById(a_target).innerHTML="שגיאה ("+ajax.status+")";
			}
		}
	}

function ajax_init(url)
	{
	if (window.XMLHttpRequest)
		{
		ajax=new XMLHttpRequest();
		}
	else if (window.ActiveXObject)
		{
		ajax=new ActiveXObject("Microsoft.XMLHTTP");
		}

	if (ajax!=null)
		{
		ts = new Date();	
		ts = ts.getTime();
		wait_panel();
		ajax.onreadystatechange=state_Change;
		ajax.open("GET", url+'&ts='+ts, true);
		ajax.send(null);
		}
	else
		{
		alert("הדפדפן בו הנך משתמש אינו מאפשר להשתמש בפונקציה זו");
		}
	}

function wait_panel()
	{
	document.getElementById(a_target).innerHTML="<br /><br /><img align='center' src='ajax_loading.gif' /><br clear='all' /><span id='loading_txt'>בטעינה...</span><br /><br />";
	}

 // obj = [target object], is_horiz = (horizonal centering), is_absolute = (use css absolute position?), moreHeight = (manually add more pixels to marginHeight/top)
function centering(obj, is_horiz, is_absolute, moreHeight)
	{
	var winHeight = document.documentElement.clientHeight;
	var winWidth = document.documentElement.clientWidth;

	var objHeight=0;
	var objWidth=0;

	if (obj.currentStyle)
		{
		objHeight = obj.currentStyle['height'];
		objWidth = obj.currentStyle['width'];
		}
	else
		{
		if (window.getComputedStyle)
			{
			objHeight = document.defaultView.getComputedStyle(obj, null).getPropertyValue('height');
			objWidth = document.defaultView.getComputedStyle(obj, null).getPropertyValue('width');
			}
		}

	objHeight = objHeight.toString();
	objHeight = parseInt(objHeight.replace('px', ''));

	objWidth = objWidth.toString();
	objWidth = parseInt(objWidth.replace('px', ''));

	if (objHeight==0 || objWidth==0)
		{
		// invalid values
		return;
		}

	if (is_absolute==0)
		{
		obj.style.position = 'static';
		obj.style.marginTop = ((winHeight/2)-(objHeight/2)+moreHeight)+'px';
		obj.style.marginBottom = 0;

		if (is_horiz==1)
			{
			obj.style.marginLeft = 'auto';
			obj.style.marginRight = 'auto';
			}
		}
	else
		{
		obj.style.position = 'absolute';
		obj.style.top = ((winHeight/2)-(objHeight/2)+moreHeight)+'px';

		if (is_horiz==1)
			{
			obj.style.left = ((winWidth/2)-(objWidth/2))+'px';
			}
		}
	}
