function OMOver(OMO){OMO.style.backgroundColor='#fffacd';}
function OMOut(OMO){OMO.style.backgroundColor='';}

function do_login(type,sell){
	if (type == "logout")
	{
		if (confirm('確定要登出嗎??')) {			
			fm1.type.value = type;
			fm1.method = "POST";
			fm1.action = "login.php?sell="+sell;
			fm1.target = "_self";
			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?&sell="+sell;
	fm1.method = "POST";
	fm1.target = "_self";
	fm1.submit();
	return false;
}
}

function do_c_down(pid,did,sell){
	
	var t_val="";
	for (var q = 0; q < fm1.down_sel.length; q++)
    	{
    		if (fm1.down_sel[q].checked == true)
    		{
    			t_val += fm1.down_sel[q].value;
    		}
    	}
    	if (t_val == "")
    	{
    		alert('請先選擇您要下載的方式');
    		document.fm1.down_sel[0].focus();
    	}else
    	{
    		if (t_val == "1")
    		{
	    		if (confirm('確定要使用「單次扣點」方式下載??\n\n說明：\n1、按下確定即為立即購買\n2、如已購買過尚在下載時效內則不扣除您的點數。')) {	
				getData2('ajax_p.php?idParse=check_down&showDiv=check_down&sell='+sell+'&t_val='+t_val+'&pid='+pid+'&did='+did, 'ajax_p.php?idParse=check_down&showDiv=check_down&sell='+sell+'&t_val='+t_val+'&pid='+pid+'&did='+did, 'check_down');
				return false;
			}
		}else
		{
			
			getData2('ajax_p.php?idParse=check_down&showDiv=check_down&sell='+sell+'&t_val='+t_val+'&pid='+pid+'&did='+did, 'ajax_p.php?idParse=check_down&showDiv=check_down&sell='+sell+'&t_val='+t_val+'&pid='+pid+'&did='+did, 'check_down');
			return false;
		}
	}
}



function do_d_down(pid,did,sell){
	
	var t_val="";
	for (var q = 0; q < fm1.down_sel.length; q++)
    	{
    		if (fm1.down_sel[q].checked == true)
    		{
    			t_val += fm1.down_sel[q].value;
    		}
    	}
    	if (t_val == "")
    	{
    		alert('請先選擇您要下載的方式');
    		document.fm1.down_sel[0].focus();
    	}else
    	{
    		if (t_val == "8")
    		{
	    		if (confirm('確定要使用「*單次扣點*」方式下載??\n\n說明：\n1、按下確定即為立即購買\n2、如已購買過尚在下載時效內則不扣除您的點數。')) {	
				getData2('ajax_p.php?idParse=check_down&showDiv=check_down&sell='+sell+'&t_val='+t_val+'&pid='+pid+'&did='+did, 'ajax_p.php?idParse=check_down&showDiv=check_down&sell='+sell+'&t_val='+t_val+'&pid='+pid+'&did='+did, 'check_down');
				return false;
			}
		}else
		{
			
			getData2('ajax_p.php?idParse=check_down&showDiv=check_down&sell='+sell+'&t_val='+t_val+'&pid='+pid+'&did='+did, 'ajax_p.php?idParse=check_down&showDiv=check_down&sell='+sell+'&t_val='+t_val+'&pid='+pid+'&did='+did, 'check_down');
			return false;
		}
	}
}



function do_c_tel(pid,did,sell){
	if (fm1.otp1.value == "")
	{
		alert ("請先輸入第一道密碼！");
		document.fm1.otp1.focus();
		return false;
	}
	
	if (fm1.otp2.value == "")
	{
		alert ("請先輸入第二道密碼！");
		document.fm1.otp2.focus();
		return false;
	}
	getData2('ajax_p.php?idParse=tel&showDiv=tel&sell='+sell+'&wOTP01='+fm1.otp1.value+'&wOTP02='+fm1.otp2.value+'&pid='+pid+'&did='+did, 'ajax_p.php?idParse=tel&showDiv=tel&sell='+sell+'&wOTP01='+fm1.otp1.value+'&wOTP02='+fm1.otp2.value+'&pid='+pid+'&did='+did, 'check_down');
	return false;		
}


function do_search(sell){
	if (fm1.sel_opt.value == "no")
	{
		alert ("請先選擇您要搜尋的類別 ！");
		document.fm1.sel_opt.focus();
		return false;
	}
	
	if (fm1.keyword.value == "")
	{
		alert ("請輸入您要搜尋的關鍵字！");
		document.fm1.keyword.focus();
		return false;
	}
	
	location='./act_search_'+sell+'_'+fm1.sel_opt.value+'_'+encodeURI(fm1.keyword.value)+'_1_1.html';	
}


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("EZCODE儲值碼有問題!");
    	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 = "vrtv";
	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_faq(sell){
		
	if (fm1.faq_tel.value.length==0){
		alert("電話尚未輸入!");
		fm1.faq_tel.focus();
		return false;
	}

	if (fm1.faq_content.value.length==0){
		alert("內容尚未輸入!!");
		fm1.faq_content.focus();
		return false;
	}
	
	fm1.type.value = "faq";
	fm1.action = "sub_result.php?sell="+sell;
	fm1.method = "POST";
	fm1.target = "_self";
	fm1.submit();
	return false;
		
}

function do_reg(sell){
	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.match(/\W/)){
	   		alert("密碼不能含有特殊的字元，請重新輸入")
	   		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(/#/)){
   		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;
	}
	
	if (!fm1.reg_sex[0].checked && !fm1.reg_sex[1].checked)
	{
		alert ("請選擇您的性別");
    		document.fm1.reg_sex[0].focus();
    		return false;
	}
	fm1.type.value = "reg";
	fm1.action = "sub_result.php?sell="+sell;
	fm1.method = "POST";
	fm1.submit();
	return false;	
}

function do_forget(webid,sell){
	  	
  	if ( document.fm1.forget_user.value.length > 12 || document.fm1.forget_user.value.length < 4) {
    		alert ("帳號長度不能超過12個字或少於4個字！");
    		document.fm1.forget_user.focus();
    		return false;
  	}
  	
  	if(document.fm1.forget_user.value.match(/\W/)){
	   		alert("帳號不能含有非字母或數字的字元，請重新輸入")
	   		document.fm1.forget_user.focus()
	   		return false; 
	  }
	 
   	
   	if(document.fm1.forget_mail.value == ""){
			   alert('email沒填哦!')
			   document.fm1.forget_mail.focus()
			   return false;
		 }
	if ( document.fm1.forget_mail.value.length < 10) {
    		alert ("email格式錯誤！");
    		document.fm1.forget_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.forget_mail.value.search(re) == -1) {
		alert ("請輸入合法的mail ！");
		document.fm1.forget_mail.focus();
		return false;
	}
	
	if (fm1.forget_code.value.length==0){
		alert("驗證碼尚未輸入!");
		fm1.forget_code.focus();
		return false;
	}
		
	
	fm1.type.value = "forget";
	fm1.action = "sub_result.php?sell="+sell;
	fm1.method = "POST";
	fm1.target = "_self";
	fm1.submit();
	return false;	
}

function do_joinmmm(sell){
	var t_val="";
	
	if (fm1.p_sel.length == undefined)
	{
		t_val = fm1.p_sel.value;
	}else
	{
		for (var q = 0; q < fm1.p_sel.length; q++)
	    	{
    		if (fm1.p_sel[q].checked == true)
	    		{
	    			t_val += fm1.p_sel[q].value;
	    		}
	    	}
    	}
    
    	
    	if (t_val == "")
    	{
    		alert('請先選擇您要購買的包月方案');
    		return false;
    	}
    	
    	if (confirm('確定要購買此包月方案??')) {
    	
		fm1.type.value = "joinmmm";
		fm1.action = "sub_result.php?sell="+sell;
		fm1.method = "POST";
		fm1.target = "_self";
		fm1.submit();
		return false;
	}
		
}

function do_bonus(webid,sell){
	if (fm1.into_bonus.value.length==0){
		alert("贈點碼尚未輸入!");
		fm1.into_bonus.focus();
		return false;
	}
	
	fm1.type.value = "bonus";
	fm1.action = "sub_result.php?sell="+sell;
	fm1.method = "POST";
	fm1.target = "_self";
	fm1.submit();
	return false;
		
}

function do_hot(webid,sell){

	
	fm1.type.value = "hot";
	fm1.action = "sub_result.php?sell="+sell;
	fm1.method = "POST";
	fm1.target = "_self";
	fm1.submit();
	return false;
		
}

function do_updatereg(webid,sell){
	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_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.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_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 = "updatereg";
	fm1.action = "sub_result.php?sell="+sell;
	fm1.method = "POST";
	fm1.target = "_self";
	fm1.submit();
	return false;	
}



function do_sel(){
	fm1.method = "POST";
	fm1.submit();
	return false;
}

function do_pay_shot(sell){
	
	
	fm1.type.value = "pay";
	fm1.action = "start.php?sell="+sell;
	fm1.method = "POST";
	fm1.target = "_self";
	fm1.submit();
	return false;
	
	
}


