﻿/******************************************************************
 制 作 人：杨彬
 用于环境：IE6.0
 技术支持：www.myweb.name
*******************************************************************/

function GetRadioValue(obj)
{
    for(i=0;i<obj.length;i++)
    {
        if(obj[i].checked)
        {
            return obj[i].value;
        }
    }
    return null;
}

/// <summary>
/// 全选，根据obj选中状态，选中其它所有同名控件
/// </summary>
/// <param name="obj">
/// 触发全选按钮的复选框控件
/// </param>
function CheckedAll(obj)
{
    // 其中obj的value是其它控件的name
    var checks = document.getElementsByName(obj.value);
    for (i=0; i<checks.length; i++)
    {
        checks[i].checked = obj.checked; 
    }
}

/// <summary>
/// 调用日历
/// </summary>
/// <param name="objInput">打开窗口的的文件名称</param>
function ShowCalendar(objInput){
	var vReturnValue = showModalDialog("../Public/DateSelect.aspx","","dialogWidth:330px;dialogHeight:220px;status:no;center:true");
	if (vReturnValue!="" && vReturnValue!=null){
		objInput.value = vReturnValue;
	}
}

function SendValue(val) 
{
    window.returnValue = val;
    window.close();
}

/// <summary>
/// 打开一个模式窗体
/// </summary>
/// <param name="srcFile">打开窗口的的文件名称</param>
/// <param name="control">回传控件的名称</param>
function GetDialogForm(srcFile, control)    
{      
    var winFeatures = "dialogHeight:400px; dialogWidth:300px;";        
    winFeatures +="status:no;scrollbars:no; resizable:yes;center:true;";
    var obj = aspnetForm;  //将form1作为默认对象传递给新窗口
    var val = window.showModalDialog(srcFile, obj, winFeatures);
    if (control == '') 
        return false;
    if (val!=null && val!='undefined') 
    {
        control.value = val;
    }  
} 

/// <summary>
/// 上传附件专用，打开一个模式窗体
/// </summary>
/// <param name="srcFile">打开窗口的的文件名称</param>
/// <param name="control">回传控件的名称</param>
function GetAttach(srcFile, control)    
{      
    var winFeatures = "dialogHeight:480px; dialogWidth:600px;";        
    winFeatures +="status:no;scrollbars:no; resizable:yes;center:true;";
    var obj = aspnetForm;  //将form1作为默认对象传递给新窗口
    var val = window.showModalDialog(srcFile, obj, winFeatures);
    if (control == '') 
        return false;
    if (val!=null && val!='undefined') 
    {
        control.value = val;
    }  
} 

/// <summary>
/// 打开一个模式窗体
/// </summary>
/// <param name="srcFile">打开窗口的的文件名称</param>
/// <param name="winFeatures">窗体的特性</param>
function GetPersonForm(srcFile, control)    
{      
    var winFeatures = "dialogHeight:480px; dialogWidth:720px;";        
    winFeatures +="status:no;center:true";
    var obj = aspnetForm;  //将form1作为默认对象传递给新窗口
    var val = window.showModalDialog(srcFile, obj, winFeatures);
    
    if (val!=null && val!='') 
    {
        control.value=val;
        window.location.href='UserRegisterOperate.aspx?OID='+val;
        //document.aspnetForm.ctl00_ContentPlaceHolderMain_HiddenFieldName.value=val;
        //document.aspnetForm.submit();
        //alert(control.value);
    }  
} 
/// <summary>
/// 打开一个模式窗体
/// </summary>
/// <param name="srcFile">打开窗口的的文件名称</param>
/// <param name="winFeatures">窗体的特性</param>
function OpenDialogForm(srcFile, winFeatures)    
{      
    if (winFeatures == null || winFeatures == '')
    {
        winFeatures = "dialogHeight:400px; dialogWidth:600px;";        
    }
    winFeatures +="status:no;scrollbars:no; resizable:yes;center:true;";
    var obj = aspnetForm;  //将form1作为默认对象传递给新窗口               
    window.showModalDialog(srcFile, obj, winFeatures);    
} 

/// <summary>
/// 从模式窗体中回送父窗体值
/// </summary>
/// <param name="obj">父窗体的控件名称</param>
/// <param name="val">值</param>
function SendDialogValue(obj, val)    
{        
    //取得父窗口传过来的对象        
    var myObj = window.dialogArguments;        
    //赋值 
    myObj[obj].value = val; 
    obj.value = val; 
    //关闭窗口        
    window.close();    
} 

