function LoadPage(id)
{
	if (document.frNav) 
	{
		document.frNav.NavigationID.value = id;
		document.frNav.submit();
	}
	return true;
}
function LoadOrderBy(orderby)
{
	if (document.frHeader)
	{
		document.frHeader.OrderBy.value = orderby;
		document.frHeader.submit();
	}
	return true;
}
function SelectAll(objName)
{
	if (document.frItems)
	{
		for(var i=0; i<document.frItems.length; i++) 
		{
            if (document.frItems[i].name.indexOf(objName) > -1)
            {
    				document.frItems[i].checked = true;    				
            }
		} 
	}
	return false;
}
function InvertSelect(objName)
{
	if (document.frItems)
	{
		for(var i=0; i<document.frItems.length; i++) 
		{
            if (document.frItems[i].name.indexOf(objName) > -1)
            {
    			document.frItems[i].checked = !document.frItems[i].checked; 
            }
		} 
	}	
	return false;
}
function LoadCompany(id)
{
	if (document.frCompany)
	{
		document.frCompany.CompanyID.value=id;
		document.frCompany.submit(); 
	}
	return false;
}

//Multi select functions
function initOptions(objNotSelect,objAreSelect,arrSelect)
{
	
	
	//remove all options from both select areas
	while(objNotSelect.options.length>0)
	{
		objNotSelect.options[0]=null;
	}
	while(objAreSelect.options.length>0)
	{
		objAreSelect.options[0]=null;
	}
	// check the array if the selected field is true then add to the selected dropdown
	// else add to the notselected dropdown
	for (i=0;i<arrSelect.length;i++)
	{
	
		var a = new Option(arrSelect[i][1],arrSelect[i][0]);
		if (arrSelect[i][2])
		{
		objAreSelect.options[objAreSelect.options.length]=a;
	
		}
		else
		{
			objNotSelect.options[objNotSelect.options.length]=a;
		}
	}
}

function moveOptions(objSelect,objArray,boolSelected,objNotSelect,objAreSelect) 
{
	var optionsToAppend = new Array();
	var optionsToRemove = new Array();
	
	for(i=0;i<objSelect.options.length;i++)
	{
	    if (objSelect.options[i].selected)
		{
			objOption = objSelect.options[i];
			optionsToAppend.push(objOption);
            optionsToRemove.push(objOption);
		}		
	}
	
	for(var a=0; a< optionsToRemove.length;a++)
	{
	  objSelect.removeChild(optionsToRemove[a]);
	}
		
	var objToAppend = null;
	
	if(objSelect.name != objNotSelect.name)
	{
		objToAppend = objNotSelect;
	} else 
	{
		objToAppend = objAreSelect;
	}
	
	for(var a=0; a<optionsToAppend.length;a++)
	{
	  objToAppend.appendChild(optionsToAppend[a]);
	}
}

function selectAll(objSelect,objNotSelect)
{
	var chk = 1;
	
	for(i=0;i<objSelect.options.length;i++)
	{
		objSelect.options[i].selected=true;
		chk = 0;
	}
	if (chk)
	{		
		if (objNotSelect)
		{
			objNotSelect.value = 1;	
		}
	}
	return true;
}
function selectOptions(objSelect,objGroup)
{	
	for(i=0;i<objSelect.length;i++)
	{
		objSelect.options[i].selected = null;
	}
	for(k=0;k<MyArrCompanyCustomDataTypeLinks0.length;k++)
	{
		for(i=0;i<objSelect.length;i++)
		{
			if (MyArrCompanyCustomDataTypeLinks0[k][3].indexOf(','+objGroup.options[objGroup.selectedIndex].value+',') > -1)
			{
				if (MyArrCompanyCustomDataTypeLinks0[k][0] == objSelect.options[i].value)
				{
					objSelect.options[i].selected = true;
				}
			}
		}
	}
}
//Editor functions
function doFormat(frName,what,val) 
{
	// Get a text range for the selection
	var tr = frName.selection.createRange();
 	// Execute the command
 	tr.execCommand(what,arguments[1],val);
 	// Reselect and give the focus back to the editor
 	tr.select();
 	frName.focus();
}
function swapModes(frName) 
{  	
	if (format=='HTML') 
	{
		frName.body.innerText = frName.body.innerHTML;
		frName.body.style.fontFamily = 'monospace';
		frName.body.style.fontSize = '10pt';
		format='Text';
	}
	else 
	{
		frName.body.innerHTML = frName.body.innerText;
		frName.body.style.fontFamily = '';
		frName.body.style.fontSize = '';
		format='HTML';
	}
	frName.focus();
	var s = frName.body.createTextRange();
	s.collapse(false);
	s.select();
}
//Upload file to server
function uploadFile(f,varName,id)
{
	var pom = "";
	var i;
	var ch;
	eval('i = f.addfile'+id+'.value.length');
	eval('j = f.addfile'+id+'.value');
	if (j != 'none')
	{
		if (i) 
		{
			eval('ch = f.addfile'+id+'.value.charAt(i)');
			i--;
			while(((ch != "/")&&(ch != "\\"))&&(i > 0))
			{
				pom = ch + pom;
				eval('ch = f.addfile'+id+'.value.charAt(i)');
				i--;
			}
			varName.value = pom;
			window.defaultStatus = "Upload in progress...";
		}
	}
	else
	{
		varName.value = j;
	}
}

function changeAnchorColor(anchorName,anchorColor,anchorBackground)
{
	try {		
		for (i=0;i<document.anchors.length;i++)
		{
			if (document.anchors[i].name == anchorName)
			{
				document.anchors[i].style.color = anchorColor;
				document.anchors[i].style.backgroundColor = anchorBackground;
			}
		}
	}
	catch(e)
	{
		/*	this is just to prevent errors being thrown on non-compatible browsers. */
	}	
}

function showHide(spanName,actionVal)
{
	if(getStyleRef(spanName))
	{
		getStyleRef(spanName).visibility = actionVal;
	}
}

function getStyleRef(id)
{
	var value = false;
	if(document.layers)
  	{
  		value = document.layers[id];
	}
  	else if(document.all)
  	{
    	value = document.all[id];
    }
    else if(document.getElementById)
    {
        value = document.getElementById(id);
    } //  end else

    if(value)
    {
    	value = value.style;
  	}   	
  	return value;
}  //  end function

