function ShowHideObject(objID)
{
	var obj=eval("document.all."+objID);
	if(obj.style.display=="none")
	{
		obj.style.display="block";
	}
	else
	{
		obj.style.display="none";
	}
}

/*
关闭，显示层并且交换显示的小图标
*/
function ShowHideObjectAndSwapImage(objID, imgID)
{
	var obj=eval("document.all."+objID);
	var obj_img=eval("document.all."+imgID);
	if(obj.style.display=="none")
	{
	    obj_img.src = "http://www.cigre.org.cn/cigre_en/images/minus.gif";
		obj.style.display="block";
	}
	else
	{
	    obj_img.src = "http://www.cigre.org.cn/cigre_en/images/plus.gif";
		obj.style.display="none";
	}
}


//Move item up
function moveUp(oSelect)
{
	var i, count=0;
	var display_1, display_2, value_1, value_2;
	
	if (oSelect.selectedIndex != -1)
	{
	  for (i=0;i<oSelect.length;i++)
				if (oSelect.options[i].selected)
					 count ++;
		
		if (count > 1)
		{
		  alert("Sorry. Only one option can be moved up at a time");
		}
		else
		{
		  i = oSelect.selectedIndex;
			if (i > 0)
			{
			display_1 = oSelect.options[i].text;
			display_2 = oSelect.options[i-1].text;
				
			value_1 = oSelect.options[i].value;
			value_2 = oSelect.options[i-1].value;
				
			oSelect.options[i].text = display_2;
			oSelect.options[i].value = value_2;
			oSelect.options[i].selected = false
					
			oSelect.options[i-1].text = display_1;
			oSelect.options[i-1].value = value_1;
			oSelect.options[i-1].selected = true;
					
			oSelect.selectedIndex = i-1;
			}
	  }
	}
	
	return true;
}

//Move item down
function moveDown(oSelect)
{
	var i, count=0;
	var display_1, display_2, value_1, value_2;
	
	if (oSelect.selectedIndex != -1)
	{
	  for (i=0;i<oSelect.length;i++)
				if (oSelect.options[i].selected)
					 count ++;
					 
		if (count > 1)
		{
		  alert("Only one reviewer can be moved down at a time")
		}
		else
		{
		  i = oSelect.selectedIndex;
			if (i < oSelect.length - 1)
			{
			display_1 = oSelect.options[i].text;
			display_2 = oSelect.options[i+1].text;
				
			value_1 = oSelect.options[i].value;
			value_2 = oSelect.options[i+1].value;
				
			oSelect.options[i].text = display_2;
			oSelect.options[i].value = value_2;
			oSelect.options[i].selected = false;
				
			oSelect.options[i+1].text = display_1;
			oSelect.options[i+1].value = value_1;
			oSelect.options[i+1].selected = true;
					
			oSelect.selectedIndex = i+1;
			}
	  }
	}
	
	return true;
}

//Resize the modal dialog

function ResizeDialog(width,height)
{
	var vOpener=window.opener;
	if(vOpener=="undefined" || vOpener==null)//modal dialog
	{
		window.dialogWidth=width+"px";	
		window.dialogHeight=height+"px";
		window.dialogTop=(screen.height-height)/2 + "px";
		window.dialogLeft=(screen.width-width)/2 + "px";
	}
	else //normal window
	{
		window.moveTo((screen.width-width)/2,(screen.height-height-76)/2)		
		window.resizeTo(width,height+76)
	}
}

//Open the modal window

function OpenModalWindow(url)
{
	var vTmd=Math.random();
	var vReturn='';
	if(url.indexOf('?')>-1)
	{
		vReturn=window.showModalDialog(url+'&tmd='+vTmd,null,'status:0;scroll:0;help:0;dialogWidth=400px;dialogHeight=250px;');
	}
	else
	{
		vReturn=window.showModalDialog(url+'?tmd='+vTmd,null,'status:0;scroll:0;help:0;dialogWidth=400px;dialogHeight=250px;');
	}
	if(typeof(vReturn)!="undefined" && vReturn!="")
	{
		__doPostBack('','__RefreshDataGrid')
	}
}

function OpenModalWindow800_500(url, parentWin)
{
	var vTmd=Math.random();
	var vReturn='';
	if(url.indexOf('?')>-1)
	{
		vReturn=window.showModalDialog(url+'&tmd='+vTmd,parentWin,'status:0;scroll:1;help:0;dialogWidth=800px;dialogHeight=520px;');
	}
	else
	{
		vReturn=window.showModalDialog(url+'?tmd='+vTmd,parentWin,'status:0;scroll:1;help:0;dialogWidth=800px;dialogHeight=520px;');
	}
	if(typeof(vReturn)!="undefined" && vReturn!="")
	{
		//__doPostBack('','__RefreshDataGrid')
		parentWin.reload();
	}
}

//Get PickerBase Control's Value
function GetPickerBaseValue(ctl)
{
	return eval("document.all."+ctl+"_Value.value");
}

//Get RadioButtonList Checked Value
function GetRadioButtonListCheckedValue(ctl)
{
	var oRadio=document.getElementById(ctl);
	var oRadioButtons=oRadio.getElementsByTagName("input");
	for(var i=0;i<oRadioButtons.length;i++)
	{
		if(oRadioButtons[i].type=="radio" && oRadioButtons[i].checked)
		{
			return oRadioButtons[i].value;
		}
	}
	
	return "";
}
