window.onload=function() 
{
	
}

function htmlspecialchars(text)
{
	text = text.replace('&', '&amp;');
	text = text.replace('<', '&lt;');
	text = text.replace('>', '&gt;');
	text = text.replace('"', '&quot;');
	return text;
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie= c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}


function getElement(div_id) {
	if (document.getElementById){
		var identification = document.getElementById(div_id);
	}
	else if (document.all){
		var identification = document.all[div_id];
	}
	else if (document.layers){
		var identification = document.layers[div_id];
	}
	return identification;
}



function getLeftFromObject(obj)
{
	var curleft = 0;
	if(obj.offsetParent)
	{
		while(1) 
		{
		  curleft += obj.offsetLeft;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	}
	else if(obj.x)
	{
		curleft += obj.x;
	}
	else
	{
	}
	return curleft;
}

function getTopFromObject(obj)
{
	var curtop = 0;
	if(obj.offsetParent)
	{
		while(1)
		{
		  curtop += obj.offsetTop;
		  if(!obj.offsetParent)
		  {
			break;
		  }
		  obj = obj.offsetParent;
		}
	}
	else if(obj.y)
	{
		curtop += obj.y;
	}
	return curtop;
}

function popupUserPane(pane, user)
{
	up = getElement('userPopup');
	oc = getElement(pane);
	
	// assign position
	up.style.top  	= (getTopFromObject(oc)  + 5) + 'px';
	up.style.left 	= (getLeftFromObject(oc) + 105) + 'px';
	up.style.display = '';
	
	// loading...
	up.innerHTML = '';

	// use ajax processor to copy data
	var obj = new WpciAjaxProcessor(); 
	obj.setCompleter(new AjaxDivLoader('userPopup'));
	
	// assign arguments
	var args = new Array();
	args['user'] = user;
	args['__ajax_call'] = 'userpopup';
	
	obj.addPostData(args);
	
	// execute against common
	obj.execute('/ncp_home/ajax_common.php');
}

function hideUserPopup()
{
	up = getElement('userPopup');
	up.style.display = 'none';
}

function popupUserSearch(id)
{
	// find the box dimensions
	box  = getElement(id);
	top  = (getTopFromObject(oc) + 20) + 'px';
	left = (getLeftFromObject(oc)) + 'px';
		
	// display the box
	pane = getElement('userSearchPopup');
	pane.style.width   = '300px';
	pane.style.height  = '200px';
	pane.style.display = 'block';
}

function popupUserSearchChange()
{
	// lookup processor
	var o = getElement('__userSearchPopupText');
	
	// use ajax processor to copy data
	var obj = new WpciAjaxProcessor(); 
	obj.setCompleter(new AjaxDivLoader('userSearchPopupResult'));
	
	// assign arguments
	var args = new Array();
	args['text'] 	= o.value;
	obj.addPostData(args);
	
	// execute against common
	obj.execute('/ncp_home/ajax_common.php?__ajax_call=usersearch&bsn=' + getElement('__bsn').value);
}

function menuMouseOver(obj)
{
	obj.style.background = '#eeeeee';
}

function menuMouseOut(obj)
{
	obj.style.background = '#ffffff';
}

function menuGo(id)
{
	document.location = getElement('bmenu' + id).href;
}