/// <summary>
/// 从模式窗体中回送父窗体2个值
/// </summary>
/// <param name="obj1">父窗体的控件名称</param>
/// <param name="val1">值</param>
/// <param name="obj2">父窗体的控件名称</param>
/// <param name="val2">值</param>
function SendDialogValue2(obj1,val1,obj2,val2)    
{        
    //取得父窗口传过来的对象        
    var myObj = window.dialogArguments;        
    //赋值 
    myObj[obj1].value = val1; 
    myObj[obj2].value = val2; 
    //关闭窗口        
    window.close();    
} 
/// <summary>
/// 从模式窗体中回送父窗体2个值
/// </summary>
/// <param name="obj1">父窗体的控件名称</param>
/// <param name="val1">值</param>
/// <param name="obj2">父窗体的控件名称</param>
/// <param name="val2">值</param>
/// <param name="obj3">父窗体的控件名称</param>
/// <param name="val3">值</param>
function SendDialogValue3(obj1,val1,obj2,val2,obj3,val3)    
{        
    //取得父窗口传过来的对象        
    var myObj = window.dialogArguments;        
    //赋值 
    myObj[obj1].value = val1; 
    myObj[obj2].value = val2; 
    myObj[obj3].value = val3; 
    //关闭窗口        
    window.close();    
} 
 
var HKEY_Root,HKEY_Path,HKEY_Key; 
HKEY_Root="HKEY_CURRENT_USER"; 
HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"; 
//设置网页打印的页眉页脚为空 
function PageSetup_Null() 
{ 
    try 
    { 
        var Wsh=new ActiveXObject("WScript.Shell"); 
        HKEY_Key="header"; 
        Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); 
        HKEY_Key="footer"; 
        Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); 
    } 
    catch(e)
    {
        alert("需要手工设置页眉和页脚：\n\n建议先点击'打印设置'，那里可以去掉页眉和页脚!");
    } 
} 
//设置网页打印的页眉页脚为默认值 
function  PageSetup_Default() 
{   
    try 
    { 
        var Wsh=new ActiveXObject("WScript.Shell"); 
        HKEY_Key="header"; 
        Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&w&b页码,&p/&P"); 
        HKEY_Key="footer"; 
        Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&u&b&d"); 
    } 
    catch(e)
    {
        alert(e);
    } 
} 
function CheckFormClose()
{
    //if (document.getElementById('ctl00_ContentPlaceHolderMain_ChineseName').value!='')
    //{
        //alert('您将关闭本页');
        window.event.returnValue='您将关闭本页么？';
    //}
    //return true;
}

function Resize(frame)
{
    parent.document.all("frame").style.height=document.body.scrollHeight;
}


//积分抽奖
function lotto(){
if (!document.all&&!document.layers)
return
for (j=1; j <16; j++)//stop zero!?
 {
 var a=Math.round(Math.random()*j+1);
 var b=Math.round(Math.random()*j+1);
 var c=Math.round(Math.random()*j+1);
 var d=Math.round(Math.random()*j+1);
 var e=Math.round(Math.random()*j+1);
 var f=Math.round(Math.random()*j+1);
 }
var x=new Array(a,b,c,d,e,f);
if ((x[0] == x[1]) || (x[0] == x[2]) || (x[0] == x[3]) || (x[0] == x[3]) || (x[0] == x[5]) ||
    (x[1] == x[2]) || (x[1] == x[3]) || (x[1] == x[4]) || (x[1] == x[5]) || 
    (x[2] == x[3]) || (x[2] == x[4]) || (x[2] == x[5]) ||                        
    (x[3] == x[4]) || (x[3] == x[5]) ||
    (x[4] == x[5]) || (x[5] == x[4]))
lotto();//restart 
else
 {
 var y=x.toString();
 var z=y.split(',');
 for (i=0; i < z.length; i++)
 {
 z[i]=z[i]+" ";
 if (z[i].length < 3)//add '0' to singles  
 z[i]="0"+z[i]+" ";
 }
 z=z.sort();
 Nos=z[0]+z[1]+z[2]+z[3]+z[4]+z[5];
  if (document.all)
  {document.all.layer1.innerHTML=Nos;}//OR Z!
  else if (document.layers)
  {
  document.layers.layer1.document.open();
  document.layers.layer1.document.write("<span style='position:absolute;top:0px;left:0px;font-family:Verdana;font-size:20px;color:#888888;text-align:center'> "+Nos+"</span>");
  document.layers.layer1.document.close();  

  }
  T=setTimeout('lotto()',50);
  document.getElementById("ctl00$ContentPlaceHolderMain$hideValue").value = Nos; 
 }
}

//文字闪烁

var divs = new Array();
var da = document.all;
var start;

//CONFIGUER THESE VARS!!!!!!
//speed of pulsing
var speed = 300;

