﻿function OMOver(OMO){OMO.style.backgroundColor='#fffacd';}
function OMOut(OMO){OMO.style.backgroundColor='';}

function do_login(type,webid){
	if (type == "logout")
	{
		if (confirm('確定要登出嗎??')) {			
			fm1.type.value = type;
			fm1.method = "POST";
			fm1.action = "login.php?webid="+webid;
			fm1.submit();
			return false;
		}
	}
else if (type == "login")
{
	if ( document.fm1.username.value == "" ) {
    		alert ("請填入您的帳號");
    		document.fm1.username.focus();
    		return false;
  	}
  	if ( document.fm1.password.value == "" ) {
    		alert ("請填入您的密碼");
    		document.fm1.password.focus();
    		return false;
  	}
	fm1.type.value = type;
	fm1.action = "login.php?webid="+webid;
	fm1.method = "POST";
	fm1.submit();
	return false;
}
}



function do_nickname(type,id){
	if(document.fm1.nickname.value.match(/_/)){
   		alert("暱稱不能有「_」，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	if ( document.fm1.nickname.value.length > 8 ) {
    		alert ("暱稱不能超過8個字！");
    		document.fm1.nickname.focus();
    		return false;
  	}
  	if(document.fm1.nickname.value.match(/ /)){
   		alert("暱稱不能有空白，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	
   	if(document.fm1.nickname.value.match(/Guest/)){
   		alert("暱稱不能有Guest，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
	
	fm1.type.value = type;
	fm1.id.value = id;
	fm1.method = "POST";
	fm1.submit();
	return false;
	
		
}



function do_chat(oid,webid){
		
	fm2.oid.value = oid;
	fm2.method = "POST";
	fm2.action = "chat.php?webid="+webid;
	fm2.submit();
	return false;
}

function do_reg(webid){
	
	if ( document.fm1.reg_user.value.length > 12 || document.fm1.reg_user.value.length < 6) {
    		alert ("帳號長度不能超過12個字或少於6個字！");
    		document.fm1.reg_user.focus();
    		return false;
  	}
  	
   	if(document.fm1.reg_user.value.match(/\W/)){
	   		alert("帳號不能含有非字母或數字的字元，請重新輸入")
	   		document.fm1.reg_user.focus()
	   		return false; 
	  }
  	if ( document.fm1.reg_pw.value.length > 12 || document.fm1.reg_pw.value.length < 6) {
    		alert ("密碼長度不能超過12個字或少於6個字！");
    		document.fm1.reg_pw.focus();
    		return false;
  	}
  	if ( document.fm1.reg_pw.value != document.fm1.reg_re_pw.value ) {
    		alert ("您的確認密碼不符");
    		document.fm1.reg_re_pw.focus();
    		return false;
  	}
  	if ( document.fm1.reg_nick.value.length > 8) {
    		alert ("暱稱長度不能超過8個字！");
    		document.fm1.reg_nick.focus();
    		return false;
  	}
  	if (fm1.reg_nick.value == "")
	{
		alert ("請填入您的暱稱");
    		document.fm1.reg_nick.focus();
    		return false;
	}
  	if(document.fm1.reg_nick.value.match(/ /)){
   		alert("暱稱不能有空白，請重新輸入")
   		document.fm1.reg_nick.focus()
   		return false; 
   	}
   	if(document.fm1.reg_nick.value.match(/_/)){
   		alert("暱稱不能有「_」，請重新輸入")
   		document.fm1.reg_nick.focus()
   		return false; 
   	}
   	if(document.fm1.reg_nick.value.match(/\"/)){
   		alert("暱稱不能有「\"」，請重新輸入")
   		document.fm1.reg_nick.focus()
   		return false; 
   	}
   	if(document.fm1.reg_nick.value.match(/\'/)){
   		alert("暱稱不能有「\'」，請重新輸入")
   		document.fm1.reg_nick.focus()
   		return false; 
   	}
   	if(document.fm1.reg_nick.value.match(/&/)){
   		alert("暱稱不能有「&」，請重新輸入")
   		document.fm1.reg_nick.focus()
   		return false; 
   	}
   	if(document.fm1.reg_nick.value.match(/>/)){
   		alert("暱稱不能有「>」，請重新輸入")
   		document.fm1.reg_nick.focus()
   		return false; 
   	}
   	if(document.fm1.reg_nick.value.match(/</)){
   		alert("暱稱不能有「<」，請重新輸入")
   		document.fm1.reg_nick.focus()
   		return false; 
   	}
   	if(document.fm1.reg_nick.value.match(/%/)){
   		alert("暱稱不能有「%」，請重新輸入")
   		document.fm1.reg_nick.focus()
   		return false; 
   	}
   	if(document.fm1.reg_nick.value.match(/#/)){
   		alert("暱稱不能有「#」，請重新輸入")
   		document.fm1.reg_nick.focus()
   		return false; 
   	}
   	if(document.fm1.reg_nick.value.match(/!/)){
   		alert("暱稱不能有「!」，請重新輸入")
   		document.fm1.reg_nick.focus()
   		return false; 
   	}
   	if(document.fm1.reg_nick.value.match(/Guest/)){
   		alert("暱稱不能有「Guest」，請重新輸入")
   		document.fm1.reg_nick.focus()
   		return false; 
   	}
   	if(document.fm1.reg_nick.value.match(/guest/)){
   		alert("暱稱不能有「guest」，請重新輸入")
   		document.fm1.reg_nick.focus()
   		return false; 
   	}
   	if(document.fm1.reg_mail.value == ""){
			   alert('email沒填哦!')
			   document.fm1.reg_mail.focus()
			   return false;
		 }
	 if ( document.fm1.reg_mail.value.length < 10) {
    		alert ("email格式錯誤！");
    		document.fm1.reg_mail.focus();
    		return false;
  	}
  	var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT|tv|TV|tw|TW|in|IN)$"
	var re = new RegExp(regu);
	if (document.fm1.reg_mail.value.search(re) == -1) {
		alert ("請輸入合法的mail ！");
		document.fm1.reg_mail.focus();
		return false;
	}
	
	fm1.type.value = "reg";
	fm1.method = "POST";
	fm1.action = "sub_result.php?webid="+webid;
	fm1.submit();
	return false;
	
}

function do_bonus(webid){
	if (fm1.bonus_code.value == "")
	{
		alert ("請填入贈點碼");
    		document.fm1.bonus_code.focus();
    		return false;
	}
	
	if ( document.fm1.bonus_code.value.length < 10) {
    		alert ("贈點碼格式不符!\n\n贈點碼格式需為10位字");
    		document.fm1.bonus_code.focus();
    		return false;
  	}
	
	fm1.type.value = "bonus";
	fm1.method = "POST";
	fm1.action = "sub_result.php?webid="+webid;
	fm1.submit();
	return false;	
}

function do_down(ocode,p,money){
	
	if (confirm('您確定要下載第 '+p+' 段影片？\n此段影片收費： '+money+' 點\n\n確定購買後請按「開始下載」')) {
	/*
	fm2.ocode.value = ocode;
	fm2.p.value = p;
	fm2.method = "GET";
	fm2.action = "down.php?st="+ocode+p;
	//fm2.target = "_blank";
	fm2.submit();
	return false;	
	*/
	getData2('ajax_p.php?idParse=down_member&showDiv=down_member&ocode='+ocode+'&p='+p, 'ajax_p.php?idParse=down_member&showDiv=down_member&ocode='+ocode+'&p='+p, 'down_member');
	
	}
}
function do_re_down(ocode,p){
	
	if (confirm('此部片您還在時效內,不做任何扣點!\n\n按確定後按下「開始下載」!')) {
	/*
	fm2.ocode.value = ocode;
	fm2.p.value = p;
	fm2.method = "GET";
	fm2.action = "down.php?st="+ocode+p;
	//fm2.target = "_blank";
	fm2.submit();
	return false;
	*/
	getData2('ajax_p.php?idParse=down_member&showDiv=down_member&ocode='+ocode+'&p='+p, 'ajax_p.php?idParse=down_member&showDiv=down_member&ocode='+ocode+'&p='+p, 'down_member');
	
	
	
	}
}
function do_tel(webid,ocode,p,aa){
	if (aa != "r")
	{
		if (fm1.pw1.value == "")
		{
			alert ("請填入第1道密碼");
	    		document.fm1.pw1.focus();
	    		return false;
		}
		if (fm1.pw2.value == "")
		{
			alert ("請填入第2道密碼");
	    		document.fm1.pw2.focus();
	    		return false;
		}
		getData2('ajax_p.php?idParse=down_phone&showDiv=down_phone&ocode='+ocode+'&p='+p+'&webid='+webid+'&pw1='+fm1.pw1.value+'&pw2='+fm1.pw2.value, 'ajax_p.php?idParse=down_phone&showDiv=down_phone&ocode='+ocode+'&p='+p+'&webid='+webid+'&pw1='+fm1.pw1.value+'&pw2='+fm1.pw2.value, 'down_phone');
	}else
	{
	
		fm1.ocode.value = ocode;
		fm1.p.value = p;
		fm1.type.value = "tel";
		fm1.webid.value = webid;
		fm1.method = "GET";
		fm1.action = "./sock/tel.php";
		fm1.submit();
		return false;
	}	
}

function do_tel_down(ocode,p){
	fm2.ocode.value = ocode;
	fm2.p.value = p;
	fm2.method = "POST";
	fm2.action = "./sock/phone.php";
	fm2.submit();
	return false;	
}

function do_faq(webid){
	
	if (fm1.phone.value == "" && fm1.msn.value == "")
	{
		alert ("請至少留下一種聯絡方式\n\n電話或msn即可");
    		document.fm1.phone.focus();
    		return false;
	}	
	
	if (fm1.content.value == "")
	{
		alert ("請填入您要發問的內容");
    		document.fm1.content.focus();
    		return false;
	}
	
	
	fm1.type.value = "faq";
	fm1.method = "POST";
	fm1.action = "sub_result.php?webid="+webid;
	fm1.submit();
	return false;
}

function do_pay(un){
	
	if ((document.fm1.code1.value.length !=4)||(document.fm1.code2.value.length !=4)
	||(document.fm1.code3.value.length !=4)||(document.fm1.code4.value.length !=4)	
	){
	alert("易付碼有問題!");
    	return false;
 	 }
 	 fm3.code.value = String(document.fm1.code1.value) + String(document.fm1.code2.value) + String(document.fm1.code3.value) + String(document.fm1.code4.value);
	
	fm3.temp.value = un;
	fm3.webid.value = "newavhigh";
	fm3.method = "POST";
	fm3.action = "http://ezcode.net/result/c_code.php";
	fm3.submit();
	return false;	
}

function do_nextfocus( thisItem, matchLength, nextItem ) {
	if( thisItem.value.length >= matchLength ) {
		nextItem.focus();
	}		
}

function do_mail(webid){
	if (fm1.re_user.value == "")
	{
		alert ("請填入您的會員帳號");
    		document.fm1.re_user.focus();
    		return false;
	}
	if ( document.fm1.re_user.value.length > 12 || document.fm1.re_user.value.length < 6) {
    		alert ("帳號長度不能超過12個字或少於6個字！");
    		document.fm1.re_user.focus();
    		return false;
  	}
  	
   	if(document.fm1.re_user.value.match(/\W/)){
	   		alert("帳號不能含有非字母或數字的字元，請重新輸入")
	   		document.fm1.re_user.focus()
	   		return false; 
	  }
	if (fm1.re_mail.value == "")
	{
		alert ("請填入您註冊會員時的mail");
    		document.fm1.re_mail.focus();
    		return false;
	}
	if ( document.fm1.re_mail.value.length < 10) {
    		alert ("email格式錯誤！");
    		document.fm1.re_mail.focus();
    		return false;
  	}
  	var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT|tv|TV|tw|TW|in|IN)$"
	var re = new RegExp(regu);
	if (document.fm1.re_mail.value.search(re) == -1) {
		alert ("請輸入合法的mail ！");
		document.fm1.re_mail.focus();
		return false;
	}
	
	fm1.type.value = "mail";
	fm1.method = "POST";
	fm1.action = "get_pw.php?webid="+webid;
	fm1.submit();
	return false;	
}

function do_my(webid){
	
	if (fm1.ch_pw.value != "")
	{
		if ( document.fm1.ch_pw.value.length > 12 || document.fm1.ch_pw.value.length < 6) {
    		alert ("密碼長度不能超過12個字或少於6個字！");
    		document.fm1.ch_pw.focus();
    		return false;
  		}
	}
	if (fm1.nickname.value == "")
	{
		alert ("暱稱不能空白");
    		document.fm1.nickname.focus();
    		return false;
	}
	if ( document.fm1.nickname.value.length > 8 ) {
    		alert ("暱稱不能超過8個字！");
    		document.fm1.nickname.focus();
    		return false;
  	}
	if(document.fm1.nickname.value.match(/ /)){
   		alert("暱稱不能有空白，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	if(document.fm1.nickname.value.match(/_/)){
   		alert("暱稱不能有「_」，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	if(document.fm1.nickname.value.match(/\"/)){
   		alert("暱稱不能有「\"」，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	if(document.fm1.nickname.value.match(/\'/)){
   		alert("暱稱不能有「\'」，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	if(document.fm1.nickname.value.match(/&/)){
   		alert("暱稱不能有「&」，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	if(document.fm1.nickname.value.match(/>/)){
   		alert("暱稱不能有「>」，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	if(document.fm1.nickname.value.match(/</)){
   		alert("暱稱不能有「<」，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	if(document.fm1.nickname.value.match(/%/)){
   		alert("暱稱不能有「%」，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	if(document.fm1.nickname.value.match(/#/)){
   		alert("暱稱不能有「#」，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	if(document.fm1.nickname.value.match(/!/)){
   		alert("暱稱不能有「!」，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	if(document.fm1.nickname.value.match(/Guest/)){
   		alert("暱稱不能有「Guest」，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
   	if(document.fm1.nickname.value.match(/guest/)){
   		alert("暱稱不能有「guest」，請重新輸入")
   		document.fm1.nickname.focus()
   		return false; 
   	}
	
	
		if (confirm('您確認要變更資料')) {	
			fm1.type.value = "my";
			fm1.method = "POST";
			fm1.action = "sub_result.php?webid="+webid;
			fm1.submit();
			return false;	
		}
	
		
}

function trim(s) {
 var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
 return (m == null) ? "" : m[1];
}

function do_pw(webid){
	if (fm1.opt_pw.value == "")
	{
		alert ("請填入分類密碼");
    		document.fm1.opt_pw.focus();
    		return false;
	}
	
	
	fm1.type.value = "pw";
	fm1.method = "POST";
	fm1.action = "sub_result.php?webid="+webid;
	fm1.submit();
	return false;	
}
function do_old_user(webid){
	if (fm1.old_user.value == "")
	{
		alert ("請填入您舊avhigh帳號");
    		document.fm1.old_user.focus();
    		return false;
	}
	if (fm1.old_pw.value == "")
	{
		alert ("請填入您舊avhigh密碼");
    		document.fm1.old_pw.focus();
    		return false;
	}
	
	fm1.type.value = "pw";
	fm1.method = "POST";
	fm1.action = "sub_result_old.php?webid="+webid;
	fm1.submit();
	return false;	
}
