// JavaScript Document
function HMRolling()
{
this.version = "mummy 2007.8";
this.name = "mummy";
this.HeaderText = "";
this.FooterText = "";
this.item = new Array();
this.itemcount = 0;
this.mitem = new Array();
this.mitemcount = 0;
this.curmitemidx = 0;
this.itemdivision = 5;
this.AutoRepli = true;
this.AutoRolling = true;
this.ContentType = "full";
this.currentspeed = 0;
this.scrollspeed = 1000;
this.pausedelay = 1000;
this.pausemouseover = false;
this.stop = false;
this.add = function()
{
var text = arguments[0];
this.item[this.itemcount] = text;
this.itemcount = this.itemcount + 1;
}
this.start = function()
{	
if(this.itemcount == "")
{
return;
}
var curitemidx = 0;	
var contents = "";
var lp; 
if(this.ContentType == "full")
{
if(this.itemcount % this.itemdivision == 0)
{
lp = parseInt(this.itemcount / this.itemdivision);
}
else
{
lp = parseInt(this.itemcount / this.itemdivision) + 1;
}
for(i = 0 ; i < lp ; i++)
{
for(j = 0 ; j < this.itemdivision ; j ++)
{

if(curitemidx >= this.itemcount)
{
if (this.AutoRepli == false)
{
break;
}
else
{
curitemidx = 0;
}
}
contents += this.item[curitemidx];
curitemidx++;				
}
this.mitem[i] = contents;
contents = ""
this.mitemcount = this.mitemcount + 1;
}
}
else
{
curitemidx = 0;
for(i = 0 ; i < this.itemcount ; i++)
{	
for(j = 0 ; j < this.itemdivision ; j ++)
{
if((i+j) < this.itemcount)
{
contents += this.item[i+j];
}
else
{						
contents += this.item[(i+j) % this.itemcount];
}
}
this.mitem[i] = contents;
contents = "";
this.mitemcount = this.mitemcount + 1;
}

}
this.display();
this.currentspeed = this.scrollspeed;
this.stop = true;
setTimeout(this.name+'.rolling()',this.currentspeed);
window.setTimeout(this.name+".stop = false", this.pausedelay);
}
this.display = function()
{
document.write('<div id="'+this.name+'" style="position:relative; overflow:hidden; " OnMouseOver="'+this.name+'.onmouseover(); " OnMouseOut="'+this.name+'.onmouseout(); ">');
document.write(this.HeaderText);
document.write(this.mitem[0]);
document.write(this.FooterText);
document.write('</div>');
}
this.rolling = function()
{
if(this.AutoRolling == false) return;

if (this.stop == false)this.next();
window.setTimeout(this.name+".rolling()",this.scrollspeed);
}
this.next = function() 
{
if(this.curmitemidx >= this.mitemcount - 1)
{
this.curmitemidx = 0;
}
else
{
this.curmitemidx++;
}
var obj = document.getElementById(this.name);
var contents = "";
contents = this.HeaderText;
contents += this.mitem[this.curmitemidx];
contents += this.FooterText;
obj.innerHTML = contents;

}
this.prev = function() 
{
if((this.curmitemidx) <= 0)
{
this.curmitemidx = this.mitemcount - 1;
}
else
{
this.curmitemidx--;
}
var obj = document.getElementById(this.name);
var contents = "";
contents = this.HeaderText;
contents += this.mitem[this.curmitemidx];
contents += this.FooterText;
obj.innerHTML = contents;
}
this.unext = function () 
{
this.onmouseover();
this.next();
window.setTimeout(this.name+".onmouseout()",this.pausedelay);
}
this.uprev = function ()
{
this.onmouseover();
this.prev();
window.setTimeout(this.name+".onmouseout()",this.pausedelay);
}
this.onmouseover = function()
{
if(this.pausemouseover) this.stop = true;
}
this.onmouseout = function()
{
if(this.pausemouseover) this.stop = false;
}
}





