﻿
function ShowLoadingImage(Loading,Conver)
{   
    Loading.style.display = "";
    Conver.style.display = "";
}

function AutoExtendByWindow(CrlName,Size,Dyn)
{
    var PageCrl = document.getElementById(CrlName);
    if (PageCrl)
    {
        if (Dyn)
            PageCrl.style.height = (window.screen.height -window.screenTop)- Size   
        else
            PageCrl.style.height = Size;
    }
}

function DivScrollPosition(CrlName,ScrollTop)
{
    var PageCrl = document.getElementById(CrlName);
    if (PageCrl)
    {
        PageCrl.scrollTop = parseFloat(ScrollTop);
    }
}

//function ShowMessge(message)
//{    
//    var div=document.createElement("DIV");
//    div.id="MessageDiv";
//    div.style.position="absolute";
//    div.style.height = "200px";
//    div.style.width = "200px";
//    div.style.top="30%";
//    div.style.left="40%";
//    div.style.border = "1px red";
//    div.innerHTML = "<table width='100%' heiht='200px'><tr style='height:30px;background:red'><td></td></tr><tr><td>"+message+"</td></tr><tr style='height:30px;'><td><input type='button' value='确定' onclick='RemoveMessage()' /></td></tr></table>";
//    document.body.appendChild(div);
//}

//function RemoveMessage()
//{
//    var div=document.getElementById("MessageDiv");
//    div.parentNode.removeChild(div);
//}

function ShowTitleInTop()
{
    //by flin cancel on 2009.9.28
    //    var PageTitle = top.TopFrame.document.getElementById("PageTitle");
    //    if (PageTitle)
    //        PageTitle.innerHTML = document.title;
    //by flin add on 2009.9.28
      if(typeof(top.TopFrame) != "undefined")
      {
          var PageTitle = top.TopFrame.document.getElementById("PageTitle");
          if (PageTitle)
             PageTitle.innerHTML = document.title;
      }
}

function CheckKeyIsSelect( Key,Message )
{
    var KeyIsSelected = true;
    if (Key == "")
    {
        alert(Message);
        KeyIsSelected = false;
    }
    return KeyIsSelected;
}
//检查文本框不为空
function CheckTextBox(CID,HelpStr)
{	
	var Result = true;
	if(CID.value == "")
	{
		Result = false;
		alert(HelpStr);
		CID.focus();
	}
	return Result;
}
// 检查电子邮箱 Add by nj
function CheckEmail(CID,HelpStr)
{
    
	var Reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	var Result = false;
	
	if (Reg.test(CID.value))
	{	    
		Result = true;
	}
	else
	{
	    alert(HelpStr);
	    CID.focus();
		Result = false;
	}
	return Result; 
}

function CheckSelect(CID,Comstr,HelpStr)
{
    var Result = true;
	if(CID.options(CID.selectedIndex).text == Comstr)
	{
		Result = false;
		alert(HelpStr);
	}
	return Result;
}

//设置编辑控件焦点

function SetFocus( EdtControl )
{
    if (EdtControl != null)
    {
        EdtControl.focus();
        EdtControl.value += "";
    }
}

function ___OpenModalWindow(url,width,height,showScroll,showStatus,allowResize,inArg)
{
    var showStyle = "dialogWidth:415px;dialogHeight:420px;scroll:no;status:no;resizable:no;";
    showStyle += "dialogWidth:" + width + "px;";
    showStyle += "dialogHeight:" + height + "px;";
    showStyle += "scroll:" + (showScroll ? "yes;" : "no;");
    showStyle += "status:" + (showStatus ? "yes;" : "no;");
    showStyle += "resizable:" + (allowResize ? "yes;" : "no;");
    if (url.indexOf("?") >= 0)
        url += "&Temp__Data__=" + String(Math.random());
    else
        url += "?Temp__Data__=" + String(Math.random());
    url = encodeURI(url);
    return window.showModalDialog(url, inArg, showStyle);
}

function ___SetWindowRreturnValue(returnValue)
{
    window.returnValue = returnValue;
}

function ___SelectTabPage(tabHeadBox, tabPageCtr)
{
    if(tabHeadBox.className == "TabItemSelected")return;
    var row = tabHeadBox.parentElement;
    var selectedIndex = -1;
    for(var i=0;i<row.cells.length-1;i++)
    {
        if (row.cells[i].className == "TabItemSelected")
        {
            row.cells[i].className = "TabItem";
            selectedIndex = i;
            break;
        }
    }
    tabHeadBox.className = "TabItemSelected";
    if (selectedIndex != -1)
        tabPageCtr.rows[selectedIndex].style.display = "none";
    tabPageCtr.rows[tabHeadBox.cellIndex].style.display = "";
}

function ___WindowInit()
{
    if (document.readyState=='complete')
    {
        var inCtrs = document.getElementsByTagName("INPUT");
        var arCtrs = document.getElementsByTagName("TEXTAREA");
        if (inCtrs)
        {
            for(var i=0;i<inCtrs.length;i++)
            {
                if (inCtrs[i].type.toLowerCase() == "text" && inCtrs[i].className.toLowerCase() == "notifytextboxcss")
                {
                    inCtrs[i].onfocus = ___NotifyTextBox_OnFocus;
                    inCtrs[i].onblur = ___NotifyTextBox_OnBlur;
                }
            }
        }
        if (arCtrs)
        {
            for(var i=0;i<arCtrs.length;i++)
            {
                if (arCtrs[i].className.toLowerCase() == "notifytextboxcss")
                {
                    arCtrs[i].onfocus = ___NotifyTextBox_OnFocus;
                    arCtrs[i].onblur = ___NotifyTextBox_OnBlur;
                }
            }
        }
        window.focus();
    }
    else
    {
        window.setTimeout(___WindowInit, 200);
    }
}
function ___NotifyTextBox_OnFocus()
{
    var ctr = event.srcElement;
    if (ctr.className.toLowerCase() == "notifytextboxcss" && !ctr.readOnly && !ctr.disabled)
    {
        ctr.className = "NotifyTextBoxSelectedCSS";
    }
}
function ___NotifyTextBox_OnBlur()
{
    var ctr = event.srcElement;
    if (ctr.className.toLowerCase() == "notifytextboxselectedcss" && !ctr.readOnly && !ctr.disabled)
    {
        ctr.className = "NotifyTextBoxCSS";
    }
}
//隐藏OboutCombobox因过期弹出的提示
function HiddenOboutComboboxDiv(id)
{
  var cid="ob_" + id + "TrialDiv"; 
  var boxdiv= document.getElementById(cid);
  if(boxdiv!=null && boxdiv!="undefined")
  {
    boxdiv.style.display="none";
  }

}
window.onload = ___WindowInit; 

