﻿/*------------------------------------------------------------
  视频播放框显示
  隐藏视频播放框：HideVideoBox（ControlID）
  ------------------------------------------------------------*/
function ShowVideoBox(ControlID,FrameName,Type,PkUrl)
{
    document.getElementById("imgFull").style.display = "";
    document.getElementById("imgSmall").style.display = "none";   
    var varhref ="ShowVideoBox.aspx?Test=1";
    if (Type.length > 0 )
    varhref  = varhref + "&action="+  Type ;
    if (PkUrl.length > 0 )
    varhref  = varhref + "&pkurl="+  PkUrl ;
    window.frames[FrameName].location.href = varhref;
    document.getElementById(ControlID).style.display = "";
    document.getElementById("Estop").style.display = "";    
    document.getElementById(ControlID).style.left = screen.width/2-200 + "px";
    document.getElementById(ControlID).style.top = (screen.height/2-300 + document.documentElement.scrollTop)  + "px";
    document.getElementById(FrameName).width = "358px";
    document.getElementById(FrameName).height = "322px";
}
/*------------------------------------------------------------
  视频播放框隐藏
  显示视频播放框：ShowVideoBox(ControlID,FrameName,FrameURL)
  ------------------------------------------------------------*/
function HideVideoBox(ControlID,FrameName)
{
    document.getElementById(ControlID).style.display = "none";
    document.getElementById("Estop").style.display = "none";
    window.frames[FrameName].location.href = "WaitBehind.aspx";
}
/*------------------------------------------------------------
  视频全屏播放
  隐藏视频播放框：HideVideoBox（ControlID）
  显示视频播放框：ShowVideoBox(ControlID,FrameName,FrameURL)
  ------------------------------------------------------------*/
function showFullVideo(ControlID)
{   
   var vartitle = ControlID.title;
   if(vartitle == 'flv')
   {
       window.frames['myiframe'].location.href = 'ShowFullVideo.aspx';
       document.getElementById("divVideo").style.display = "";
       document.getElementById("Estop").style.display = "";       
       document.getElementById("myiframe").width = "602px";
       document.getElementById("myiframe").height = "502px";
       document.getElementById("divVideo").style.left = screen.width/2-300 + "px";
       document.getElementById("divVideo").style.top = (screen.height/2-350 + document.documentElement.scrollTop)  + "px";
       document.getElementById("imgFull").style.display = "none";
       document.getElementById("imgSmall").style.display = "";                
   }
   else
   {
        ControlID.displaysize=3;//MediaPlayer全屏
   }
}

/*------------------------------------------------------------
  自定义内容对话框显示
  隐藏对话框：HideDLG（ControlID）
  ------------------------------------------------------------*/
function ShowDialog(ControlID)
{
    var width = document.getElementById(ControlID).style.width; 
    var height = document.getElementById(ControlID).style.height;
    width = width.substr(0,width.length - 2);
    height = height.substr(0,height.length - 2);
    document.getElementById(ControlID).style.left=((screen.width-width)/2) + "px";
    document.getElementById(ControlID).style.top=(screen.height/2-200) + "px";
    //document.getElementById(ControlID).style.top=screen.height/2-0;
    ShowDLG(ControlID);
}

/*------------------------------------------------------------
  文本提示内容对话框显示
  隐藏对话框：HideDLG（ControlID）
  ------------------------------------------------------------*/
function ShowMessage(ControlID,strMessage)
{
    document.getElementById(ControlID).style.left=screen.width/2-100 + "px";
    document.getElementById(ControlID).style.top=(screen.height/2-200 + document.documentElement.scrollTop)  + "px";
    document.getElementById("DialogMessage").innerHTML=strMessage;
    ShowDLG(ControlID);
}
/*------------------------------------------------------------
    显示带遮罩的对话框
-/**//*------------------------------------------------------------
增加一个半透明的遮罩
注:（宽高为自适应屏幕）  HidShieldDiv(隐藏)
-----------------------------------------------------------------*/

function ShowShieldDiv(ControlID,strMessage)
{
    ShowMessage(ControlID,strMessage);
    window.setTimeout("addDivControl()",50);
}


function addDivControl()
{
     if( document.getElementById("shieldDiv"))
        {
              document.getElementById("shieldDiv").style.display="";  
        }
        else
        {
            var shield = document.createElement("DIV");
                shield.id = "shieldDiv";
                shield.style.position = "absolute";
                shield.style.left = "0px";
                shield.style.top = "0px";
                shield.style.width = "100%";
                shield.style.height = ((document.documentElement.clientHeight>document.documentElement.scrollHeight)?document.documentElement.clientHeight:document.documentElement.scrollHeight)+"px";
                shield.style.background = "#000000";
                shield.style.textAlign = "center";
                shield.style.zIndex =  "999";
                if (document.all)
                {
                    shield.style.filter = "alpha(opacity=20)";
                }
                else
                {
                    shield.style.opacity =  0.20;
                }
              document.body.appendChild(shield);
         }
    
}
/*------------------------------------------------------------
隐藏遮罩对话框

-----------------------------------------------------------------*/
function HidShieldDiv(ControlID)
{
     if ( document.getElementById("shieldDiv"))
      {
         document.getElementById("shieldDiv").style.display="none"; 
      }
      HideDLG(ControlID);
}

 
 



/*------------------------------------------------------------
  文本提示内容对话框显示
-------------------------------------------------------------*/
function ShowMessage1(strMessage)
{
    alert(strMessage);
    
    
    
}

/*------------------------------------------------------------
  验证输入的是否为数字
 使用例子onBlur="CheckIfNumerical(this)" 
  ------------------------------------------------------------*/
