//***************************************************
// 画像透過処理関数(imgTrans)
// 【使い方】
//    ・画像オンマウス時に透過処理を行います。
// 【書式】
//    function imgTrans( $img_id , $trans_par )
// 【引数】
//    1. $img_id    : 対象の画像id ( imgタグ内で指定したid値と同一のものを設定してください ※ページ内での重複厳禁 )
//    2. $trans_par : 透明度       ( 画像の透過度 ※例 0.5→50% ,1→100%(元画像) )
//***************************************************

function imgTrans($img_id, $trans_par) {
    
    var user_agent = navigator.userAgent;
    if(document.layers) {
        if($trans_par > 0) {
            document.layers[$img_id].visibility='visible';
        }
        else if($trans_par==0) {
            document.layers[$img_id].visibility='hidden';
        }
    } else if(user_agent.indexOf('Safari')!=-1) {
        
        document.getElementById($img_id).style.Opacity = $trans_par;
		  
    } else if(user_agent.indexOf('Mac_PowerPC') !=-1 && document.all) {
        if($trans_par > 0) {
            document.all($img_id).style.visibility='visible';
        }
        else if($trans_par==0) {
            document.all($img_id).style.visibility='hidden';
        }
    } else if(document.all) {
        
        document.getElementById($img_id).style.filter="alpha(opacity=0)";
        document.getElementById($img_id).filters.alpha.opacity  = ($trans_par * 100);
        
    } else if(user_agent.indexOf('Gecko')!=-1) {
        
        document.getElementById($img_id).style.MozOpacity = $trans_par;
    }
}

//***************************************************
// 画像切り替え(imgChange)
// 【使い方】
//    ・オンマウスイベント時、画像の切り替えを行います。
// 【書式】
//    function imgChange( $id , $img_path )
// 【引数】
//    1. $id       ：　変換対象の画像id（画像タグ内で指定したidを渡してください。※ページ内重複厳禁）
//    2. $img_path ：　変換後の画像パス
//***************************************************

function imgChange( $id , $img_path ) {
    
    document.getElementById($id).src = $img_path;

}

//***************************************************
//ページのトップになめらかにスクロールする（smoothToTop）
//***************************************************
function smoothToTop() {
    var scrj   = 1;
    var scdist = document.body.parentNode.scrollTop;
    if( scrj < 50 && scdist ) {
        scdist = ( scdist > 2 ) ? Math.ceil(scdist*.2) : 1;
        scrj++;
        scrollBy( 0 ,-scdist );
        setTimeout( "smoothToTop()" ,20 );
    } else {
        scrollTo( 0 ,0 );
        scrj = 1;
    }
} 

//***************************************************
// swfファイルを出力する(insertFlash)
//***************************************************
function insertFlash(flafile, wsize, hsize) {
    document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
    document.write('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
    document.write('WIDTH="'+wsize+'" HEIGHT="'+hsize+'" id="top" ALIGN="">');
    document.write('<PARAM NAME=movie VALUE="'+flafile+'">');
    document.write('<PARAM NAME=quality VALUE=high>');
    document.write('<PARAM NAME=bgcolor VALUE=#FFFFFF>');
    document.write('<PARAM name=loop value=true>');
    document.write('<PARAM name=wmode value=transparent>');
    document.write('<EMBED src="'+flafile+'" loop=true quality=high bgcolor=#FFFFFF  WIDTH="'+wsize+'" HEIGHT="'+hsize+'" NAME="top" ALIGN=""');
    document.write('TYPE="application/x-shockwave-flash" PLUGINSPAGE="'+flafile+'://www.macromedia.com/go/getflashplayer" wmode="transparent"></EMBED> ');
    document.write('</OBJECT>');
}
