function setLocation(dropdown){
	if (document.getElementById){
		if (dropdown.options[dropdown.selectedIndex].value!=""){
			location.href=dropdown.options[dropdown.selectedIndex].value;
		}
	}
}

function hideObj(objId)
{
	var obj = document.getElementById(objId);
	if (!obj) return;
	if (!obj.style) return;
	obj.style.display = "none";
}

function showObj(objId)
{
	var obj = document.getElementById(objId);
	if (!obj) return;
	if (!obj.style) return;
	obj.style.display = "block";
}



function selectAll (chkVal, idVal) 
{ 
	var frm = document.forms[0];
	// Loop through all elements
	for (i=0; i<frm.length; i++) 
	{
		// Look for our Header Template's Checkbox
		if (idVal.indexOf ('CheckAll') != -1) 
		{
			// Check if main checkbox is checked, then select or deselect datagrid checkboxes 
			if(chkVal == true) 
			{
				frm.elements[i].checked = true;
			}
			else
			{
				frm.elements[i].checked = false;
			}
			// Work here with the Item Template's multiple checkboxes
		} 
		else if (idVal.indexOf ('SelectThis') != -1) 
		{
			// Check if any of the checkboxes are not checked, and then uncheck top select all checkbox
			if(frm.elements[i].checked == false) 
			{
				frm.elements[1].checked = false; 
				//Uncheck main select all checkbox
			}
		}
	}
}

function confirmDelete (frm) 
{ 
// loop through all elements
	for (i=0; i<frm.length; i++) 
	{
		// Look for our checkboxes only
		if (frm.elements[i].name.indexOf('SelectThis') !=-1) 
		{
			// If any are checked then confirm alert, otherwise nothing happens
			if(frm.elements[i].checked) 
			{
				return confirm ('确定删除所选择的项吗?')
			}
		}
	}
}

function confirmDelete (frm, msg) 
{ 
// loop through all elements
	for (i=0; i<frm.length; i++) 
	{
		// Look for our checkboxes only
		if (frm.elements[i].name.indexOf('SelectThis') !=-1) 
		{
			// If any are checked then confirm alert, otherwise nothing happens
			if(frm.elements[i].checked) 
			{
				return confirm (msg)
			}
		}
	}
}
	

function checkParent(src,dest)
{
	//Search for a specific parent of the current element.
	while(src !=null)
	{
		if(src.tagName == dest)
		{
			return src;
		}
		src = src.parentElement;
	}
	return null;
}



//Swapping images
function MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}

//查找控件
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;
}



/* Begin: Popup Window */
function PopWin(myurl,width,height) 
{//弹出窗口
    var Height=window.screen.height;
    var Width=window.screen.width;
    var top,left;
    if (Height==600)
    {
       top="10px";
       left=(Width-parseInt(width))/2;
    }
    else
    {
      top=(Height-parseInt(height))/2;
      left=(Width-parseInt(width))/2;
    }
	newwin = window.open(myurl,"","width="+width+",height="+height+",top="+top+",left="+left+",scrollbars,resizable"); 
	
}
function PopWin(myurl,width,height,x,y) 
{//重载弹出窗口
    var Height=window.screen.height;
    var Width=window.screen.width;
  
    var top=0,left=0;
     top=y;
     left=x;
	newwin = window.open(myurl,"","width="+width+",height="+height+",top="+top+",left="+left+",scrollbars,resizable"); 
	
}
/* End: Popup Window */

function PopCalendar(obj)
{//日期函数
	showx = event.screenX - event.offsetX - 4 - 10 ; // + deltaX;
	showy = event.screenY - event.offsetY -168; // + deltaY;
	newWINwidth = 210 + 4 + 18;
	var e = document.getElementById(obj);
 	window.showModalDialog("/WebClient/JS/Calendar.htm",e,"dialogWidth:206px; dialogHeight:230px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no; ");    
}	
function ObjFocus(objid)
{//某控件焦点
	obj=MM_findObj(objid);
	if(obj!=null)
	{
	obj.focus();
	}		
}
	

