﻿function showFileModalDialog(userid,headid)
{
    var username = document.getElementById(userid).value;
    var zheng = /^[a-zA-Z_0-9]{5,18}$/;
    if(username == "")
    {
        alert("用户名不能为空");
    }
    else if(!zheng.test(username))
    {
        alert("用户名不合规范!");
    }
    else
    {
	    var retvalue =showModalDialog("/templates/default/ShowPic.aspx?username="+username, "", "font-family:Verdana; font-size:12; status:no;resizable:yes;help:no;dialogWidth:500px;dialogHeight:470px");
	    if (retvalue != null)
	    {
		    document.getElementById(headid).value=retvalue;
	    }
	}
}


function usernamefocus()
{
    document.getElementById("user_li").innerText="(5-18位英文数字)";
}
function usernameblur()
{
    var zheng = /^[a-zA-Z_0-9]{5,18}$/;
    var text_username = document.getElementById("Register1_TextBox_username").value;
    if(text_username == "")
    {
       document.getElementById("user_li").innerHTML="<font color=#FF0000>用户名不能为空</font>";
    }
    else if(!zheng.test(text_username))
    {
       document.getElementById("user_li").innerHTML="<font color=#FF0000>用户名不合规范</font>";
    }
    else
    {
       try
       {
          XmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
       }
       catch(e)
       {}
   
       XmlHttp.onreadystatechange=ok_user;
       XmlHttp.open("GET","../ashx/users.aspx?username="+text_username,true);
       XmlHttp.send(null);
    }
      
}
function ok_user()
{
  if(XmlHttp.readyState == 4)
  {
     if(XmlHttp.status == 200)
     {
           if(XmlHttp.responseText == "1")
           {
             document.getElementById("user_li").innerHTML="<font color=#FF0000>用户名已经存在</font>";
           }
           else
           {
             document.getElementById("user_li").innerHTML="用户名通过验证";
           }
     }
     else
     {
        document.getElementById("user_li").innerHTML="font color=#FF0000>访问异常!</font>";
     }
  }
}


function IMG_code_onclick() 
{
    document.getElementById("IMG_code").src = "../auth_code/yanzheng.aspx?"+Math.random();
}

function regyanzheng()
{
    var zheng = /^[a-zA-Z_0-9]{5,18}$/;
    var zhengmail = new RegExp(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/g);

    var username = document.getElementById("Register1_TextBox_username").value;
    var password = document.getElementById("Register1_TextBox_password").value;
    var secdword = document.getElementById("Register1_TextBox_second").value;
    var nickname = document.getElementById("Register1_TextBox_nick").value;
    var usqqcode = document.getElementById("Register1_TextBox_qq").value;
    var usermail = document.getElementById("Register1_TextBox_mail").value;
    var yanzheng = document.getElementById("Register1_TextBox_code").value;

    if(!zheng.test(username))
    {
        alert("用户名不合规范!");
        return false;
    }
    else if(!zheng.test(password))
    {
        alert("密码不合规范!");
        return false;
    }
    else if(secdword != password)
    {
        alert("两次密码输入不一致!");
        return false;
    }
    else if(nickname == "")
    {
        alert("昵称不能为空!");
        return false;
    }
    else if(usqqcode == "")
    {
        alert("QQ号码不能为空");
        return false;
    }
    else if(!zhengmail.test(usermail))
    {
        alert("电子邮箱格式不正确，正例：xiaoli@126.com");
        return false;
    }
    else if(yanzheng == "")
    {
        alert("请输入验证码");
        return false;
    }
    else
        return true;
}

function loginzheng()
{
    var zheng = /^[a-zA-Z_0-9]{5,18}$/;
    var username = document.getElementById("Login1_TextBox_username").value;
    var password = document.getElementById("Login1_TextBox_password").value;
    var yanzheng = document.getElementById("Login1_TextBox_code").value;

    if(!zheng.test(username))
    {
        alert("用户名不合规范!");
        return false;
    }
    else if(!zheng.test(password))
    {
        alert("密码不合规范!");
        return false;
    }
    else if(yanzheng == "")
    {
        alert("请输入验证码");
        return false;
    }
    else
        return true;
}


