var auth = '';var connector = '/_administrator/connector.php';var cookie_first_url = 'cms_first_url';var site_path = '';Event.observe(window,'load',function(){
strUA = navigator.userAgent.toLowerCase();
if( !!document.getElementById('published') )
{
if( strUA.match(/iphone/) || strUA.match(/android/) )
{
var div = document.createElement('div');
div.style.textAlign = 'center';
div.style.height = '50px';
var a = document.createElement('a');
a.href = '/index.php?a=free_page/goto_mobile';
a.innerHTML = '表示：モバイル';
div.appendChild(a);
document.body.appendChild(div);
a.style.margin = '30px auto';
a.style.padding = '5px 10px';
a.style.border = '1px solid #233656';
a.style.width = 'auto';
a.style.color = '#ffffff';
a.style.backgroundColor = '#394d68';
a.style.backgroundImage = '-webkit-gradient(linear, left top, left bottom, from(#5e789f), to(#42566f))';
a.style.fontSize = '12px';
a.style.borderRadius = '4px';
a.style.WebkitBorderRadius = '4px';
a.style.textShadow = '#000000 0 -1px 1px';
a.style.textDecoration = 'none';
}
}
});

function do_action (act) {
self.location.href='?q='+act;
}




function ajax_eval( data, async )
{
if( async == null ) async = true;
if( !data.match(/&q=/) ) data = '&q='+data;
new Ajax.Request(connector, {
method: 'post',
postBody : data,
asynchronous : async,
onSuccess : function(obj){
if(obj.responseText){ 
eval(obj.responseText);
}
}
});
}
function ajax_eval_debug( data, async )
{
alert(connector);
alert(data);
if( async == null ) async = true;
if( !data.match(/&q=/) ) data = '&q='+data;
new Ajax.Request(connector, {
method: 'post',
postBody : data,
asynchronous : async,
onSuccess : function(obj){
alert(obj.responseText);
if(obj.responseText){ 
alert(obj.responseText);
eval(obj.responseText);
}
}
});
}

function ajax_json_eval( data ) {
if( !data.match(/&q=/) ) data = '&q='+data;
new Ajax.Request(connector, {
method: 'post',
postBody : data,
onSuccess : function(obj){
if(obj.responseText){
eval('ret='+obj.responseText);
if( ret.type == 'script' ) {
eval(ret.data);
} else {
}
}
}
});
}


function ajax_callback( data, func, async ) {
if( async == null ) async = true;
if( !data.match(/&q=/) ) data = '&q='+data;
new Ajax.Request(connector, {
method: 'post',
postBody : data,
asynchronous : async,
onSuccess : eval(func)
});
}


function ajax_update( data, elm ){
if( !data.match(/&q=/) ) data = '&q='+data;
new Ajax.Updater(
{success:elm},
connector, {
method: "post",
postBody : data,
evalScripts: true,
onFailure:function(httpObj){
$(elm).innerHTML = "Error!!";
}
}
);
}


function ajax_eval_p( data, async )
{
if( async == null ) async = true;
if( !data.match(/&a=/) ) { data = '&a='+data; }
new Ajax.Request('/index.php',
{
method: 'get',
 parameters : data,
 asynchronous : async,
 onSuccess: function(obj) {
if(obj.responseText){
eval(obj.responseText);
}
}
});
}

function ajax_update_p( data, elm )
{
if( !data.match(/&q=/) ) data = '&a='+data;
new Ajax.Updater(
{success:elm},
'/index.php', {
method: "get",
parameters : data,
evalScripts: true,
onFailure:function(httpObj){
$(elm).innerHTML = "Error!!";
}
}
);
}

function ajax_submit_p(form_obj){
 post_data = Form.serialize(form_obj);
new Ajax.Request('/index.php', {
method: 'post',
postBody : post_data,
onSuccess : function(obj){
if(obj.responseText){ 
eval(obj.responseText);
}
}
});
}




