//Debiew/Copyright(c) 2009 portarte,inc. All rights reserved.
var blstr=new Array("false","true"); var title=null; var main=null; var screen_mask=null; var timer=null; var book_panel=null; var book_view=null; var frame=null; var canvas=null; var fade_mask=null; var b_canvas=null; var f_canvas=null; var map=null; var map_view=null; var scope=null; var touch=null; var tool=null; var subtool=null; var edittool=null; var book=null; var lefteffect=null; var righteffect=null; var map_mask=null; var credit=null; var help_panel=null; var canvas_margin=4; var default_size=200; var map_size=128; var contents_format=".jpg"; var view_id=null; var effect_id=null; var effect_rate=20; var turn_step=40; var fade_step=0.2; var move_step=4; var current_fade=0; var effect_mode=0; var bc_count=0; var br_count=0; var fc_count=0; var fr_count=0; var img_format=".jpg.JPG.jpeg.JPEG.gif.GIF.png.PNG"; var bookmark=get_cookie("bookmark"); var keyword=get_cookie("keyword"); var frame_width=0; var frame_height=0; var current_spread=1; var target_spread=0; var current_scale=0; var block_size=200; var point_x=-1; var point_y=-1; var drag_x=0; var drag_y=0; var offset_x=0; var offset_y=0; var drag_mode=0; var map_mode=0; var book_mode=1; var image_cache=new Array(); var edit_flag=0; var edit_mode=0; var editdrag_mode=0; var editresize_mode=0; var editslide_mode=0; var media_mode=0; var cursor_type=""; var edit_id=null; if(navigator.userAgent.match (/MSIE (5.)/)){ pointer_cursor ="hand";}
else{ pointer_cursor ="pointer";}
function blank(){ }
function get_time_stamp(){ time_stamp=new Date().getTime(); return time_stamp;}
function arr(num,col){ while(String(num).length<col){ num="0"+String(num);}
return String(num);}
function get_style(target_object,property_name){ if(target_object.currentStyle){ return target_object.currentStyle[property_name];}
else if( document.defaultView.getComputedStyle ){ return document.defaultView.getComputedStyle(target_object, null).getPropertyValue(property_name);}
return "";}
function ww(){ var ww=parseInt(document.body.clientWidth); if (parseInt(document.body.clientHeight)==0){ ww=parseInt(document.documentElement.clientWidth);}
if ((navigator.appVersion.indexOf("KHTML")>-1)&&((navigator.appVersion.indexOf("AppleWebKit/1")>-1)||(navigator.appVersion.indexOf("AppleWebKit/2")>-1)||(navigator.appVersion.indexOf("AppleWebKit/3")>-1)||(navigator.appVersion.indexOf("AppleWebKit/4")>-1))) { ww=parseInt(window.innerWidth);}
return ww;}
function wh(){ var wh=parseInt(document.body.clientHeight); if (parseInt(document.body.clientHeight)==0){ wh=parseInt(document.documentElement.clientHeight);}
if ((navigator.appVersion.indexOf("KHTML")>-1)&&((navigator.appVersion.indexOf("AppleWebKit/1")>-1)||(navigator.appVersion.indexOf("AppleWebKit/2")>-1)||(navigator.appVersion.indexOf("AppleWebKit/3")>-1)||(navigator.appVersion.indexOf("AppleWebKit/4")>-1))) { wh=parseInt(window.innerHeight);}
return wh;}
function load_image(object_name,image_src){ if (image_cache[image_src]){ if (image_cache[image_src].complete){ if (object_name!=""){ var target_object=document.getElementById(object_name); if (target_object){ if (target_object.firstChild){ if (target_object.firstChild.src!=image_cache[image_src].src){ target_object.innerHTML="<img src=\""+image_cache[image_src].src+"\" style=\"width:"+parseInt(target_object.style.width)+"px;height:"+parseInt(target_object.style.height)+"px;\">";}}
else{ target_object.innerHTML="<img src=\""+image_cache[image_src].src+"\" style=\"width:"+parseInt(target_object.style.width)+"px;height:"+parseInt(target_object.style.height)+"px;\">";}}}}}
else{ image_cache[image_src]=new Image(); image_cache[image_src].onload=function(){ if (object_name!=""){ var target_object=document.getElementById(object_name); if (target_object){ if (target_object.firstChild){ if (target_object.firstChild.src!=image_cache[image_src].src){ target_object.innerHTML="<img src=\""+image_cache[image_src].src+"\" style=\"width:"+parseInt(target_object.style.width)+"px;height:"+parseInt(target_object.style.height)+"px;\">";}}
else{ target_object.innerHTML="<img src=\""+image_cache[image_src].src+"\" style=\"width:"+parseInt(target_object.style.width)+"px;height:"+parseInt(target_object.style.height)+"px;\">";}}}}
image_cache[image_src].src=image_src;}}
function load_png(object_name,image_src){ var target_object=document.getElementById(object_name); target_object.firstChild.src=image_src; target_object.firstChild.style.width=get_style(target_object,"width"); target_object.firstChild.style.height=get_style(target_object,"height"); if (typeof document.body.style.maxHeight=="undefined"){ target_object.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + target_object.firstChild.src + ", sizingMethod=scale)"; target_object.firstChild.style.visibility="hidden";}}
function get_cookie(cookie_name){ var cookie_data=document.cookie; var i=0; var cookie_value=""; for (i=0; i<cookie_data.split(";").length; i++){ if (cookie_data.split(";")[i].split("=")[0].replace(" ","")==cookie_name){ cookie_value=unescape(cookie_data.split(";")[i].split("=")[1]); break;}}
if (cookie_value=="undefined"){ cookie_value="";}
return cookie_value;}
function set_cookie(cookie_name,cookie_value,cookie_term){ var cookie_data=""; cookie_data=cookie_name+"="+escape(cookie_value); if (cookie_term>0){ cookie_date=new Date(); cookie_date.setTime(cookie_date.getTime()+(cookie_term*24*60*60*1000)); cookie_data=cookie_data+";expires="+cookie_date.toGMTString();}
document.cookie=cookie_data;}
function get_spread_number(b,f,s,pn){ var sn=0; if (!f){ sn=pn;}
else{ if (b==s){ sn=parseInt((pn+1)/2);}
else{ sn=parseInt((pn)/2)+1;}}
return sn;}
function get_page_number(b,f,s,sn){ var pn=0; if (!f){ pn=sn;}
else{ if (b==s){ pn=sn*2-1;}
else{ pn=(sn-1)*2;}}
return pn;}
function init(){ var object_html=""; object_html=object_html+"<iframe id=\"title\" src=\"title.html\" style=\"position:absolute;left:"+canvas_margin+"px;top:"+canvas_margin+"px;width:"+(ww()-(canvas_margin*2))+"px;border:0px;cursor: default;z-index:1;overflow:hidden;\" scrolling=\"no\" frameborder=\"0\"></iframe>"; object_html=object_html+"<div id=\"main\" style=\"position:absolute;cursor: default;left:"+canvas_margin+"px;top:"+canvas_margin+"px;width:"+(ww()-(canvas_margin*2))+"px;z-index:2;overflow:hidden;\"></div>"; object_html=object_html+"<div id=\"edittool\" style=\"position:absolute;left:"+(160+canvas_margin)+"px;top:"+canvas_margin+"px;height:32px;background-color: #EEEEEE;z-index:10001;visibility:hidden;\">"; object_html=object_html+"<table cellpadding=\"0px\" cellspacing=\"0px\">"; object_html=object_html+"<tr style=\"height:16px;\">"; object_html=object_html+"<td style=\"width:70px;text-align:right;font-size:10px;font-weight:bold;\">基本：</td>"; object_html=object_html+"<td style=\"text-align:left;\">"; if (!edit_mode){ object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_mode\" value=\"エディットモードへ\" style=\"width:100px;\" onclick=\"change_editmode(null)\"></input>";}
else{ object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_mode\" value=\"プレビューモードへ\" style=\"width:100px;\" onclick=\"change_editmode(null)\"></input>";}
object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_help\" value=\"ヘルプ\" style=\"width:40px;\" onclick=\"show_helpedit()\"></input>"; object_html=object_html+"<span style=\"font-size:10px;font-weight:bold;\">　スクリプト：</span>"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_scriptchapter\" value=\"チャプタ\" style=\"width:50px;\" onclick=\"script_chapter();\"></input>"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_scriptanchor\" value=\"アンカー\" style=\"width:50px;\" onclick=\"script_anchor();\"></input>"; object_html=object_html+"</td>"; object_html=object_html+"<td style=\"width:70px;text-align:right;font-size:10px;font-weight:bold;\">メディア：</td>"; object_html=object_html+"<td style=\"text-align:left;\">"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_addmedia\" value=\"追加\" style=\"width:40px;\" onclick=\"add_media()\"></input>"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_deletemedia\" value=\"削除\" style=\"width:40px;\" onclick=\"delete_media()\"></input>"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_deleteallmedia\" value=\"全削除\" style=\"width:40px;\" onclick=\"delete_all_media()\"></input>"; object_html=object_html+"</td>"; object_html=object_html+"</tr>"; object_html=object_html+"<tr style=\"height:16px;\">"; object_html=object_html+"<td style=\"width:70px;text-align:right;font-size:10px;font-weight:bold;\">目次：</td>"; object_html=object_html+"<td style=\"text-align:left;\">"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_addchapter\" value=\"チャプタ追加\" style=\"width:80px;\" onclick=\"add_chapter()\"></input>"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_addanchor\" value=\"アンカー追加\" style=\"width:80px;\" onclick=\"add_anchor()\"></input>"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_deleteindex\" value=\"削除\" style=\"width:40px;\" onclick=\"delete_index()\"></input>"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_upindex\" value=\"▲\" style=\"width:30px;\" onclick=\"up_index()\"></input>"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_downindex\" value=\"▼\" style=\"width:30px;\" onclick=\"down_index()\"></input>"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_deleteallindex\" value=\"全削除\" style=\"width:40px;\" onclick=\"delete_all_index()\"></input>"; object_html=object_html+"</td>"; object_html=object_html+"<td style=\"width:70px;text-align:right;font-size:10px;font-weight:bold;\">リンク：</td>"; object_html=object_html+"<td style=\"text-align:left;\">"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_addhyperlink\" value=\"追加\" style=\"width:40px;\" onclick=\"add_hyperlink()\"></input>"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_duplicatehyperlink\" value=\"複製\" style=\"width:40px;\" onclick=\"duplicate_hyperlink()\"></input>"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_deletehyperlink\" value=\"削除\" style=\"width:40px;\" onclick=\"delete_hyperlink()\"></input>"; object_html=object_html+"<input type=\"button\" class=\"pushbutton\" id=\"edittool_deleteallhyperlink\" value=\"全削除\" style=\"width:40px;\" onclick=\"delete_all_hyperlink()\"></input>"; object_html=object_html+"</td>"; object_html=object_html+"</tr>"; object_html=object_html+"</table>"; object_html=object_html+"</div>"; object_html=object_html+"<div id=\"screen_mask\" style=\"position:absolute;cursor: default;left:0px;top:0px;width:"+ww()+"px;height:"+wh()+"px;z-index:20001;overflow:hidden;background-color: #000000;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;visibility:hidden;\"></div>"; object_html=object_html+"<div id=\"timer\" style=\"position:absolute;cursor: default;left:"+(parseInt((ww()-64)/2))+"px;top:"+(parseInt((wh()-64)/2))+"px;width:64px;height:64px;z-index:20001;visibility:hidden;\";><img src=\"image/timer.gif\"></div>"; document.body.innerHTML=object_html; title=document.getElementById("title"); title.style.width=(ww()-(canvas_margin*2)); main=document.getElementById("main"); main.style.width=(ww()-(canvas_margin*2)); edittool=document.getElementById("edittool"); if (parseInt(get_style(title,"height"))){ main.style.top=(parseInt(get_style(title,"height"))+canvas_margin*2)+"px"; main.style.height=(wh()-parseInt(get_style(title,"height"))-canvas_margin*3)+"px";}
else{ main.style.top=(canvas_margin)+"px"; main.style.height=(wh()-canvas_margin*2)+"px";}
edittool.style.width=(parseInt(ww()-parseInt(get_style(edittool,"left"))-(canvas_margin)))+"px"; screen_mask=document.getElementById("screen_mask"); timer=document.getElementById("timer"); current_scale=0; frame_width=parseInt(get_style(main,"width")); frame_height=parseInt(get_style(main,"height")); if (point_x<0 && point_y<0){ point_x=parseInt(current_scale*block_size/2); point_y=parseInt(current_scale*block_size/2);}
var object_html=""; object_html=object_html+"<div id=\"frame\" style=\"position:absolute;cursor: default;left:0px;top:0px;width:"+frame_width+"px;height:"+frame_height+"px;z-index:3;overflow:hidden;\">"; object_html=object_html+"<div id=\"canvas\" style=\"position:absolute;cursor: default;left:0px;top:0px;width:"+(max_block*default_size)+"px;height:"+(max_block*default_size)+"px;z-index:4;\"></div>"; object_html=object_html+"</div>"; object_html=object_html+"<div id=\"fade_mask\" style=\"position:absolute;cursor: default;left:0px;top:0px;width:"+frame_width+"px;height:"+frame_height+"px;background-color: #000000;z-index:5;visibility:hidden;\"></div>"; object_html=object_html+"<div id=\"book_panel\" style=\"position:absolute;left:"+(canvas_margin)+"px;top:"+(canvas_margin)+"px;height:"+(frame_height-canvas_margin*2)+"px;cursor: default;z-index:5001;visibility:hidden;\"></div>"; object_html=object_html+"<div id=\"map\" style=\"position:absolute;left:"+(frame_width-map_size-canvas_margin*3)+"px;top:"+(canvas_margin)+"px;width:"+(map_size+canvas_margin*2)+"px;height:"+(map_size+canvas_margin*2)+"px;cursor: default;z-index:5002;overflow:hidden;\"></div>"; object_html=object_html+"<div id=\"map_view\" style=\"position:absolute;left:"+(frame_width-map_size-canvas_margin*3)+"px;top:"+(canvas_margin)+"px;width:"+(map_size+canvas_margin*2)+"px;height:"+(map_size+canvas_margin*2)+"px;cursor: default;z-index:5003;overflow:hidden;\"></div>"; object_html=object_html+"<div id=\"book\" style=\"position:absolute;cursor:"+pointer_cursor+";z-index:6001;overflow:hidden;\" onclick=\"show_book()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"tool\" style=\"position:absolute;cursor: default;z-index:6002;overflow:hidden;\">"; object_html=object_html+"<div id=\"tool_leftedge\" style=\"position:absolute;cursor: default;\"><img></div>"; object_html=object_html+"<div id=\"tool_zoomin\" style=\"position:absolute;cursor:"+pointer_cursor+";\" onclick=\"change_scale(1)\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"tool_zoomout\" style=\"position:absolute;cursor:"+pointer_cursor+";\" onclick=\"change_scale(-1)\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"tool_fit\" style=\"position:absolute;cursor:"+pointer_cursor+";\" onclick=\"fit_scale()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"tool_leftendspread\" style=\"position:absolute;cursor:"+pointer_cursor+";\" onclick=\"leftend_spread()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"tool_leftspread\" style=\"position:absolute;cursor:"+pointer_cursor+";\" onclick=\"left_spread()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"tool_rightspread\" style=\"position:absolute;cursor:"+pointer_cursor+";\" onclick=\"right_spread()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"tool_rightendspread\" style=\"position:absolute;cursor:"+pointer_cursor+";\" onclick=\"rightend_spread()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"tool_rightedge\" style=\"position:absolute;cursor: default;\"><img></div>"; object_html=object_html+"</div>"; object_html=object_html+"<div id=\"subtool\" style=\"position:absolute;cursor: default;z-index:6003;overflow:hidden;\">"; object_html=object_html+"<div id=\"subtool_leftedge\" style=\"position:absolute;cursor: default;\"><img></div>"; object_html=object_html+"<div id=\"subtool_getpdf\" style=\"position:absolute;cursor:"+pointer_cursor+";\" onclick=\"get_pdf()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"subtool_help\" style=\"position:absolute;cursor:"+pointer_cursor+";\" onclick=\"show_help()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"subtool_close\" style=\"position:absolute;cursor:"+pointer_cursor+";\" onclick=\"window_close()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"subtool_rightedge\" style=\"position:absolute;cursor: default;\"><img></div>"; object_html=object_html+"</div>"; object_html=object_html+"<div id=\"help_panel\" style=\"position:absolute;;cursor: default;z-index:7001;visibility:hidden;\"></div>"; object_html=object_html+"<a id=\"credit\" href=\"http://www.debiew.com/\" target=\"_blank\" style=\"position:absolute;left:"+(frame_width-112-canvas_margin)+"px;top:"+(frame_height-16-canvas_margin)+"px;width:112px;height:16px;cursor:"+pointer_cursor+";z-index:7002;\"><img src=\"image/credit.png\" style=\"border:0px;\"></a>"; main.innerHTML=object_html; book=document.getElementById("book"); tool=document.getElementById("tool"); subtool=document.getElementById("subtool"); book.style.left=(canvas_margin)+"px"; book.style.top=(parseInt(frame_height-parseInt(get_style(book,"height")))-canvas_margin)+"px"; tool.style.left=(parseInt((frame_width-parseInt(get_style(tool,"width"))-parseInt(get_style(subtool,"width"))-canvas_margin)/2))+"px"; tool.style.top=(parseInt(frame_height-parseInt(get_style(tool,"height")))-canvas_margin)+"px"; subtool.style.left=(parseInt(parseInt(get_style(tool,"left"))+parseInt(get_style(tool,"width"))+canvas_margin))+"px"; subtool.style.top=(parseInt(frame_height-parseInt(get_style(subtool,"height")))-canvas_margin)+"px"; load_button("book"); load_png("tool_leftedge","image/tool_leftedge.png"); load_png("tool_rightedge","image/tool_rightedge.png"); load_button("tool_zoomin"); load_button("tool_zoomout"); load_button("tool_fit"); load_button("tool_leftendspread"); load_button("tool_leftspread"); load_button("tool_rightspread"); load_button("tool_rightendspread"); load_png("subtool_leftedge","image/subtool_leftedge.png"); load_png("subtool_rightedge","image/subtool_rightedge.png"); load_button("subtool_getpdf"); load_button("subtool_help"); load_button("subtool_close"); book_panel=document.getElementById("book_panel"); frame=document.getElementById("frame"); canvas=document.getElementById("canvas"); fade_mask=document.getElementById("fade_mask"); map=document.getElementById("map"); map_view=document.getElementById("map_view"); help_panel=document.getElementById("help_panel"); credit=document.getElementById("credit"); load_png("credit","http://www.debiew.com/image/credit.png"); object_html=""; object_html=object_html+"<div id=\"book_frame\" style=\"position:absolute;cursor: default;left:0px;top:0px;width:"+parseInt(get_style(book_panel,"width"))+"px;height:"+parseInt(get_style(book_panel,"height"))+"px;\"></div>"; object_html=object_html+"<div id=\"book_image\" style=\"position:absolute;left:0px;top:"+canvas_margin+"px;cursor:"+pointer_cursor+";overflow:hidden;visibility:hidden;\" onclick=\"load_book(0)\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"book_index\" style=\"position:absolute;left:0px;top:"+canvas_margin+"px;cursor:"+pointer_cursor+";overflow:hidden;visibility:hidden;\" onclick=\"load_book(1)\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"book_search\" style=\"position:absolute;left:0px;top:"+canvas_margin+"px;cursor:"+pointer_cursor+";overflow:hidden;visibility:hidden;\" onclick=\"load_book(2)\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"book_bookmark\" style=\"position:absolute;left:0px;top:"+canvas_margin+"px;cursor:"+pointer_cursor+";overflow:hidden;visibility:hidden;\" onclick=\"load_book(3)\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"book_close\" style=\"position:absolute;left:0px;top:"+canvas_margin+"px;cursor:"+pointer_cursor+";overflow:hidden;\" onclick=\"hide_book()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"book_view\" style=\"position:absolute;left:"+canvas_margin+"px;top:0px;width:"+(parseInt(get_style(book_panel,"width"))-canvas_margin*2)+"px;height:0px;cursor: default;overflow:hidden;\"></div>"; book_panel.innerHTML=object_html; book_view=document.getElementById("book_view"); document.getElementById("book_image").style.left=(canvas_margin)+"px"; if (parseInt(get_style(document.getElementById("book_index"),"width"))){ document.getElementById("book_index").style.left=(parseInt(get_style(document.getElementById("book_image"),"left"))+parseInt(get_style(document.getElementById("book_image"),"width"))+canvas_margin)+"px";}
else{ document.getElementById("book_index").style.left=(parseInt(get_style(document.getElementById("book_image"),"left"))+parseInt(get_style(document.getElementById("book_image"),"width")))+"px";}
if (parseInt(get_style(document.getElementById("book_search"),"width"))){ document.getElementById("book_search").style.left=(parseInt(get_style(document.getElementById("book_index"),"left"))+parseInt(get_style(document.getElementById("book_index"),"width"))+canvas_margin)+"px";}
else{ document.getElementById("book_search").style.left=(parseInt(get_style(document.getElementById("book_index"),"left"))+parseInt(get_style(document.getElementById("book_index"),"width")))+"px";}
if (parseInt(get_style(document.getElementById("book_bookmark"),"width"))){ document.getElementById("book_bookmark").style.left=(parseInt(get_style(document.getElementById("book_search"),"left"))+parseInt(get_style(document.getElementById("book_search"),"width"))+canvas_margin)+"px";}
else{ document.getElementById("book_bookmark").style.left=(parseInt(get_style(document.getElementById("book_search"),"left"))+parseInt(get_style(document.getElementById("book_search"),"width")))+"px";}
document.getElementById("book_close").style.left=(parseInt(get_style(book_panel,"width"))-canvas_margin-parseInt(get_style(document.getElementById("book_close"),"width")))+"px"; book_view.style.top=(canvas_margin*2+parseInt(get_style(document.getElementById("book_image"),"height")))+"px"; book_view.style.height=(parseInt(get_style(book_panel,"height"))-canvas_margin*3-parseInt(get_style(document.getElementById("book_image"),"height")))+"px"; load_button("book_image"); load_button("book_index"); load_button("book_search"); load_button("book_bookmark"); load_button("book_close"); load_book(0); object_html=""; object_html=object_html+"<div id=\"book_frame\" style=\"position:absolute;cursor:default;left:0px;top:0px;width:"+parseInt(get_style(help_panel,"width"))+"px;height:"+parseInt(get_style(help_panel,"height"))+"px;\"></div>"; object_html=object_html+"<div id=\"help_close\" style=\"position:absolute;left:0px;top:"+canvas_margin+"px;cursor:"+pointer_cursor+";overflow:hidden;\" onclick=\"hide_help()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<iframe id=\"helpview\" src=\"help.html\" style=\"position:absolute;left:"+canvas_margin+"px;top:0px;width:"+(parseInt(get_style(help_panel,"width"))-canvas_margin*2)+"px;height:0px;border:0px;cursor: default;overflow:hidden;\" scrolling=\"no\" frameborder=\"0\"></iframe>"; help_panel.innerHTML=object_html; document.getElementById("help_close").style.left=(parseInt(get_style(help_panel,"width"))-canvas_margin-parseInt(get_style(document.getElementById("help_close"),"width")))+"px"; document.getElementById("helpview").style.top=(canvas_margin*2+parseInt(get_style(document.getElementById("help_close"),"height")))+"px"; document.getElementById("helpview").style.height=(parseInt(get_style(help_panel,"height"))-canvas_margin*3-parseInt(get_style(document.getElementById("help_close"),"height")))+"px"; load_button("help_close"); help_panel.style.left=(parseInt((frame_width-parseInt(get_style(help_panel,"width")))/2))+"px"; help_panel.style.top=(parseInt((frame_height-parseInt(get_style(help_panel,"height")))/2))+"px"; window.onresize=init; document.onmousemove=mouse_move; document.onmouseup=mouse_up; fit_scale(); preload_spread(); edit();}
function load_book(val){ clear_edit(); var i=0; var object_html=""; var result_html=""; book_view.innerHTML=object_html; if (val==0){ result_html=""; for(i=1;i<=spread_count;i=i+1){ var hm=0; var vm=0; var pns=0; var pne=0; var pnf=""; var tc=""; if (proportion>=1){ vm=parseInt((1-(1/proportion))*map_size/2);}
if (proportion<1){ hm=parseInt((1-proportion)*map_size/2);}
var pw=(map_size-hm*2); if ((i==1)&&(facing==1)&&(bind!=start_page)){ if (!bind){ pw=pw/2; hm=map_size/2;}
else{ pw=pw/2; hm=0;}}
else if ((i==spread_count)&&(facing==1)&&((bind+start_page+page_count)%2==1)){ if (!bind){ pw=pw/2; hm=0;}
else{ pw=pw/2; hm=map_size/2;}}
if (!facing){ pns=get_page_number(bind,facing,start_page,i); pne="&nbsp;";}
else{ pns=get_page_number(bind,facing,start_page,i); pne=get_page_number(bind,facing,start_page,i)+1; if ((i==1)&&(facing==1)&&(bind!=start_page)){ pns="&nbsp;";}
else if ((i==spread_count)&&(facing==1)&&((bind+start_page+page_count)%2==1)){ pne="&nbsp;";}}
if (!bind){ pnf="left";}
else{ pnf="right";}
if (i!=current_spread){ tc="thumbnail_default";}
else{ tc="thumbnail_highlight";}
result_html=result_html+"<div id=\"thumbnail_"+i+"\" class=\""+tc+"\" name=\"thumbnail\" style=\"position:relative;cursor:"+pointer_cursor+";\" onclick=\"show_spread("+i+")\" onmouseover=\"focus_object(this)\" onmouseout=\"blur_object(this)\"><div style=\"width:"+map_size+"px;height:"+(map_size-vm*2)+"px;margin:auto;border:0px transparent solid;text-align:left;\">"; result_html=result_html+"<div style=\"width:"+(pw)+"px;height:"+(map_size-vm*2)+"px;margin-left:"+(hm)+"px;margin-top:0px;border:1px #000000 solid;overflow:hidden;\"><img src=\"contents/"+earr(job_id,i,3)+"/"+earr(job_id,0,3)+contents_format+"\" style=\"margin-left:"+(-hm)+"px;margin-top:"+(-vm)+"px;\"></div>"; result_html=result_html+"</div>"; result_html=result_html+"<div style=\"width:"+(map_size)+"px;padding-top:"+(canvas_margin)+"px;margin:auto;\">"; if (!facing){ result_html=result_html+"<div>"+pns+"</div>";}
else{ result_html=result_html+"<div style=\"float:"+pnf+";width:"+(map_size/2)+"px;\">"+pns+"</div>"; result_html=result_html+"<div>"+pne+"</div>";}
result_html=result_html+"</div>"; result_html=result_html+"</div>";}
object_html=result_html;}
if (val==1){ result_html=""; for(i=0;i<index.length;i=i+1){ if (!edit_mode){ if (index[i].split("^")[0]=="chapter"){ result_html=result_html+"<div id=\"index_"+i+"\" class=\""+index[i].split("^")[0]+"_default\" name=\""+index[i].split("^")[0]+"\" style=\"position:relative;cursor:"+pointer_cursor+";\" onclick=\"show_spread("+index[i].split("^")[2]+")\" onmouseover=\"focus_object(this)\" onmouseout=\"blur_object(this)\">"+index[i].split("^")[1]+"</div>";}
if (index[i].split("^")[0]=="anchor"){ result_html=result_html+"<div id=\"index_"+i+"\" class=\""+index[i].split("^")[0]+"_default\" name=\""+index[i].split("^")[0]+"\" style=\"position:relative;cursor:"+pointer_cursor+";\" onclick=\"show_anchor("+index[i].split("^")[2]+","+index[i].split("^")[3]+","+index[i].split("^")[4]+","+index[i].split("^")[5]+")\" onmouseover=\"focus_object(this)\" onmouseout=\"blur_object(this)\">"+index[i].split("^")[1]+"</div>";}}
else{ if (index[i].split("^")[0]=="chapter"){ result_html=result_html+"<div id=\"index_"+i+"\" class=\""+index[i].split("^")[0]+"_default\" name=\""+index[i].split("^")[0]+"\" style=\"position:relative;cursor:"+pointer_cursor+";\"><input type=\"text\" class=\"\" style=\"width:80%;\" value=\""+index[i].split("^")[1]+"\" onchange=\"update_index(this.parentNode)\"><input type=\"text\" class=\"\" style=\"width:10%;font-size:9px;\" value=\""+index[i].split("^")[2]+"\" onchange=\"update_index(this.parentNode)\"></div>";}
if (index[i].split("^")[0]=="anchor"){ result_html=result_html+"<div id=\"index_"+i+"\" class=\""+index[i].split("^")[0]+"_default\" name=\""+index[i].split("^")[0]+"\" style=\"position:relative;cursor:"+pointer_cursor+";\"><input type=\"text\" class=\"\" style=\"width:90%;\" value=\""+index[i].split("^")[1]+"\" onchange=\"update_index(this.parentNode)\"><input type=\"hidden\" class=\"\" value=\""+index[i].split("^")[2]+","+index[i].split("^")[3]+","+index[i].split("^")[4]+","+index[i].split("^")[5]+"\"></div>";}}}
if (result_html==""){ result_html="<div class=\"book_message\">目次は設定されていません。</div>";}
object_html=result_html;}
if (val==2){ object_html=object_html+"<form action=\"JavaScript:go_search(1)\"><input id=\"search_field\" type=\"text\" class=\"\" style=\"\" value=\""+keyword+"\"></form>"; object_html=object_html+"<div id=\"search_go\" style=\"position:absolute;left:0px;top:0px;cursor:"+pointer_cursor+";overflow:hidden;\" onclick=\"go_search(1)\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"search_clear\" style=\"position:absolute;left:0px;top:0px;cursor:"+pointer_cursor+";overflow:hidden;\" onclick=\"clear_search()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"searchview\" style=\"position:absolute;left:0px;top:0px;width:"+(parseInt(get_style(book_view,"width")))+"px;height:0px;cursor: default;overflow:auto;\">"; object_html=object_html+"</div>";}
if (val==3){ object_html=object_html+"<div id=\"bookmark_add\" style=\"position:absolute;left:0px;top:0px;cursor:"+pointer_cursor+";overflow:hidden;\" onclick=\"add_bookmark()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"bookmark_deleteall\" style=\"position:absolute;left:0px;top:0px;cursor:"+pointer_cursor+";overflow:hidden;\" onclick=\"delete_all_bookmark()\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div class=\"object\"><img></div></div>"; object_html=object_html+"<div id=\"bookmarkview\" style=\"position:absolute;left:0px;top:0px;width:"+(parseInt(get_style(book_view,"width")))+"px;height:0px;cursor: default;overflow:auto;\">"; result_html=""; for(i=0;i<bookmark.split("¶").length;i=i+1){ if (bookmark.split("¶")[i]!=""){ result_html=result_html+"<div id=\"bookmark_"+i+"\" class=\"bookmark_default\" name=\"bookmark\" style=\"clear:both;\" onmouseover=\"focus_object(this)\" onmouseout=\"blur_object(this)\">"; result_html=result_html+"<div id=\"bookmark_header_"+i+"\" class=\"bookmark_header\" style=\"\">"; result_html=result_html+"<div id=\"bookmark_edit_"+i+"\" class=\"bookmark_edit\" style=\"float:left;cursor:"+pointer_cursor+";overflow:hidden;\" onclick=\"edit_bookmark("+i+")\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div style=\"position:relative;\"><img src=\"image/bookmark_edit.png\"></div></div>"; result_html=result_html+"<div id=\"bookmark_delete_"+i+"\" class=\"bookmark_delete\" style=\"cursor:"+pointer_cursor+";overflow:hidden;\" onclick=\"delete_bookmark("+i+")\" onmouseover=\"rollover(this)\" onmouseout=\"rollout(this)\"><div style=\"position:relative;\"><img src=\"image/bookmark_delete.png\"></div></div>"; result_html=result_html+"</div>"; result_html=result_html+"<div id=\"bookmark_text_"+i+"\" class=\"bookmark_text\" style=\"cursor:"+pointer_cursor+";\" onclick=\"show_anchor("+bookmark.split("¶")[i].split("^")[2]+","+bookmark.split("¶")[i].split("^")[3]+","+bookmark.split("¶")[i].split("^")[4]+","+bookmark.split("¶")[i].split("^")[5]+")\">"+bookmark.split("¶")[i].split("^")[1]+"</div>"; result_html=result_html+"</div>";}}
if (result_html==""){ result_html="<div class=\"book_message\">ブックマークは設定されていません。</div>";}
object_html=object_html+result_html+"</div>";}
book_view.innerHTML=object_html; if (val==2){ document.getElementById("search_go").style.left=(canvas_margin+parseInt(get_style(document.getElementById("search_field"),"width")))+"px"; document.getElementById("search_clear").style.left=(canvas_margin*2+parseInt(get_style(document.getElementById("search_field"),"width"))+parseInt(get_style(document.getElementById("search_go"),"width")))+"px"; document.getElementById("searchview").style.top=((canvas_margin)+parseInt(get_style(document.getElementById("search_field"),"height")))+"px"; document.getElementById("searchview").style.height=(parseInt(get_style(book_view,"height"))-(canvas_margin)-parseInt(get_style(document.getElementById("search_field"),"height")))+"px"; load_button("search_go"); load_button("search_clear"); go_search(0);}
if (val==3){ document.getElementById("bookmark_deleteall").style.left=(canvas_margin+parseInt(get_style(document.getElementById("bookmark_add"),"width")))+"px"; document.getElementById("bookmarkview").style.top=(canvas_margin+parseInt(get_style(document.getElementById("bookmark_add"),"height")))+"px"; document.getElementById("bookmarkview").style.height=(parseInt(get_style(book_view,"height"))-canvas_margin-parseInt(get_style(document.getElementById("bookmark_add"),"height")))+"px"; load_button("bookmark_add"); load_button("bookmark_deleteall"); for(i=0;i<bookmark.split("¶").length;i=i+1){ if (bookmark.split("¶")[i]!=""){ load_button("bookmark_edit_"+i); load_button("bookmark_delete_"+i);}}}
if (edit_mode){ for (i=0; i<book_view.childNodes.length; i++) { if (book_view.childNodes[i].getAttribute("name")=="chapter" || book_view.childNodes[i].getAttribute("name")=="anchor"){ book_view.childNodes[i].onmousedown=mouse_down;}}
if (document.getElementById(edit_id)){ focus_object(document.getElementById(edit_id));}
else{ edit_id=null;}}
if (!edit_mode && book_panel.style.visibility=="visible"){ document.getElementById("book_image").style.visibility="visible"; document.getElementById("book_index").style.visibility="visible"; document.getElementById("book_search").style.visibility="visible"; document.getElementById("book_bookmark").style.visibility="visible";}
else{ document.getElementById("book_image").style.visibility="hidden"; document.getElementById("book_index").style.visibility="hidden"; document.getElementById("book_search").style.visibility="hidden"; document.getElementById("book_bookmark").style.visibility="hidden";}}
function load_canvas(){ var r=0; var c=0; var m=0; bc_count=parseInt(frame_width/(block_size*2))+2; br_count=parseInt(frame_height/(block_size*2))+2; fc_count=parseInt(frame_width/block_size)+2; fr_count=parseInt(frame_height/block_size)+2; if (bc_count>(current_scale/2)){ bc_count=current_scale/2;}
if (br_count>(current_scale/2)){ br_count=current_scale/2;}
if (fc_count>current_scale){ fc_count=current_scale;}
if (fr_count>current_scale){ fr_count=current_scale;}
var object_html=""; if (proportion>=1){ m=parseInt((1-(1/proportion))*(current_scale*block_size)/2);}
if (proportion<1){ m=parseInt((1-proportion)*(current_scale*block_size)/2);}
if (proportion>=1){ object_html=object_html+"<div id=\"b_canvas\" class=\"object\" style=\"left:0px;top:"+m+"px;width:"+(block_size*current_scale)+"px;height:"+(block_size*current_scale-m*2)+"px;overflow:hidden;z-index:1001;\"></div>"; object_html=object_html+"<div id=\"f_canvas\" class=\"object\" style=\"left:0px;top:"+m+"px;width:"+(block_size*current_scale)+"px;height:"+(block_size*current_scale-m*2)+"px;overflow:hidden;z-index:2001;\"></div>";}
if (proportion<1){ object_html=object_html+"<div id=\"b_canvas\" class=\"object\" style=\"left:"+m+"px;top:0px;width:"+(block_size*current_scale-m*2)+"px;height:"+(block_size*current_scale)+"px;overflow:hidden;z-index:1001;\"></div>"; object_html=object_html+"<div id=\"f_canvas\" class=\"object\" style=\"left:"+m+"px;top:0px;width:"+(block_size*current_scale-m*2)+"px;height:"+(block_size*current_scale)+"px;overflow:hidden;z-index:2001;\"></div>";}
if (proportion>=1){ object_html=object_html+"<div id=\"lefteffect\" class=\"object\" style=\"left:0px;top:"+m+"px;width:"+((current_scale/2)*block_size)+"px;height:"+(current_scale*block_size-m*2)+"px;z-index:4001;overflow:hidden;\"></div>"; object_html=object_html+"<div id=\"righteffect\" class=\"object\" style=\"left:"+((current_scale/2)*block_size)+"px;top:"+m+"px;width:"+((current_scale/2)*block_size)+"px;height:"+(current_scale*block_size-m*2)+"px;z-index:4002;overflow:hidden;\"></div>";}
if (proportion<1){ object_html=object_html+"<div id=\"lefteffect\" class=\"object\" style=\"left:"+m+"px;top:0px;width:"+((current_scale/2)*block_size-m)+"px;height:"+(current_scale*block_size)+"px;z-index:4001;overflow:hidden;\"></div>"; object_html=object_html+"<div id=\"righteffect\" class=\"object\" style=\"left:"+((current_scale/2)*block_size)+"px;top:0px;width:"+((current_scale/2)*block_size-m)+"px;height:"+(current_scale*block_size)+"px;z-index:4002;overflow:hidden;\"></div>";}
object_html=object_html+"<div id=\"gutter\" class=\"gutter\" style=\"position:absolute;z-index:4003;\"><img></div>"; if (proportion>=1){ object_html=object_html+"<div id=\"touch\" style=\"position:absolute;cursor: move;left:0px;top:"+m+"px;width:"+(current_scale*block_size)+"px;height:"+(current_scale*block_size-m*2)+"px;z-index:4004;overflow:hidden;\"></div>";}
if (proportion<1){ object_html=object_html+"<div id=\"touch\" style=\"position:absolute;cursor: move;left:"+m+"px;top:0px;width:"+(current_scale*block_size-m*2)+"px;height:"+(current_scale*block_size)+"px;z-index:4004;overflow:hidden;\"></div>";}
object_html=object_html+"<div id=\"skin_corner_topleft\" class=\"skin\" style=\"position:absolute;z-index:4011;\"><img></div>"; object_html=object_html+"<div id=\"skin_cornerside_topleft\" class=\"skin\" style=\"position:absolute;z-index:4012;\"><img></div>"; object_html=object_html+"<div id=\"skin_bar_topleft\" class=\"skin\" style=\"position:absolute;z-index:4013;\"><img></div>"; object_html=object_html+"<div id=\"skin_center_top\" class=\"skin\" style=\"position:absolute;z-index:4014;\"><img></div>"; object_html=object_html+"<div id=\"skin_bar_topright\" class=\"skin\" style=\"position:absolute;z-index:4015;\"><img></div>"; object_html=object_html+"<div id=\"skin_cornerside_topright\" class=\"skin\" style=\"position:absolute;z-index:4016;\"><img></div>"; object_html=object_html+"<div id=\"skin_corner_topright\" class=\"skin\" style=\"position:absolute;z-index:4017;\"><img></div>"; object_html=object_html+"<div id=\"skin_cornerside_lefttop\" class=\"skin\" style=\"position:absolute;z-index:4018;\"><img></div>"; object_html=object_html+"<div id=\"skin_bar_lefttop\" class=\"skin\" style=\"position:absolute;z-index:4019;\"><img></div>"; object_html=object_html+"<div id=\"skin_center_left\" class=\"skin\" style=\"position:absolute;z-index:4020;\"><img></div>"; object_html=object_html+"<div id=\"skin_bar_leftbottom\" class=\"skin\" style=\"position:absolute;z-index:4021;\"><img></div>"; object_html=object_html+"<div id=\"skin_cornerside_leftbottom\" class=\"skin\" style=\"position:absolute;z-index:4022;\"><img></div>"; object_html=object_html+"<div id=\"skin_cornerside_righttop\" class=\"skin\" style=\"position:absolute;z-index:4023;\"><img></div>"; object_html=object_html+"<div id=\"skin_bar_righttop\" class=\"skin\" style=\"position:absolute;z-index:4024;\"><img></div>"; object_html=object_html+"<div id=\"skin_center_right\" class=\"skin\" style=\"position:absolute;z-index:4025;\"><img></div>"; object_html=object_html+"<div id=\"skin_bar_rightbottom\" class=\"skin\" style=\"position:absolute;z-index:4026;\"><img></div>"; object_html=object_html+"<div id=\"skin_cornerside_rightbottom\" class=\"skin\" style=\"position:absolute;z-index:4027;\"><img></div>"; object_html=object_html+"<div id=\"skin_corner_bottomleft\" class=\"skin\" style=\"position:absolute;z-index:4028;\"><img></div>"; object_html=object_html+"<div id=\"skin_cornerside_bottomleft\" class=\"skin\" style=\"position:absolute;z-index:4029;\"><img></div>"; object_html=object_html+"<div id=\"skin_bar_bottomleft\" class=\"skin\" style=\"position:absolute;z-index:4030;\"><img></div>"; object_html=object_html+"<div id=\"skin_center_bottom\" class=\"skin\" style=\"position:absolute;z-index:4031;\"><img></div>"; object_html=object_html+"<div id=\"skin_bar_bottomright\" class=\"skin\" style=\"position:absolute;z-index:4032;\"><img></div>"; object_html=object_html+"<div id=\"skin_cornerside_bottomright\" class=\"skin\" style=\"position:absolute;z-index:4033;\"><img></div>"; object_html=object_html+"<div id=\"skin_corner_bottomright\" class=\"skin\" style=\"position:absolute;z-index:4034;\"><img></div>"; object_html=object_html+"<div id=\"media_property\" style=\"position:absolute;padding:4px;border:2px #000000 solid;left:0px;top:0px;background-color: #EEEEEE;font-size:10px;font-weight:bold;z-index:4035;visibility:hidden;\">"; object_html=object_html+"メディアファイル：<form id=\"source\" name=\"source\" method=\"post\" target=\"\" enctype=\"multipart/form-data\" action=\"JavaScript:blank()\"><input type=\"file\" id=\"file\" name=\"file\" value=\"\" onchange=\"upload_media()\"><input type=\"hidden\" name=\"job_id\" value=\""+job_id+"\"><input type=\"hidden\" id=\"media_file\"  name=\"media_file\" value=\"\"></form>"; object_html=object_html+"URL：<input type=\"text\" id=\"media_src\" class=\"\" style=\"width:280px;font-size:10px;\" value=\"\" onchange=\"update_media()\">"; object_html=object_html+"<br>"; object_html=object_html+"X：<input type=\"text\" id=\"media_x\" class=\"\" style=\"width:40px;font-size:10px;\" value=\"\" onchange=\"update_media()\">"; object_html=object_html+"　Y：<input type=\"text\" id=\"media_y\" class=\"\" style=\"width:40px;font-size:10px;\" value=\"\" onchange=\"update_media()\">"; object_html=object_html+"　幅：<input type=\"text\" id=\"media_w\" class=\"\" style=\"width:40px;font-size:10px;\" value=\"\" onchange=\"update_media()\">"; object_html=object_html+"　高さ：<input type=\"text\" id=\"media_h\" class=\"\" style=\"width:40px;font-size:10px;\" value=\"\" onchange=\"update_media()\">"; object_html=object_html+"<br>"; object_html=object_html+"<input type=\"checkbox\" id=\"media_start\" class=\"\" value=\"1\" onClick=\"update_media()\">自動再生"; object_html=object_html+"　<input type=\"checkbox\" id=\"media_loop\" class=\"\" value=\"1\" onClick=\"update_media()\">ループ"; object_html=object_html+"　<input type=\"checkbox\" id=\"media_control\" class=\"\" value=\"1\" onClick=\"update_media()\">コントロール"; object_html=object_html+"　バック：<input type=\"text\" id=\"media_back\" class=\"\" style=\"width:60px;font-size:10px;\" value=\"\" onchange=\"update_media()\">"; object_html=object_html+"<iframe name=\"temp\" src=\"image/dot.png\" width=0px height=0px border=0px frameborder=0px style=\"visibility:hidden;\"></iframe>"; object_html=object_html+"</div>"; object_html=object_html+"<div id=\"hyperlink_property\" style=\"position:absolute;padding:4px;border:2px #000000 solid;left:0px;top:0px;background-color: #EEEEEE;font-size:10px;font-weight:bold;z-index:4036;visibility:hidden;\">"; object_html=object_html+"タイトル：<input type=\"text\" id=\"hyperlink_title\" class=\"\" style=\"width:280px;font-size:10px;\" value=\"\" onchange=\"update_hyperlink()\">"; object_html=object_html+"<br>"; object_html=object_html+"URL：<input type=\"text\" id=\"hyperlink_url\" class=\"\" style=\"width:200px;font-size:10px;\" value=\"\" onchange=\"update_hyperlink()\">"; object_html=object_html+"　ターゲット：<input type=\"text\" id=\"hyperlink_target\" class=\"\" style=\"width:40px;font-size:10px;\" value=\"\" onchange=\"update_hyperlink()\">"; object_html=object_html+"<br>"; object_html=object_html+"X：<input type=\"text\" id=\"hyperlink_x\" class=\"\" style=\"width:40px;font-size:10px;\" value=\"\" onchange=\"update_hyperlink()\">"; object_html=object_html+"　Y：<input type=\"text\" id=\"hyperlink_y\" class=\"\" style=\"width:40px;font-size:10px;\" value=\"\" onchange=\"update_hyperlink()\">"; object_html=object_html+"　幅：<input type=\"text\" id=\"hyperlink_w\" class=\"\" style=\"width:40px;font-size:10px;\" value=\"\" onchange=\"update_hyperlink()\">"; object_html=object_html+"　高さ：<input type=\"text\" id=\"hyperlink_h\" class=\"\" style=\"width:40px;font-size:10px;\" value=\"\" onchange=\"update_hyperlink()\">"; object_html=object_html+"</div>"; canvas.innerHTML=object_html; f_canvas=document.getElementById("f_canvas"); b_canvas=document.getElementById("b_canvas"); lefteffect=document.getElementById("lefteffect"); righteffect=document.getElementById("righteffect"); touch=document.getElementById("touch"); if (demo_mode){ touch.style.backgroundImage="url('image/demo.gif')";}
touch.onmousedown=mouse_down;}
function load_touch(){ clear_edit(); var i=0; var object_html=""; object_html=object_html+"<div style=\"position:absolute;left:0px;top:0px;width:"+parseInt(get_style(touch,"width"))+"px;height:"+parseInt(get_style(touch,"height"))+"px;background-color: #FFFFFF;filter:alpha(opacity=0);-moz-opacity:0;opacity:0;\"></div>"; if (media[arr(current_spread,3)]){ for(i=0;i<media[arr(current_spread,3)].length;i=i+1){ if (!edit_mode){ object_html=object_html+"<"+media[arr(current_spread,3)][i].split("^")[0]+" id=\"media_"+i+"\" class=\"media_default\" name=\"media\"  src=\""+media[arr(current_spread,3)][i].split("^")[1]+"\" width=\""+parseInt(parseInt(media[arr(current_spread,3)][i].split("^")[5])/1000*(current_scale*block_size))+"px\" height=\""+parseInt(parseInt(media[arr(current_spread,3)][i].split("^")[6])/1000*(current_scale*block_size))+"px\" bgcolor=\""+media[arr(current_spread,3)][i].split("^")[10]+"\" play=\""+blstr[parseInt(media[arr(current_spread,3)][i].split("^")[7])]+"\" autostart=\""+blstr[parseInt(media[arr(current_spread,3)][i].split("^")[7])]+"\" autoplay=\""+blstr[parseInt(media[arr(current_spread,3)][i].split("^")[7])]+"\" loop=\""+blstr[parseInt(media[arr(current_spread,3)][i].split("^")[8])]+"\" showcontrols=\""+blstr[parseInt(media[arr(current_spread,3)][i].split("^")[9])]+"\" controller=\""+blstr[parseInt(media[arr(current_spread,3)][i].split("^")[9])]+"\" scale=\"aspect\" style=\"position:absolute;left:"+parseInt(parseInt(media[arr(current_spread,3)][i].split("^")[3])/1000*(current_scale*block_size))+"px;top:"+parseInt(parseInt(media[arr(current_spread,3)][i].split("^")[4])/1000*(current_scale*block_size))+"px;width:"+parseInt(parseInt(media[arr(current_spread,3)][i].split("^")[5])/1000*(current_scale*block_size))+"px;height:"+parseInt(parseInt(media[arr(current_spread,3)][i].split("^")[6])/1000*(current_scale*block_size))+"px;\">";}
else{ object_html=object_html+"<div id=\"media_"+i+"\" class=\"media_highlight\" name=\"media\"  style=\"position:absolute;left:"+parseInt(parseInt(media[arr(current_spread,3)][i].split("^")[3])/1000*(current_scale*block_size))+"px;top:"+parseInt(parseInt(media[arr(current_spread,3)][i].split("^")[4])/1000*(current_scale*block_size))+"px;width:"+parseInt(parseInt(media[arr(current_spread,3)][i].split("^")[5])/1000*(current_scale*block_size))+"px;height:"+parseInt(parseInt(media[arr(current_spread,3)][i].split("^")[6])/1000*(current_scale*block_size))+"px;cursor:"+pointer_cursor+";\"><img src=\"image/dot.png\" style=\"border:0px;\"></div>";}}}
if (hyperlink[arr(current_spread,3)]){ for(i=0;i<hyperlink[arr(current_spread,3)].length;i=i+1){ if (!edit_mode){ object_html=object_html+"<a id=\"hyperlink_"+i+"\" class=\"hyperlink_default\" name=\"hyperlink\" title=\""+hyperlink[arr(current_spread,3)][i].split("^")[0]+"\" href=\""+hyperlink[arr(current_spread,3)][i].split("^")[1]+"\" target=\""+hyperlink[arr(current_spread,3)][i].split("^")[2]+"\" style=\"position:absolute;left:"+parseInt(parseInt(hyperlink[arr(current_spread,3)][i].split("^")[3])/1000*(current_scale*block_size))+"px;top:"+parseInt(parseInt(hyperlink[arr(current_spread,3)][i].split("^")[4])/1000*(current_scale*block_size))+"px;width:"+parseInt(parseInt(hyperlink[arr(current_spread,3)][i].split("^")[5])/1000*(current_scale*block_size))+"px;height:"+parseInt(parseInt(hyperlink[arr(current_spread,3)][i].split("^")[6])/1000*(current_scale*block_size))+"px;cursor:"+pointer_cursor+";\" onmouseover=\"focus_object(this)\" onmouseout=\"blur_object(this)\"><img src=\"image/dot.png\" style=\"border:0px;\"></a>";}
else{ object_html=object_html+"<div id=\"hyperlink_"+i+"\" class=\"hyperlink_highlight\" name=\"hyperlink\"  style=\"position:absolute;left:"+parseInt(parseInt(hyperlink[arr(current_spread,3)][i].split("^")[3])/1000*(current_scale*block_size))+"px;top:"+parseInt(parseInt(hyperlink[arr(current_spread,3)][i].split("^")[4])/1000*(current_scale*block_size))+"px;width:"+parseInt(parseInt(hyperlink[arr(current_spread,3)][i].split("^")[5])/1000*(current_scale*block_size))+"px;height:"+parseInt(parseInt(hyperlink[arr(current_spread,3)][i].split("^")[6])/1000*(current_scale*block_size))+"px;cursor:"+pointer_cursor+";\"><img src=\"image/dot.png\" style=\"border:0px;\"></div>";}}}
var m=0; if (proportion>=1){ m=parseInt((1-(1/proportion))*(current_scale*block_size)/2);}
if (proportion<1){ m=parseInt((1-proportion)*(current_scale*block_size)/2);}
object_html=object_html+"<div id=\"curl_left\" class=\"curl\" style=\"position:absolute;left:0px;top:"+parseInt(get_style(touch,"height"))+"px;cursor:"+pointer_cursor+";visibility:hidden;\" onclick=\"left_spread()\"><img></div>"; object_html=object_html+"<div id=\"curl_right\" class=\"curl\" style=\"position:absolute;left:"+parseInt(get_style(touch,"width"))+"px;top:"+parseInt(get_style(touch,"height"))+"px;cursor:"+pointer_cursor+";visibility:hidden;\" onclick=\"right_spread()\"><img></div>"; touch.innerHTML=object_html; document.getElementById("curl_left").style.top=(parseInt(get_style(document.getElementById("curl_left"),"top"))-parseInt(get_style(document.getElementById("curl_left"),"height")))+"px"; document.getElementById("curl_right").style.left=(parseInt(get_style(document.getElementById("curl_right"),"left"))-parseInt(get_style(document.getElementById("curl_right"),"width")))+"px"; document.getElementById("curl_right").style.top=(parseInt(get_style(document.getElementById("curl_right"),"top"))-parseInt(get_style(document.getElementById("curl_right"),"height")))+"px"; if (!edit_mode){ if((!bind && current_spread>1)||(bind && current_spread<spread_count)){ document.getElementById("curl_left").style.visibility="visible";}
if((!bind && current_spread<spread_count)||(bind && current_spread>1)){ document.getElementById("curl_right").style.visibility="visible";}
load_png("curl_left","image/curl_left.png"); load_png("curl_right","image/curl_right.png");}
for (i=0; i<touch.childNodes.length; i++) { if (touch.childNodes[i].getAttribute("name")=="media"){ touch.childNodes[i].onmousedown=mouse_down;}}
if (edit_mode){ for (i=0; i<touch.childNodes.length; i++) { if (touch.childNodes[i].getAttribute("name")=="hyperlink" || touch.childNodes[i].getAttribute("name")=="media"){ touch.childNodes[i].onmousedown=mouse_down;}}
if (document.getElementById(edit_id)){ focus_object(document.getElementById(edit_id));}
else{ edit_id=null;}}}
function load_map(){ var m=0; var object_html=""; if (proportion>=1){ m=parseInt((1-(1/proportion))*map_size/2);}
if (proportion<1){ m=parseInt((1-proportion)*map_size/2);}
object_html=object_html+"<div class=\"object\" style=\"left:"+canvas_margin+"px;top:"+canvas_margin+"px;width:"+map_size+"px;height:"+map_size+"px;\">"; if (proportion>=1){ object_html=object_html+"<div id=\"map_mask\" class=\"object\" style=\"left:0px;top:"+m+"px;width:"+(map_size)+"px;height:"+(map_size-m*2)+"px;overflow:hidden;\"><img class=\"object\" src=\"contents/"+earr(job_id,current_spread,3)+"/"+earr(job_id,0,3)+contents_format+"\" style=\"left:0px;top:"+(-m)+"px;width:"+map_size+"px;height:"+map_size+"px;\"></div>";}
if (proportion<1){ object_html=object_html+"<div id=\"map_mask\" class=\"object\" style=\"left:"+m+"px;top:0px;width:"+(map_size-m*2)+"px;height:"+(map_size)+"px;overflow:hidden;\"><img class=\"object\" src=\"contents/"+earr(job_id,current_spread,3)+"/"+earr(job_id,0,3)+contents_format+"\" style=\"left:"+(-m)+"px;top:0px;width:"+map_size+"px;height:"+map_size+"px;\"></div>";}
object_html=object_html+"<div id=\"scope\" class=\"object\" style=\"position:absolute;left:0px;top:0px;width:0px;height:0px;cursor:"+pointer_cursor+";\"><div class=\"object\" style=\"left:0px;top:0px;width:0px;height:0px;background-color: #FFFFFF;filter:alpha(opacity=0);-moz-opacity:0;opacity:0;\"></div></div>"; object_html=object_html+"</div>"; map_view.innerHTML=object_html; scope=document.getElementById("scope"); map_mask=document.getElementById("map_mask"); scope.onmousedown=mouse_down;}
function masking(){ var t=parseInt(get_style(f_canvas,"top")); var l=parseInt(get_style(f_canvas,"left")); var b=parseInt(get_style(f_canvas,"top"))+parseInt(get_style(f_canvas,"height")); var r=parseInt(get_style(f_canvas,"left"))+parseInt(get_style(f_canvas,"width")); var p=parseInt(get_style(document.getElementById("skin_corner_topleft"),"width")); var h=parseInt(p/2); var g=parseInt(get_style(document.getElementById("gutter"),"width")); var c=0; if (facing){ c=1;}
if (((current_spread==1)||(target_spread==1))&&(facing==1)&&(bind!=start_page)){ if (!bind){ l=parseInt(get_style(f_canvas,"left"))+parseInt(parseInt(get_style(f_canvas,"width"))/2); map_mask.style.clip="rect(auto auto auto "+(parseInt(get_style(map_mask,"width"))/2)+"px)";}
else{ r=parseInt(get_style(f_canvas,"left"))+parseInt(parseInt(get_style(f_canvas,"width"))/2); map_mask.style.clip="rect(auto "+(parseInt(get_style(map_mask,"width"))/2)+"px auto auto)";}
c=0;}
else if (((current_spread==spread_count)||(target_spread==spread_count))&&(facing==1)&&((bind+start_page+page_count)%2==1)){ if (!bind){ r=parseInt(get_style(f_canvas,"left"))+parseInt(parseInt(get_style(f_canvas,"width"))/2); map_mask.style.clip="rect(auto "+(parseInt(get_style(map_mask,"width"))/2)+"px auto auto)";}
else{ l=parseInt(get_style(f_canvas,"left"))+parseInt(parseInt(get_style(f_canvas,"width"))/2); map_mask.style.clip="rect(auto auto auto "+(parseInt(get_style(map_mask,"width"))/2)+"px)";}
c=0;}
var hc=l+parseInt((r-l)/2); var vc=t+parseInt((b-t)/2); touch.style.left=(l)+"px"; touch.style.width=(r-l)+"px"; document.getElementById("skin_corner_topleft").style.cssText="position:absolute;left:"+(l-p)+"px;top:"+(t-p)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_cornerside_topleft").style.cssText="position:absolute;left:"+(l)+"px;top:"+(t-p)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_bar_topleft").style.cssText="position:absolute;left:"+(l+p)+"px;top:"+(t-p)+"px;width:"+(hc-l-p-h*c)+"px;height:"+(p)+"px;"; if (c){ document.getElementById("skin_center_top").style.cssText="position:absolute;left:"+(hc-h)+"px;top:"+(t-p)+"px;width:"+(p)+"px;height:"+(p)+"px;visibility:visible;";}
else{ document.getElementById("skin_center_top").style.cssText="position:absolute;left:"+(hc-h)+"px;top:"+(t-p)+"px;width:"+(p)+"px;height:"+(p)+"px;visibility:hidden;";}
document.getElementById("skin_bar_topright").style.cssText="position:absolute;left:"+(hc+h*c)+"px;top:"+(t-p)+"px;width:"+(r-hc-p-h*c)+"px;height:"+(p)+"px;"; document.getElementById("skin_cornerside_topright").style.cssText="position:absolute;left:"+(r-p)+"px;top:"+(t-p)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_corner_topright").style.cssText="position:absolute;left:"+(r)+"px;top:"+(t-p)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_cornerside_lefttop").style.cssText="position:absolute;left:"+(l-p)+"px;top:"+(t)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_bar_lefttop").style.cssText="position:absolute;left:"+(l-p)+"px;top:"+(t+p)+"px;width:"+(p)+"px;height:"+(vc-t-p-h)+"px;"; document.getElementById("skin_center_left").style.cssText="position:absolute;left:"+(l-p)+"px;top:"+(vc-h)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_bar_leftbottom").style.cssText="position:absolute;left:"+(l-p)+"px;top:"+(vc+h)+"px;width:"+(p)+"px;height:"+(b-vc-p-h)+"px;"; document.getElementById("skin_cornerside_leftbottom").style.cssText="position:absolute;left:"+(l-p)+"px;top:"+(b-p)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_cornerside_righttop").style.cssText="position:absolute;left:"+(r)+"px;top:"+(t)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_bar_righttop").style.cssText="position:absolute;left:"+(r)+"px;top:"+(t+p)+"px;width:"+(p)+"px;height:"+(vc-t-p-h)+"px;"; document.getElementById("skin_center_right").style.cssText="position:absolute;left:"+(r)+"px;top:"+(vc-h)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_bar_rightbottom").style.cssText="position:absolute;left:"+(r)+"px;top:"+(vc+h)+"px;width:"+(p)+"px;height:"+(b-vc-p-h)+"px;"; document.getElementById("skin_cornerside_rightbottom").style.cssText="position:absolute;left:"+(r)+"px;top:"+(b-p)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_corner_bottomleft").style.cssText="position:absolute;left:"+(l-p)+"px;top:"+(b)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_cornerside_bottomleft").style.cssText="position:absolute;left:"+(l)+"px;top:"+(b)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_bar_bottomleft").style.cssText="position:absolute;left:"+(l+p)+"px;top:"+(b)+"px;width:"+(hc-l-p-h*c)+"px;height:"+(p)+"px;"; if (c){ document.getElementById("skin_center_bottom").style.cssText="position:absolute;left:"+(hc-h)+"px;top:"+(b)+"px;width:"+(p)+"px;height:"+(p)+"px;visibility:visible;";}
else{ document.getElementById("skin_center_bottom").style.cssText="position:absolute;left:"+(hc-h)+"px;top:"+(b)+"px;width:"+(p)+"px;height:"+(p)+"px;visibility:hidden;";}
document.getElementById("skin_bar_bottomright").style.cssText="position:absolute;left:"+(hc+h*c)+"px;top:"+(b)+"px;width:"+(r-hc-p-h*c)+"px;height:"+(p)+"px;"; document.getElementById("skin_cornerside_bottomright").style.cssText="position:absolute;left:"+(r-p)+"px;top:"+(b)+"px;width:"+(p)+"px;height:"+(p)+"px;"; document.getElementById("skin_corner_bottomright").style.cssText="position:absolute;left:"+(r)+"px;top:"+(b)+"px;width:"+(p)+"px;height:"+(p)+"px;"; if (c){ document.getElementById("gutter").style.cssText="position:absolute;left:"+(hc-parseInt(g/2))+"px;top:"+(t)+"px;width:"+(g)+"px;height:"+(b-t)+"px;visibility:visible;z-index:4003;";}
else{ document.getElementById("gutter").style.cssText="position:absolute;left:"+(hc-parseInt(g/2))+"px;top:"+(t)+"px;width:"+(g)+"px;height:"+(b-t)+"px;visibility:hidden;z-index:4003;";}
load_png("skin_corner_topleft","image/skin_corner_topleft.png"); load_png("skin_cornerside_topleft","image/skin_cornerside_topleft.png"); load_png("skin_bar_topleft","image/skin_bar_top.png"); load_png("skin_center_top","image/skin_center_top.png"); load_png("skin_bar_topright","image/skin_bar_top.png"); load_png("skin_cornerside_topright","image/skin_cornerside_topright.png"); load_png("skin_corner_topright","image/skin_corner_topright.png"); load_png("skin_cornerside_lefttop","image/skin_cornerside_lefttop.png"); load_png("skin_bar_lefttop","image/skin_bar_left.png"); load_png("skin_center_left","image/skin_center_left.png"); load_png("skin_bar_leftbottom","image/skin_bar_left.png"); load_png("skin_cornerside_leftbottom","image/skin_cornerside_leftbottom.png"); load_png("skin_cornerside_righttop","image/skin_cornerside_righttop.png"); load_png("skin_bar_righttop","image/skin_bar_right.png"); load_png("skin_center_right","image/skin_center_right.png"); load_png("skin_bar_rightbottom","image/skin_bar_right.png"); load_png("skin_cornerside_rightbottom","image/skin_cornerside_rightbottom.png"); load_png("skin_corner_bottomleft","image/skin_corner_bottomleft.png"); load_png("skin_cornerside_bottomleft","image/skin_cornerside_bottomleft.png"); load_png("skin_bar_bottomleft","image/skin_bar_bottom.png"); load_png("skin_center_bottom","image/skin_center_bottom.png"); load_png("skin_bar_bottomright","image/skin_bar_bottom.png"); load_png("skin_cornerside_bottomright","image/skin_cornerside_bottomright.png"); load_png("skin_corner_bottomright","image/skin_corner_bottomright.png"); load_png("gutter","image/gutter.png");}
function change_scale(val){ if (((val<=0)&&(current_scale<=min_block)) || ((val>0)&&(current_scale>=max_block))){ return;}
point_x=point_x/(current_scale*block_size); point_y=point_y/(current_scale*block_size); if (val>0){ current_scale=current_scale*2;}
else{ current_scale=current_scale/2;}
if (current_scale<min_block){ current_scale=min_block;}
if (current_scale>max_block){ current_scale=max_block;}
if (block_size!=default_size){ block_size=default_size;}
point_x=parseInt((current_scale*block_size)*point_x); point_y=parseInt((current_scale*block_size)*point_y); load_canvas(); load_map(); masking(); load_touch(); view_point();}
function fit_scale(){ var fit_adjust=parseInt(parseInt(get_style(tool,"height"))/2); if (get_fit_count()!=current_scale || point_x!=parseInt(current_scale*block_size/2) || point_y!=parseInt(current_scale*block_size/2+fit_adjust)){ current_scale=get_fit_count(); load_canvas(); point_x=parseInt(current_scale*block_size/2); point_y=parseInt(current_scale*block_size/2+fit_adjust); load_map(); masking(); load_touch(); view_point();}}
function get_fit_count(){ var fit_count=min_block; var w=0; var h=0; var overlook=0.9; while(1){ if (proportion>=1){ w=(fit_count*block_size); h=(1/proportion)*(fit_count*block_size);}
if (proportion<1){ w=(proportion)*(fit_count*block_size); h=(fit_count*block_size);}
if (frame_width<(w*overlook) || frame_height<(h*overlook)){ if (fit_count>min_block){ fit_count=fit_count/2;}
break;}
if (fit_count>=max_block){ break;}
fit_count=fit_count*2;}
return fit_count;}
function view_point(){ clearTimeout(view_id); var start_bc=(parseInt((point_x-frame_width/2)/(block_size*2))+1); if (start_bc<1){ start_bc=1;}
var end_bc=start_bc+bc_count-1; if (end_bc>(current_scale/2)){ end_bc=current_scale/2;}
var start_br=(parseInt((point_y-frame_height/2)/(block_size*2))+1); if (start_br<1){ start_br=1;}
var end_br=start_br+br_count-1; if (end_br>(current_scale/2)){ end_br=current_scale/2;}
var start_fc=(parseInt((point_x-frame_width/2)/block_size)+1); if (start_fc<1){ start_fc=1;}
var end_fc=start_fc+fc_count-1; if (end_fc>current_scale){ end_fc=current_scale;}
var start_fr=(parseInt((point_y-frame_height/2)/block_size)+1); if (start_fr<1){ start_fr=1;}
var end_fr=start_fr+fr_count-1; if (end_fr>current_scale){ end_fr=current_scale;}
var i=0; var r=0; var c=0; var cr=0; var sr=0; var er=0; var cc=0; var sc=0; var ec=0; canvas.style.left=(parseInt(frame_width/2-point_x))+"px"; canvas.style.top=(parseInt(frame_height/2-point_y))+"px"; if (current_scale>min_block){ for(i=b_canvas.childNodes.length-1;i>=0;i=i-1){ r=parseInt("1"+b_canvas.childNodes[i].id.split("_")[1])-1000; c=parseInt("1"+b_canvas.childNodes[i].id.split("_")[2])-1000; if(r<start_br || r>end_br || c<start_bc || c>end_bc){ b_canvas.removeChild(b_canvas.childNodes[i]);}}
for (r=start_br;r<=end_br;r=r+1) { for (c=start_bc;c<=end_bc;c=c+1) { load_block(b_canvas,current_scale/2,r,c,block_size*2);}}}
for(i=f_canvas.childNodes.length-1;i>=0;i=i-1){ r=parseInt("1"+f_canvas.childNodes[i].id.split("_")[1])-1000; c=parseInt("1"+f_canvas.childNodes[i].id.split("_")[2])-1000; if(r<start_fr || r>end_fr || c<start_fc || c>end_fc){ f_canvas.removeChild(f_canvas.childNodes[i]);}}
cc=(parseInt(point_x/block_size)+1); if (cc<start_fc){ cc=start_fc;}
if (cc>end_fc){ cc=end_fc;}
cr=(parseInt(point_y/block_size)+1); if (cr<start_fr){ cr=start_fr;}
if (cr>end_fr){ cr=end_fr;}
i=0; while(sr!=start_fr || er!=end_fr || sc!=start_fc || ec!=end_fc){ sr=cr-i; er=cr+i; sc=cc-i; ec=cc+i; if (sc<start_fc){ sc=start_fc;}
if (ec>end_fc){ ec=end_fc;}
if (sr<start_fr){ sr=start_fr;}
if (er>end_fr){ er=end_fr;}
for (r=sr;r<=er;r=r+1) { for (c=sc;c<=ec;c=c+1) { load_block(f_canvas,current_scale,r,c,block_size);}}
i=i+1;}
if (get_fit_count()<current_scale){ scope.style.width=(parseInt(frame_width/(current_scale*block_size)*map_size))+"px"; scope.style.height=(parseInt(frame_height/(current_scale*block_size)*map_size))+"px"; scope.style.left=(parseInt(map_size/(current_scale*block_size)*point_x-parseInt(scope.style.width)/2))+"px"; scope.style.top=(parseInt(map_size/(current_scale*block_size)*point_y-parseInt(scope.style.height)/2))+"px"; scope.firstChild.style.width=(parseInt(frame_width/(current_scale*block_size)*map_size))+"px"; scope.firstChild.style.height=(parseInt(frame_height/(current_scale*block_size)*map_size))+"px"; map.style.visibility="visible"; map_view.style.visibility="visible";}
else{ map.style.visibility="hidden"; map_view.style.visibility="hidden";}
if(document.selection){ if (canvas.getAttribute("style")=="[object]"){ if(!document.activeElement.type){ document.selection.empty();}}}
view_id=setTimeout("review_point()",500);}
function review_point(){ clearTimeout(view_id); if (!effect_mode && !drag_mode && !map_mode){ view_point();}
view_id=setTimeout("review_point()",500);}
function load_block(target_canvas,bb,br,bc,bs){ var b=0; if (((current_spread==1)||(target_spread==1))&&(facing==1)&&(bind!=start_page)){ if (!bind){ b=1;}
else{ b=2;}}
else if (((current_spread==spread_count)||(target_spread==spread_count))&&(facing==1)&&((bind+start_page+page_count)%2==1)){ if (!bind){ b=2;}
else{ b=1;}}
var m=0; if (proportion>=1){ m=parseInt((1-(1/proportion))*(current_scale*block_size)/2);}
if (proportion<1){ m=parseInt((1-proportion)*(current_scale*block_size)/2);}
var new_object=null; if (!document.getElementById(arr(bb,3)+"_"+arr(br,3)+"_"+arr(bc,3))){ new_object=document.createElement("div"); if (proportion>=1){ new_object.innerHTML="<div id=\""+arr(bb,3)+"_"+arr(br,3)+"_"+arr(bc,3)+"\" class=\"object\" style=\"left:"+((bc-1)*bs)+"px;top:"+((br-1)*bs-m)+"px;width:"+(bs)+"px;height:"+(bs)+"px;\"></div>";}
if (proportion<1){ new_object.innerHTML="<div id=\""+arr(bb,3)+"_"+arr(br,3)+"_"+arr(bc,3)+"\" class=\"object\" style=\"left:"+((bc-1)*bs-m)+"px;top:"+((br-1)*bs)+"px;width:"+(bs)+"px;height:"+(bs)+"px;\"></div>";}
target_canvas.appendChild(new_object.lastChild); if (!(b==1 && bc<=bb/2)&&!(b==2 && bc>bb/2)){ load_image(arr(bb,3)+"_"+arr(br,3)+"_"+arr(bc,3),"contents/"+earr(job_id,current_spread,3)+"/"+earr(job_id,bb,3)+"_"+earr(job_id,br,3)+"_"+earr(job_id,bc,3)+contents_format);}}
else{ if (!(b==1 && bc<=bb/2)&&!(b==2 && bc>bb/2)){ load_image(arr(bb,3)+"_"+arr(br,3)+"_"+arr(bc,3),"contents/"+earr(job_id,current_spread,3)+"/"+earr(job_id,bb,3)+"_"+earr(job_id,br,3)+"_"+earr(job_id,bc,3)+contents_format);}
else{ document.getElementById(arr(bb,3)+"_"+arr(br,3)+"_"+arr(bc,3)).innerHTML="";}}}
function preload_spread(){ var r=0; var c=0; if (get_fit_count()==current_scale){ if (current_spread<spread_count){ for (r=1;r<=current_scale;r=r+1) { for (c=1;c<=current_scale;c=c+1) { load_image("","contents/"+earr(job_id,current_spread+1,3)+"/"+earr(job_id,current_scale,3)+"_"+earr(job_id,r,3)+"_"+earr(job_id,c,3)+contents_format);}}}
if (current_spread>1){ for (r=1;r<=current_scale;r=r+1) { for (c=1;c<=current_scale;c=c+1) { load_image("","contents/"+earr(job_id,current_spread-1,3)+"/"+earr(job_id,current_scale,3)+"_"+earr(job_id,r,3)+"_"+earr(job_id,c,3)+contents_format);}}}}}
function earr(cd,num,col){ var k=0; var r=0; var l=new Array(); var e="9u_oil2ws1vqj0ac"; num=arr(num,col); k=parseInt(cd.substr(7,1), 16); r=k%5; if (r==0){ l=new Array(3,2,1);}
if (r==1){ l=new Array(2,1,3);}
if (r==2){ l=new Array(3,1,2);}
if (r==3){ l=new Array(2,3,1);}
if (r==4){ l=new Array(1,3,2);}
num=e.substr(((parseInt(num.substr(l[0]-1,1))+k)%16),1)+e.substr(((parseInt(num.substr(l[1]-1,1))+k)%16),1)+e.substr(((parseInt(num.substr(l[2]-1,1))+k)%16),1); return num;}
function load_button(button_name){ var button_object=document.getElementById(button_name); button_object.firstChild.style.left="0px"; button_object.firstChild.style.top="0px"; button_object.firstChild.style.width=(parseInt(get_style(button_object,"width")))+"px"; button_object.firstChild.style.height=(parseInt(get_style(button_object,"height"))*2)+"px"; if (button_name.indexOf("bookmark_edit_")==-1 && button_name.indexOf("bookmark_delete_")==-1){ button_object.firstChild.firstChild.src="image/"+button_name+".png";}
button_object.firstChild.firstChild.style.width=(parseInt(get_style(button_object.firstChild,"width")))+"px"; button_object.firstChild.firstChild.style.height=(parseInt(get_style(button_object.firstChild,"height")))+"px"; if (button_object.getAttribute("style")=="[object]"){ button_object.firstChild.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + button_object.firstChild.firstChild.src + ", sizingMethod=scale)"; button_object.firstChild.firstChild.style.visibility="hidden";}}
function rollover(button_object){ button_object.firstChild.style.top="-"+(parseInt(get_style(button_object,"height")))+"px";}
function rollout(button_object){ button_object.firstChild.style.top="0px";}
function show_book(){ book_panel.style.visibility="visible"; if (!edit_mode){ document.getElementById("book_image").style.visibility="visible"; document.getElementById("book_index").style.visibility="visible"; document.getElementById("book_search").style.visibility="visible"; document.getElementById("book_bookmark").style.visibility="visible";}
book_view.style.overflow="auto"; book.style.visibility="hidden";}
function hide_book(){ book_panel.style.visibility="hidden"; document.getElementById("book_image").style.visibility="hidden"; document.getElementById("book_index").style.visibility="hidden"; document.getElementById("book_search").style.visibility="hidden"; document.getElementById("book_bookmark").style.visibility="hidden"; book_view.style.overflow="hidden"; book.style.visibility="visible";}
function focus_object(target_object){ if (target_object.getAttribute("name")=="thumbnail"){ target_object.className="thumbnail_highlight";}
if (target_object.getAttribute("name")=="chapter"){ target_object.className="chapter_highlight";}
if (target_object.getAttribute("name")=="anchor"){ target_object.className="anchor_highlight";}
if (target_object.getAttribute("name")=="search"){ target_object.className="search_highlight";}
if (target_object.getAttribute("name")=="bookmark"){ target_object.className="bookmark_highlight";}
if (target_object.getAttribute("name")=="hyperlink"){ if (edit_mode){ target_object.className="hyperlink_edit"; document.getElementById("hyperlink_property").style.left=(parseInt(touch.style.left)+parseInt(target_object.style.left))+"px"; document.getElementById("hyperlink_property").style.top=(parseInt(touch.style.top)+parseInt(target_object.style.top)+parseInt(target_object.style.height)+canvas_margin)+"px"; document.getElementById("hyperlink_title").value=hyperlink[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[0]; document.getElementById("hyperlink_url").value=hyperlink[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[1]; document.getElementById("hyperlink_target").value=hyperlink[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[2]; document.getElementById("hyperlink_x").value=hyperlink[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[3]; document.getElementById("hyperlink_y").value=hyperlink[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[4]; document.getElementById("hyperlink_w").value=hyperlink[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[5]; document.getElementById("hyperlink_h").value=hyperlink[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[6]; document.getElementById("hyperlink_property").style.visibility="visible"; set_mouse_on(1);}
else{ target_object.className="hyperlink_highlight";}}
if (target_object.getAttribute("name")=="media"){ if (edit_mode){ target_object.className="media_edit"; document.getElementById("media_property").style.left=(parseInt(touch.style.left)+parseInt(target_object.style.left))+"px"; document.getElementById("media_property").style.top=(parseInt(touch.style.top)+parseInt(target_object.style.top)+parseInt(target_object.style.height)+canvas_margin)+"px"; document.getElementById("media_src").value=media[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[1]; document.getElementById("media_file").value=media[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[2]; document.getElementById("media_x").value=media[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[3]; document.getElementById("media_y").value=media[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[4]; document.getElementById("media_w").value=media[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[5]; document.getElementById("media_h").value=media[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[6]; if (parseInt(media[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[7])){ document.getElementById("media_start").checked=true;}
else{ document.getElementById("media_start").checked=false;}
if (parseInt(media[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[8])){ document.getElementById("media_loop").checked=true;}
else{ document.getElementById("media_loop").checked=false;}
if (parseInt(media[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[9])){ document.getElementById("media_control").checked=true;}
else{ document.getElementById("media_control").checked=false;}
document.getElementById("media_back").value=media[arr(current_spread,3)][parseInt(target_object.id.split("_")[1])].split("^")[10]; document.getElementById("media_property").style.visibility="visible"; set_mouse_on(1);}}}
function blur_object(target_object){ if (target_object.getAttribute("name")=="thumbnail"){ if (target_object.id!="thumbnail_"+current_spread){ target_object.className="thumbnail_default";}}
if (target_object.getAttribute("name")=="chapter"){ target_object.className="chapter_default";}
if (target_object.getAttribute("name")=="anchor"){ target_object.className="anchor_default";}
if (target_object.getAttribute("name")=="search"){ target_object.className="search_default";}
if (target_object.getAttribute("name")=="bookmark"){ target_object.className="bookmark_default";}
if (target_object.getAttribute("name")=="hyperlink"){ if (edit_mode){ update_hyperlink(); target_object.className="hyperlink_highlight"; document.getElementById("hyperlink_property").style.visibility="hidden"; set_mouse_on(0);}
else{ target_object.className="hyperlink_default";}}
if (target_object.getAttribute("name")=="media"){ if (edit_mode){ update_media(); target_object.className="media_highlight"; document.getElementById("media_property").style.visibility="hidden"; set_mouse_on(0);}}}
function mouse_down(event_value) { if (this==touch){ if (media_mode){ return true;}
if (!editdrag_mode && !editresize_mode){ if (document.getElementById(edit_id)){ blur_object(document.getElementById(edit_id)); edit_id=null;}
drag_mode=1; set_mouse_on(0); drag_x=point_x; drag_y=point_y; if (document.all) { offset_x=event.clientX; offset_y=event.clientY;}
else if (touch.getElementsByTagName) { offset_x=event_value.pageX; offset_y=event_value.pageY;}}
return false;}
else if (this==scope){ map_mode=1; set_mouse_on(0); drag_x=parseInt(scope.style.left); drag_y=parseInt(scope.style.top); if (document.all) { offset_x=event.clientX-drag_x; offset_y=event.clientY-drag_y;}
else if (map.getElementsByTagName) { offset_x=event_value.pageX-drag_x; offset_y=event_value.pageY-drag_y;}
return false;}
else if (this.getAttribute("name")=="chapter" || this.getAttribute("name")=="anchor"){ if (document.getElementById(edit_id)){ blur_object(document.getElementById(edit_id))}
edit_id=this.id; focus_object(document.getElementById(edit_id)); return true; return false;}
else if (this.getAttribute("name")=="hyperlink"){ cursor_type=get_style(this,"cursor"); if (document.getElementById(edit_id)){ blur_object(document.getElementById(edit_id))}
edit_id=this.id; focus_object(document.getElementById(edit_id)); document.getElementById("hyperlink_property").style.visibility="hidden"; if(cursor_type==pointer_cursor){ editdrag_mode=1;}
else{ editresize_mode=1;}
set_mouse_on(0); drag_x=parseInt(document.getElementById(edit_id).style.left); drag_y=parseInt(document.getElementById(edit_id).style.top); if (document.all) { offset_x=event.clientX-drag_x; offset_y=event.clientY-drag_y;}
else if (this.getElementsByTagName) { offset_x=event_value.pageX-drag_x; offset_y=event_value.pageY-drag_y;}
return false;}
else if (this.getAttribute("name")=="media"){ if (!edit_mode){ media_mode=1; return true;}
else{ cursor_type=get_style(this,"cursor"); if (document.getElementById(edit_id)){ blur_object(document.getElementById(edit_id))}
edit_id=this.id; focus_object(document.getElementById(edit_id)); document.getElementById("media_property").style.visibility="hidden"; if(cursor_type==pointer_cursor){ editdrag_mode=1;}
else{ editresize_mode=1;}
set_mouse_on(0); drag_x=parseInt(document.getElementById(edit_id).style.left); drag_y=parseInt(document.getElementById(edit_id).style.top); if (document.all) { offset_x=event.clientX-drag_x; offset_y=event.clientY-drag_y;}
else if (this.getElementsByTagName) { offset_x=event_value.pageX-drag_x; offset_y=event_value.pageY-drag_y;}
return false;}}
else{ return true;}}
function mouse_move(event_value) { var current_x=0; var current_y=0; if (drag_mode){ if (document.all) { current_x=drag_x-(event.clientX-offset_x); current_y=drag_y-(event.clientY-offset_y);}
else if (touch.getElementsByTagName) { current_x=drag_x-(event_value.pageX-offset_x); current_y=drag_y-(event_value.pageY-offset_y);}
if ((Math.abs(point_x-current_x))>move_step || (Math.abs(point_y-current_y))>move_step){ point_x=current_x; point_y=current_y; view_point(); return false;}
else{ return true;}}
else if (map_mode){ if (document.all) { current_x=event.clientX-offset_x; current_y=event.clientY-offset_y;}
else if (touch.getElementsByTagName) { current_x=event_value.pageX-offset_x; current_y=event_value.pageY-offset_y;}
if (current_x<0){ current_x=0;}
if (current_x+parseInt(scope.style.width)>map_size){ current_x=map_size-parseInt(scope.style.width);}
if (current_y<0){ current_y=0;}
if (current_y+parseInt(scope.style.height)>map_size){ current_y=map_size-parseInt(scope.style.height);}
scope.style.left=(current_x)+"px"; scope.style.top=(current_y)+"px"; return false;}
else if (editdrag_mode){ if (document.all) { current_x=event.clientX-offset_x; current_y=event.clientY-offset_y;}
else if (document.getElementById(edit_id).getElementsByTagName) { current_x=event_value.pageX-offset_x; current_y=event_value.pageY-offset_y;}
if (current_x<0){ current_x=0;}
if (current_x+parseInt(document.getElementById(edit_id).style.width)>parseInt(touch.style.width)){ current_x=parseInt(touch.style.width)-parseInt(document.getElementById(edit_id).style.width);}
if (current_y<0){ current_y=0;}
if (current_y+parseInt(document.getElementById(edit_id).style.height)>parseInt(touch.style.height)){ current_y=parseInt(touch.style.height)-parseInt(document.getElementById(edit_id).style.height);}
if (document.getElementById(edit_id).getAttribute("name")=="hyperlink"){ document.getElementById("hyperlink_x").value=pp(current_x); document.getElementById("hyperlink_y").value=pp(current_y);}
if (document.getElementById(edit_id).getAttribute("name")=="media"){ document.getElementById("media_x").value=pp(current_x); document.getElementById("media_y").value=pp(current_y);}
document.getElementById(edit_id).style.left=(op(pp(current_x)))+"px"; document.getElementById(edit_id).style.top=(op(pp(current_y)))+"px"; return false;}
else if (editresize_mode){ if (document.all) { move_x=event.clientX-parseInt(main.style.left)-parseInt(frame.style.left)-parseInt(canvas.style.left)-parseInt(touch.style.left); move_y=event.clientY-parseInt(main.style.top)-parseInt(frame.style.top)-parseInt(canvas.style.top)-parseInt(touch.style.top);}
else if (document.getElementById(edit_id).getElementsByTagName) { move_x=event_value.pageX-parseInt(main.style.left)-parseInt(frame.style.left)-parseInt(canvas.style.left)-parseInt(touch.style.left); move_y=event_value.pageY-parseInt(main.style.top)-parseInt(frame.style.top)-parseInt(canvas.style.top)-parseInt(touch.style.top);}
move_x=pp(move_x); move_y=pp(move_y); if (document.getElementById(edit_id).getAttribute("name")=="hyperlink"){ rl=parseInt(document.getElementById("hyperlink_x").value); rt=parseInt(document.getElementById("hyperlink_y").value); rr=parseInt(document.getElementById("hyperlink_x").value)+parseInt(document.getElementById("hyperlink_w").value); rb=parseInt(document.getElementById("hyperlink_y").value)+parseInt(document.getElementById("hyperlink_h").value);}
if (document.getElementById(edit_id).getAttribute("name")=="media"){ rl=parseInt(document.getElementById("media_x").value); rt=parseInt(document.getElementById("media_y").value); rr=parseInt(document.getElementById("media_x").value)+parseInt(document.getElementById("media_w").value); rb=parseInt(document.getElementById("media_y").value)+parseInt(document.getElementById("media_h").value);}
if (cursor_type=="nw-resize"){ if (move_x>rr){ move_x=rr;}
if (move_x<0){ move_x=0;}
if (move_y>rb){ move_y=rb;}
if (move_y<0){ move_y=0;}
rl=move_x; rt=move_y;}
if (cursor_type=="sw-resize"){ if (move_x>rr){ move_x=rr;}
if (move_x<0){ move_x=0;}
if (move_y<rt){ move_y=rt;}
if (move_y>pp(parseInt(touch.style.height))){ move_y=pp(parseInt(touch.style.height));}
rl=move_x; rb=move_y;}
if (cursor_type=="ne-resize"){ if (move_x<rl){ move_x=rl;}
if (move_x>pp(parseInt(touch.style.width))){ move_x=pp(parseInt(touch.style.width));}
if (move_y>rb){ move_y=rb;}
if (move_y<0){ move_y=0;}
rt=move_y; rr=move_x;}
if (cursor_type=="se-resize"){ if (move_x<rl){ move_x=rl;}
if (move_x>pp(parseInt(touch.style.width))){ move_x=pp(parseInt(touch.style.width));}
if (move_y<rt){ move_y=rt;}
if (move_y>pp(parseInt(touch.style.height))){ move_y=pp(parseInt(touch.style.height));}
rr=move_x; rb=move_y;}
if (cursor_type=="w-resize"){ if (move_x>rr){ move_x=rr;}
if (move_x<0){ move_x=0;}
rl=move_x;}
if (cursor_type=="n-resize"){ if (move_y>rb){ move_y=rb;}
if (move_y<0){ move_y=0;}
rt=move_y;}
if (cursor_type=="e-resize"){ if (move_x<rl){ move_x=rl;}
if (move_x>pp(parseInt(touch.style.width))){ move_x=pp(parseInt(touch.style.width));}
rr=move_x;}
if (cursor_type=="s-resize"){ if (move_y<rt){ move_y=rt;}
if (move_y>pp(parseInt(touch.style.height))){ move_y=pp(parseInt(touch.style.height));}
rb=move_y;}
if (document.getElementById(edit_id).getAttribute("name")=="hyperlink"){ document.getElementById("hyperlink_x").value=rl; document.getElementById("hyperlink_y").value=rt; document.getElementById("hyperlink_w").value=rr-rl; document.getElementById("hyperlink_h").value=rb-rt;}
if (document.getElementById(edit_id).getAttribute("name")=="media"){ document.getElementById("media_x").value=rl; document.getElementById("media_y").value=rt; document.getElementById("media_w").value=rr-rl; document.getElementById("media_h").value=rb-rt;}
document.getElementById(edit_id).style.left=(op(rl))+"px"; document.getElementById(edit_id).style.top=(op(rt))+"px"; document.getElementById(edit_id).style.width=(op(rr-rl))+"px"; document.getElementById(edit_id).style.height=(op(rb-rt))+"px"; return false;}
else{ return true;}}
function mouse_up(event_value) { if (drag_mode){ drag_mode=0; set_mouse_on(1); return false;}
else if (map_mode){ map_mode=0; set_mouse_on(1); point_x=((parseInt(scope.style.left))+(parseInt(scope.style.width)/2))*((current_scale*block_size)/map_size); point_y=((parseInt(scope.style.top))+(parseInt(scope.style.height)/2))*((current_scale*block_size)/map_size); view_point(); return false;}
else if (editdrag_mode){ editdrag_mode=0; set_mouse_on(1); if (document.getElementById(edit_id).getAttribute("name")=="hyperlink"){ update_hyperlink();}
if (document.getElementById(edit_id).getAttribute("name")=="media"){ update_media();}
return false;}
else if (editresize_mode){ editresize_mode=0; set_mouse_on(1); if (document.getElementById(edit_id).getAttribute("name")=="hyperlink"){ update_hyperlink();}
if (document.getElementById(edit_id).getAttribute("name")=="media"){ update_media();}
return false;}
else if (media_mode){ media_mode=0; return true;}
else{ return true;}}
function set_mouse_on(mode_flag){ if (document.getElementById(edit_id)){ if (mode_flag){ document.onmousemove=null; document.getElementById(edit_id).onmousemove=mouse_on;}
else{ document.onmousemove=mouse_move; document.getElementById(edit_id).onmousemove=null; document.getElementById(edit_id).style.cursor=pointer_cursor;}}}
function mouse_on(event_value) { var target_object=this; target_object=document.getElementById(target_object.id); var mouse_cursor=pointer_cursor; var mouse_x=0; var mouse_y=0; var ol=parseInt(target_object.style.left); var ot=parseInt(target_object.style.top); var ow=parseInt(target_object.style.width); var oh=parseInt(target_object.style.height); var object_edge=4; if (document.all) { mouse_x=event.clientX-parseInt(main.style.left)-parseInt(frame.style.left)-parseInt(canvas.style.left)-parseInt(touch.style.left); mouse_y=event.clientY-parseInt(main.style.top)-parseInt(frame.style.top)-parseInt(canvas.style.top)-parseInt(touch.style.top);}
else if (this.getElementsByTagName) { mouse_x=event_value.pageX-parseInt(main.style.left)-parseInt(frame.style.left)-parseInt(canvas.style.left)-parseInt(touch.style.left); mouse_y=event_value.pageY-parseInt(main.style.top)-parseInt(frame.style.top)-parseInt(canvas.style.top)-parseInt(touch.style.top);}
if (mouse_x<=ol+object_edge && mouse_y<=ot+object_edge){ mouse_cursor="nw-resize";}
else if (mouse_x<=ol+object_edge && mouse_y>=ot+oh-object_edge){ mouse_cursor="sw-resize";}
else if (mouse_x>=ol+ow-object_edge && mouse_y<=ot+object_edge){ mouse_cursor="ne-resize";}
else if (mouse_x>=ol+ow-object_edge && mouse_y>=ot+oh-object_edge){ mouse_cursor="se-resize";}
else if (mouse_x<=ol+object_edge ){ mouse_cursor="w-resize";}
else if (mouse_y<=ot+object_edge ){ mouse_cursor="n-resize";}
else if (mouse_x>=ol+ow-object_edge){ mouse_cursor="e-resize";}
else if (mouse_y>=ot+oh-object_edge){ mouse_cursor="s-resize";}
target_object.style.cursor=mouse_cursor;}
function left_spread(){ if (effect_mode){ return;}
if (!bind){ if (current_spread>1){ target_spread=current_spread-1; move_spread("turn");}}
else{ if (current_spread<spread_count){ target_spread=current_spread+1; move_spread("turn");}}}
function right_spread(){ if (effect_mode){ return;}
if (!bind){ if (current_spread<spread_count){ target_spread=current_spread+1; move_spread("turn");}}
else{ if (current_spread>1){ target_spread=current_spread-1; move_spread("turn");}}}
function leftend_spread(){ if (effect_mode){ return;}
if (!bind){ if (current_spread>1){ target_spread=1; move_spread("turn");}}
else{ if (current_spread<spread_count){ target_spread=spread_count; move_spread("turn");}}}
function rightend_spread(){ if (effect_mode){ return;}
if (!bind){ if (current_spread<spread_count){ target_spread=spread_count; move_spread("turn");}}
else{ if (current_spread>1){ target_spread=1; move_spread("turn");}}}
function show_spread(val){ if (effect_mode){ return;}
if (val!=current_spread){ if (val>=1 && val<=spread_count){ target_spread=val; move_spread("turn");}}
else{ fit_scale();}}
function show_anchor(sn,bc,x,y){ if (sn<1 || sn>spread_count){ return;}
if (bc<min_block || bc>max_block){ return;}
if (current_spread==sn && current_scale==bc && point_x==op(x) && point_y==op(y)){ return;}
current_spread=sn; target_spread=sn; current_scale=bc; point_x=op(x); point_y=op(y); if (block_size!=default_size){ block_size=default_size;}
move_spread("fade");}
function get_pdf(){ if (pdf_embed==0){ window.open("pdf/"+job_name+".pdf","pdf","resizable=yes");}
if (pdf_embed==1){ window.open("pdf/"+job_name+arr(current_spread,3)+".pdf","pdf","resizable=yes");}}
function show_help(){ help_panel.style.visibility="visible"}
function hide_help(){ help_panel.style.visibility="hidden"}
function window_close(){ window.close();}
function move_spread(effect_type){ effect_mode=1; effect_id=setTimeout("effect_page('"+effect_type+"')",effect_rate);}
function highlight_thumbnail(){ var i=0; var target_object=null; if (document.getElementById("thumbnail_1")){ for (i=1; i<=spread_count; i++) { target_object=document.getElementById("thumbnail_"+i); if (target_object.className=="thumbnail_highlight"){ target_object.className="thumbnail_default";}}
focus_object(document.getElementById("thumbnail_"+current_spread));}}
function effect_page(effect_type){ if (effect_type=="turn"){ clearTimeout(effect_id); if (effect_mode==1){ fit_scale(); var r=0; var c=0; var mask_x=0; var mask_y=0; var target_object=null; var object_html=""; if (proportion>=1){ mask_x=0; mask_y=parseInt((1-(1/proportion))*(current_scale*block_size)/2);}
if (proportion<1){ mask_x=parseInt((1-proportion)*(current_scale*block_size)/2); mask_y=0;}
var b=0; if ((current_spread==1)&&(facing==1)&&(bind!=start_page)){ if (!bind){ b=1;}
else{ b=2;}}
else if ((current_spread==spread_count)&&(facing==1)&&((bind+start_page+page_count)%2==1)){ if (!bind){ b=2;}
else{ b=1;}}
if (b!=1){ for (r=1;r<=current_scale;r=r+1) { for (c=1;c<=(current_scale/2);c=c+1) { object_html=object_html+"<div class=\"object\" style=\"left:"+((c-1)*block_size-mask_x)+"px;top:"+((r-1)*block_size-mask_y)+"px;width:"+block_size+"px;height:"+block_size+"px;\"><img src=\"contents/"+earr(job_id,current_spread,3)+"/"+earr(job_id,current_scale,3)+"_"+earr(job_id,r,3)+"_"+earr(job_id,c,3)+contents_format+"\" style=\"width:"+block_size+"px;height:"+block_size+"px;\"></div>";}}}
object_html=object_html+"<div id=\"leftshadow\" class=\"object\" style=\"left:0px;top:0px;width:"+parseInt(lefteffect.style.width)+"px;height:"+parseInt(lefteffect.style.height)+"px;\"></div>"; lefteffect.innerHTML=object_html; set_opacity(lefteffect.lastChild,0); lefteffect.lastChild.style.backgroundColor="#000000"; object_html=""; if (b!=2){ for (r=1;r<=current_scale;r=r+1) { for (c=(current_scale/2)+1;c<=current_scale;c=c+1) { object_html=object_html+"<div class=\"object\" style=\"left:"+((c-(current_scale/2)-1)*block_size)+"px;top:"+((r-1)*block_size-mask_y)+"px;width:"+block_size+"px;height:"+block_size+"px;\"><img src=\"contents/"+earr(job_id,current_spread,3)+"/"+earr(job_id,current_scale,3)+"_"+earr(job_id,r,3)+"_"+earr(job_id,c,3)+contents_format+"\" style=\"width:"+block_size+"px;height:"+block_size+"px;\"></div>";}}}
object_html=object_html+"<div id=\"rightshadow\" class=\"object\" style=\"left:0px;top:0px;width:"+parseInt(righteffect.style.width)+"px;height:"+parseInt(righteffect.style.height)+"px;\"></div>"; righteffect.innerHTML=object_html; set_opacity(righteffect.lastChild,0); righteffect.lastChild.style.backgroundColor="#000000"; if ((!bind && current_spread<target_spread)||(bind && current_spread>target_spread)){ if ((current_spread==1)||(current_spread==spread_count)){ lefteffect.style.zIndex=4002; righteffect.style.zIndex=4001;}
else{ lefteffect.style.zIndex=4002; righteffect.style.zIndex=4001;}}
else{ if ((current_spread==1)||(current_spread==spread_count)){ lefteffect.style.zIndex=4001; righteffect.style.zIndex=4002;}
else{ lefteffect.style.zIndex=4001; righteffect.style.zIndex=4002;}}
masking(); touch.innerHTML=""; var b=0; if (((current_spread==1)||(target_spread==1))&&(facing==1)&&(bind!=start_page)){ if (!bind){ b=1;}
else{ b=2;}}
else if (((current_spread==spread_count)||(target_spread==spread_count))&&(facing==1)&&((bind+start_page+page_count)%2==1)){ if (!bind){ b=2;}
else{ b=1;}}
for (r=1;r<=current_scale;r=r+1) { for (c=1;c<=current_scale;c=c+1) { if (!(b==1 && c<=current_scale/2)&&!(b==2 && c>current_scale/2)){ load_image(arr(current_scale,3)+"_"+arr(r,3)+"_"+arr(c,3),"contents/"+earr(job_id,target_spread,3)+"/"+earr(job_id,current_scale,3)+"_"+earr(job_id,r,3)+"_"+earr(job_id,c,3)+contents_format);}
else{ load_image("","contents/"+earr(job_id,target_spread,3)+"/"+earr(job_id,current_scale,3)+"_"+earr(job_id,r,3)+"_"+earr(job_id,c,3)+contents_format); if (document.getElementById(arr(current_scale,3)+"_"+arr(r,3)+"_"+arr(c,3))){ document.getElementById(arr(current_scale,3)+"_"+arr(r,3)+"_"+arr(c,3)).innerHTML="";}}}}
b_canvas.innerHTML=""; effect_mode=2; effect_id=setTimeout("effect_page('"+effect_type+"')",effect_rate);}
if (effect_mode==2){ if ((!bind && current_spread<target_spread)||(bind && current_spread>target_spread)){ if ((parseInt(righteffect.style.left)+parseInt(righteffect.style.width)-turn_step)<(parseInt(lefteffect.style.left)+parseInt(lefteffect.style.width))){ righteffect.style.width="0px"; righteffect.style.left=(parseInt(lefteffect.style.left)+parseInt(lefteffect.style.width))+"px"; effect_mode=3;}
else{ set_opacity(righteffect.lastChild,(parseInt(lefteffect.style.left)+parseInt(lefteffect.style.width)-parseInt(righteffect.style.left))/parseInt(lefteffect.style.width)); righteffect.style.left=(parseInt(righteffect.style.left)-turn_step)+"px"; righteffect.style.clip="rect(auto auto auto "+((parseInt(lefteffect.style.left)+parseInt(lefteffect.style.width))-parseInt(righteffect.style.left))+"px)";}}
else{ if ((parseInt(lefteffect.style.left)+turn_step)>(parseInt(righteffect.style.left))){ lefteffect.style.width="0px"; lefteffect.style.left=(parseInt(righteffect.style.left))+"px"; effect_mode=3;}
else{ set_opacity(lefteffect.lastChild,(1-(parseInt(righteffect.style.left)-parseInt(lefteffect.style.left))/parseInt(righteffect.style.width))); lefteffect.style.left=(parseInt(lefteffect.style.left)+turn_step)+"px"; lefteffect.style.clip="rect(auto "+(parseInt(righteffect.style.left)-parseInt(lefteffect.style.left))+"px auto auto)";}}
effect_id=setTimeout("effect_page('"+effect_type+"')",effect_rate);}
if (effect_mode==3){ var r=0; var c=0; var mask_x=0; var mask_y=0; var object_html=""; if (proportion>=1){ mask_x=0; mask_y=parseInt((1-(1/proportion))*(current_scale*block_size)/2);}
if (proportion<1){ mask_x=parseInt((1-proportion)*(current_scale*block_size)/2); mask_y=0;}
if ((!bind && current_spread<target_spread)||(bind && current_spread>target_spread)){ for (r=1;r<=current_scale;r=r+1) { for (c=1;c<=(current_scale/2);c=c+1) { object_html=object_html+"<div class=\"object\" style=\"left:"+((c-1)*block_size-mask_x)+"px;top:"+((r-1)*block_size-mask_y)+"px;width:"+block_size+"px;height:"+block_size+"px;\"><img src=\"contents/"+earr(job_id,target_spread,3)+"/"+earr(job_id,current_scale,3)+"_"+earr(job_id,r,3)+"_"+earr(job_id,c,3)+contents_format+"\" style=\"width:"+block_size+"px;height:"+block_size+"px;\"></div>";}}
object_html=object_html+"<div id=\"rightshadow\" class=\"object\" style=\"left:0px;top:0px;width:"+parseInt(lefteffect.style.width)+"px;height:"+parseInt(lefteffect.style.height)+"px;\"></div>"; righteffect.innerHTML=object_html; set_opacity(righteffect.lastChild,1); righteffect.lastChild.style.backgroundColor="#000000"; righteffect.style.clip="rect(auto auto auto auto)"; lefteffect.style.zIndex=4001; righteffect.style.zIndex=4002;}
else{ for (r=1;r<=current_scale;r=r+1) { for (c=current_scale/2+1;c<=current_scale;c=c+1) { object_html=object_html+"<div class=\"object\" style=\"left:"+((c-current_scale/2-1)*block_size)+"px;top:"+((r-1)*block_size-mask_y)+"px;width:"+block_size+"px;height:"+block_size+"px;\"><img src=\"contents/"+earr(job_id,target_spread,3)+"/"+earr(job_id,current_scale,3)+"_"+earr(job_id,r,3)+"_"+earr(job_id,c,3)+contents_format+"\" style=\"width:"+block_size+"px;height:"+block_size+"px;\"></div>";}}
object_html=object_html+"<div id=\"leftshadow\" class=\"object\" style=\"left:0px;top:0px;width:"+parseInt(righteffect.style.width)+"px;height:"+parseInt(righteffect.style.height)+"px;\"></div>"; lefteffect.innerHTML=object_html; set_opacity(lefteffect.lastChild,1); lefteffect.lastChild.style.backgroundColor="#000000"; lefteffect.style.clip="rect(auto auto auto auto)"; lefteffect.style.zIndex=4002; righteffect.style.zIndex=4001;}
effect_mode=4; effect_id=setTimeout("effect_page('"+effect_type+"')",effect_rate);}
if (effect_mode==4){ if ((!bind && current_spread<target_spread)||(bind && current_spread>target_spread)){ if ((parseInt(righteffect.style.left)-turn_step)<(parseInt(lefteffect.style.left))){ lefteffect.innerHTML=""; righteffect.innerHTML=""; righteffect.style.width=(parseInt(lefteffect.style.width))+"px"; righteffect.style.left=(parseInt(lefteffect.style.left)+parseInt(lefteffect.style.width))+"px"; lefteffect.style.zIndex=4001; righteffect.style.zIndex=4002; current_spread=target_spread; effect_mode=0; load_map(); masking(); load_touch(); view_point(); highlight_thumbnail(); preload_spread();}
else{ set_opacity(righteffect.lastChild,1-parseInt(righteffect.style.width)/parseInt(lefteffect.style.width)); righteffect.style.width=(parseInt(righteffect.style.width)+turn_step)+"px"; righteffect.style.left=(parseInt(righteffect.style.left)-turn_step)+"px";}}
else{ if ((parseInt(lefteffect.style.left)+parseInt(lefteffect.style.width)+turn_step)>(parseInt(righteffect.style.left)+parseInt(righteffect.style.width))){ lefteffect.innerHTML=""; righteffect.innerHTML=""; lefteffect.style.width=(parseInt(righteffect.style.width))+"px"; lefteffect.style.left=(parseInt(righteffect.style.left)-parseInt(righteffect.style.width))+"px"; lefteffect.style.zIndex=4001; righteffect.style.zIndex=4002; current_spread=target_spread; effect_mode=0; load_map(); masking(); load_touch(); view_point(); highlight_thumbnail(); preload_spread();}
else{ set_opacity(lefteffect.lastChild,1-parseInt(lefteffect.style.width)/parseInt(righteffect.style.width)); lefteffect.style.width=(parseInt(lefteffect.style.width)+turn_step)+"px"; lefteffect.style.left=(parseInt(lefteffect.style.left))+"px";}}
effect_id=setTimeout("effect_page('"+effect_type+"')",effect_rate);}}
if (effect_type=="fade"){ clearTimeout(effect_id); if (effect_mode==1){ if (current_fade==0){ fade_mask.style.visibility="visible";}
if (current_fade==1){ effect_mode=2;}
else if ((current_fade+fade_step)>=1){ current_fade=1;}
else{ current_fade=current_fade+fade_step;}
set_opacity(fade_mask,current_fade); effect_id=setTimeout("effect_page('"+effect_type+"')",effect_rate);}
if (effect_mode==2){ effect_mode=3; load_canvas(); load_map(); masking(); load_touch(); view_point(); highlight_thumbnail(); effect_id=setTimeout("effect_page('"+effect_type+"')",effect_rate);}
if (effect_mode==3){ if ((current_fade-fade_step)<=0){ current_fade=0; effect_mode=0; fade_mask.style.visibility="hidden";}
else{ current_fade=current_fade-(fade_step/2);}
set_opacity(fade_mask,current_fade); effect_id=setTimeout("effect_page('"+effect_type+"')",effect_rate);}}}
function set_opacity(target_object,value){ target_object.style.filter="alpha(opacity="+(value*100)+")"; target_object.style.MozOpacity=value; target_object.style.opacity=value;}
function add_bookmark(){ bookmark=bookmark+"bookmark^新しいブックマーク^"+current_spread+"^"+current_scale+"^"+pp(point_x)+"^"+pp(point_y)+"¶"; set_cookie("bookmark",bookmark,365); load_book(3);}
function edit_bookmark(val){ var object_html=""; object_html="<input type=\"text\" class=\"\" style=\"\" value=\""+(bookmark.split("¶")[val].split("^")[1])+"\" onChange=\"set_bookmark("+val+")\" onBlur=\"set_bookmark("+val+")\">"; document.getElementById("bookmark_text_"+val).innerHTML=object_html; document.getElementById("bookmark_text_"+val).onclick="";}
function set_bookmark(val){ var i=0; var temp_bookmark=""; var bookmark_text=""; if (document.getElementById("bookmark_text_"+val).firstChild.value){ bookmark_text=document.getElementById("bookmark_text_"+val).firstChild.value; for(i=0;i<bookmark.split("¶").length;i=i+1){ if (i==val){ temp_bookmark=temp_bookmark+"bookmark^"+bookmark_text+"^"+bookmark.split("¶")[i].split("^")[2]+"^"+bookmark.split("¶")[i].split("^")[3]+"^"+bookmark.split("¶")[i].split("^")[4]+"^"+bookmark.split("¶")[i].split("^")[5]+"¶";}
else{ temp_bookmark=temp_bookmark+bookmark.split("¶")[i]+"¶";}}
bookmark=temp_bookmark; set_cookie("bookmark",bookmark,365); load_book(3);}}
function delete_bookmark(val){ var i=0; var temp_bookmark=""; for(i=0;i<bookmark.split("¶").length;i=i+1){ if (i!=val){ temp_bookmark=temp_bookmark+bookmark.split("¶")[i]+"¶";}}
bookmark=temp_bookmark; set_cookie("bookmark",bookmark,365); load_book(3);}
function delete_all_bookmark(){ if (confirm("ブック内のすべてのブックマークを削除します。\nよろしいですか？")){ bookmark=""; set_cookie("bookmark",bookmark,365); load_book(3);}}
function go_search(blank_flag){ var i=0; var j=0; var fixword=""; var wordlist=new Array(); var result_html=""; var object_html=""; keyword=document.getElementById("search_field").value; set_cookie("keyword",keyword,365); fixword=keyword.replace("　"," "); for(i=0;i<fixword.split(" ").length;i=i+1){ if (fixword.split(" ")[i]!=""){ wordlist.splice(wordlist.length,0,fixword.split(" ")[i]);}}
wordlist=unique_array(wordlist); if (blank_flag){ if (!wordlist.length){ alert("有効な検索キーワードが設定されていません。"); return;}}
result_html=""; for(i=0;i<index.length;i=i+1){ for(j=0;j<wordlist.length;j=j+1){ var regword=new RegExp(wordlist[j],"ig"); if (index[i].split("^")[1].search(regword)>-1){ var result_text=""; result_text=index[i].split("^")[1]; result_text=escape_metastring(result_text,true); result_text=result_text.replace(regword,"<span class=\"search_strong\">"+wordlist[j]+"</span>"); if (index[i].split("^")[0]=="chapter"){ result_html=result_html+"<div id=\"index_"+i+"\" class=\""+index[i].split("^")[0]+"_default\" name=\""+index[i].split("^")[0]+"\" style=\"position:relative;cursor:"+pointer_cursor+";\" onclick=\"show_spread("+index[i].split("^")[2]+")\" onmouseover=\"focus_object(this)\" onmouseout=\"blur_object(this)\">"+result_text+"</div>";}
if (index[i].split("^")[0]=="anchor"){ result_html=result_html+"<div id=\"index_"+i+"\" class=\""+index[i].split("^")[0]+"_default\" name=\""+index[i].split("^")[0]+"\" style=\"position:relative;cursor:"+pointer_cursor+";\" onclick=\"show_anchor("+index[i].split("^")[2]+","+index[i].split("^")[3]+","+index[i].split("^")[4]+","+index[i].split("^")[5]+")\" onmouseover=\"focus_object(this)\" onmouseout=\"blur_object(this)\">"+result_text+"</div>";}}}}
if (result_html==""){ result_html="<div class=\"book_message\">見つかりません。</div>";}
object_html=object_html+"<div class=\"search_header\">目次との一致</div>"+result_html; result_html=""; i=1; while(search[arr(i,3)]){ for(j=0;j<wordlist.length;j=j+1){ var regword=new RegExp(wordlist[j],"ig"); if (search[arr(i,3)].search(regword)>-1){ var result_text=""; var start_point=0; var end_point=0; var hit_point=0; var start_extension=""; var end_extension=""; result_text=search[arr(i,3)]; hit_point=result_text.toLowerCase().split(wordlist[j].toLowerCase()).length-1; start_point=(result_text.search(regword))-10; if (start_point<0){ start_point=0;}
end_point=start_point+100; if (end_point>(result_text.length)){ end_point=result_text.length;}
start_point=end_point-100; if (start_point<0){ start_point=0;}
if (start_point!=0){ start_extension="...";}
if (end_point!=(result_text.length)){ end_extension="...";}
result_text=result_text.substring(start_point,end_point); result_text=escape_metastring(result_text,true); result_text=result_text.replace(regword,"<span class=\"search_strong\">"+wordlist[j]+"</span>"); result_text=start_extension+result_text+end_extension+"（計"+hit_point+"ヶ所）"; result_html=result_html+"<div id=\"search_"+i+"\" class=\"search_default\" name=\"search\" style=\"position:relative;cursor:"+pointer_cursor+";\" onclick=\"show_spread("+(i)+")\" onmouseover=\"focus_object(this)\" onmouseout=\"blur_object(this)\">"+result_text+"</div>";}}
i=i+1;}
if (result_html==""){ result_html="<div class=\"book_message\">見つかりません。</div>";}
object_html=object_html+"<div class=\"search_header\">本文との一致</div>"+result_html; document.getElementById("searchview").innerHTML=object_html;}
function unique_array(souce_array) { var temp_array=new Array(); var result_array=new Array(); var i=0; for(i=0;i<souce_array.length;i++){ if (!(souce_array[i] in temp_array)){ temp_array[souce_array[i]]=true; result_array.push(souce_array[i]);}}
return result_array;}
function clear_search(){ document.getElementById("search_field").value=""; keyword=""; set_cookie("keyword","",365); load_book(2);}
function change_editmode(val){ if (val==null){ if (edit_mode){ edit_mode=0;}
else{ edit_mode=1;}}
else if (val){ edit_mode=1;}
else{ edit_mode=0;}
if (edit_mode){ document.getElementById("edittool_mode").value="プレビューモードへ"; document.getElementById("edittool_scriptchapter").disabled=false; document.getElementById("edittool_scriptanchor").disabled=false; if (index_enable){ document.getElementById("edittool_addchapter").disabled=false; document.getElementById("edittool_addanchor").disabled=false; document.getElementById("edittool_deleteindex").disabled=false; document.getElementById("edittool_upindex").disabled=false; document.getElementById("edittool_downindex").disabled=false; document.getElementById("edittool_deleteallindex").disabled=false;}
document.getElementById("edittool_addhyperlink").disabled=false; document.getElementById("edittool_duplicatehyperlink").disabled=false; document.getElementById("edittool_deletehyperlink").disabled=false; document.getElementById("edittool_deleteallhyperlink").disabled=false; document.getElementById("edittool_addmedia").disabled=false; document.getElementById("edittool_deletemedia").disabled=false; document.getElementById("edittool_deleteallmedia").disabled=false; if (index_enable){ load_book(1);}
else{ load_book(0);}
load_touch();}
else{ document.getElementById("edittool_mode").value="エディットモードへ"; document.getElementById("edittool_scriptchapter").disabled=true; document.getElementById("edittool_scriptanchor").disabled=true; document.getElementById("edittool_addchapter").disabled=true; document.getElementById("edittool_addanchor").disabled=true; document.getElementById("edittool_deleteindex").disabled=true; document.getElementById("edittool_upindex").disabled=true; document.getElementById("edittool_downindex").disabled=true; document.getElementById("edittool_deleteallindex").disabled=true; document.getElementById("edittool_addhyperlink").disabled=true; document.getElementById("edittool_duplicatehyperlink").disabled=true; document.getElementById("edittool_deletehyperlink").disabled=true; document.getElementById("edittool_deleteallhyperlink").disabled=true; document.getElementById("edittool_addmedia").disabled=true; document.getElementById("edittool_deletemedia").disabled=true; document.getElementById("edittool_deleteallmedia").disabled=true; if (index_enable){ load_book(1);}
else{ load_book(0);}
load_touch();}}
function save_edit(){ var index_data=""
index_data=index_data+"var index=new Array();\n"; for(i=0;i<index.length;i=i+1){ index_data=index_data+"index["+i+"]=\""+index[i]+"\";\n";}
var hyperlink_data=""
hyperlink_data=hyperlink_data+"var hyperlink=new Array();\n"; for(i=1;i<=spread_count;i=i+1){ if (hyperlink[arr(i,3)]){ hyperlink_data=hyperlink_data+"hyperlink[\""+arr(i,3)+"\"]=new Array();\n"; for(j=0;j<hyperlink[arr(i,3)].length;j=j+1){ hyperlink_data=hyperlink_data+"hyperlink[\""+arr(i,3)+"\"]["+j+"]=\""+hyperlink[arr(i,3)][j]+"\";\n";}}}
var media_data=""
media_data=media_data+"var media=new Array();\n"; for(i=1;i<=spread_count;i=i+1){ if (media[arr(i,3)]){ media_data=media_data+"media[\""+arr(i,3)+"\"]=new Array();\n"; for(j=0;j<media[arr(i,3)].length;j=j+1){ media_data=media_data+"media[\""+arr(i,3)+"\"]["+j+"]=\""+media[arr(i,3)][j]+"\";\n";}}}
var request_parameter=null; request_parameter=$H({job_id:job_id,index_data:index_data,hyperlink_data:hyperlink_data,media_data:media_data}).toQueryString(); new Ajax.Request( "../../../../../../../../save.html?ts="+get_time_stamp(), { method:"post", postBody:request_parameter, onSuccess:function(httpObject){ }, onFailure:function(){ }} );}
function show_helpedit(){ window.open("http://www.debiew.com/debiewmanual.html#edit","helpedit","width=540,scrollbars=yes,location=no,menubar=no,left=10,top=30");}
function script_chapter(){ prompt("現在のチャプタを表示するためのJavaScript", "JavaScript:show_spread("+current_spread+")");}
function script_anchor(){ prompt("現在のアンカーを表示するためのJavaScript", "JavaScript:show_anchor("+current_spread+","+current_scale+","+pp(point_x)+","+pp(point_y)+")");}
function add_chapter(){ if (book_panel.style.visibility!="visible"){ show_book();}
if (document.getElementById(edit_id)){ index.splice(parseInt(edit_id.split("_")[1])+1,0,"chapter^新しいチャプタ^"+current_spread); edit_id="index_"+(parseInt(edit_id.split("_")[1])+1);}
else{ index.splice(index.length,0,"chapter^新しいチャプタ^"+current_spread); edit_id="index_"+(index.length-1);}
save_edit(); load_book(1);}
function add_anchor(){ if (book_panel.style.visibility!="visible"){ show_book();}
if (document.getElementById(edit_id)){ index.splice(parseInt(edit_id.split("_")[1])+1,0,"anchor^新しいアンカー^"+current_spread+"^"+current_scale+"^"+pp(point_x)+"^"+pp(point_y)); edit_id="index_"+(parseInt(edit_id.split("_")[1])+1);}
else{ index.splice(index.length,0,"anchor^新しいアンカー^"+current_spread+"^"+current_scale+"^"+pp(point_x)+"^"+pp(point_y)); edit_id="index_"+(index.length-1);}
save_edit(); load_book(1);}
function delete_index(){ if (document.getElementById(edit_id)){ if (document.getElementById(edit_id).getAttribute("name")=="chapter" || document.getElementById(edit_id).getAttribute("name")=="anchor"){ index.splice(parseInt(edit_id.split("_")[1]),1); edit_id=null; save_edit(); load_book(1);}}}
function delete_all_index(){ if (confirm("ブック内のすべての目次を削除します。\nよろしいですか？")){ index=new Array(); edit_id=null; save_edit(); load_book(1);}}
function up_index(){ if (document.getElementById(edit_id)){ if (document.getElementById(edit_id).getAttribute("name")=="chapter" || document.getElementById(edit_id).getAttribute("name")=="anchor"){ if (parseInt(edit_id.split("_")[1])>0){ index.splice(parseInt(edit_id.split("_")[1])-1,0,index[parseInt(edit_id.split("_")[1])]); index.splice(parseInt(edit_id.split("_")[1])+1,1); edit_id="index_"+(parseInt(edit_id.split("_")[1])-1); save_edit(); load_book(1);}}}}
function down_index(){ if (document.getElementById(edit_id)){ if (document.getElementById(edit_id).getAttribute("name")=="chapter" || document.getElementById(edit_id).getAttribute("name")=="anchor"){ if (parseInt(edit_id.split("_")[1])<index.length-1){ index.splice(parseInt(edit_id.split("_")[1])+2,0,index[parseInt(edit_id.split("_")[1])]); index.splice(parseInt(edit_id.split("_")[1]),1); edit_id="index_"+(parseInt(edit_id.split("_")[1])+1); save_edit(); load_book(1);}}}}
function add_hyperlink(){ var hyperlink_size=100; var l=point_x-parseInt(touch.style.left)-op(hyperlink_size/2); var t=point_y-parseInt(touch.style.top)-op(hyperlink_size/2); if (l<0){ l=0;}
if (l+op(hyperlink_size)>parseInt(touch.style.width)){ l=parseInt(touch.style.width)-op(hyperlink_size);}
if (t<0){ t=0;}
if (t+op(hyperlink_size)>parseInt(touch.style.height)){ t=parseInt(touch.style.height)-op(hyperlink_size);}
if (!hyperlink[arr(current_spread,3)]){ hyperlink[arr(current_spread,3)]=new Array();}
hyperlink[arr(current_spread,3)].splice(hyperlink[arr(current_spread,3)].length,0,"新しいリンク^http://www.debiew.com/^_blank^"+pp(l)+"^"+pp(t)+"^"+hyperlink_size+"^"+hyperlink_size); edit_id="hyperlink_"+(hyperlink[arr(current_spread,3)].length-1); save_edit(); load_touch();}
function duplicate_hyperlink(){ if (document.getElementById(edit_id)){ if (document.getElementById(edit_id).getAttribute("name")=="hyperlink"){ hyperlink[arr(current_spread,3)].splice(hyperlink[arr(current_spread,3)].length,0,(hyperlink[arr(current_spread,3)][parseInt(edit_id.split("_")[1])].split("^")[0])+"^"+(hyperlink[arr(current_spread,3)][parseInt(edit_id.split("_")[1])].split("^")[1])+"^"+(hyperlink[arr(current_spread,3)][parseInt(edit_id.split("_")[1])].split("^")[2])+"^"+(parseInt(hyperlink[arr(current_spread,3)][parseInt(edit_id.split("_")[1])].split("^")[3])+20)+"^"+(parseInt(hyperlink[arr(current_spread,3)][parseInt(edit_id.split("_")[1])].split("^")[4])+20)+"^"+(hyperlink[arr(current_spread,3)][parseInt(edit_id.split("_")[1])].split("^")[5])+"^"+(hyperlink[arr(current_spread,3)][parseInt(edit_id.split("_")[1])].split("^")[6])); edit_id="hyperlink_"+(hyperlink[arr(current_spread,3)].length-1); save_edit(); load_touch();}}}
function delete_hyperlink(){ if (document.getElementById(edit_id)){ if (document.getElementById(edit_id).getAttribute("name")=="hyperlink"){ hyperlink[arr(current_spread,3)].splice(parseInt(edit_id.split("_")[1]),1); edit_id=null; save_edit(); load_touch();}}}
function delete_all_hyperlink(){ if (confirm("ブック内のすべてのリンクを削除します。\nよろしいですか？")){ hyperlink=new Array(); edit_id=null; save_edit(); load_touch();}}
function add_media(){ var media_size=100; var l=point_x-parseInt(touch.style.left)-op(media_size/2); var t=point_y-parseInt(touch.style.top)-op(media_size/2); if (l<0){ l=0;}
if (l+op(media_size)>parseInt(touch.style.width)){ l=parseInt(touch.style.width)-op(media_size);}
if (t<0){ t=0;}
if (t+op(media_size)>parseInt(touch.style.height)){ t=parseInt(touch.style.height)-op(media_size);}
if (!media[arr(current_spread,3)]){ media[arr(current_spread,3)]=new Array();}
media[arr(current_spread,3)].splice(media[arr(current_spread,3)].length,0,"embed^^^"+pp(l)+"^"+pp(t)+"^"+media_size+"^"+media_size+"^1^1^0^#000000"); edit_id="media_"+(media[arr(current_spread,3)].length-1); save_edit(); load_touch();}
function upload_media(){ document.source.action="../../../../../../../../upload_media.html?ts="+get_time_stamp(); document.source.target="temp"; document.source.submit(); screen_mask.style.visibility="visible"; timer.style.visibility="visible";}
function complete_upload_media(media_file){ var object_html=""; object_html="<input type=\"file\" id=\"file\" name=\"file\" value=\"\" onchange=\"upload_media()\"><input type=\"hidden\" name=\"job_id\" value=\""+job_id+"\"><input type=\"hidden\" id=\"media_file\"  name=\"media_file\" value=\""+media_file+"\">"; document.source.innerHTML=object_html; document.getElementById("media_src").value="media/"+media_file; update_media(); screen_mask.style.visibility="hidden"; timer.style.visibility="hidden";}
function delete_media(){ if (document.getElementById(edit_id)){ if (document.getElementById(edit_id).getAttribute("name")=="media"){ var media_file=document.getElementById("media_file").value; media[arr(current_spread,3)].splice(parseInt(edit_id.split("_")[1]),1); var request_parameter=null; request_parameter=$H({job_id:job_id,media_file:media_file}).toQueryString(); new Ajax.Request( "../../../../../../../../delete_media.html?ts="+get_time_stamp(), { method:"post", postBody:request_parameter, onSuccess:function(httpObject){ edit_id=null; save_edit(); load_touch();}, onFailure:function(){ }} );}}}
function delete_all_media(){ if (confirm("ブック内のすべてのメディアを削除します。\nよろしいですか？")){ media=new Array(); var request_parameter=null; request_parameter=$H({job_id:job_id,media_file:"all"}).toQueryString(); new Ajax.Request( "../../../../../../../../delete_media.html?ts="+get_time_stamp(), { method:"post", postBody:request_parameter, onSuccess:function(httpObject){ edit_id=null; save_edit(); load_touch();}, onFailure:function(){ }} );}}
function update_index(index_object){ index[parseInt(index_object.id.split("_")[1])]=(index_object.getAttribute("name"))+"^"+(index_object.firstChild.value)+"^"+(index_object.lastChild.value); save_edit();}
function update_hyperlink(){ var hyperlink_object=document.getElementById(edit_id); var hyperlink_title=document.getElementById("hyperlink_title").value; var hyperlink_url=document.getElementById("hyperlink_url").value; var hyperlink_target=document.getElementById("hyperlink_target").value; var hyperlink_x=parseInt(document.getElementById("hyperlink_x").value); var hyperlink_y=parseInt(document.getElementById("hyperlink_y").value); var hyperlink_w=parseInt(document.getElementById("hyperlink_w").value); var hyperlink_h=parseInt(document.getElementById("hyperlink_h").value); if (hyperlink_w<4){ hyperlink_w=4}
if (hyperlink_h<4){ hyperlink_h=4}
hyperlink[arr(current_spread,3)][parseInt(hyperlink_object.id.split("_")[1])]=hyperlink_title+"^"+hyperlink_url+"^"+hyperlink_target+"^"+hyperlink_x+"^"+hyperlink_y+"^"+hyperlink_w+"^"+hyperlink_h; hyperlink_object.style.left=op(hyperlink_x); hyperlink_object.style.top=op(hyperlink_y); hyperlink_object.style.width=op(hyperlink_w); hyperlink_object.style.height=op(hyperlink_h); focus_object(hyperlink_object); save_edit();}
function update_media(){ var mediatype=""; var media_object=document.getElementById(edit_id); var media_src=document.getElementById("media_src").value; var media_file=document.getElementById("media_file").value; var media_x=parseInt(document.getElementById("media_x").value); var media_y=parseInt(document.getElementById("media_y").value); var media_w=parseInt(document.getElementById("media_w").value); var media_h=parseInt(document.getElementById("media_h").value); var media_start=0; var media_loop=0; var media_control=0; var media_back=document.getElementById("media_back").value; var ext="."+media_src.split("?")[0].split(".").pop(); if (img_format.indexOf(ext)>-1){ mediatype="img";}
else{ mediatype="embed";}
if (document.getElementById("media_start").checked){ media_start=1;}
if (document.getElementById("media_loop").checked){ media_loop=1;}
if (document.getElementById("media_control").checked){ media_control=1;}
if (media_w<4){ media_w=4}
if (media_h<4){ media_h=4}
media[arr(current_spread,3)][parseInt(media_object.id.split("_")[1])]=mediatype+"^"+media_src+"^"+media_file+"^"+media_x+"^"+media_y+"^"+media_w+"^"+media_h+"^"+media_start+"^"+media_loop+"^"+media_control+"^"+media_back; media_object.style.left=op(media_x); media_object.style.top=op(media_y); media_object.style.width=op(media_w); media_object.style.height=op(media_h); focus_object(media_object); save_edit();}
function clear_edit(){ document.onmousemove=mouse_move; if (document.getElementById("hyperlink_property")){ document.getElementById("hyperlink_property").style.visibility="hidden";}
if (document.getElementById("media_property")){ document.getElementById("media_property").style.visibility="hidden";}}
function pp(val){ return parseInt(val/(current_scale*block_size)*1000);}
function op(val){ return parseInt(val/1000*(current_scale*block_size));}
