// JavaScript Document
// This function simplify the coding of puting embedded video on web pages.
// It supports 
// 0 : YouTube
// 1:  Tudou
// 2:  YouKu
// 3:  KU6
// 4:  Google
//  For comments and bug reports, please write to me at hktintat@gmail.com.
function OpenNetVideo(iMode,url,iWidth,iHeight,sColor1,sColor2) {
   var param1, param2 ;
   // height of control panel
   switch (iMode)
   {
	  case 0 :
	     nExtHeight = 25 ;
	  case 1 :
	     nExtHeight = 28 ;
	  case 2 :
	     nExtHeight = 40 ;
	  case 3 :
	     nExtHeight = 46 ;	
	  case 4 :
	     nExtHeight = 27 ;
   }

   if (iWidth == null) 
     {
	   nWidth = iDefWidth ;
	   nHeight = iDefHeight ;
     }
   else if ((iWidth == 0) && (iHeight == 0)) 
     {
	   nWidth = iDefWidth ;
	   nHeight = iDefHeight ;
     }
   else if (iWidth >= 100 && ((iHeight == null) || (iHeight == '') || (iHeight <= 0)))
     {
	   nWidth = iWidth ;
	   nHeight = ((iWidth / 4) * 3) + nExtHeight ;
	 }
   else if (iWidth >=100 && iHeight >=100) 
     {
	   nWidth = iWidth ;
	   nHeight = iHeight ;
	 }
   else
     {
	   nWidth = iDefWidth ;
	   nHeight = iDefHeight  ;
	 }
   
   if ((sColor1 == null) || (sColor1 == ''))
   {
	  cColor1 = "0x666666" ;
   }
   else
   {
      cColor1 = sColor1 ;
   }
   if ((sColor2 == null) || (sColor2 == ''))
   {
	  cColor2 = "0xefefef" ;
   }
   else
   {
      cColor2 = sColor2 ;
   }
   switch (iMode)
   {
        case 0 : //YouTube
          document.write('<object width="' + nWidth + '" height="' + nHeight + '">') ;
          document.write('<param name="movie" value="http://www.youtube.com/v/' + url + '=en_US&fs=1&rel=0&color1=' + cColor1 + '&color2=' + cColor2 + '&hd=0"></param>');
	      document.write('<param name="allowFullScreen" value="true"></param>');
          document.write('<param name="allowscriptaccess" value="always"></param>');
          document.write('<embed src="http://www.youtube.com/v/' + url +'&hl=en_US&fs=1&rel=0&color1=' + cColor1 + '&color2=' + cColor2 + '&hd=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' + nWidth + '" height="' + nHeight + '"></embed>');
          document.write('</object>') ;
	      break
	   case 1 : //Tudou
	      document.write('<object width="' + nWidth + '" height="' + nHeight + '">') ;
		  document.write('<param name="movie" value="http://www.tudou.com/v/' + url + '"></param>') ;
          document.write('<param name="allowFullScreen" value="true"></param>');
          document.write('<param name="allowscriptaccess" value="always"></param>');
   		  document.write('<param name="wmode" value="opaque"></param>') ;
          document.write('<embed src="http://www.tudou.com/v/' + url +'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="' + nWidth + '" height="' + nHeight + '"></embed>');
          document.write('</object>') ;
		  break
        case 2 : //YouKu
          document.write('<embed src="http://player.youku.com/player.php/sid/' + url + '/v.swf" quality="high" width="' + nWidth + '" height="' + nHeight + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"></embed>') ;
		  break
	    case 3 : //KU6
          document.write('<embed src="http://player.ku6.com/refer/' + url + '/v.swf" quality="high" width="' + nWidth + '" height="' + nHeight + '" align="middle" allowScriptAccess="always" allowfullscreen="true" type="application/x-shockwave-flash"></embed>') ;
		  break
	    case 4 : //Google
          document.write('<embed id=VideoPlayback src=http://video.google.com/googleplayer.swf?docid=' + url + '&hl=en&fs=true style=width:' + nWidth + 'px;height:' + nHeight + 'px allowFullScreen=true allowScriptAccess=always type=application/x-shockwave-flash> </embed>') ;
    }

}