var s,cn,m,n,count;
s   = document.cookie;
cn  = "cookie_name=";
n   = s.indexOf(cn,0);
//str = navigator.appName.toUpperCase();
str = navigator.userAgent;
ref = document.referrer; 
host = location.host;
//dom = document.domain;

if (n != -1) {
  m = s.indexOf(";",n+cn.length);
  if (m == -1) m = s.length;
   count = s.substring(n+cn.length,m);
 }
  else { count = "0"; }

 if (ref.indexOf("/hanazukan") >= 0) { location.href ="stop.htm"; }
 // if (ref == '') { location.href ="no_direct.htm"; }

 if (str.indexOf("TencentTr") >= 0) { location.href ="stop.htm"; }
 if (str.indexOf("Crawler") >= 0) { location.href ="stop.htm"; }
 if (str.indexOf("NaverBot") >= 0) { location.href ="stop.htm"; }
 if (str.indexOf("Capture") >= 0) { location.href ="stop.htm"; }

 if (count >= 180) { location.href = "stop.htm"; }
 if (!navigator.cookieEnabled)  { location.href ="cookie.htm"; }


function chk() {
 cn = "cookie_name=";
 c_date = new Date();
 n = c_date.getTime() + 1000*60*60*2;
 c_date.setTime(n);
 kigen = c_date.toGMTString();
 count++;
 document.cookie = cn + count + "; expires=" + kigen;
}

 myWin ='';

