function AddHiddenFieldTarget(name, value, target)
{
var hidden;
hidden = document.createElement('input');
hidden.setAttribute('type',  'hidden');
hidden.setAttribute('name',  name);
hidden.setAttribute('value', value);
target.appendChild(hidden);
}
function tologin(userid, password) {
var form;
form = document.createElement('form');
form.setAttribute('action', '/login.php');
form.setAttribute('method', 'POST');
AddHiddenFieldTarget('username', userid, form);
AddHiddenFieldTarget('password', password, form);
AddHiddenFieldTarget('origurl', window.location.href, form);
document.getElementsByTagName('body')[0].appendChild(form);
form.submit();
}
function getHttpRequest()
{
if( window.XMLHttpRequest )
return new XMLHttpRequest();
else if( window.ActiveXObject )
return new ActiveXObject("Microsoft.XMLHTTP");
else {
alert("unable to initialize ajax");
return ;
}
}
function call2Flash(cmd, arg)
{
return document.getElementById("myFlash").jsCALL(cmd, arg);
}
function myFlash_DoFSCommand(command, args)
{
if( command.substr(0, 10) == "FSCommand:" ){
// for firefox above Mac
command = command.substring(10);
}
if( command == "prevpage" ){
history.go(-1);
} else if( command == "nextpage" ){
history.go(1);
} else if( command == "reloadpage" ){
history.go(0);
} else if( command == "homepage" ){
window.open('/', '', 'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+screen.width+',height='+screen.height+',top=150,left=150');
} else if( command == "myhome" ){
window.location.href = "/frame.php?hompy=" + args;
} else if( command == "randompage" ){
window.location.href = "/random.php";
} else if( command == "decoratepage" ){
window.location.href = "/swf.php?swf=decorate_ui";
} else if( command == "login" ){
var sp = args.indexOf(":");
tologin(args.substr(0, sp), args.substring(sp + 1));
} else if( command == "logout" ){
window.location.href = "/logout.php?origurl="+escape(window.location.href);
} else if( command == "helppage" ){
window.location.href = "/frame.php?hompy=service";
} else if( command == "mappage" ){
window.location.href = "/swf.php?swf=parkmap";
} else if( command == "nwurl" ){
window.open(args, '','menubar=no,scrollbars=no,width=1000,height=665');
} else if( command == "chpreview" ){
var form = document.createElement('form');
form.setAttribute('action', '/.in2');
form.setAttribute('method', 'POST');
form.setAttribute('target', '_blank');
AddHiddenFieldTarget('act', 'chpreview', form);
AddHiddenFieldTarget('args', args, form);
document.getElementsByTagName('body')[0].appendChild(form);
form.submit();
} else if( command == "chsend" ){
var http_request = getHttpRequest();
http_request.open("POST", "/.in2");
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Connection", "close");
http_request.send("act=chsend&args=" + escape(args));
} else if( command == "picpreview" ) {
var form = document.createElement('form');
form.setAttribute('action', '/.in2');
form.setAttribute('method', 'POST');
AddHiddenFieldTarget('act', 'picpreview', form);
AddHiddenFieldTarget('args', args, form);
document.getElementsByTagName('body')[0].appendChild(form);
form.submit();
} else if( command == "picpreviewA" ) {
var form = document.createElement('form');
form.setAttribute('action', '/.in2');
form.setAttribute('method', 'POST');
AddHiddenFieldTarget('act', 'picpreviewA', form);
AddHiddenFieldTarget('args', args, form);
document.getElementsByTagName('body')[0].appendChild(form);
form.submit();
} else if( command == "picpopup" ){
window.open(args, '', 'width=770');
} else if( command == "alert" ){
alert(args);
} else if( command == "checkemail" ){
var suggest = correctEMail(args);
if( suggest ){
if( confirm("您是不是要輸入 " + suggest + " ?") ){
call2Flash("correctEMail", suggest);
}
}
} else if( command == "checkemailwrapper" ){
var id = args.substr(0, args.indexOf(","));
var email = args.substr(args.indexOf(",") + 1);
var suggest = correctEMail(email);
if( suggest ){
if( confirm("您是不是要輸入 " + suggest + " ?") ){
call2Flash("correctEMail2", id + "," + suggest);
}
}
} else if( command == "billing" ){
window.open('/?op=mymini&sub_op=ValueMain');
} else if( command == "vippasswd" ){
var pwd, form;
if( (pwd = prompt("嘗試進入受密碼保護的聊天室，請輸入密碼")) ){
form = document.createElement('form');
form.setAttribute('action', '/vipparty.php?hostuid=' + args);
form.setAttribute('method', 'POST');
AddHiddenFieldTarget('passwd', pwd, form);
document.getElementsByTagName('body')[0].appendChild(form);
form.submit();
}
} else if( command == "popupHompy" ){
var name = "miniWorld";
var argv = "menubar=no,scrollbars=no,width=1000,height=665";
if (!hompywindow.closed && hompywindow.location) {
hompywindow.location.href = args;
} else {
hompywindow = window.open(args,name,argv);
if (!hompywindow.opener) hompywindow.opener = self;
}
if (window.focus) { hompywindow.focus(); }
return false;
} else if( command == "connecterror" ){
} else {
//alert("unknown command " + command + " " + args);
}
}