function initVars(){

if (!document.all)
return

addDiv(message,"purple",2,4)
addDiv(message1,"blue",1,3)
//NO MORE EDITING!!!!!!



startGlow();
}
function initVars2(){

if (!document.all)
return

addDiv(message1,"blue",1,3)
//NO MORE EDITING!!!!!!



startGlow();
}
function addDiv(id,color,min,max)
{
var j = divs.length;
divs[j] = new Array(5);
divs[j][0] = id;
divs[j][1] = color;
divs[j][2] = min;
divs[j][3] = max;
divs[j][4] = true;
}

function startGlow()
{
	if (!document.all)
		return 0;

	for(var i=0;i<divs.length;i++)
	{
		divs[i][0].style.filter = "Glow(Color=" + divs[i][1] + ", Strength=" + divs[i][2] + ")";
		divs[i][0].style.width = "100%";
	}

	start = setInterval('update()',speed);
}

function update()
{
	for (var i=0;i<divs.length;i++)
	{
		if (divs[i][4])
		{
			divs[i][0].filters.Glow.Strength++;
			if (divs[i][0].filters.Glow.Strength == divs[i][3])
				divs[i][4] = false;
		}
	
		if (!divs[i][4])
		{
			divs[i][0].filters.Glow.Strength--;
			if (divs[i][0].filters.Glow.Strength == divs[i][2])
				divs[i][4] = true;
		}
	}
}


//文字循环滚动
function ScrollText(content,btnPrevious,btnNext,autoStart)
{
    this.Delay = 10;
    this.LineHeight = 20;
	this.Amount = 1;//注意:LineHeight一定要能整除Amount.
	this.Direction = "up";
    this.Timeout = 1500;
    this.ScrollContent = this.$(content);
    this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;
    //this.ScrollContent.scrollTop = 0;
    if(btnNext)
    {
        this.NextButton = this.$(btnNext);
        this.NextButton.onclick = this.GetFunction(this,"Next");
        this.NextButton.onmouseover = this.GetFunction(this,"Stop");
        this.NextButton.onmouseout = this.GetFunction(this,"Start");
    }
    if(btnPrevious)
    {
        this.PreviousButton = this.$(btnPrevious);
        this.PreviousButton.onclick = this.GetFunction(this,"Previous");
        this.PreviousButton.onmouseover = this.GetFunction(this,"Stop");
        this.PreviousButton.onmouseout = this.GetFunction(this,"Start");
    }
    this.ScrollContent.onmouseover = this.GetFunction(this,"Stop");
    this.ScrollContent.onmouseout = this.GetFunction(this,"Start");
    if(autoStart)
    {
        this.Start();
    }
}

ScrollText.prototype.$ = function(element)
{
    return document.getElementById(element);
}

ScrollText.prototype.Previous = function()
{
    clearTimeout(this.AutoScrollTimer);
    clearTimeout(this.ScrollTimer);
    this.Scroll("up");
}

ScrollText.prototype.Next = function()
{
    clearTimeout(this.AutoScrollTimer);
    clearTimeout(this.ScrollTimer);
    this.Scroll("down");
}

ScrollText.prototype.Start = function()
{
    clearTimeout(this.AutoScrollTimer);
    this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout);
}

ScrollText.prototype.Stop = function()
{
    clearTimeout(this.ScrollTimer);
    clearTimeout(this.AutoScrollTimer);
}

ScrollText.prototype.AutoScroll = function()
{
    if(this.Direction == "up")
    {
        if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
        {
            this.ScrollContent.scrollTop = 0;
        }
        this.ScrollContent.scrollTop += this.Amount;
    }
    else
    {
        if(parseInt(this.ScrollContent.scrollTop) <= 0)
        {
            this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
        }
        this.ScrollContent.scrollTop -= this.Amount;
    }
    if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0)
    {
        this.ScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Delay);
    }
    else
    {
        this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout);
    }
}

ScrollText.prototype.Scroll = function(direction)
{
    if(direction=="up")
    {
        if(this.ScrollContent.scrollTop == 0)
        {
            this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
        }
        this.ScrollContent.scrollTop -= this.Amount;
    }
    else
    {
        this.ScrollContent.scrollTop += this.Amount;
    }
    if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
        {
            this.ScrollContent.scrollTop = 0;
        }
    if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0)
    {
        this.ScrollTimer = setTimeout(this.GetFunction(this,"Scroll",direction), this.Delay);
    }
}

ScrollText.prototype.GetFunction = function(variable,method,param)
{
    return function()
    {
        variable[method](param);
    }
}

function addFav()
{ 
    window.external.AddFavorite(document.location.href,document.title);
   
}

function addHome()
{
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage('http://www.myweb.name/');
}