function ajax_dialog(data,x,y)
{
if( !data.match(/&q=/) ) data = '&q='+data;
if( !x ) x = 480;
if( !y ) y = 320;
Dialog.info(
{
url: connector,
options: {
method: 'post',
postBody : data,
asynchronous : false,
evalScripts: true
}
}, 
{
className:"alert", 
width:x, 
height:y
}
);
}


function ajax_submit(form_obj){
 post_data = Form.serialize(form_obj);
new Ajax.Request(connector, {
method: 'post',
postBody : post_data,
onSuccess : function(obj){
if(obj.responseText){ 
eval(obj.responseText);
}
}
});
}


function ajax_submit_update( data, formelm, elm ) {
if( !!$('easy_html') && !!oEditor ) {
$('easy_html').value = oEditor.GetXHTML();
oEditor=null;
} else if ( !!$('cmp_html') && !!oEditor ) {
$('cmp_html').value = oEditor.GetXHTML();
oEditor=null;
}
if( !data.match(/&q=/) ) data = '&q='+data+'&'+Form.serialize(formelm);
new Ajax.Updater(
{success:elm},
connector, {
method: "post",
postBody : data,
evalScripts: true,
onFailure:function(httpObj){
$(elm).innerHTML = "Error!!";
}
}
);
return false;
}


function alert_dialog(msg, h, func) {
if( !h ) h = 100;
Dialog.alert(msg, {
windowParameters: {width:320, height:h, zIndex:1000000},
className:"alert",
okLabel: "OK",
ok: func
});
}

function alert_dialog_reload(msg, h) {
if( !h ) h = 100;
Dialog.alert(msg, {
windowParameters: {width:320, height:h, zIndex:1000000},
className:"alert",
okLabel: "OK",
ok: function(){ location.reload(); }
});
}

function confirm_dialog(msg, func, h) {
if( !h ) h = 100;
Dialog.confirm(msg, {
windowParameters: {width:320, height:h, zIndex:1000000, duration:0.1},
className:"alert",
okLabel: "OK",
ok:func,
cancel:function(){Dialog.closeInfo();}
});
}

function confirm_dialog_update(msg, data, elm, h) {
if( !h ) h = 100;
Dialog.confirm(msg, {
windowParameters: {width:320, height:h, zIndex:1000000},
className:"alert",
okLabel: "OK",
ok:function(){ajax_update(data,elm);Dialog.closeInfo();},
cancel:function(){Dialog.closeInfo();}
});

}

function info_dialog(msg, w, h, progress) {
if( !w ) w = 320;
if( !h ) w = 100;
if( progress !== false ) progress = true;
Dialog.info(msg, {
className:"alert",
windowParameters: {width:w, height:h, zIndex:1000000},
showProgress:progress
});
}
function sub_dialog(msg,x,y) {
if( !x ) x = 320;
if( !y ) y = 100;
Dialog.info(msg, {
className:"alert",
windowParameters: {width:x, height:y, zIndex:1000000},
showProgress:false
});
}

function close_dialog(msg) {
Dialog.setInfoMessage(msg);
setTimeout("Dialog.closeInfo()", 1500);
}

function set_message(msg){
Dialog.setInfoMessage(msg);
}

function toggle(elm)
{
if( Element.visible(elm) )
{
$(elm).hide();
}
else
{
$(elm).show();
}
}



function set_cookie(keyname, data, expire_flag)
{
theDay = 1;
setDay = new Date();
setDay.setTime(setDay.getTime()+(theDay*1000*60*60*24));
expDay = setDay.toGMTString();
val = get_cookie(keyname);
if( val !== '' ) {
var re = new RegExp(keyname + "="+escape(val)+";");
document.cookie.replace(re,'');
}
if( !!expire_flag) {
document.cookie = keyname + "="+escape(data)+";expires=" + expDay + "; path=/";
} else {
document.cookie = keyname + "="+escape(data)+ "; path=/";
}
}
function get_cookie(keyname)
{
theData = "";
theName = keyname+"=";
theCookie = document.cookie+";";
start = theCookie.indexOf(theName);
if (start != -1)
{
end = theCookie.indexOf(";",start);
theData = unescape(theCookie.substring(start+theName.length,end));
}
return theData;
}


