﻿function GameStart(isReg, id, pwd)
{
   var paramdata;
   var TEST = 'INET';
   //var ID = document.getElementById("userid").value;
   var ID = id;
   //var DEC_PW = document.getElementById("userpwd").value;
   var DEC_PW = pwd;
   //var AGE = document.getElementById("age").value;;
   var AGE = 25;
   var WFFM_Download_Link = "http://wffm.yam.com/download/WffmOnlineSetup.exe"; 
   var commDir = "\\\\Yam\\\\Common";
   var theIni = "WffmOnline.ini";
   var headVal = "GAME";
   var fullPath = "FullPath";
   
   
   //var HKEY = document.getElementById("hkey").value;
   //var SubKey = document.getElementById("subKey").value;
   //var Path = document.getElementById("Path").value;
   
   /*
   alert("id/pwd: "+ ID+","+DEC_PW);
   alert("commDir: "+ commDir);
   alert("theIni: "+ theIni);
   alert("headVal: "+ headVal);
   alert("fullPath: "+ fullPath);
   alert("HKEY: "+ HKEY );
   alert("SubKey: "+ SubKey);
   alert("Path: "+ Path);
   */
   
   paramdata = TEST + ' ' + ID + ' ' + DEC_PW + ' ' + AGE + '1';
   //paramdata = TEST + ' ' + ID+ ' ' +DEC_PW ;
   //alert("paramdata: "+ paramdata);
		
   if(isReg)
   {    

	   //REG CHECK
  	 var bcheck = Preparer.CheckREG(HKEY ,SubKey ,Path);
  	 //alert("bcheck: "+bcheck);

	   if(bcheck)
	   { 
		     Preparer.StartGameREG(HKEY,SubKey,Path,'Launcher.exe',
                               WFFM_Download_Link, paramdata);
     }
     else
     {
         //alert("Download");
     }    
   }
   else
   {
     //INI CHECK , not REG yet
 	 var bcheck = Preparer.CheckINI(commDir, theIni, headVal, fullPath);
 	 //alert("bcheck: "+bcheck);
 	 //alert("commDir =>" + commDir + ";theIni =>" + theIni + ";headVal =>" + headVal);
 	   
	   
	 if(bcheck)
	 {  
		Preparer.StartGameINI(commDir, theIni, headVal, 'Path','Launcher.exe', WFFM_Download_Link, paramdata);
        window.location.href = '/main.htm';
     }
	   else
     {
        alert("請下載安裝遊戲主程式");
        window.location.href = '/download.asp';
     }	 
   }
   
}

/*
	2009/06/05 Add by Bruno Sun
	若userName與按下flash的開始遊戲的按鈕
*/
function LoginGameStart(){
	var id = document.getElementById('id');
	var pwd = document.getElementById('pwd');
	var url = document.getElementById('url');
	if(id.value.length != 0 && pwd.value.length != 0){
		//如果有輸入帳號密碼的話，則submit後將頁面導向啟動遊戲
		url.value = '/gameStart.asp';
		document.getElementById("frmLogin").submit();
	}else{
		document.getElementById("frmLogin").submit();
	}
}