//////////////////////////////////////////////////////////////////////
////////////########  Javascript library of functions ########////////
//////////////////////////////////////////////////////////////////////
function openWindow(filePath,winName,toolbar,height,width) {
	if (!filePath) filePath = '';
	if (!winName) winName = 'newWin';
	if (!height) height = (window.screen.availHeight * 0.85);
	if (!width) width = (window.screen.availWidth * 0.85);		
	xPos = (window.screen.availHeight * 0.015);
	yPos = (window.screen.availWidth * 0.015);
	attribs='height='+height+','+'width='+width;
	//if ((toolbar) && (!toolbar == '')) attribs=attribs+','+toolbar;
	//if ((menubar) && (!menubar == '')) attribs=attribs+','+menubar;
	attribs=attribs+',toolbar,menubar,scrollbars';
	//attribs=attribs+',menubar,scrollbars';
	newWindow=window.open(filePath,winName,attribs);		
	newWindow.moveTo(xPos,yPos) 
	newWindow.focus();		
}
//////////////////////////////////////////////////////////////////////
function left(string,count) {
	return string.substr(0,count);
}
//////////////////////////////////////////////////////////////////////
function right(mystring,count)  {
	return mystring.substring(mystring.length-count,mystring.length);
}
/////////////////////////////////////////////////////////////////////
function mid(myString,start,count) {
	return myString.substr(start-1,count)
}
/////////////////////////////////////////
function len(mystring)  {
	return mystring.length;
	}
/////////////////////////////////////////

function AddOption(form, sObj, tObj,Remove) 
{
	var sTemp     = document.forms[form].elements[sObj];
	var tTemp     = document.forms[form].elements[tObj];
	if (Remove==1)
	{
		//for (var i=0; i < sTemp.length; i++)
		for (var i=sTemp.length-1; i >= 0; i--)
		{
			if (sTemp.options[i].selected==1) 
			{
				var found=false;
				for (var j=0; j < tTemp.length; j++)
				{
					if (tTemp.options[j].value==sTemp.options[i].value) 
					{
						found=true;
						break; 
					}
					else found=false;
				}
				if (!found) {
					tTemp.options[tTemp.length]= new Option (sTemp.options[i].text, sTemp.options[i].value);
					}
				
				//if (Remove==1)
					sTemp.options[i]= null;
				//else	
					//sTemp.options[i].selected=0;
			}
		}
	}
	else
	{
		for (var i=0; i < sTemp.length; i++)
		{
			if (sTemp.options[i].selected==1) 
			{
				var found=false;
				for (var j=0; j < tTemp.length; j++)
				{
					if (tTemp.options[j].value==sTemp.options[i].value) 
					{
						found=true;
						break; 
					}
					else found=false;
				}
				if (!found) {
					tTemp.options[tTemp.length]= new Option (sTemp.options[i].text, sTemp.options[i].value);
					}
				sTemp.options[i].selected=0;
			}
		}
	}
}

function DeleteOption(form,Obj) 
{
	var Temp     = document.forms[form].elements[Obj];
	for (var i=(Temp.length-1); i>=0 ; i--)
	{
		if (Temp.options[i].selected==1) 
		{
			Temp.options[i]= null; 
		}
	}
}