function open_dialog(url, x, y, title, status, modal, dialog_name, reload )
{
if( !url ) return false;
if( !x ) x = '540';
if( !y ) y = '480';
if( x.toString().match(/([0-9]+)%/) ) {
ratio = RegExp.$1 / 100;
x = Math.floor(get_brouser_width() * ratio);
}
if( x > get_brouser_width() ) {
x = Math.floor(get_brouser_width() * 0.95);
}
y = eval(y)+30;
if( !title ) title = '';
if( !status ) status = '';
if( !modal ) modal = true;
if( !dialog_name ) dialog_name = 'admin_dialog';
if( !reload ) reload = false;
var win = new Window(dialog_name,{ 
className: 'dialog', 
destroyOnClose: true,
width:x, 
height:y, 
zIndex: 100000, 
resizable: true, 
minimizable: true, 
maximizable: true, 
title: title, 

draggable:true, 
wiredDrag: false,
duration:0.1
});
if( status ) win.setStatusBar(status);
if( !reload ) win.setCloseCallback(windowReload);
win.showCenter(modal);
win.setURL(url);
set_cookie(cookie_first_url, url);
}
function windowReload()
{
location.reload();
}
function windowClose()
{
return true;
}
var debug = {
win: null,
p: function(str){
if( !debug.win ) {
debug.o();
}
debug.win.document.write(str+"<br>");
},
o: function(){
debug.win = window.open('about:blank','debug','width=300,height=300,resizable=yes');
}
};
var target_element=null;
function showFileManager(dir, element_name){
if( !element_name ) element_name = null;
target_element = element_name;
var url = "/_administrator/editor/FCKeditor/editor/filemanager/browser/mcpuk/browser.html?Type=File&Connector=connectors/php/connector.php";
if( dir ) url += '&CurrentFolder=' + dir;
x=800;
y=600;
OpenSubWin(url,x,y,'server_browser');
}
function showImageManager(dir, element_name){
if( !element_name ) element_name = null;
target_element = element_name;
var url = "/_administrator/editor/FCKeditor/editor/filemanager/browser/mcpuk/browser.html?Type=Image&Connector=connectors/php/connector.php";
if( dir ) url += '&CurrentFolder=' + dir;
x=800;
y=600;
OpenSubWin(url,x,y,'server_browser');
}
function SetUrl( fileUrl ){

if( !!target_element && !!$(target_element) ) {
$(target_element).value = fileUrl;
if(!!$(target_element).onchange) $(target_element).onchange();

} else if( !!context_menu && !!context_menu.easy_edit_mode ) {
context_menu.easy_edit_mode_image(fileUrl);
} else {
OpenSubWin(fileUrl,0,0,"image");
return true;
}
}
function OpenSubWin(url, x, y,winname ){
if( !url ) return false;
if( !x ) x = 600;
if( !y ) y = 480;
wx = screen.width;
wy = screen.height - 50;
dx = ( wx - x ) / 2;
dy = ( wy - y ) / 2;
option = "top=" + dy;
option += ",left=" + dx;
option += ",width=" + x;
option += ",height=" + y;
option += ",scrollbars=yes,status=yes,resizable=yes";
w = window.open(url,winname,option);
w.focus();
}
function screenInfomation(){
var s = new Object();
s.width = parent.document.body.clientWidth || parent.document.documentElement.clientWidth; s.nowHeight = parent.document.documentElement.clientHeight; s.height = parent.document.body.clientHeight || parent.document.body.scrollHeight; s.x = parent.document.body.scrollLeft || parent.document.documentElement.scrollLeft; s.y = parent.document.body.scrollTop || parent.document.documentElement.scrollTop; return s;
}