//================================
function check(theform,func)
{
var e=theform.elements;
for (var i=0,lngLeng = e.length;i<lngLeng;i++)
{
if (e[i].disabled) continue;
if (e[i].leixing==null) continue;
if (e[i].chulibz=='R') continue
var strValue;
strValue=e[i].value.replace(/^\s+|\s+$/,"");
e[i].value=strValue;

if (strValue==""){
if (e[i].allowNull==null){
if (e[i].chulibz=='M'){
_goError(e[i],func," 该项目不能为空!")
return false
}
continue
}
if (e[i].allowNull=='Y'){
continue
}
if (e[i].chulibz=='M'){
_goError(e[i],func," 该项目不能为空!")
return false
}
switch(e[i].leixing){
case "NVC":
case "VC":
case "C":
continue
default:
_goError(e[i],func," 该项目不能为空!")
return false
}
}// end if strValue==""
if (e[i].value.length>e[i].maxlength&&(e[i].tagName=='TEXTAREA')){
alert (e[i].parentElement.previousSibling.innerText+"长度过长应该小于 "+e[i].maxlength);
e[i].focus();
return (false);
}
switch(e[i].leixing)
{
case 'NVC':
break
case 'VC':
break
case 'I':
if (!isintstr(strValue)){
_goError(e[i],func)
return false
}
break
case 'IP':
{
var filter=/[0-5]{1,3}.[0-5]{1,3}.[0-5]{1,3}.[0-5]{1,3}/;
if (!filter.test(strValue))
{
_goError(e[i],func)
return false
}
}
break
case 'DA':
if (!isdatestr(strValue)){
_goError(e[i],func)
return false
}
//alert(e[i].value)
if (!isValidSmallDate(strValue)){
_goError(e[i],func,"日期超出了SmallDate的范围(1900-1-1 to 2079-6-6)!")
return false
}
break
case 'LDA':
//alert("HI");
if (!isdatestr_lda(strValue)){
_goError(e[i],func)
return false
}
//alert(e[i].value)
if (!isValidSmallDate(strValue)){
_goError(e[i],func,"日期超出了SmallDate的范围(1900-1-1 to 2079-6-6)!")
return false
}
break
case 'DE': //decimal
if (!isDecimal(e[i].value)){
_goError(e[i],func)
return false
}
break
case 'R':
if (!isintstr(strValue)){
_goError(e[i],func)
return false
}
break
case 'M':
if (!isMoney(e[i].value)){
_goError(e[i],func)
return false
}
break
case 'SJ':
//if (!(/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/.test(strValue))){
if (!(/^(([0-1][0-9])|([2][0-3])|[0-9]):(([0][0-9]|([1-5][0-9]|[0-9])))$/.test(strValue))){
_goError(e[i],func)
return false
}
case 'DASJ':
if (!isDASJ(e[i].value)){
_goError(e[i].value,func)
return false
}
case 'LLDA':
if (!isLLDA(e[i].value)){
_goError(e[i],func)
return false
}
break
case 'Y':
break
case 'YM':
break
}//end switch
}//end for
return true
}
function _goError(e,func,s){
if (s!=null) alert(e.parentElement.previousSibling.innerText+s)
else alert(e.parentElement.previousSibling.innerText+" 类型错误!");
if (func!=null) {
func(e)
}
else{
//alert (e.type)
e.focus();
//e.select();
}
}
function _selItem(item1,item2)
{
var option1 = document.all(item1).options
var option2 = document.all(item2).options

var arrText = new Array();
var arrValue = new Array();
var j;
j = 0;
for(var i=option1.length-1;i>=0;i--)
{
if (option1(i).selected)
{
arrText[j]=option1(i).text;
arrValue[j]=option1(i).value;
option1.remove(i);
j = j + 1;
}
}
for(i=arrText.length-1;i>=0;i--)
{
var oOption = document.createElement("OPTION");
option2.add(oOption);
oOption.innerText = arrText[i];
oOption.value = arrValue[i];
}
}
function _rollup(sel_item)
{
var option = document.all(sel_item).options
var value
var text
if (document.all(sel_item).options.length == 0) return false
if (document.all(sel_item).selectedIndex == 0) return false
for (var i=0;i<option.length;i++)
{
if (option(i).selected)
{
value = option(i-1).value
text = option(i-1).innerText
option(i-1).value = option(i).value
option(i-1).innerText = option(i).innerText
option(i).value = value
option(i).innerText = text
option(i-1).selected=true
option(i).selected=false
}
}
}
function _rolldown(sel_item)
{
var option = document.all(sel_item).options
var value
var text
if (document.all(sel_item).selectedIndex == option.length-1) return false
for (var i=option.length-1;i>=0;i--)
{
if (option(i).selected)
{
if (i==(option.length-1)) return false
value = option(i+1).value
text = option(i+1).innerText
option(i+1).value = option(i).value
option(i+1).innerText = option(i).innerText
option(i).value = value
option(i).innerText = text
option(i+1).selected=true
option(i).selected=false
}
}
}

