// JavaScript Document

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



//ウインドウオープン関数
//move ： ターゲットファイル指定
//num ：パラメータ１
//kishu ： パラメータ２
//ukishu ： パラメータ３
//unum　：パラメータ４
//editer ： ryoin sasagawa
////////////
function PdfDL(move,num,kishu,ukishu,unum) {
	var url = "";
	url = "http://kenkipro.com/products/catalog/download/pdfdl.php";
	if(kishu != 0){
		url += '?KISHU='+ kishu;
	}
	
	window.location.href=url;
	window.location.target='P_WND'; 
}

//ウインドウオープン関数
//move ： ターゲットファイル指定
//num ：パラメータ１
//kishu ： パラメータ２
//ukishu ： パラメータ３
//unum　：パラメータ４
//editer ： ryoin sasagawa
////////////
function FormOpen(move,num,kishu,ukishu,unum) {
	var url = "";
	if(move != 4){
		if(move == 1){
			url = "http://kenkipro.com/contact/otoiawase/index.html";
		}else if(move == 2){
			url = "http://kenkipro.com/contact/mitsumori/index.html";
		}else if(move == 3){
			url = "http://kenkipro.com/products/catalog/download/index.html";
		}else if(move == 5){
			url = "http://kenkipro.com/oyakudachi/mail_magazine/entry/index.html";
		}

		if(num != 0){
			url += '?NUM='+ num;
		}
		if(kishu != 0){
			url += '&KISHU='+ kishu;
		}
		if(ukishu != 0){
			url += '&UKISHU='+ ukishu;
		}
		if(unum != 0){
			url += '&UNUM='+ unum;
		}
	}else{
		url = "http://kenkipro.com/news/event_topics/entry/index.html";
		if(num != 0){
			url += '?MID='+ num;
		}
	}
	
	window.open(url, "F_Wnd", "width=850px,height=600px,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes");
}


//希望入手方法操作関数１
//editer ： ryoin sasagawa
////////////
function set_get_type(){
	var get_type1 = document.getElementById('get_type1');
	var get_type2 = document.getElementById('get_type2');
	var get_type3 = document.getElementById('get_type3');
	
	get_type1.checked= true;
	get_type2.checked= false;
	get_type3.checked= false;
}


//希望入手方法操作関数２
//editer ： ryoin sasagawa
////////////
function del_buy_type(){
	var buy_type1 = document.getElementById('buy_type1');
	var buy_type2 = document.getElementById('buy_type2');
	var buy_type3 = document.getElementById('buy_type3');
	
	buy_type1.checked= false;
	buy_type2.checked= false;
	buy_type3.checked= false;
}

//イベント情報送信操作関数
//editer ： ryoin sasagawa
////////////
function event_send(title,place,host,date,time){
	var url = '/news/event_topics/entry/index.html';
	url += '?title='+ URLencode(title);
	url += '&place='+ URLencode(place);
	url += '&host='+ URLencode(host);
	url += '&date='+ URLencode(date);
	url += '&time='+ URLencode(time);
	window.open(url, "F_Wnd", "width=850px,height=600px,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes");
}


function URLencode(str){
 // Unicode to URL encoded UTF-8
 var i, encoded_str, char_code, padded_str;
         encoded_str = "";
         for (i = 0; i < str.length; i++){
             char_code = str.charCodeAt(i);
             if (char_code == 0x20){
                // space -> "+"
                encoded_str += "+";}
             else { // else 1
                  if (((0x30 <= char_code) && (char_code <= 0x39)) || ((0x41 <= char_code) && (char_code <= 0x5a)) || ((0x61 <= char_code) && (char_code <= 0x7a))){
		     // [0-9a-z-A-Z]
                     // no escape
                     encoded_str += str.charAt(i);
                  }
		  else if ((char_code == 0x2a) || (char_code == 0x2e) || (char_code == 0x2d) || (char_code == 0x5f)) {
		     // [.-_]
                     // no escape
                     encoded_str += str.charAt(i);
		  }
                  else { // else 2
                       // for internal unicode to UTF-8
		       // Ref. http://homepage3.nifty.com/aokura/jscript/utf8.html
		       // Ref. http://homepage1.nifty.com/nomenclator/unicode/ucs_utf.htm
                       if ( char_code > 0xffff ) {
                          encoded_str += "%" + ((char_code >> 18) | 0xf0).toString(16).toUpperCase();
                          encoded_str += "%" + (((char_code >> 12) & 0x3f) | 0x80).toString(16).toUpperCase();
			  encoded_str += "%" + (((char_code >> 6) & 0x3f) | 0x80).toString(16).toUpperCase();
			  encoded_str += "%" + ((char_code & 0x3f) | 0x80).toString(16).toUpperCase();
		       }
                       else if ( char_code > 0x7ff ) {
                          encoded_str += "%" + ((char_code >> 12) | 0xe0).toString(16).toUpperCase();
			  encoded_str += "%" + (((char_code >> 6) & 0x3f) | 0x80).toString(16).toUpperCase();
			  encoded_str += "%" + ((char_code & 0x3f) | 0x80).toString(16).toUpperCase();
                       }
                       else if ( char_code > 0x7f ) {
		          encoded_str += "%" + (((char_code >> 6) & 0x1f) | 0xc0).toString(16).toUpperCase();
			  encoded_str += "%" + ((char_code & 0x3f) | 0x80).toString(16).toUpperCase();
                       }
                       else {
                          // for ascii
                          padded_str = "0" + char_code.toString(16).toUpperCase();
                          encoded_str += "%" + padded_str.substr(padded_str.length - 2, 2);
                       }
                    } // else 2
                } // else 1
        } // for
        return encoded_str;
}

