// FlashLink Javascript Library
function loadAdmin()
{
	var headID = document.getElementsByTagName("head")[0];         
	var newScript = document.createElement('script');
	newScript.type = 'text/javascript';
	newScript.src = 'WA2_Admin/FLAdmin.js';
	headID.appendChild(newScript);	
//	if(scr == 'WA2_Admin/FLAdmin.js') newScript.onload=function() { InitAdmin("", 0);};
}

/////////////////////////////////////////	Generic modules	//////////////////////////////////
function FlashLinkVertNewsBar(hdiv, dx, dy, dw, dh)
{	//	create bar inside hosting div (hdiv = id)
	
	var elm = document.getElementById(hdiv);
	if(!elm) return '';
	
	var w = dw;
	var h = dh;
	
	var stContID = hdiv + '_cont';		//	outer container
	var stBlockID = hdiv + '_block';	//	scrolling data block
	var st="<div id='"+stContID+"' style='position:relative; top:"+dy+"px; left:"+dx+"px; overflow:hidden; width:"+w+"px; height:"+(h-2)+"px'>";
	st += "<div id='"+stBlockID+"' style='position:absolute; top:"+h+"px; left:8px; height:auto; width:"+(w-16)+"px; text-align:left' onmouseover=\" this.setAttribute('over', '1')\" onmouseout=\" this.setAttribute('over', '0')\" ></div></div>";
	
	elm.innerHTML = st;
	window.setInterval("FlashLinkScrollNewsBar('"+stBlockID+"',"+h+")", document.all ? 25 : 35);

	return stBlockID;
}

function FlashLinkScrollNewsBar(elmID, h)
{	
	var elm = document.getElementById(elmID);
	
	if(elm.offsetHeight < h && elm.offsetTop <= -5)
	{
		return;
	}
	
	if(elm.getAttribute('over'))
		if(elm.getAttribute('over') == '1')
			return;
	var max_top = - elm.offsetHeight;
	var ctop = elm.offsetTop;
	if(ctop > max_top)
		elm.style.top = ctop - 1 + 'px';
	else
		elm.style.top = h + 'px';
}


/////////////////////////////////////////	Generic services	//////////////////////////////////
function getAbsTop(elmID)
{
	var elm=document.getElementById(elmID);
	if(!elmID) return(0);
	var ret=0;
	while (elm)
	{
		ret+=elm.offsetTop;
		elm=elm.offsetParent;
	}
	return ret;
}

function getAbsLeft(elmID)
{
	var elm=document.getElementById(elmID);
	if(!elmID) return(0);
	var ret=0;
	while (elm)
	{
		ret+=elm.offsetLeft;
		elm=elm.offsetParent;
	}
	return ret;
}

function getCurrentPageName()
{
	var loc = location.pathname;
	return loc.substring(loc.lastIndexOf('/') + 1);
}

////////	Date / time
function convertSQLDateToUSADate(sql_date)
{	//	YYYY-MM-DD HH:MM:SS to Jan 12, 2011
	var arm=['','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
	var ar = sql_date.substring(0, 10).split('-');
	return arm[ar[1]-0] + ' ' + (ar[2]-0) + ', ' + ar[0];
}