function gpzheng()
{
    var zheng = /^[a-zA-Z_0-9]{5,18}$/;
    var zhengmail = new RegExp(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/g);
    var username = document.getElementById("Getpass1_TextBox_username").value;
    var usermail = document.getElementById("Getpass1_TextBox_mail").value;
    var password = document.getElementById("Getpass1_TextBox_newpass").value;
    var secdword = document.getElementById("Getpass1_TextBox_secpass").value;
    var yanzheng = document.getElementById("Getpass1_TextBox_code").value;
    
    if(!zheng.test(username))
    {
        alert("用户名不合规范!");
        return false;
    }
    else if(!zhengmail.test(usermail))
    {
        alert("电子邮箱格式不正确，正例：xiaoli@126.com");
        return false;
    }
    else if(!zheng.test(password))
    {
        alert("密码不合规范!");
        return false;
    }
    else if(secdword != password)
    {
        alert("两次密码输入不一致!");
        return false;
    }
    else if(yanzheng == "")
    {
        alert("请输入验证码");
        return false;
    }
    else
        return true;
}


function contribute()
{
    var title = document.getElementById("Contribute1_TextBox_title").value;
    var keyword = document.getElementById("Contribute1_TextBox_keyword").value;
    var author = document.getElementById("Contribute1_TextBox_auth").value;
    var yancode = document.getElementById("Contribute1_TextBox_code").value;
 
    if(title == "")
    {
        alert("文章标题不能为空!");
        return false;
    }
    else if(keyword == "")
    {
        alert("文章关键字!");
        return false;
    }
    else if(author == "")
    {
        alert("文章作者不能为空");
        return false;
    }
    else if(yancode == "")
    {
        alert("请输入验证码");
        return false;
    }
    else
        return true;
}


function comeclub(club_id,nick_name,web_mode)
{
    window.location.href="/ashx/ComeClub.aspx?club_id="+club_id+"&nick_name="+nick_name+"&web_mode="+web_mode;
}


function nick_qq()
{
    var nick_name = document.getElementById("PersonManage1_TextBox_nick").value;
    var qq_code = document.getElementById("PersonManage1_TextBox_qq").value;
 
    if(nick_name == "")
    {
        alert("昵称不能为空!");
        return false;
    }
    else if(qq_code == "")
    {
        alert("QQ号码不能为空");
        return false;
    }
    else
        return true;
}

function passupda()
{
    var zheng = /^[a-zA-Z_0-9]{5,18}$/;
    var password = document.getElementById("PersonManage1_TextBox_password").value;
    var secdword = document.getElementById("PersonManage1_TextBox_newpass").value;
    
    if(!zheng.test(password))
    {
        alert("新密码不合规范!");
        return false;
    }
    else if(secdword != password)
    {
        alert("两次密码输入不一致!");
        return false;
    }
    else
        return true;
}


function outclub()
{
    if(confirm("确定退出吗?"))
    {
        return true;
    }
    else
        return false;
}




function clubnickfocus()
{
    document.getElementById("user_li").innerText="(2-10位英文数字)";
}
function clubnickblur()
{
    var zheng = /^[a-zA-Z_0-9]{2,10}$/;
    var club_nick = document.getElementById("CreateClub1_TextBox_nick").value;
    if(!zheng.test(club_nick))
    {
       document.getElementById("user_li").innerHTML="<font color=#FF0000>家族地址不合规范</font>";
    }
    else
    {
       try
       {
          XmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
       }
       catch(e)
       {}
   
       XmlHttp.onreadystatechange=return_nick;
       XmlHttp.open("GET","../ashx/creclub.aspx?club_nick="+club_nick,true);
       XmlHttp.send(null);
    }   
}

function return_nick()
{
  if(XmlHttp.readyState == 4)
  {
     if(XmlHttp.status == 200)
     {
           if(XmlHttp.responseText == "1")
           {
             document.getElementById("user_li").innerHTML="<font color=#FF0000>该地址已经存在</font>";
           }
           else
           {
             document.getElementById("user_li").innerHTML="家族地址通过验证";
           }
     }
     else
     {
        document.getElementById("user_li").innerHTML="font color=#FF0000>访问异常!</font>";
     }
  }
}


function clubcreat()
{
    var zheng = /^[a-zA-Z_0-9]{2,10}$/;

    var cluburl = document.getElementById("CreateClub1_TextBox_nick").value;
    var clubname = document.getElementById("CreateClub1_TextBox_name").value;
    var clubgame = document.getElementById("CreateClub1_TextBox_game").value;
    var clubtips = document.getElementById("CreateClub1_TextBox_tips").value;
    var clubdesp = document.getElementById("CreateClub1_TextBox_des").value;
    var clubcode = document.getElementById("CreateClub1_TextBox_code").value;

    if(!zheng.test(cluburl))
    {
        alert("家族地址不合规范");
        return false;
    }
    else if(clubname == "")
    {
        alert("家族名称不能为空!");
        return false;
    }
    else if(clubgame == "")
    {
        alert("家族所在游戏不能为空");
        return false;
    }
    else if(clubtips == "")
    {
        alert("家族宣言不能为空");
        return false;
    }
    else if(clubdesp == "")
    {
        alert("家族说明不能为空");
        return false;
    }
    else if(clubcode == "")
    {
        alert("请输入验证码");
        return false;
    }
    else
        return true;
}


