//////////////////////////////////////////////////////////////////////
// blog montlyリスト変更
function ChengeMonthlyList(d)
{
	var url;
	
	url = d.options[d.selectedIndex].value

	if( url != "" )
	{
		location.href=url;
	}

}

//////////////////////////////////////////////////////////////////////
// ページトップのスムーススクロールをラップ
// tanavexのアコーディオンと相性が悪い。。
function SmoothScroll(d,name)
{
	try
	{
		Scroll(this,'top-aname');
	}
	catch(e)
	{
		location.href="#"+name;
	}
}


//////////////////////////////////////////////////////////////////////
// ボタンクリック -> 入力チェック -> 送信 tanavex.htmlにて仕様
function funcForm(f){
	if (f == 0){
		val = document.f1.entMail.value;	
	}else{
		val = document.f1.delMail.value;	
	}
	
	if (funcChkEmail(val)){
		window.location.href="/cgi/getEmail.cgi?"+f+val;
	}
}

//////////////////////////////////////////////////////////////////////
//e-mailチェック
function funcChkEmail (email) {

	var chkStr =/^(\S+)@(\S+\.\S+)$/;		//形式がaaa@aaa.com
	var chkuserStr =  new Array();				
		chkuserStr[0]=/[^a-zA-Z0-9\._-]/;	//英数かどうか
		chkuserStr[1]=/^[\.]/;				//.で始まってないか
		chkuserStr[2]=/[\.]$/;				//.で終わってないか
		chkuserStr[3]=/\.{2}/;				//.が２個以上つながってないか
		chkuserStr[4]=/^.+\..+\..+$/;		//.が2個以上ないか（ユーザー名のみ）
		
	
	var arrEmail = email.match(chkStr);		//形式チェック
	
	var a = "";
	
	if(email == ""){
		alert("NO E-MAIL");
		return false;	
	}
	if(arrEmail == null){
		alert("E-MAIL ERROR");
		return false;	
	}
	
	//ユーザー名チェック
	if(arrEmail[1].length < 2){
		alert("E-MAIL ERROR");
		return false;	
	}
	for(i=0;i<5;i++){
		if(arrEmail[1].match(chkuserStr[i])!=null){
			alert("E-MAIL ERROR");
			return false;	
		}	
	}
	//ドメイン名チェック
	if(arrEmail[2].length < 3){
		alert("E-MAIL ERROR");
		return false;	
	}
	for(i=0;i<4;i++){
		if(arrEmail[2].match(chkuserStr[i])!=null){
			alert("E-MAIL ERROR");
			return false;	
		}	
	}

	return true;	

}


function openWin( title ,url, top, left, width, height, zIndex, resizable, draggable ){

	var win = new Window("win01", {
		url:url,
		title: title,
		className: "mac_os_x_dialog",
		top:top, left:left,
		width:width, height:height,
		zIndex: zIndex,
		resizable: true,
		draggable:true
	});
	win.setDestroyOnClose();
	win.show();
}

window.onload = function() {

	// スムーススクロール bytefx.js

	// ページトップへ
	if(document.getElementById("top-ahref"))
	{
		document.getElementById("top-ahref").onclick = function(){
			bytefx.scroll(document.getElementById("top-aname"), 3);
		}
	}

	// レイヤ表示 rico.js

	if(document.getElementById("hdic-beauty"))
	{
		Event.observe('hdic-beauty', 'mouseover', up); 
		Event.observe('hdic-foods', 'mouseover', up); 
		Event.observe('hdic-meds', 'mouseover', up); 
		Event.observe('hdic-healthcare', 'mouseover', up); 
	} 

}




// png透過
var AlphaChanneledPNG = Class.create();
AlphaChanneledPNG.prototype = {
  initialize: function(imgId, blankImgSrc) {
    this.imgId = imgId;
    this.blankImgSrc = blankImgSrc;
    Event.observe(window, 'load', this.show.bind(this));
  },
  show: function() {
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent)) {
      imgObj = $(this.imgId);
      orgSrc = imgObj.src;
      imgObj.src = this.blankImgSrc;
      imgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader("
                          + "src='" + orgSrc + "', sizingMethod='scale')";
    }
  }
};

