// JavaScript Document 
var start=0;
var end=0;
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);
//alert(fileNameStart);
//alert(fileNameEnd);
//alert(fileName);
	}

//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 savePos(textBox){
	if(typeof(textBox.selectionStart) == "number"){
		start = textBox.selectionStart;
		end = textBox.selectionEnd;
	}
	else if(document.selection){
		var range = document.selection.createRange();
		if(range.parentElement().id == textBox.id){
			/*-------modifined by k.kaneyasu  20080128 start-----*/			
			var range_all_e = document.body.createTextRange();	
			var r_length = range.text.length;
			range_all_e.moveToElementText(textBox);		
			range_all_e.setEndPoint("EndToEnd",range);
			end = range_all_e.text.length;
			start = end-r_length;	
			/*-------modifined by k.kaneyasu  20080128 end-----*/
		}
	}
}

function insertTag(startTag,endTag){ 
  
  var textBox  =  document.getElementsByName("body")[0];
  
  var length  =  textBox.value.length;
  
  var pre  =  textBox.value.substr(0,  start);
  
  var substr  =  textBox.value.substr(start, end-start);
  var post  =  textBox.value.substr(end, length);
  
  textBox.value  =  pre + startTag +substr+ endTag + post;
  document.execCommand("Unselect");
  document.focus();
}

function setFontSize( font_size )
{
	var s_tag="";
	var e_tag="";
	switch( font_size )
	{
		case "1":	
			s_tag = "<font size=1>";
			e_tag = "</font>";
			break;
		case "2":
			s_tag = "<font size=2>";
			e_tag = "</font>";
			break;
		case "5":
			s_tag = "<span style=line-height:1.2;><font size=5>";
			e_tag = "</font></span>";
			break;
		case "7":
			s_tag = "<span style=line-height:1.4;><font size=7>";
			e_tag = "</font></span>";
			break;
		default:
			break;
	}
	if( s_tag != "" && e_tag != "" )
	{
		insertTag(s_tag,e_tag);
	}	
	return;
}

function showColorPallet(e)
{   
	var mode,posX,posY;
	var obj = null;
	
	posX = parseInt(getEventX(e)) + 125;
	posY = parseInt(getEventY(e)) - 70;
	
	obj  = getObject("colorPallet");
    
	if( obj != null )
	{	
		if( obj.style.visibility == "hidden")
		{
			obj.style.left = posX + "px";
			obj.style.top  = posY + "px";
			obj.style.visibility = "visible";
		}
	}
}

function hideColorPallet()
{
	var obj  = getObject("colorPallet");
	obj.style.visibility = "hidden";
}

function setColor( color )
{
	color = color.substr(1,color.length -1 );
	if( parseInt( color,16 ) < parseInt("FFFFFF+1",16) ){
		var color_tag = ""+ parseInt(color.substr( 0,2 ),16) + "," + parseInt( color.substr( 2,2 ) ,16 )+ "," + parseInt( color.substr( 4,2 ) ,16 );
		
		var s_tag = "<span style=color:rgb("+color_tag+");>";
		var e_tag = "</span>";
		insertTag( s_tag,e_tag );
	}
	hideColorPallet();
} 

function getObject(objId)
{  
	if( navigator.userAgent.search(
			"Opera(\ |\/)6") != -1)
	{
		return document.getElementById( objId );
	
	}else if (document.all)
	{
		return document.getElementById(objId);
	
	}else if( document.layers || document.getElementById )
	{
		return document.getElementById( objId );
	}
}

function getEventX( e ){
	if( navigator.userAgent.search(
	    "Opera(\ |\/)6") != -1 ){   //o6用
		return e.clientX;
	
	} else if ( document.all )
	{								//e4,e5,e6用
		var scrollleft = document.body.scrollLeft || document.documentElement.scrollLeft;
        return scrollleft + event.clientX;
    
    } else if ( document.layers || document.getElementById )
    {								//n4,n6,n7,m1,o7,s1用
		return e.clientX;
	}
}

function getEventY( e ){
	if( navigator.userAgent.search(
	    "Opera(\ |\/)6") != -1 ){   //o6用
		return e.clientY;

	} else if ( document.all )
	{								//e4,e5,e6用
    	var scrolltop = document.body.scrollTop || document.documentElement.scrollTop;
        return scrolltop + window.event.clientY
    } else if ( document.layers || document.getElementById )
    {								//n4,n6,n7,m1,o7,s1用
		return e.pageY;
	}
}