function clubmusicadd()
{
    if(document.getElementById("ClubManage_Music1_TextBox_name").value == "")
    {
        alert("歌曲名称不能为空");
        return false;
    }
    else if(document.getElementById("ClubManage_Music1_TextBox_url").value =="")
    {
        alert("歌曲地址不能为空!");
        return false;
    }
    else
        return true;
}

function musicdel()
{
    if(confirm("确定删除吗"))
    {
        return true;
    }
    else
        return false;
}


function LMsg()
{
    if(document.getElementById("LeaveMsg1_TextBox_msg").value == "")
    {
        alert("留言内容不能为空");
        return false;
    }
    else if(document.getElementById("LeaveMsg1_TextBox_code").value =="")
    {
        alert("验证码不能为空");
        return false;
    }
    else
        return true;
}


function checkLength(which,maxChars) 
{ 
    if (which.value.length > maxChars) 
    {
        alert("您出入的字数超多限制!");
        which.value = which.value.substring(0,maxChars); 
        return false;
    }
} 


function divshow()
{
    var url = window.location.href;
    if(url.substring(url.length-3,url.length) == "htm")
    {
        window.location.href="/iSpeakList.aspx";
    }
    else
    {
        if(document.getElementById("div_ispeak").style.display == "none")
        {
            document.getElementById("div_ispeak").style.display = "block";
        }
        else
        {
            document.getElementById("div_ispeak").style.display = "none";
        }
    }
}

function ispeaksubmit()
{
    var strname = document.getElementById("ISpeakList1_Text_name").value;
    var strid = document.getElementById("ISpeakList1_Text_id").value;
    var strcode = document.getElementById("ISpeakList1_Text_code").value;
    if(strname == "")
    {
        alert("公会名称不能为空");
        return false;
    }
    else if(strid == "")
    {
        alert("频道ID不能为空");
        return false;
    }
    else if(strcode == "" || strcode.length != 5)
    {
        alert("验证码不正确");
        return false;
    }
    else
        return true;
}


function SiteSearch()
{
    var strfild = null;
    if(document.getElementById("Radio1").checked==true)
    {
        strfild = "0";
    }
    else if(document.getElementById("Radio2").checked==true)
    {
        strfild = "1";
    }
    else if(document.getElementById("Radio3").checked==true)
    {
        strfild = "2";
    }
    
    var strkey = document.getElementById("Text_key").value;
    window.location.href="/ashx/SearchFile.aspx?fild="+strfild+"&keyword="+strkey;
}


function txtCheck()
{
	var name1=document.getElementById("Name1");
	var con1=document.getElementById("Content1");
	var code1=document.getElementById("Text_code");

	if(name1.value=="")
	{
		alert("评论人不能为空");
		return false;
	}

	if(con1.value=="")
	{
		alert("评论内容不能为空");
		return false;
	}
	
	if(code1.value== "")
	{
	    alert("验证码不能为空");
		return false;
	}
	
	return true;
}	
function txtsubmit(form1)
{
	if(!txtCheck())
	{
		return false;
	}
	
	form1.method="post";
	form1.target="_parent";
	form1.action="/ashx/RemarkOk.aspx";
	form1.submit();
}


function __i1()
{
	if(window.ActiveXObject)
	{
		try
		{
			var xmlhttp=new ActiveXObject('ISACTIVEX.ISActiveXCtrl.1');
			return true;
		}
		catch(e)
		{
			return false;
		}
	}
	else
	{
		return true;
	}
};

function __run(id)
{
	if(__i1())
	{
		location.href='iSpeakto:'+id
	}
	else
	{
		window.open('http://help.ipark.cn/iSpeakto.asp?roomid='+id+'&sid=');
	}
}



function ClubVote(flag)
{
document.clubform.innerHTML+='<INPUT id="cid" name="cid" type="hidden" value="'+flag+'">';
document.clubform.method="post";
document.clubform.target="_self";
document.clubform.action="/ashx/ClubVote.aspx";
document.clubform.submit();
}


function UploadMusicDialog(t)
{
	var retvalue =showModalDialog("/templates/default/ShowMusic.aspx", "", "font-family:Verdana; font-size:12; status:no;resizable:yes;help:no;dialogWidth:500px;dialogHeight:470px");
	if (retvalue != null)
	{
		document.getElementById(t).value=retvalue;
	}
}
