var isPlay = true;
var isMute = false;
var mplayId = "WMP1";
var frameId = "prdetail";
var nowPrno = "";
var oldPrno = "";
var isServerAccess = false;
var noPrnoCount = 0;
var isFirstTime = true;

function init() {
    nowPrnoCheck();
}

var timeout = 3 * 60 * 1000;
function nowPrnoCheck() {
    setTimeout("nowPrnoCheck()", timeout);
	if( isFirstTime ){
		isFirstTime = false;
		return ;
	}
    if (!isServerAccess) {
        isServerAccess = true;
        OnAirProductUtil.getOnAirProductInfo(cbUpdatePrno);
    }
}

/**
 * フレームを更新します。
 *
 * @param obj iframeオブジェクト
 */
function reloadFrame( obj ) {
	if( obj == null){
		return ;
	}
	var win;
	if( obj.contentWindow ){
		win = obj.contentWindow;
	}
	else {
		win = document.frames[frameId];
	}
	win.location.reload( true );
}

function cbUpdatePrno(retdata) {
    if (retdata != null && retdata != "") {
        if (oldPrno != retdata) {
            // 商品詳細フレームを新しい画面に置き換える
			reloadFrame( document.getElementById(frameId) );
            oldPrno = retdata;
        }
        noPrnoCount = 0;
    } else {
        noPrnoCount++;
        if (noPrnoCount > 2) {
            // 商品詳細のフレームをクリアする
			reloadFrame( document.getElementById(frameId) );
            noPrnoCount = 0;
            oldPrno = "";
        }
    }
    isServerAccess = false;
}

function mplayerPlay() {
    var mplay = document.getElementById(mplayId);
    if (mplay) {
        mplay.Controls.Play();
    }
}

//静止
function mplayerPause() {
    if(mo==2){
        play20();
    }else{
        var mplay = document.getElementById(mplayId);
        if (mplay) {
            mplay.Controls.Pause();
        }
    }
}

//閉じる
function mplayerClose() {
    var mplay = document.getElementById(mplayId);
    if (mplay) {
        mplay.Controls.Stop();
    }
}

//フルスクリーン
function mplayerFullScreen() {
    var mplay = document.getElementById(mplayId);
    if (mplay) {
        //mplay.Controls.fullScreen = true;
        if( mplay.playState == 3 ){
	        mplay.fullScreen = true;
	  	}
    }
}

//初期音量セット
function set_volume2(s) {
    var mplay = document.getElementById(mplayId);
    if (mplay) {
        mplay.Settings.Volume=s;
        document.obj_form.obj_text2.value = s;
    }
}

//音量増減
function volume2(s) {
    v = document.obj_form.obj_text2.value * 1;
    v += s * 1;
    if (v>100) { v=100; }
    if (v<0) { v=0; }
    var mplay = document.getElementById(mplayId);
    if (mplay) {
        mplay.Settings.Volume=s;
        document.obj_form.obj_text2.value = v;
    }
}


//	オブジェクトファイルを記述します。
//	@param objId id属性を指定します。
//	@param url   URLを指定します。
//	@param w     オブジェクトの幅を指定します。
//	@param h     オブジェクトの高さを指定します。
function writeObject( objId, url, w, h ) {
	var content = "";
	content += "<object id='" + objId + "' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' width='" + w + "' height='" + h + "' standby='Loading Microsoft Windows Media Player' type='application/x-oleobject'>";
	content += "<param name='AutoStart' value='true'>";
	content += "<param name='URL' value='" + url + "'>";
	content += "<param name='uiMode' value='none'>";
	content += "<embed src='" + url + "' width='" + w + "' height='" + h + "' type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/' name='WMP1' showcontrols='0' showdisplay='0' showstatusbar='0' autostart='true' showvolumecontrols='0'></embed>";
	content += "</object>";	
	document.write( content );
}


//	オブジェクトファイルを記述します。
//	@param objId id属性を指定します。
//	@param url   URLを指定します。
//	@param w     オブジェクトの幅を指定します。
//	@param h     オブジェクトの高さを指定します。
function writeMovieObject( objId, url, w, h ) {
	var content = "";
	content += "<object id='" + objId + "' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' width='" + w + "' height='" + h + "' standby='Loading Microsoft Windows Media Player' type='application/x-oleobject'>";
	content += "<param name='AutoStart' value='true'>";
	content += "<param name='URL' value='" + url + "'>";
	content += "<param name='uiMode' value='full'>";
	content += "<embed src='" + url + "' width='" + w + "' height='" + h + "' type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/' name='WMP1' showcontrols='1' showdisplay='0' showstatusbar='1' autostart='true' showvolumecontrols='1'></embed>";
	content += "</object>";	
	document.write( content );
}


//	オブジェクトファイルを記述します。
//	@param objId id属性を指定します。
//	@param url   URLを指定します。
//	@param w     オブジェクトの幅を指定します。
//	@param h     オブジェクトの高さを指定します。
//function writeMovieObject( objId, url, w, h ) {
//	var content = "";
//	content += "<object id='" + objId + "' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' //width='" + w + "' height='" + h + "' standby='Loading Microsoft Windows Media Player' //type='application/x-oleobject'>";
//	content += "<param name='URL' value='" + url + "'>";
//	content += "<param name='ShowControls' value='true'>"; //コントロール表示
//	content += "<param name='AutoStart' value='true'>";// 自動再生
//	content += "<param name='ShowAudioControls' value='true'>";// 音声調節表示 
//	content += "<param name='ShowPositionControls' value='false'>";// 巻戻し・早送り・前へ・次へボタン非表示
//	content += "<param name='ShowTracker' value='true'>";// 再生位置調節非表示
//	content += "<embed src='" + url + "' width='" + w + "' height='" + h + "' type='application/x-mplayer2' type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/' name='WMP' showcontrols='1' autostart='1' showaudiocontrols='1' showpositioncontrols='0' showtracker='1'></embed>";
//	content += "</object>";
//	document.write( content );
//}


/**
 * ポップアップ画面を閉じます。
 *
 * @param parentWindow 親ウィンドウ
 */
function closePopup( parentWindow ){
	if( parentWindow == null ){
		return false;
	}
	var popupWindow = window.top.popup;
	if( popupWindow && !popupWindow.closed ){
		popupWindow.close();
	}
}

function detailControlDone() {}

//	オブジェクトファイルを記述します。
//	@param objId id属性を指定します。
//	@param url   URLを指定します。
//	@param w     オブジェクトの幅を指定します。
//	@param h     オブジェクトの高さを指定します。
function writeObjectHD( objId, url, w, h ) {
	var content = "";
	content += "<object id='" + objId + "' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' width='" + w + "' height='" + h + "' standby='Loading Microsoft Windows Media Player' type='application/x-oleobject'>";
	content += "<param name='AutoStart' value='true'>";
	content += "<param name='URL' value='" + url + "'>";
	content += "<param name='uiMode' value='none'>";
	content += "<embed src='" + url + "' width='" + w + "' height='" + h + "' type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/' name='WMP1' showcontrols='0' showdisplay='0' showstatusbar='0' autostart='true' showvolumecontrols='0'></embed>";
	content += "</object>";	
	document.write( content );
}