function RicoFade( f, id )
{

	var oj = getObj(id);

	if( f == 0 )
	{
		new Rico.Effect.FadeTo(id, 1, 100, 10);
	}
	else
	{
		new Rico.Effect.FadeTo(id, 0, 100, 10);
	}


}



//著作権表示
function writeCopy(ny,co){
	var strYear = "";
	myD = new Date();
	myYear = myD.getYear();
	myYears = (myYear < 2000) ? myYear+1900 : myYear;//古いブラウザ用
	
	//次の年
	if(ny != myYears){
		strYear = "-"+myYears;
	}

	document.write("COPYRIGHT&copy; 2004"+strYear+" "+co+" ALLRIGHT RESERVED.");

}

function getBrowserWidth ( ) {  
    if ( window.innerWidth ) { return window.innerWidth; }  
    else if ( document.documentElement && document.documentElement.clientWidth != 0 ) { return document.documentElement.clientWidth; }  
    else if ( document.body ) { return document.body.clientWidth; }  
    return 0;  
}  
function getBrowserHeight ( ) {  
     if ( window.innerHeight ) { return window.innerHeight; }  
     else if ( document.documentElement && document.documentElement.clientHeight != 0 ) { return document.documentElement.clientHeight; }  
     else if ( document.body ) { return document.body.clientHeight; }  
     return 0;  
}  