function formatInt(value)
{
if (value<10)
{
return '0'+value
}
else
{
return ''+value
}
}
function getDateFormat10(d)
{
if (d=="") return ''
var arrDa
arrDa = d.split("-")
var s
s = formatInt(arrDa[0])+'-'+formatInt(arrDa[1])+'-'+formatInt(arrDa[2])
return s

}
function checkAllItemsISNull(thisform) {
var e=theform.elements;
var flag = 0;
for (var i=0,lngLeng = e.length;i<lngLeng;i++)
{
if (e[i].type=="text") {
alert(e[i].value);
if (e[i].value!="") 
flag = 1;
}
}
if (flag == 0) {
alert("error");
return false;
}
else
return true;
}
function changeHints(subject,spanid,strlen){
var l=strlength(subject.value)
if (l<=strlen) {
var templen = strlen-l
if (document.all!=null) document.all(spanid).innerHTML="<font color=blue>(可以输入"+templen+"字符)</font>"
}
else{
if (document.all!=null) {
document.all(spanid).innerHTML="<font color=red>(输入字符超出"+strlen+"字符)</font>"
}
}
return true
}
function strlength(str){
var l=str.length;
var n=l
for (var i=0;i<l;i++)
{
if (str.charCodeAt(i)<0||str.charCodeAt(i)>255) n++
}
return n
}



//显示隐藏
var tt='start';
var ii='start';
function turnit(ss,bb) {
if (ss.style.display=="none") {
if(tt!='start') tt.style.display="none";
if(ii!='start') ii.src="";
ss.style.display="";
tt=ss;
ii=bb;
bb.src="";
//ss.style.color="red"
}
else {
ss.style.display="none"; 
bb.src="";
}
}

function _delete(thisform)
{
if (confirm("危险操作,你确信删除!"))
return true;
else
return false;
}
//-------------------------------------------
function createxmlhttprequest()
{
	var xmlhttp=false;
	try
	{
		xmlhttp=new ActiveXObject('Msxm12.XMLHTTP');
	}
	catch(e)
	{
		try
		{
			xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch(e)
		{
			try
			{
				xmlhttp=new XmlHttpRequest();
			}
			catch(e)
			{
			}
		}
	 }
	return xmlhttp;
}
function checkuser()
{	
if (out_username()){
	var xmlhttp=createxmlhttprequest();
	var username=document.getElementById('mem_username');
	var chk=true;
	xmlhttp.open('get','/member/check.asp?UName='+username.value);
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
		
			if(xmlhttp.status==200)
			{
				if(xmlhttp.responseText=="false")
				{  
					chk=false;
					alert('此用户不可以注册!');
					document.getElementById('mem_username').select();
				//}
				//else
				//{	
					//alert(username+'可以注册!');
					//obj.innerHTML=obj.innerHTML+'并且该用户名可以注册';					
				}
			}
		}
	}
	xmlhttp.send(null);
	return chk;
}
}

function out_username(){
	var obj=document.getElementById("usernametext");
	var str=document.getElementById("mem_username").value;
	var chk=true;
	//alert(str);
	if (str==''|| !str.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){chk=false}
	if (chk){
		//obj.innerHTML='用户名已经输入 ';
		//obj.style.color="#72AC42";
	}else{
		alert('请使用正确邮箱做为用户名!');
		//document.getElementById('mem_username').select();
		//obj.innerHTML='请使用常用邮箱做为登录用户名';
		//obj.style.color="#ff0000";
	}
	return chk;
} 

function checkusername(){
	var obj=document.getElementById("usernametext");
	var str=document.getElementById("strusername").value;
	var chk=true;
	//alert(str);
	if (str==''|| !str.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){chk=false}
	if (chk){
		//obj.innerHTML='用户名已经输入 ';
		//obj.style.color="#72AC42";
	}else{
		alert('请使用正确邮箱做为用户名!');
		//document.getElementById('strusername').select();
		//obj.innerHTML='请使用常用邮箱做为登录用户名';
		//obj.style.color="#ff0000";
	}
	return chk;
} 

function checkemail(){
	var obj=document.getElementById("usernametext");
	var str=document.getElementById("email").value;
	var chk=true;
	//alert(str);
	if (str==''|| !str.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){chk=false}
	if (chk){
		//obj.innerHTML='用户名已经输入 ';
		//obj.style.color="#72AC42";
	}else{
		alert('请使用正确邮箱做为用户名!');
		//document.getElementById('email').select();
		//obj.innerHTML='请使用常用邮箱做为登录用户名';
		//obj.style.color="#ff0000";
	}
	return chk;
} 