var movwin = null;

function CheckQuickTimeJS(){

    if (navigator.plugins) {
        for (i=0; i < navigator.plugins.length; i++ ) {
            if (navigator.plugins[i].name.indexOf("QuickTime") >= 0) {
                return true;
            }
        }
    }
    
    return false;
}

function ShowMovieMacro(fpass,width,height,volume,youtube){
    //MTMacroに移行完了後、ShowMovieにリネーム。MTMacroDefineも変更。
    if ( (youtube == undefined) || (youtube.length < 1) ){
		if (haveqt) {
			ShowQuickTime(fpass,width,height,volume);
		}
		else {
			ShowMediaPlayer(fpass,width,height,volume);
		}
	}
	else{
		ShowYouTube(youtube);
	}
	
	return;
}

function ShowMovieSilent(fpass,width,height,alter){
    //MTMacroに移行完了後、削除
    if (haveqt) {
        ShowQuickTime(fpass,width,height,0);
    }
    else {
        ShowMediaPlayer(fpass,width,height,0);
    }
    AddLinkTemp(fpass,alter);
}

function ShowMovie(fpass,width,height,alter){
    //MTMacroに移行完了後、削除
    if (haveqt) {
        ShowQuickTime(fpass,width,height,100);
    }
    else {
        ShowMediaPlayer(fpass,width,height,100);
    }
    AddLinkTemp(fpass,alter);
}

function AddLinkTemp(fpass,alter){
    //MTMacroに移行完了後、削除
    var htm="";
    htm+="<br>\n";
    if(alter == undefined){
        htm+="<a class='movie' href='"+fpass+"' target='_kishumovie'>動画が表示されない場合はこちらをお試しください。</a>\n";    
    }
    else{
        htm+="<a class='movie' href='"+alter+"' target='_kishumovie'>動画が表示されない場合はYouTubeでご覧ください。</a>\n";    
    }
    document.write(htm);
    document.close();
}

function AddLink(fpass,youtube){
    var htm="";
    htm+="<br>\n";
    if( (youtube == undefined) || (youtube.length < 1) ){
        htm+="<a class='movie' href='"+fpass+"' target='_kishumovie'>動画が表示されない場合はお試しください。</a>\n";    
    }
	else{
        htm+="<a class='movie' style='cursor : pointer;' onclick='OpenYouTube(\""+youtube+"\");'>動画が表示されない場合はお試しください。</a>\n";    
    }
    document.write(htm);
    document.close();
}

function ShowQuickTime(fpass,width,height,volume){
    var f_controll="true";
    var f_auto="false";

    var htm="";
    if(f_controll=="true"){ // コントロール表示の場合はコントロールの高さ(45px)をプラス
        height=eval(height+16);
    }

    //OBJECT TAG
    htm+="<object";
    htm+=" name='QT'";
    htm+=" style='margin:0px;padding:0px'";
    htm+=" type='video/quicktime'";
    htm+=" classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'";
    htm+=" alt='|>ボタンをクリックして再生'";
    htm+=" width='"+width+"' height='"+height+"'>\n";
    htm+="<param name='src' value='"+fpass+"'>\n";
    htm+="<param name='qtsrc' value='"+fpass+"'>\n";
    htm+="<param name='autoplay' value='"+f_auto+"'>\n";
    htm+="<param name='controller' value='"+f_controll+"'>\n";
    htm+="<param name='bgcolor' value='silver'>\n";
    htm+="<param name='volume' value='"+volume+"'>\n";
    //EMBED TAG
    htm+="<embed";
    htm+=" name='QT'";
    htm+=" style='margin:0px;padding:0px'";
    htm+=" type='video/quicktime'";
    htm+=" pluginspage='http://www.apple.com/qtactivex/qtplugin.cab'";
    htm+=" alt='|>ボタンをクリックして再生'";
    htm+=" width='"+width+"' height='"+height+"'";
    htm+=" src='"+fpass+"'";
    htm+=" qsrc='"+fpass+"'";
    htm+=" autoplay='"+((f_auto=="true")?1:0)+"'";
    htm+=" controller='"+((f_controll=="true")?1:0)+"'";
    htm+=" bgcolor='silver'";
    htm+=" volume='"+volume+"'";
    htm+=">";
    //CLOSE
    htm+="</embed>\n";
    htm+="</object>\n";
    
    document.write(htm);
    document.close();
}