function writeFlashHTML2( arg )
{
  
  /**
   * 引数から属性を抽出する
   */
   
  var parm = []
  
  //すべての引数を順番に
  for( i = 0 ; i < arguments.length ; i++ )
  {
    //属性名と属性値をあらわす文字列を配列parmへセットする(半角空白は除去)
    parm[i] = arguments[i].split(' ').join('').split('!')
    
    //有効な属性名があれば属性値で変数化( 無効な名前は無視 )
    switch (parm[i][0])
    {
      case '_swf'     : var _swf     = parm[i][1] ; break ; // フラッシュのURL
      case '_quality' : var _quality = parm[i][1] ; break ; // 画質
      case '_loop'    : var _loop    = parm[i][1] ; break ; // 繰り返し
      case '_bgcolor' : var _bgcolor = parm[i][1] ; break ; // 背景色
      case '_wmode'   : var _wmode   = parm[i][1] ; break ; // 背景透明(WinIEのみ)
      case '_play'    : var _play    = parm[i][1] ; break ; // 自動再生
      case '_menu'    : var _menu    = parm[i][1] ; break ; // 右クリックメニュー
      case '_scale'   : var _scale   = parm[i][1] ; break ; // 幅高さが%の時の縦横比等
      case '_salign'  : var _salign  = parm[i][1] ; break ; // 表示領域内表示位置
      case '_height'  : var _height  = parm[i][1] ; break ; // ムービーの高さ
      case '_width'   : var _width   = parm[i][1] ; break ; // ムービーの幅
      case '_hspace'  : var _hspace  = parm[i][1] ; break ; // まわりの余白(水平方向)
      case '_vspace'  : var _vspace  = parm[i][1] ; break ; // まわりの余白(垂直方向)
      case '_align'   : var _align   = parm[i][1] ; break ; // 表示位置
      case '_class'   : var _class   = parm[i][1] ; break ; // クラス
      case '_id'      : var _id      = parm[i][1] ; break ; // ID名
      case '_name'    : var _name    = parm[i][1] ; break ; // ムービー名
      case '_style'   : var _style   = parm[i][1] ; break ; // スタイル
      case '_declare' : var _declare = parm[i][1] ; break ; // 読み込まれるだけで実行しない
      default        :;
    }
  }
  

  // タグ用文字列生成
  var htm = ""
  
  htm+="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'"
  htm+="        codebase='http://download.macromedia.com/pub/shockwave/"
                    htm+="cabs/flash/swflash.cab'"
  if(!!_width)   htm+="        width    = '" + _width   + "'"
  if(!!_height)  htm+="        height   = '" + _height  + "'"
  if(!!_hspace)  htm+="        hspace   = '" + _hspace  + "'"
  if(!!_vspace)  htm+="        vspace   = '" + _vspace  + "'"
  if(!!_align)   htm+="        align    = '" + _align   + "'"
  if(!!_class)   htm+="        class    = '" + _class   + "'"
  if(!!_id)      htm+="        id       = '" + _id      + "'"
  if(!!_name)    htm+="        name     = '" + _name    + "'"
  if(!!_style)   htm+="        style    = '" + _style   + "'"
  if(!!_declare) htm+="                    " + _declare  
  htm+=" />"
  if(!!_swf)     htm+="<param  name     = 'movie'   value ='" + _swf     + "' />"
  if(!!_quality) htm+="<param  name     = 'quality' value ='" + _quality + "' />"
  if(!!_loop)    htm+="<param  name     = 'loop'    value ='" + _loop    + "' />"
  if(!!_bgcolor) htm+="<param  name     = 'bgcolor' value ='" + _bgcolor + "' />"
  if(!!_play)    htm+="<param  name     = 'play'    value ='" + _play    + "' />"
  if(!!_menu)    htm+="<param  name     = 'menu'    value ='" + _menu    + "' />"
  if(!!_scale)   htm+="<param  name     = 'scale'   value ='" + _scale   + "' />"
  if(!!_salign)  htm+="<param  name     = 'salign'  value ='" + _salign  + "' />"
  if(!!_wmode)   htm+="<param  name     = 'wmode'   value ='" + _wmode   + "' />"
  htm+=""
  htm+="<embed                          "
  htm+="        pluginspage='http://www.macromedia.com/go/getflashplayer'"
  if(!!_width)   htm+="        width    = '" + _width   + "'"
  if(!!_height)  htm+="        height   = '" + _height  + "'"
  if(!!_hspace)  htm+="        hspace   = '" + _hspace  + "'"
  if(!!_vspace)  htm+="        vspace   = '" + _vspace  + "'"
  if(!!_align)   htm+="        align    = '" + _align   + "'"
  if(!!_class)   htm+="        class    = '" + _class   + "'"
  if(!!_id)      htm+="        id       = '" + _id      + "'"
  if(!!_name)    htm+="        name     = '" + _name    + "'"
  if(!!_style)   htm+="        style    = '" + _style   + "'"
  htm+="        type     = 'application/x-shockwave-flash' "
  if(!!_declare) htm+="                    " + _declare  
  if(!!_swf)     htm+="        src      = '" + _swf     + "'"
  if(!!_quality) htm+="        quality  = '" + _quality + "'"
  if(!!_loop)    htm+="        loop     = '" + _loop    + "'"
  if(!!_bgcolor) htm+="        bgcolor  = '" + _bgcolor + "'"
  if(!!_play)    htm+="        play     = '" + _play    + "'"
  if(!!_menu)    htm+="        menu     = '" + _menu    + "'"
  if(!!_scale)   htm+="        scale    = '" + _scale   + "'"
  if(!!_salign)  htm+="        salign   = '" + _salign  + "'"
  if(!!_wmode)  htm+="         wmode    = '" + _wmode   + "'"
  htm+="></embed>"
  htm+="</object>"

  //書き出し処理
  document.write(htm)
  
}


//---------------------------------------------------------------------------
// ウインドウオープン

function funcWinOpen(file,w,h,scroll){
	strL = 'location=no,status=no,scrollbars='+scroll+',resizable=yes,width='+w+',height='+h;
	strWin = window.open(file,'_blank',strL);

}

//---------------------------------------------------------------------------
// マウスイベント

function funcMouse(d,f){
	if (f == 0){
		d.src = d.src.replace(/.gif/i,"_b.gif");
	}else{
		d.src = d.src.replace(/_b.gif/i,".gif");
	}
}

