//
//	Author		:Taku Kayanuma
//	Access		:http://stinc.jp
//	Comment		:main.js
//	Date		:2009/5
//

//--------------------------------------------------------------------------------// windowオープン
function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

//--------------------------------------------------------------------------------// imageプリロード
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];}}
}

//--------------------------------------------------------------------------------// meイメージ入れ替え
function cngimg(n){
	var imgsrc = document.images[n].src;
	var ext = imgsrc.substring(imgsrc.lastIndexOf("."), imgsrc.length);
	
	if(imgsrc.indexOf("-on") < 0){
		document.images[n].src=imgsrc.substring(0,imgsrc.length-ext.length) + "-on" + ext;
	}
	else{
		document.images[n].src=imgsrc.substring(0,imgsrc.length-ext.length-3) + ext;
	}
}

//--------------------------------------------------------------------------------// 画像入れ替え
function _HpbImgSwap(imgName, imgSrc)
{
  var appVer=parseInt(navigator.appVersion);
  var isNC=false,isN6=false,isIE=false;
  if (document.all && appVer >= 4) isIE=true; else
    if (document.getElementById && appVer > 4) isN6=true; else
      if (document.layers && appVer >= 4) isNC=true;
  if (isNC||isN6||isIE)
  {
    if (document.images)
    {
      var img = document.images[imgName];
      if (!img) img = _HpbImgFind(document, imgName);
      if (img) img.src = imgSrc;
    }
  }
}


//--------------------------------------------------------------------------------// 確認メッセージ表示
function chk_confirm_(){ 
	if(window.confirm("よろしいですか？")){
	return true;
	} 
	else{
	return false;
	} 
}

//--------------------------------------------------------------------------------// 確認メッセージ表示 削除
function chk_confirm_delete() {
	if(window.confirm("削除してよろしいですか？")){
	return true;
	} 
	else{
	return false;
	} 
} 

//--------------------------------------------------------------------------------// 確認メッセージ表示 送信
function chk_confirm_send() {
	if(window.confirm("送信します。よろしいですか？")){
	return true;
	} 
	else{
	return false;
	} 
}




//--------------------------------------------------------------------------------// FLASH表示
function run_flash_top(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="830" height="270">');
	document.write('<param name=movie value="img/flash/top.swf">');
	document.write('<param name="play" value="true">');
	document.write('<param name="loop" value="false">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="menu" value="false">');
	document.write('<param name="wmode" value="transparent"/>');
	document.write('<embed src="img/flash/top.swf" width="830" height="270" type="application/x-shockwave-flash">');
	document.write('</object>');
}

//--------------------------------------------------------------------------------// アイコン表示
image = new Image();
image.src = "img/common/favicon.ico";


//--------------------------------------------------------------------------------// クリックで表示
function clickopen(no){
	var menuID=document.getElementById('clickopen'+no);
	var subID=document.getElementById('clickopensub'+no);
	if(menuID.className=='0'){
		subID.style.display='none';
		menuID.className='1';
	}else{
		subID.style.display='block';
		menuID.className='0';
	}
}

//--------------------------------------------------------------------------------// UTF-8 文字化け対策 \記号 &yen;
//<input type='text' name='memo' onkeypress='return text_key_press(this, event);'>
function text_key_press(obj, e){
    if (document.all) {
        if (event.keyCode == 0x5c) {
            event.keyCode = 0x00a5;
        }
    } else {
        if (e.which == 0x5c) {
            var sPos = obj.selectionStart;
            var ePos = obj.selectionEnd;
            var str = obj.value.substring(sPos, ePos);
            obj.value = obj.value.substring(0, sPos) + unescape('%u00a5') + obj.value.substr(ePos);
            obj.setSelectionRange(sPos + 1, sPos + 1);
            return false;
        }
    }

    return true;
}





