// JavaScript Document
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MoveItem(sourceID,desID,option,max){
	var source = document.getElementById(sourceID);
	var destination = document.getElementById(desID);
	if(option=='all') //move all
		while(source.length>0){
			newoption = new Option(source.options[0].text, source.options[0].value);
			destination.options[destination.length]=newoption;
			source.options[0]=null;
		}
	else//move selected ones
		for (i=0; i<source.length; i++)
			if(source.options[i].selected==true){
				newoption = new Option(source.options[i].text, source.options[i].value);
				if(max > 0){
				    if(destination.length < max){
				        destination.options[destination.length]=newoption;
				        source.options[i]=null;
				    }
				    else
				        break;
				}
				else {//the destination has no limit the number of items
				    destination.options[destination.length]=newoption;
				    source.options[i]=null;
				}
				i--;
			}
	Sort(destination);
}
function Sort(obj)
{
	var content = new Array();
	for (i=0;i<obj.length;i++) 
	    content.push(new Option(obj.options[i].text, obj.options[i].value));
	content.sort(SortByText);
	
	for(i=0;i<content.length;i++) 
	    obj.options[i]=content[i];
}

function SortByText(obj1, obj2)
{
	var a = obj1.text.toLowerCase();
	var b = obj2.text.toLowerCase();
	return ((a < b) ? -1 : ((a > b) ? 1 : 0));
}

function setSelect(rowID,checked)
{		
	var	row = (rowID=='') ? null : document.getElementById(rowID);
	if(checked) css = "rowSelected";
	else css = "rowLine";
	if(row!=null)
	{
		if(!checked) row.childNodes[1].className="rowRowHeader"; else row.childNodes[1].className="rowSelected";
		for(k=1;k<row.childNodes.length;k++) row.childNodes[k].className=css;			
	}
}
function setSelectGridView(objID,containerID)
{
	var objContainer = document.getElementById(containerID);
	for(i=0;i<objContainer.rows.length;i++)
	{
		if(objContainer.rows[i].id!=objID) setSelect(objContainer.rows[i].id,false);
	}
	setSelect(objID,true);
}
function ShowWindow(pnlControlMinId, pnlControlMaxId, objId, pnlBackgroundId, pnlTitleId)
{
	var pnlBackground = document.getElementById(pnlBackgroundId);
	var pnlTitle = document.getElementById(pnlTitleId);

	pnlBackground.className = "boxContent";
	pnlTitle.className = "txtTitle";
	ShowHideObject(objId,true);
	ShowHideObject(pnlControlMinId,true);
	ShowHideObject(pnlControlMaxId,false);
}
function HideWindow(pnlControlMinId, pnlControlMaxId, objId, pnlBackgroundId, pnlTitleId)
{
	var pnlBackground = document.getElementById(pnlBackgroundId);
	var pnlTitle = document.getElementById(pnlTitleId);
	
	pnlBackground.className = "boxContentCollapse";
	pnlTitle.className = "txtTitleInvert";
	ShowHideObject(objId,false);		
	ShowHideObject(pnlControlMinId,false);
	ShowHideObject(pnlControlMaxId,true);

}

function ShowHideObject(objId, isShow)
{
	var obj = document.getElementById(objId);
	if(isShow) obj.className = "";
	else obj.className = "hide";
}

//this function will be remove. Please use the one in Common.js
function ChangeCheckAll(objSource,desTableID){
	var form = document.forms[0];
	for(i=0;i<form.length;i++)
		if(form[i].id.indexOf("chkRow")!=-1 && form[i].disabled==false) 
		{
			form[i].checked=objSource.checked;
			setSelect("row"+form[i].id,objSource.checked)
		}
}
function OpenWindow(theURL,winName,features,width,height) { //v2.0
	position = "width=" + width + ",height=" + height + ",top=" + (screen.height-height)/2 + ",left=" + (screen.width-width)/2;
	features += (features=='') ? position : ","+position;
	window.open(theURL,winName,features);
}
//-->