// 参照(大）画像表示
function ref_disp(img,name,kname,re,w,h) {

  imgDir = img.split('/');
  imgDir = imgDir.reverse();
  img_file = imgDir[0];
  no = img_file.charCodeAt(0);

//               if (no < 105) { img = 'Image_RLa/' + img_file; } 
//  if (no >= 105 && no < 109) { img = 'Image_RLi/' + img_file; } 
//  if (no >= 109 && no < 115) { img = 'Image_RLm/' + img_file; } 
//              if (no >= 115) { img = 'Image_RLs/' + img_file; }
 
               if( no < 104 ) { img = 'AG~RL/' + img_file; } 
  if( no >= 104 && no < 107 ) { img = 'HJ~RL/' + img_file; } 
  if( no >= 107 && no < 109 ) { img = 'KL~RL/' + img_file; } 
  if( no >= 109 && no < 111 ) { img = 'MN~RL/' + img_file; } 
  if( no >= 111 && no < 115 ) { img = 'OR~RL/' + img_file; } 
  if( no == 115             ) { img = 'SS~RL/' + img_file; } 
              if( no >= 116 ) { img = 'TZ~RL/' + img_file; } 

   img = '../../shiki/'+img;
   image=new Image();
   image.src=(img); 

  str = navigator.userAgent;
 if (str.indexOf("MSIE 7") >= 0 || str.indexOf("MSIE 8") >= 0) { 
 //    while(1) {
       for (i=0; i< 60000 ; i++) {
        image.src=(img); 
        if (image.width > 0) { break; }
     }
  }

 if (str.indexOf("MSIE 6") >= 0) { 
   image.onload = function() {
    wa = image.width; ha = image.height;
    wa = wa + 10; ha = ha + 32;
    if(wa < 20 ) { wa = 520; ha = 540; } 

  if(myWin !='')  { myWin.close(); }

   myWin=window.open('','参照','width='+wa+',height='+ha+',left=1,top=40,scrollbars=no');
   myWin.document.open();
   myWin.document.writeln('<HTML><HEAD><TITLE>'+ name +'</TITLE></HEAD>\n')
   myWin.document.writeln('<BODY bgcolor=#BBBBBB topmargin=4 leftmargin=4>\n')
   myWin.document.writeln('<CENTER>\n')
   myWin.document.writeln('<img src=' + img + ' border=0><font size=2><BR>\n')
   myWin.document.writeln(name +'（'+kname+'）</font>\n')
   myWin.document.writeln('<a href=# onClick=\"window.close()\"><img src=close.gif border=0></a>\n')
   myWin.document.writeln('</BODY></HTML>')
   myWin.document.close();
   myWin.focus();
  }
   return;
}

//  image.onload = function() { 

    wa = image.width; ha = image.height;
    wa = wa + 10; ha = ha + 32;
    if(wa < 20 ) { wa = 520; ha = 540; } 

 if(myWin !='')  { myWin.close(); }

  myWin=window.open('','参照','width='+wa+',height='+ha+',left=1,top=40,scrollbars=no');
  myWin.document.open();
  myWin.document.writeln('<HTML><HEAD><TITLE>'+ name +'</TITLE></HEAD>\n')
  myWin.document.writeln('<BODY bgcolor=#BBBBBB topmargin=4 leftmargin=4>\n')
  myWin.document.writeln('<CENTER>\n')
  myWin.document.writeln('<img src=' + img + ' border=0><font size=2><BR>\n')
  myWin.document.writeln(name +'（'+kname+'）</font>\n')
  myWin.document.writeln('<a href=# onClick=\"window.close()\"><img src=close.gif border=0></a>\n')
  myWin.document.writeln('</BODY></HTML>')
  myWin.document.close();
  myWin.focus();
  return false;
// }

}
// コメント内参照画像表示
function img_disp(img) { 

  img = img.replace("1.","L1.");
  img = img.replace("2.","L2.");
  img = img.replace("3.","L3.");
  img = img.replace("4.","L4.");
  img = img.replace("5.","L5.");
  img = img.replace("6.","L6.");
  img = img.replace("7.","L7.");
  img = img.replace("8.","L8.");
  img = img.replace("9.","L9.");
   if (img.indexOf("L",0) == -1) { img = img.replace(".","L."); }
 
 no = img.charCodeAt(0);

//               if (no < 105) { img='img_La/' + img; } 
//  if (no >= 105 && no < 109) { img='img_Li/' + img; } 
//  if (no >= 109 && no < 115) { img='img_Lm/' + img; } 
//              if (no >= 115) { img='img_Ls/' + img; }
  
               if( no < 104 ) { img = 'AG_L/' + img; } 
  if( no >= 104 && no < 107 ) { img = 'HJ_L/' + img; } 
  if( no >= 107 && no < 109 ) { img = 'KL_L/' + img; } 
  if( no >= 109 && no < 111 ) { img = 'MN_L/' + img; } 
  if( no >= 111 && no < 115 ) { img = 'OR_L/' + img; } 
  if( no == 115             ) { img = 'SS_L/' + img; } 
              if( no >= 116 ) { img = 'TZ_L/' + img; } 

   img = 'http://www.ootk.net/shiki/'+img;
   image=new Image();
   image.src= img;

   str = navigator.userAgent;
 if (str.indexOf("MSIE 7") >= 0 || str.indexOf("MSIE 8") >= 0  ) { 
 //    while(1) {
       for (i=0; i< 60000 ; i++) {
        image.src=(img); 
        if (image.width > 0) { break; }
      }
  }
 
 if (str.indexOf("MSIE 6") >= 0) { 
   image.onload = function() {
       wa = image.width; ha = image.height;
       wa= wa+10; ha = ha+28;
 
 if(myWin !='')  { myWin.close(); }

   myWin=window.open('','参照','width='+wa+',height='+ha+',left=1,top=10,scrollbars=no')
   myWin.document.open();
   myWin.document.writeln('<HTML><HEAD><TITLE>イメージ</TITLE>\n')
   myWin.document.writeln('</HEAD><BODY bgcolor=#888888 topmargin=4 leftmargin=4><center>\n')
   myWin.document.writeln('<img border=0 src='+img+'><BR>\n')
   myWin.document.writeln('<a href=# onClick=window.close();><img src=close.gif border=0></a>\n')
   myWin.document.writeln('</BODY></HTML>\n')
   myWin.document.close();
   myWin.focus();
  }
   return;
 }
 
   wa = image.width; ha = image.height;
   wa= wa+10; ha = ha+28;
   if(wa < 20 ) { wa = 400; ha = 430; } 

  if(myWin !='')  { myWin.close(); }

  myWin=window.open('','参照','width='+wa+',height='+ha+',left=1,top=10,scrollbars=no')
  myWin.document.open();
  myWin.document.writeln('<HTML><HEAD><TITLE>イメージ</TITLE>\n')
  myWin.document.writeln('</HEAD><BODY bgcolor=#888888 topmargin=4 leftmargin=4><center>\n')
  myWin.document.writeln('<img border=0 src='+img+'><BR>\n')
  myWin.document.writeln('<a href=# onClick=window.close();><img src=close.gif border=0></a>\n')
  myWin.document.writeln('</BODY></HTML>\n')
  myWin.document.close();
  myWin.focus();
  return false;
// }

}

// 画面クローズ
function win_closed(winVar) { 
 var ua = navigator.userAgent; 
  if( !!winVar ) 
   if( ( ua.indexOf('Gecko')!=-1 || ua.indexOf('MSIE 4')!=-1 ) 
     && ua.indexOf('Win')!=-1 ) 
    return winVar.closed; 
   else return typeof winVar.document  != 'object'; 
 else return true; 
} 