function CheckIfNumerical(TextID)
{
	//var searchStr = /^(\-)?(0|[1-9](\d)*)(\.(\d)+)?$/    //这是判断是否为浮点型数字
	var searchStr = /^(\-)?(0|[1-9](\d)*)$/  //这是判断是否为整型数字

	if( !searchStr.test(document.getElementById(TextID).value) )
	{
		if(""==document.getElementById(TextID).value)
		{}
		else
		{
			document.getElementById(TextID).value="";
			alert("必须是数字!");
			document.getElementById(TextID).focus();
			return;
		}
	}
}


/*------------------------------------------------------------
  验证输入的是否为浮点数,百分制，保留两位小数
 使用例子onBlur="CheckIffloat(this)" 
  ------------------------------------------------------------*/
function CheckIffloat(txtValue)
{
	var searchStr = /^[0-9]{1,}(|.[0-9]{1,2})$/    //这是判断是否为浮点型数字，保留两位小数

	if (!searchStr.test(txtValue))
		return false;
	else
	    return true;
}

/*------------------------------------------------------------
  验证身份证号码
 使用例子onBlur="CheckIfidCard(this)" 
  ------------------------------------------------------------*/
function CheckIfidCard(TextID)
{
	//var searchStr = /^(\-)?(0|[1-9](\d)*)(\.(\d)+)?$/    //这是判断是否为浮点型数字
	var searchStr = /^(\d{15}|\d{17}[\dXx])$/  //这是判断是否为整型数字

	if( !searchStr.test(TextID.value) )
	{
		if(""==TextID.value)
		{}
		else
		{
			TextID.value="";
			alert("身份证号码错误!");
			return;
		}
	}
}

/*------------------------------------------------------------
  验证电话号码
 使用例子onBlur="CheckTelephone(this)" 
  ------------------------------------------------------------*/
function CheckTelephone(TextID)
{
	//var searchStr = /(?<GP1>((\(|（)0([0-9]|[１-８]){2,3}(\)|）))|(0([0-9]|[１-８]){2,3})(\-)?)(?<GP2>([0-9]|[１-８]){7,8})/
	var searchStr = /(^\d{3,4}-\d{7,8}$)|(^13\d{9}$)/
	if( !searchStr.test(TextID.value) )
	{
		if(""==TextID.value)
		{}
		else
		{
			TextID.value = "";
			alert("电话号码格式错误，格式应为：010-12345678");
		}
	}
}

/*------------------------------------------------------------
 验证手机号码
 使用例子onBlur="CheckMobile(this)" 
  ------------------------------------------------------------*/
function CheckMobile(TextID)
{
	var searchStr = /^13[0123456789]{1}\d{8}$/
	if( !searchStr.test(TextID.value) )
	{
		if(""==TextID.value)
		{}
		else
		{
			TextID.value = "";
			alert("手机号码格式错误，格式应为：13512345678");
		}
	}
}

/*------------------------------------------------------------
 验证邮政编码
 使用例子onBlur="CheckPostcode(this)" 
  ------------------------------------------------------------*/
function CheckPostcode(TextID)
{
	var searchStr = /\d{6}/
	if( !searchStr.test(TextID.value) )
	{
		if(""==TextID.value)
		{}
		else
		{
			TextID.value = "";
			alert("邮编错误，格式应为：515063");
		}
	}
}
/*------------------------------------------------------------
 判断输入的是否为电子邮件，如含非法字符则提示
 text-------输入的电子邮件
 使用例子onBlur="IsEmail(this)" 
  ------------------------------------------------------------*/
function IsEmail(text)
{   
 var email=text.value.Trim();
 var m=email.indexOf("@");
 var n=email.indexOf(".");
 if(email!="")
 {
  if(m<1||m>email.length-3)
  {
   alert("请输入正确的电子邮件格式!");
   text.focus();
   return false;
  }
  else if(n<m+2||n>email.length-2)
  {
   alert("请输入正确的电子邮件格式!");
   text.focus();
   return false;
  }
 }
}

/**//*------------------------------------------------------------
 Trim()去左右空格
  ------------------------------------------------------------*/

String.prototype.Trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.LTrim = function()
{
    return this.replace(/(^\s*)/g, "");
}
String.prototype.Rtrim = function()
{
    return this.replace(/(\s*$)/g, "");
}






/**//*------------------------------------------------------------
 两个时间进行比较，当开始日期大于结束日期则提示
 startDate----开始日期
 endDate------结束日期
 使用例子onClick="CompareTwoDate(startDate,endDate,'开始日期不能大于结束日期!')" 
  ------------------------------------------------------------*/
function CompareTwoDate(startDate,endDate,s)
{
var a=startDate.value;
var b=endDate.value;
if(((Number(a.substring(0,4))-Number(b.substring(0,4)))*356+
       (Number(a.substring(5,7))-Number(b.substring(5,7)))*31+
    (Number(a.substring(8,10))-Number(b.substring(8,10))))>0)
 {
  alert(s);
  startDate.focus();
 }
}

/**//*------------------------------------------------------------
 两个时间进行比较，当开始日期大于结束日期则提示
 startDate----开始日期
 endDate------结束日期
 使用例子 return CompareTwoDate(startDate,endDate)" 
  ------------------------------------------------------------*/
function CompareDate(startDate,endDate)
{
    var a = startDate;
    var b = endDate;
    if(((Number(a.substring(0,4))-Number(b.substring(0,4)))*356+
    (Number(a.substring(5,7))-Number(b.substring(5,7)))*31+
    (Number(a.substring(8,10))-Number(b.substring(8,10))))>0)
    {
        return false;
    }
    else
    {
        return true;
    }
}
