<!-- ALIEN CODE-->
function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function


Array.prototype.sum = function(){
	for(var i=0,sum=0;i<this.length;sum+=this[i++]);
	return sum;
	}

function getRealLeft(obj) {
    xPos = obj.offsetLeft;
    tempEl = obj.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getRealTop(obj) {
    yPos = obj.offsetTop;
    tempEl = obj.offsetParent;
    while (tempEl != null) {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}

function strip_tags(source) {
var newString = "";
   var inTag = false;
   for(var i = 0; i < source.length; i++) {
   
        if(source.charAt(i) == '<') inTag = true;
        if(source.charAt(i) == '>') {
              inTag = false;
              i++;
        }
   
        if(!inTag) newString += source.charAt(i);

   }

   return newString;
}

var detectbrow=navigator.userAgent.toLowerCase();
var browsername;
if (checkIt('msie')&&!checkIt('opera'))
{
 optparam=-1;
 browsername='msie';
}
else
{optparam=null;}


function checkIt(string)
{
place = detectbrow.indexOf(string) + 1;
thestring = string;
return place;
}

<!-- END ALIEN CODE-->


function clearlist(list)
{
 for(i=list.length;i>=0;i--)
 {
 list.remove(i);
 }
}

function addlistelement(list, element, value, optparam, first)
{
 var newel = document.createElement('option');
 newel.text = element;
 newel.value = element;
 list.add(newel, optparam);
}

function arraytolist(arr, list, optparam, clear)
{
 if (clear) {clearlist(list);}
 for(i=0;i<=arr.length-1;i++)
 {
 var newel = document.createElement('option');
 newel.text = arr[i];
 newel.value = arr[i];
 list.add(newel, optparam);
 }
}

function multipleselected(list)
{
counter=0;
if (list.selectedIndex<0)
{
 	return -1; //no selection!
}

for(var i=list.selectedIndex;i<list.length;i++)
{
	if (list.options[i].selected == true)
	{
	counter++;	
	}
	if (counter>1)
	{
		return 1;
	}
}
 if (counter==1)
 {
	return 0; //single selection
 }
}

function hasspaces(s)
{
 var ss= new String();
 ss=s;
 if (ss.indexOf(" ")>=0)
 {
 return true;
 }
 else	
 {
 return false;
 }
}

function islegalname(name, accepted)
{
 nums= new String("0123456789");
 lits= new String("abcdefghijklmnopqrstuvwxyz");
 accs= new String();
 accs=accepted;
 accs=accs.toLowerCase();
 ss=new String(name);
 ss= ss.toLowerCase();
 bfound=false;
 for (i=0;i<=ss.length-1;i++)
 {
	for (j=0;j<=nums.length-1;j++)
	{
		if (ss.charAt(i)==nums.charAt(j))
		{
			bnum=true;
			break;
		}
		else
		{
			bnum=false;
		}
	}
	for (j=0;j<=lits.length-1;j++)
	{
		if (ss.charAt(i)==lits.charAt(j))
		{
			blit=true;
			break;	
		}
		else
		{
			blit=false;
		}
	}
	for (j=0;j<=accs.length-1;j++) <!-- check accepted chars -->
	{
		if (ss.charAt(i)==accs.charAt(j))
		{
			bother=true;
			break;	
		}
		else
		{
			bother=false;
		}
	}
	bfound=bnum||blit||bother;
	if (!bfound){break};
 }
 return bfound;
}

function hasillegals(s, ills) <!-- ills must be an Array -->
{
 var ss= new String();
 ss=s;
 for (i=0;ills.length-1;i++)
 {
	if (ss.indexOf(ills[i])>=0)
	{
	return true;
	}
 }
}

function isvalidemail(email)
{
 var s= new String();
 s=email;
 var ss= s.split('@');	 
 if (!islegalname(ss[0], '._')) <!-- theoretical username -->
 {
 return false;
 }
 if (!islegalname(ss[1], '._-')) <!-- theoretical domain name -->
 {
 return false;
 }
 if ((s.indexOf('@')<=0)|| <!-- no @ in it -->
	(s.indexOf('@')==s.length-1)|| <!-- misplaced @ in it -->
	(s.indexOf('@')>=s.length-4)||
	(s.indexOf('@')!=s.lastIndexOf('@'))|| <!-- too many @s -->
	(s.indexOf('.')<=0)||<!-- no . in it -->
	(s.lastIndexOf('.')==s.length-2)||<!-- misplaced . in it -->
	(s.lastIndexOf('.')<s.length-4)||
	(s.lastIndexOf('.')==s.lastIndexOf('@')+1)<!-- the @. situation -->
     	)
 {
 return false; 
 }
 else
 {
 return true;
 }
}

function isObject(item)
{
	return (item && typeof item == 'object') || isFunction(item);
}
function isArray(item)
{
	return isObject(item) && item.constructor == Array;
}

function isFunction(item) {
    return typeof item == 'function';
}

function removespaces(fs)
{
 var s="";
 split=fs.split(" ");
 for(i=0;i<=split.length-1;i++)
 {
  s=s+split[i];
 }
 return s;
}

function FindInArray(arr, text) // returns index of Text in array; if not fount returns -1
{
 temp=new String();
 temp= text;
 for(i=0; i<=arr.length-1; i++)
 {
	if (arr[i].toUpperCase() == temp.toUpperCase())
	{
		return i;
	}
 }
 return -1;	
}

function FindInList(options, text) // returns index of Text in array; if not fount returns -1
{
 temp=new String();
 temp= text;
 for(i=0; i<=options.length-1; i++)
 {
	if (options[i].value.toUpperCase() == temp.toUpperCase())
	{
		return i;
	}
 }
 return -1;	
}

function IsNavigKey(key)
{
 	result=false;
	var navigs = new Array(0,8);
	for (i=0;i<=navigs.length-1;i++)
	 {
		result=(key==navigs[i]);
		if (result)
		{
		 	//alert(key);
			break;	
		}	
	 }
	return result; 
}

function ShortenStr(source, maxlen, ellipsis)
{
	sub=source.substr(0, maxlen);
	if(maxlen<source.length && ellipsis)
		sub+='...';
	return sub;	
}

function GetNodeText(node)
{
	node=node.firstChild;
	while(node.nodeName.toLowerCase()!='#text')
		node=node.firstChild;
	if(browsername=='msie')
	{
		return Trim(node.nodeValue.replace(/[\r\n]+/g, " "));
	}	
		else
	{	
		return Trim(node.nodeValue.replace(/[\r\n]+/g, " "));
	}	
}

function quotes_to_entity(source)
{
	return source.replace(/"/g, '&#34');
}

function nos_ShowSplash()
{
	splash=document.getElementById('splash_screen');
	splash.style.display='block';
}

nos_utf8_chars_replace=new Array('ă','î','â','ţ','ş','Ă','Î','Â','Ţ','Ş');
nos_utf8_chars_replacements=new Array('a','i','a','t','s','A','I','A','T','S');

function nos_urlize_string(s)
{
	for(i=0;i<nos_utf8_chars_replace.length;i++)
	{
		s=s.replace(nos_utf8_chars_replace[i], nos_utf8_chars_replacements[i]);
	}	
	s=s.replace(/\s+/gim, '-').toLowerCase();
	return s;
}