function ShowMediaPlayer(fpass,width,height,volume){
    var f_controll="true";
    var f_auto="false";

    var htm="";
    if(f_controll=="true"){ // コントロール表示の場合はコントロールの高さ(45px)をプラス
        height=eval(height+45);
    }

    //OBJECT TAG
    htm+="<object";
    htm+=" name='MP'";
    htm+=" style='margin:0px;padding:0px'";
    htm+=" type='application/x-mplayer2'";
    htm+=" classid='clsid:22D6f312-B0F6-11D0-94AB-0080C74C7E95'";
    htm+=" alt='|>ボタンをクリックして再生'";
    htm+=" width='"+width+"' height='"+height+"'>\n";
    htm+="<param name='src' value='"+fpass+"'>\n";
    htm+="<param name='autoStart' value='"+f_auto+"'>\n";
    htm+="<param name='controller' value='"+f_controll+"'>\n";
    htm+="<param name='bgcolor' value='silver'>\n";
    htm+="<param name='volume' value='"+volume+"'>\n";
    //EMBED TAG
    htm+="<embed";
    htm+=" name='MP'";
    htm+=" style='margin:0px;padding:0px'";
    htm+=" type='application/x-mplayer2'";
    htm+=" pluginspage='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112'";
    htm+=" alt='|>ボタンをクリックして再生'";
    htm+=" width='"+width+"' height='"+height+"'";
    htm+=" src='"+fpass+"'";
    htm+=" autoStart='"+((f_auto=="true")?1:0)+"'";
    htm+=" controller='"+((f_controll=="true")?1:0)+"'";
    htm+=" bgcolor='silver'";
    htm+=" volume='"+volume+"'";
    htm+=">";
    //CLOSE
    htm+="</embed>\n";
    htm+="</object>\n";
    
    document.write(htm);
    document.close();
}

function ShowYouTube(youtube){

    htm="";
    
	//OBJECT TAG
	htm+='<object';
	htm+=' width="408"';
	htm+=' height="336"';
	htm+=' align="middle"';
//	htm+=' style="text-align:center;vertical-align:middle;"'
	htm+=' >\n';
	htm+='<param name="movie" value="http://www.youtube.com/v/'+youtube+'"></param>\n';
	htm+='<param name="wmode" value="transparent"></param>\n';
	//EMBED TAG
	htm+='<embed';
	htm+=' src="http://www.youtube.com/v/'+youtube+'"';
	htm+=' type="application/x-shockwave-flash"';
	htm+=' wmode="transparent"';
	htm+=' width="408"';
	htm+=' height="336"';
	htm+=' align="middle"';
//	htm+=' style="text-align:center;vertical-align:middle;"'
	htm+='>';
	//CLOSE
	htm+='</embed></object>\n';
    
    document.write(htm);
    document.close();
}

function OpenYouTube(youtube){
    var wwidth=eval(425+0);
    var wheight=eval(350+0);

    if(movwin && !movwin.closed) {
        movwin.close();
    }
    
    movwin=window.open("","_kishumovie","height="+wheight+",width="+wwidth+",location=no,menubar=no,resizable=yes,titlebar=yes,toolbar=no");
    movwin.document.open();

    htm="";
    htm+="<html>\n";
    htm+="<title>キシュウアルバム</title>\n";
    htm+="<body style='margin:0px;padding:0px;background: url(../parts/color2/body_back.gif);'>\n";
    
	//OBJECT TAG
	htm+='<object';
	htm+=' width="425"';
	htm+=' height="350"';
	htm+=' align="middle"';
//	htm+=' style="text-align:center;vertical-align:middle;"'
	htm+=' >\n';
	htm+='<param name="movie" value="http://www.youtube.com/v/'+youtube+'"></param>\n';
	htm+='<param name="wmode" value="transparent"></param>\n';
	//EMBED TAG
	htm+='<embed';
	htm+=' src="http://www.youtube.com/v/'+youtube+'"';
	htm+=' type="application/x-shockwave-flash"';
	htm+=' wmode="transparent"';
	htm+=' width="425"';
	htm+=' height="350"';
	htm+=' align="middle"';
//	htm+=' style="text-align:center;vertical-align:middle;"'
	htm+='>';
	//CLOSE
	htm+='</embed></object>\n';
    
    htm+="</body>\n";
    htm+="</html>";
    movwin.document.write(htm);
    movwin.document.close();
    movwin.focus();

}
