﻿function loadMediaFile(fileName){
    if (fileName.lastIndexOf('.') > 0){
        fileExt = fileName.substring(fileName.lastIndexOf('.'),fileName.length);
        var mediaContent;        
        width = 231;
        height = 180;
        autoStart = true;
        playBack = false;
        fileName = 'images/picturevideo/' + fileName;
        fileType = 0;
        switch (fileExt)
        {
        case '.flv':
          mediaContent = loadFlashMedia(fileName, width, height, playBack);
          break;
        case '.wmv':
          mediaContent = loadWindowsMedia(fileName, width, height, autoStart, autoStart);
          break;
        case '.wma':
          mediaContent = loadWindowsMedia(fileName, width, height, autoStart, autoStart);
          break;
        }
        document.write(mediaContent);
    }  
}
function loadMediaFile1(divID, fileName){
    if (fileName.lastIndexOf('.') > 0){
        fileExt = fileName.substring(fileName.lastIndexOf('.'),fileName.length);
        var mediaContent;        
        width = 480;
        height = 320;
        autoStart = true;
        playBack = false;
        fileName = 'images/picturevideo/' + fileName;
        fileType = 0;
        switch (fileExt)
        {
        case '.flv':
          mediaContent = loadFlashMedia(fileName, width, height, playBack);
          break;
        case '.wmv':
          mediaContent = loadWindowsMedia(fileName, width, height, autoStart, autoStart);
          break;
        case '.wma':
          mediaContent = loadWindowsMedia(fileName, width, height, autoStart, autoStart);
          break;
        }
        document.write(mediaContent);
    }    
}
 
function loadWindowsMedia(fileName, width, height, autoStart, playBack){
    var objValue;
        objValue="<OBJECT id=winMediaPlayerID ";
        objValue+="codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 ";
        objValue+="type=application/x-oleobject height=" + height + " ";
        objValue+="standby=\"Loading Microsoft Windows Media Player components...\" "; 
        objValue+="width=" + width + " classid=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6 ";
        objValue+="name=winMediaPlayerID>";
        objValue+="<PARAM NAME=\"URL\" VALUE=\""+fileName+"\"> ";
        objValue+="<PARAM NAME=\"rate\" VALUE=\"1\">";
        objValue+="<PARAM NAME=\"balance\" VALUE=\"0\">";
        objValue+="<PARAM NAME=\"currentPosition\" VALUE=\"0\">";
        objValue+="<PARAM NAME=\"defaultFrame\" VALUE=\"1\">";
        objValue+="<PARAM NAME=\"playCount\" VALUE=\"999\">";
        objValue+="<PARAM NAME=\"CursorType\" VALUE=\"-1\">";
        objValue+="<PARAM NAME=\"autoStart\" VALUE=\"0\">";
        objValue+="<PARAM NAME=\"autoplay\" VALUE=\"0\">";
        objValue+="<PARAM NAME=\"currentMarker\" VALUE=\"0\">";
        objValue+="<PARAM NAME=\"invokeURLs\" VALUE=\"-1\">";
        objValue+="<PARAM NAME=\"volume\" VALUE=\"50\">";
        objValue+="<PARAM NAME=\"mute\" VALUE=\"0\">";
        objValue+="<PARAM NAME=\"stretchToFit\" VALUE=\"-1\">";
        objValue+="<PARAM NAME=\"windowlessVideo\" VALUE=\"1\">";
        objValue+="<PARAM NAME=\"enabled\" VALUE=\"1\">";
        objValue+="<PARAM NAME=\"fullScreen\" VALUE=\"0\">";
        objValue+="<PARAM NAME=\"enableContextMenu\" VALUE=\"0\">";
        objValue+="<PARAM NAME=\"enableErrorDialogs\" VALUE=\"0\"> \n";
        objValue+="<param name=\"loop\" value=\""+playBack+"\">";        
        objValue+="<Embed id='winMediaPlayerIDFF' type='application/x-mplayer2' pluginspage='http://www.microsoft.com/windows/windowsmedia/download/' filename='"+fileName+"' src='"+fileName+"' Name='winMediaPlayerIDFF' "; 
            objValue+="width='" + width + "' ";
            objValue+="height='" + height + "' ";
            objValue+="AutoSize='1' ";
            objValue+="AutoStart='0' ";
            objValue+="AutoPlay='0' ";
            objValue+="ClickToPlay='1' ";
            objValue+="DisplaySize='4' ";
            objValue+="EnableContextMenu='0' ";
            objValue+="EnableFullScreenControls='1' "; 
            objValue+="EnableTracker='1' ";
            objValue+="Mute='0' ";
            objValue+="PlayCount='999' "; 
            objValue+="ShowControls='1' "; 
            objValue+="ShowAudioControls='1' "; 
            objValue+="ShowDisplay='1' ";
            objValue+="ShowGotoBar='0' ";
            objValue+="ShowPositionControls='1' "; 
            objValue+="ShowStatusBar='1' ";
            objValue+="ShowTracker='1'> ";
            objValue+="</embed> ";
    objValue+="</OBJECT>";
    return objValue;
}

