function MediaPlay(path,iw2,ih2){

var str = '<OBJECT ID="Player" width="'+iw2+'" height="'+ih2+'"';
   str += ' CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">';
   str += '<PARAM name="autoStart" value="True">';
   str += '<PARAM name="URL" value="'+path+'">';
   str += '<EMBED TYPE="application/x-mplayer2" ';
   str += ' SRC="'+path+'"';
   str += ' NAME="MediaPlayer"';
   str += ' autostart="1" ';
   str += ' WIDTH="'+iw2+'"';
   str += ' HEIGHT="'+ih2+'"></EMBED></OBJECT>';
   
   return str;
}

function DivxPlay(path,path2,iw2,ih2){ 

var str = '<object classid="clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616"';
   str += ' width="'+iw2+'" height="'+ih2+'"';
   str += ' codebase="http://go.divx.com/plugin/DivXBrowserPlugin.cab">';
   str += '<param name="custommode" value="Stage6" />';
   str += '<param name="autoPlay" value="True" />'
   str += '<param name="src" value="'+path2+'" />';
   str += '<embed type="video/divx"';
   str += ' src="'+path2+'"';
   str += ' custommode="Stage6" width="'+iw2+'" height="'+ih2+'"';
   str += ' autoPlay="True"';
   str += '  pluginspage="http://go.divx.com/plugin/download/">';
   str += '</embed></object>';

   return str;
}

function QuickPlay(path,iw2,ih2){ 

var str = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
   str += 'width="'+iw2+'" height="'+ih2+'"';
   str += ' codebase="http://www.apple.com/qtactivex/qtplugin.cab">';
   str += ' <param name="src" value="'+path+'" />';
   str += '<param name="qtsrc" value="'+path+'" />';
   str += '<param name="autoplay" value="true" />';
   str += '<param name="controller" value="true" />';
   str += '<embed pluginspage="http://www.apple.co.jp/quicktime/download/"';
   str += ' src="'+path+'"';
   str += ' qtsrc="'+path+'"';
   str += ' width="'+iw2+'" height="'+ih2+'"';
   str += ' autoplay="true" controller="true">';
   str += '</embed></object>';
   
   return str;
}

function RealPlay(path,path2,iw2,ih2){ 

var str = '<OBJECT CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"';
   str += ' WIDTH="'+iw2+'" HEIGHT="'+ih2+'">';
   str += '<PARAM NAME="SRC" VALUE="'+path2+'">';
   str += '<PARAM NAME="CONSOLE" VALUE="group1">';
   str += '<PARAM NAME="CONTROLS" VALUE="ImageWindow">';
   str += '<PARAM NAME="BACKGROUNDCOLOR" VALUE="white">';
   str += '<PARAM NAME="CENTER" VALUE="true">';
   str += '<embed src="'+path2+'"';
   str += ' type="audio/x-pn-realaudio-plugin"';
   str += ' width="'+iw2+'" height="'+ih2+'"';
   str += ' console=group1 controls=ImageWindow';
   str += ' autostart="true"';
   str += ' backgroundcolor=white center=true ><embed></OBJECT>';
   
   return str;
}

function FlashPlay(path,iw2,ih2){ 

var str = '<object id="mySwf"';
   str += ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
   str += ' width="'+iw2+'" height="'+ih2+'"';
   str += ' codebase="http://active.macromedia.com/flash7/cabs/ swflash.cab#version=9,0,0,0">';
   str += ' <param name="src" value="'+path+'">';
   str += ' <param name="play" value="true">';
   str += ' <param name="loop" value="true">';
   str += ' <param name="quality" value="high">';
   str += '<embed src="'+path+'"';
   str += ' width="'+iw2+'" height="'+ih2+'" play="true" loop="true"';
   str += ' quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
   str +='</embed></object>';
   
   return str;
}

   var moX;
   var moY;

document.onmousedown = getMouseXY;

function getMouseXY(e){
   if(document.all){
       moX = document.body.scrollLeft+event.clientX;
       moY = document.body.scrollLeft+event.clientY;
   }
   else if(document.layers||document.getElementById){
       moX = e.pageX;
       moY = e.pageY;
   }
}

function appChk(){
   if(navigator.appName == 'Netscape'){
       return -1;
   }else{
       return 0;
   }
}

function WinOne(path,iw,ih,title){
   var YY = moY - ih - 100 ;
   if(YY < 0){YY = 0;}
   var XX = 0 ;
   with(aa.style){
      left = XX + "px";
      top = YY + "px";
   }
   if(appChk()){var iw2 = iw - 10 +"px";}
   else{var iw2 = iw +"px";}
   var str = '<div id="Win"><div id="WinTitle" style="width:'+iw2+';"><span id="CloseIcon"><img src="../images/close_m.gif" onclick="WinClose();"></span><span id="WinTitleName">'+title+'</span></div><iframe src="'+path+'" width = "'+iw+'" height = "'+ih+'" marginheight=0 marginwidth=0 frameborder=0></iframe></div>';

	aa.innerHTML = str ;

}

function WinTwo(st,iw,ih,title){
   var YY = moY - ih ;
   if(YY < 0){YY = 0;}
   var XX = 0 ;
   with(aa.style){
      left = XX + "px";
      top = YY + "px";
   }
   if(appChk()){var iw2 = iw - 10 +"px";}
   else{var iw2 = iw +"px";}
   var str = '<div id="Win"><div id="WinTitle" style="width:'+iw2+';"><span id="CloseIcon"><img src="../images/close_m.gif" onclick="WinClose();"></span><span id="WinTitleName">'+title+'</span></div><div style="width:'+iw+' height:'+ih+'">'+st+'</div></div>';

	aa.innerHTML = str ;

}

function WinClose(){
	aa.innerHTML = "" ;
}

function Display(path,path2,iw,ih,title){ 
   var str = "";
   if(path2 == ""){ /* 画像 */
  	   WinOne(path,iw,ih,title);
  }else{ /* メディア */
       var Flag = new Array();
       Flag = path.split("\.");
       var Plen = Flag.length;
       Plen--;
       var Type = Flag[Plen];
       
       if(mm1.indexOf(Type,0) != -1){
           str = MediaPlay(path,iw,ih);
       }else if(mm2.indexOf(Type,0) != -1){
           str = DivxPlay(path,path2,iw,ih);
       }else if(mm3.indexOf(Type,0) != -1){
           str = QuickPlay(path,iw,ih);
       }else if(mm4.indexOf(Type,0) != -1){
           str = RealPlay(path,path2,iw,ih);
       }else if(mm5.indexOf(Type,0) != -1){
           str = FlashPlay(path,iw,ih);
       }
   if(str == ""){WinOne(path,iw,ih,title);}
   else{WinTwo(str,iw,ih,title);}
   }
}