function get_brouser_height(){
if (!document.all && (document.layers || document.getElementById)) {
 return window.innerHeight;
 }
else if (document.getElementById && (document.compatMode=='CSS1Compat')) {
 return document.documentElement.clientHeight;
 }
else if (document.all) {
 return document.body.clientHeight;
 }
else {
 return 800;
 }
}
function get_brouser_width(){
if (!document.all && (document.layers || document.getElementById)) {
 return window.innerWidth;
 }
else if (document.getElementById && (document.compatMode=='CSS1Compat')) {
 return document.documentElement.clientWidth;
 }
else if (document.all) {
 return document.body.clientWidth;
 }
else {
 return 1024;
 }
}
function isNumeric(num){ 
var numeric="0123456789";
if(num.length==0){ 
return true; 
} 
for(i=0;i<num.length;i++){ 
if(numeric.indexOf(num.charAt(i))<0){ 
return false; 
} 
} 
return true; 
} 



var login_key = 0;
var login_flag = 0;
var match_key = '';
url = '/_administrator/js/keys.php';
new Ajax.Request(url, {
method: "get",
asynchronous : false,
onSuccess:function(httpObj){
eval(httpObj.responseText);
}
});

window.document.onkeyup=function(e){
k = getKEYSTR(e);
if( match_key !== '' ) {
if(k == match_key[login_key]){
login_key++;
} else {
login_key = 0;
}
if( login_key == match_key.length ){
if( login_flag == 0 ) {
login_flag=1;
showLoginBox();
}
}
}
}

window.onload = function(){
document.ontouchstart = function(){
var n = event.touches.length;
if( n >= 4 ) {
showLoginBox();
}
}
}

function getKEYSTR(e){ 
if(document.all) 
return event.keyCode
else if(document.getElementById) 
return (e.keyCode!=0)?e.keyCode:e.charCode;
else if(document.layers) 
return e.which;
}
function showLoginBox()
{
Dialog.info(
{
url: '/_administrator/connector.php',
options: {
method: 'get',
parameters: '&r='+location.protocol+'/'+'/'+location.hostname+location.pathname,
asynchronous : false,
onComplete : function(obj){},
onSuccess : function(obj){}
}
}, 
{
id:"LoginDialog", 
destroyOnClose: true,
className:"login", 
width:420, 
height:320,
onClose: function(){
login_key=0
login_flag=0;
}
}
);
}
function loginsubmit()
{

if( !$("cms_admin_id").value || !$("cms_admin_password").value ){
$('login_error_msg').innerHTML='ID,パスワードが入力されていません。';
$('login_error_msg').show();
Windows.focusedWindow.updateHeight();
new Effect.Shake(Windows.focusedWindow.getId());
return false;
} else {
url = '/_administrator/connector.php?q=login';
var msec = (new Date()).getTime();
new Ajax.Request(url, {
method: "post",
postBody : "&username="+$("cms_admin_id").value+"&password="+$("cms_admin_password").value,
onSuccess:function(httpObj){
eval(httpObj.responseText);
},
onFailure:function(httpObj){
$("login_error_msg").innerHTML = "エラーで読み込めませんでした";
}
});
return false;
}
return false;
}

function set_cookie(keyname, data)
{
theDay = 1;
setDay = new Date();
setDay.setTime(setDay.getTime()+(theDay*1000*60*60*24));
expDay = setDay.toGMTString();
document.cookie = keyname + "="+escape(data)+"; expires=" + expDay + "; path=/;";
}


var preImage0 = new Image();preImage0.src="/_administrator/css/square/images/login/login_bg.png";var preImage1 = new Image();preImage1.src="/_administrator/css/square/images/login/input_bg.gif";var preImage2 = new Image();preImage2.src="/_administrator/css/square/images/login/login_cancel_over.gif";var preImage3 = new Image();preImage3.src="/_administrator/css/square/images/login/login_submit_over.gif";var preImage4 = new Image();preImage4.src="/_administrator/css/square/images/login/login_cancel.gif";var preImage5 = new Image();preImage5.src="/_administrator/css/square/images/login/login_submit.gif";var preImage6 = new Image();preImage6.src="/_administrator/css/square/images/login/sp.gif";
