﻿// JavaScript Document 
function headImg() { 
	headImage_top = "../../image/top_main_m03.jpg";
	headImage_top_height = "200";
	headImage_other = "../../image/top_main_s03.jpg";
	headImage_other_height = "130";
	
	fpath = document.location.href;
	if (fpath.indexOf('file:///') >= 0) { localpath = 1 } else { localpath = 0 }
	if (localpath) {
		fdir = fpath.substring(fpath.length,fpath.lastIndexOf('/html/')+5);
		num=0;dkey=0;N=0;
		while (num>=0) {
			num = fdir.indexOf('/',N);
			if (num>=0) {
				dkey++;
				N=num+1;
			}
		}
	} else {
		fdir = fpath.substring(fpath.length,fpath.lastIndexOf('//')+2);
		num=0;dkey=0;N=0;
		while (num>=0) {
			num = fdir.indexOf('/',N);
			if (num>=0) {
				dkey++;
				N=num+1;
			}
		}
	}
	
//	if (dkey >= 2) {
	if (document.topPage != 1) {
		headImage = headImage_other;
		headImage_height = headImage_other_height;
	} else {
		headImage = headImage_top;
		headImage_height = headImage_top_height;
	}

	document.write('<a href="/"><img src="' + headImage + '" width="790" height="' + headImage_height + '" alt="Team kobukuro" /></a>');
}

// access ckeck tag ver060712

function axschk() { 

//	domainKey = "//test-teamkobukuro.excite.co.jp/";
	domainKey = "//teamkobukuro.com/";
//	domainKey = "teamkobukuro";
	sslKey = "https://";

	filePath = document.location.href;
	validDomain = filePath.indexOf(domainKey);
	sslSession = filePath.indexOf(sslKey);
	fileNameStart = validDomain + domainKey.length;
	fileNameEnd = filePath.length;

	fileName = filePath.slice(fileNameStart,fileNameEnd);

	if ((validDomain != -1)&&(sslSession != 0)) {
		document.write("<img src=\"http://www.excite.co.jp/3rd/ping.dcg?SN=okb&SP=/");
		document.write(fileName);
		document.write("&SLC=jp\" width=1 height=1 border=0>");
	}

//alert(validDomain);
}

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 movr(wk) {
	document.images[wk].src = "../../image/" + wk + "_o.gif";
}

function movrSoon(wk) {
	document.images[wk].src = "../../image/navi_soon.gif";
}

function mout(wk) {
	document.images[wk].src = "../../image/" + wk + ".gif";
}

function JustSizeWindow(img,width,height){

    /* ウィンドウサイズを指定 */
    var opt = "";
    opt += ',width='+width+',height='+height+',';
    opt += 'directories=0,toolbar=0,menubar=0,scrollbars=0,status=0,resizable=0';

    /* 新ウィンドウを開く */
    jsw=window.open('','jsw',opt);
    /* 新ウィンドウにフォーカスを当てる */
    jsw.focus();

    /* 新ウィンドウにドキュメントを書出 */
    jsw.document.open();
    htm  = '<html><head>';
    htm += '<meta http-equiv="Content-Type" content="text/html; charset=shift_JIS">';
    htm += '<title>コブクロファンのためのコミュニティサイト「Team Kobukuro」｜</title>';
    htm += '</head>';
    /* BODYタグの余白をゼロに指定 */
    htm += '<bod' + 'y style="margin:0; padding:0;">';
    /* 画像をクリックすると、ウィンドウを閉じるようにする */
    htm += '<a href="javascript:window.close();">';
    htm += '<img src="'+img+'" width="'+width+'" height="'+height+'" border="0" alt="画像をクリックするとウィンドウを閉じます">';
    htm += '</a>';
    htm += '</bod'+'y></html>';
    jsw.document.write(htm);
    jsw.document.close();

}

function pressedChar(event) { 
	var code = 0; 
	if (event.charCode === 0) { // Firefox, Safari control code 
		code = 0; 
	} else if (!event.keyCode && event.charCode) { // Firefox 
		code = event.charCode; 
	} else if (event.keyCode && !event.charCode) { // IE 
		code = event.keyCode; 
	} else if (event.keyCode == event.charCode) { // Safari 
		code = event.keyCode; 
	} 
	if (32 <= code && code <= 126) { // ASCII文字の範囲内 
		return String.fromCharCode(code); 
	} else { 
		return null; 
	} 
} 

function numberonly(event) { 
	var char = pressedChar(event); 
	if (char && !char.match(/\d/)) { 
		return false; 
	} else { 
		return true; 
	} 
}