//---------------------------------------------------------------------------
// ブラウザ振分け ieとそれ以外に振分ける
//function bfuriwake(n,m){
//	b = navigator.appName.charAt(0);
//	if (b == "M") {
//		return m;
//	} 
//	return n;
//}

//---------------------------------------------------------------------------
// 

function FuncChangeImg(p_NO,p_SRC){
	document.images[p_NO].src = p_SRC;
}

//---------------------------------------------------------------------------
// 

function funcGoPrintPage(){
	window.open("map"+document.forms[0].map.value+".html", "_blank", "status=no,menubar=yes,scrollbars=yes");
}

//---------------------------------------------------------------------------
// 

function funcPrintMap(){
	document.all.btn_map1.style.display = "none";
	window.print();	
	document.all.btn_map1.style.display = "block";
}
//---------------------------------------------------------------------------
// 
function changeDisp(id,act){

	var obj=getObj(id);
	if(obj){
		obj.style.display=act;
	}
}

//---------------------------------------------------------------------------
// HTMLオブジェクト取得

function getObj( id )
{
	return document.all && document.all(id) || document.getElementById && document.getElementById(id);
}

//---------------------------------------------------------------------------
// レイヤーを表示

function showLayer( obj )
{
	if(obj){
		obj.style.display='block';
	}
}

//---------------------------------------------------------------------------
// レイヤーを消す

function noneLayer( obj )
{

	if(obj){
		obj.style.display='none';
		return true;
	}
	else
	{
		return false;
	}
}

//---------------------------------------------------------------------------
// 絶対配置のレイヤーを画面中央からオフセットして配置

function showAbsoluteLayer( id, offset, top )
{
	var nCenter = getWindowCenter();

	nCenter = nCenter + offset;

	var obj=getObj( id );

	obj.style.top=top+"px";
	obj.style.left=nCenter+"px";
	showLayer( obj );


}

//---------------------------------------------------------------------------
// ウインドウの中央軸取得

function getWindowCenter( )
{

	var nWinWidth = eval(getWindowWidth());	// ウインドウサイズ

	var nCenter = ( nWinWidth / 2 );

	return nCenter;

}

//---------------------------------------------------------------------------
// 横幅 ウインドウサイズ取得

function getWindowWidth(){

  if(window.innerWidth) return window.innerWidth; // Mozilla, Opera, NN4
  if(document.documentElement && document.documentElement.clientWidth){ // 以下 IE
   return document.documentElement.clientWidth;
  }
  else if(document.body && document.body.clientWidth){
   return document.body.clientWidth;
  }
  return 0;
}

//---------------------------------------------------------------------------
// 絶対配置のレイヤーを画面中央からオフセットして配置

function showDicNavi( id, offset, top )
{
	noneLayer( getObj('dic-navi-food') );
	noneLayer( getObj('dic-navi-beauty') );
	noneLayer( getObj('dic-navi-healthcare') );

	showAbsoluteLayer( id, offset, top );

}

function hiddenDicNavi( id )
{
	noneLayer( getObj(id) );
}

function writeFlashTag( id, w, h, movie, quality, loop, bgcolor, wmode )
{
	var tag = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'";
	tag += "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'";
	tag += "width='"+w+"' height='"+h+"'>";
	tag += "<param name='movie' value='"+movie+"'>";
	tag += "<param name='quality' value='"+quality+"'>";
	tag += "<param name='loop' value='"+loop+"'>";
	tag += "<param name='bgcolor' value='"+bgcolor+"'>";
	tag += "<param name='wmode'	value='"+wmode+"'>";
	tag += "<embed src='"+movie+"'";
	tag += "pluginspage='http://www.macromedia.com/go/getflashplayer'";
	tag += "width='"+w+"'";
	tag += "height='"+h+"'";
	tag += "loop='"+loop+"'";
	tag += "quality='"+movie+"'";
	tag += "bgcolor='"+bgcolor+"'";
	tag += "wmode='"+wmode+"'>";
	tag += "</object>";
	var obj = getObj( id );
	obj.innerHTML = ( tag );
}

