function insertFlash(elm, url, w, h) {
 if (!document.getElementById(elm)) return;
 var str = '';
 str += '<object  id="FlashControl"  width="'+ w +'" height="'+ h +'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" id="index">';
 str += '<param name="movie" value="'+ url +'">';
 str += '<param name="wmode" value="opaque">';
 str += '<param name="quality" value="autohigh">';
 str += '<embed width="'+ w +'" height="'+ h +'" src="'+ url +'" quality="autohigh" wmode="Transparent" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
 str += '</object>';
 document.getElementById(elm).innerHTML = str;
}

function insertFlashTran(elm, url, w, h) {
 if (!document.getElementById(elm)) return;
 var str = '';
 str += '<object id="FlashControl" width="'+ w +'" height="'+ h +'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" id="index">';
 str += '<param name="movie" value="'+ url +'">';
 str += '<param name="wmode" value="Transparent">';
 str += '<param name="quality" value="autohigh">';
 str += '<embed width="'+ w +'" height="'+ h +'" src="'+ url +'" quality="autohigh" wmode="opaque" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
 str += '</object>';
 document.getElementById(elm).innerHTML = str;
}
function insertFlashVar(elm,url,parastr,w,h) {
	if (!document.getElementById(elm)) return;
  var str = '';
	str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="'+ w +'" height="'+ h +'" id="flashplayerid" align="middle">';
	str += '<param name="allowScriptAccess" value="always" />';
	str += '<param name="allownetworking" value="allowNetworking" />';
	str += '<param name="movie" value="'+url+'" />';
	str += '<param name="scale" value="noscale" />';
	str += '<param name="FlashVars" value="'+ parastr +'"/>';
	str += '<param name="quality" value="high" />';
	str += '<param name="wmode" value="Transparent">';
	str += '<param name="allowFullScreen" value="true" />';
	str += '<embed src="'+url+'" quality="high"  width="'+ w +'" height="'+ h +'" name="FlashVars"  wmode="Transparent"  align="middle" allowScriptAccess="always" FlashVars="'+ parastr +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	str += '</object>';
	document.getElementById(elm).innerHTML = str;
 }
function insertFlashVarP(elm,url,parastr,w,h) {
	if (!document.getElementById(elm)) return;
  var str = '';
	str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,18,60" width="'+ w +'" height="'+ h +'" id="flashplayerid" align="middle">';	
	str += '<param name="allowScriptAccess" value="" />';
	str += '<param name="movie" value="'+url+'" />';	
	str += '<param name="FlashVars" value="'+ parastr +'"/>';	
	str += '<param name="quality" value="high" />';	
  str += '<param name="wmode" value="Transparent">';
	str += '<param name="allowFullScreen" value="true" />';
	str += '<embed src="'+url+'" quality="high" wmode="Transparent" width="'+ w +'" height="'+ h +'" name="FlashVars" align="middle" allowScriptAccess="sameDomain" FlashVars="'+ parastr +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';	
	str += '</object>';
	document.getElementById(elm).innerHTML = str;
 }
function insertFlashVarAs3(elm,url,parastr,w,h) {
	if (!document.getElementById(elm)) return;
  var str = '';
	str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,18,60"  width="'+ w +'" height="'+ h +'" id="update_" align="middle">';
	str += '<param name="allowFullScreen" value="false" />';
	str += '<param name="allowScriptAccess" value="always" />';
	str += '<param name="allownetworking" value="allowNetworking" />';
	str += '<param name="movie" value="'+url+'" />';
	str += '<param name="FlashVars" value="'+ parastr +'"/>';	
	str += '<param name="quality" value="high" />';
	str += '<param name="wmode" value="Transparent">';
	str += '<embed src="flash/mglblog_photo_update.swf" quality="high" wmode="Transparent"  width="408" height="350" name="update_" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	str += '</object>';
	document.getElementById(elm).innerHTML = str;
 }
function toTop(){
   window.scrollTo(0,0);
}

function toBotttom(){
	 window.scrollTo(0,900);
	}
function openNewWindow(URLtoOpen, windowName, windowFeatures) { 
	window.open(URLtoOpen, windowName, windowFeatures); 
}
function doMenu(MenuName,msID,msFlashVars,msW,msH){
 toTop();
 
 var msWith    = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth)
 var msHeight  = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight)
 var msLeft    = (msWith-msW-20)/2;
 document.getElementById("swin").style.width =  msWith   + "px";
 document.getElementById("swin").style.height = msHeight + "px";
 var arrMenus = new Array("swin1","swin2","swin3");
 for (var i=0; i<arrMenus.length; i++){
  if (MenuName == arrMenus[i]) {
     if(document.getElementById(MenuName).style.display == "block"){
      document.getElementById(arrMenus[i]).style.display = "none";
      document.getElementById("swin").style.display      = "none";
     }else{
       document.getElementById("swin").style.display   = "block";
       document.getElementById(MenuName).style.display = "block";
       document.getElementById(MenuName).style.left =  msLeft+ "px";
      insertFlashVar(MenuName+'Frame', msID+'.swf',msFlashVars, msW, msH);  
	   }
  }else{
   document.getElementById(arrMenus[i]).style.display = "none";
  }
 }
}
function doMenuSwf(MenuName,msID,msFlashVars,msW,msH){
 toTop();
 var msWith    = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth)
 var msHeight  = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight)
 var msLeft    = (msWith-msW-20)/2;
 document.getElementById("swin").style.width =  msWith   + "px";
 document.getElementById("swin").style.height = msHeight + "px";
 var arrMenus = new Array("swin1","swin2","swin3");
 for (var i=0; i<arrMenus.length; i++){
  if (MenuName == arrMenus[i]) {
     if(document.getElementById(MenuName).style.display == "block"){
      document.getElementById(arrMenus[i]).style.display = "none";
      document.getElementById("swin").style.display      = "none";
      insertFlashVar('swin3FrameTop', '','', 0, 0);   
      insertFlashVar(MenuName+'Frame', '', 0, 0);
     }else{
       document.getElementById("swin").style.display   = "block";
       document.getElementById(MenuName).style.display = "block";
       document.getElementById(MenuName).style.left =  msLeft+ "px";
      insertFlashVar('swin3FrameTop', "/flash/swin_close.swf",'', 720, 30);   
      insertFlashVar(MenuName+'Frame', '/flash/'+msID,msFlashVars, msW, msH);  
	   }
  }else{
  	
   document.getElementById(arrMenus[i]).style.display = "none";
  }
 }
}
function CopyText(msText,msID) {
   window.clipboardData.setData("Text",msText);
   //alert(msText);
   doMenu('swin1','/app/share_code','msID='+msID,500,400);
}

function CopyFlash(msText,msID) {
   window.clipboardData.setData("Text",msText);
   //alert(msText);
   doMenu('swin1','/app/share_flash','msID='+msID,500,400);
}


function doTvClose(msID){
 toTop();
 document.getElementById("swin").style.display = "none";
 var arrMenus = new Array("swin1","swin2","swin3");
 for (var i=0; i<arrMenus.length; i++){
  document.getElementById(arrMenus[i]).style.display = "none";
 }
  window.top.location = "tv_view.asp?msID="+msID;
}