function loadFlashMedia(fileName, width, height){
		var objValue;
		objValue='<div align=center><a href="'+fileName+'"';
		objValue+='style=\'display:block;width:'+width+'px;height:'+height+'px;border:solid 1px #187a15\' id=\'player\'></a></div>';
		//objValue='<div style=\"display:block; width:'+dwidth+'px; height:'+dheight+'px; border:solid 1px black\"><a href='+filename+' style=\'display:block; width:'+dwidth+'px; height:'+dheight+'px\'id=\"play\">YAHOO VIETNAM</a></div>';
		return objValue;
        //flowplayer("", "flash/flowplayer-3.2.7.swf");		
}
/*
function loadRealMedia(fileName, width, height, autoStart, playBack){
    var objValue;
    objValue = '<OBJECT id=\'rvocx\' classid=\'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\' width="'+width+'" height="'+height+'">';
    objValue += '<param name=\'src\' value="'+fileName+'">';
    objValue += '<param name=\'autostart\' value="'+autoStart+'">';
    objValue += '<param name=\'controls\' value=\'imagewindow\'>';
    objValue += '<param name=\'console\' value=\'video\'>';
    objValue += '<param name=\'loop\' value="'+playBack+'">';
    objValue += '<EMBED src="'+fileName+'" width="'+width+'" height="'+height+'" ';
    objValue += ' loop="'+playBack+'" type=\'audio/x-pn-realaudio-plugin\' controls=\'imagewindow\' console=\'video\' autostart="'+autoStart+'">';
    objValue += '</EMBED>';
    objValue += '</OBJECT>';
    return objValue;
}
function loadQuickTimeMedia(fileName, width, height, autoStart, playBack){
    var objValue;
    objValue = '<OBJECT classid=\'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\' width="320'+width+' height="'+height+'" codebase=\'http://www.apple.com/qtactivex/qtplugin.cab\'>';
    objValue += '<param name=\'src\' value="'+fileName+'">';
    objValue += '<param name=\'autoplay\' value="'+autoStart+'">';
    objValue += '<param name=\'controller\' value="'+playBack+'">';
    objValue += '<param name=\'loop\' value="false">';
    objValue += '<EMBED src="'+fileName+'" width="'+width+'" height="'+height+'" autoplay="'+autoStart+'" ';
    objValue += ' controller="false" loop="'+playBack+'" pluginspage=\'http://www.apple.com/quicktime/download/\'>';
    objValue += '</EMBED>';
    objValue += '</OBJECT>';
    return objValue;
}
*/
/*
function changeSource( strSource )
{
	//scrollTo(0,100);
	var width=380;
	var height=340;
    var s;
    
        s="<OBJECT id=winMediaPlayerID ";
        s+="codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 ";
        s+="type=application/x-oleobject height=" + height + " ";
        s+="standby=\"Loading Microsoft Windows Media Player components...\" "; 
        s+="width=" + width + " classid=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6 ";
        s+="name=winMediaPlayerID>";
        s+="<PARAM NAME=\"URL\" VALUE=\""+strSource+"\"> ";
        s+="<PARAM NAME=\"rate\" VALUE=\"1\">";
        s+="<PARAM NAME=\"balance\" VALUE=\"0\">";
        s+="<PARAM NAME=\"currentPosition\" VALUE=\"0\">";
        s+="<PARAM NAME=\"defaultFrame\" VALUE=\"0\">";
        s+="<PARAM NAME=\"playCount\" VALUE=\"999\">";
        s+="<PARAM NAME=\"CursorType\" VALUE=\"-1\">";
        s+="<PARAM NAME=\"autoStart\" VALUE=\"1\">";
        s+="<PARAM NAME=\"autoplay\" VALUE=\"1\">";
        s+="<PARAM NAME=\"currentMarker\" VALUE=\"0\">";
        s+="<PARAM NAME=\"invokeURLs\" VALUE=\"-1\">";
        s+="<PARAM NAME=\"volume\" VALUE=\"50\">";
        s+="<PARAM NAME=\"mute\" VALUE=\"0\">";
        s+="<PARAM NAME=\"stretchToFit\" VALUE=\"-1\">";
        s+="<PARAM NAME=\"windowlessVideo\" VALUE=\"0\">";
        s+="<PARAM NAME=\"enabled\" VALUE=\"1\">";
        s+="<PARAM NAME=\"fullScreen\" VALUE=\"0\">";
        s+="<PARAM NAME=\"enableContextMenu\" VALUE=\"0\">";
        s+="<PARAM NAME=\"enableErrorDialogs\" VALUE=\"0\"> \n";
        
        s+="<Embed id='winMediaPlayerIDFF' type='application/x-mplayer2' pluginspage='http://www.microsoft.com/windows/windowsmedia/download/' filename='"+strSource+"' src='"+strSource+"' Name='winMediaPlayerIDFF' "; 
            s+="width='" + width + "' ";
            s+="height='" + height + "' ";
            s+="AutoSize='1' ";
            s+="AutoStart='"+autoStart+"'";
            s+="AutoPlay='1' ";
            s+="ClickToPlay='1' ";
            s+="DisplaySize='1' ";
            s+="EnableContextMenu='0' ";
            s+="EnableFullScreenControls='1' "; 
            s+="EnableTracker='1' ";
            s+="Mute='0' ";
            s+="PlayCount='999' "; 
            s+="ShowControls='1' "; 
            s+="ShowAudioControls='1' "; 
            s+="ShowDisplay='0' ";
            s+="ShowGotoBar='0' ";
            s+="ShowPositionControls='1' "; 
            s+="ShowStatusBar='1' ";
            s+="ShowTracker='1'> ";
            s+="</embed> ";
    s+="</OBJECT>";
	
    document.getElementById("MediaPlayer").innerHTML=s;
    //scrollTo(0,100);
 }   */
