var previewID;
var previewRSSID;
var previewPushed;
var previewURL;
var previousTitle;
var previewTitle;
var videoHTML;
var iframeHTML;
var flashurl;
var videoFrom;
var previewimg;
function embedflash(src,size,id){
   if (typeof size.width == 'number') size.width += 'px';
   if (typeof size.height == 'number') size.height += 'px';
   return '<div cass="video"><embed wmode="transparent" style="width:'+(size.width)+'; height:'+(size.height)+';" id="target_'+id+'" src="'+src+'&auto=true" type="application/x-shockwave-flash"></embed></div>';
}
function previewBox(url,size,id){
   if (!id) id = 'quickView';
   /* YouTube */
   if (matched=url.match(/^http:\/\/(www.|tw.)?youtube.com\/(watch)?\?(.*?)v=([^&]+)/i))
      return embedflash('http://www.youtube.com/v/'+matched[4], size, id);
   /* IMTV */
   if (matched=url.match(/^http:\/\/(www|hk).im.tv\/VLOG\/personal.asp\?Memid=(\d+)\&FID=(\d+)/i)) {
      if (matched[1] == 'hk') t = 'hk'; else t = '';
      return embedflash('http://'+t+'myvlog.im.tv/?id='+matched[3]+'&mid='+matched[2], size, id);
   }
   if (matched=url.match(/^http:\/\/(www|hk).im.tv\/VLOG\/personal.asp\?FID=(\d+)\&Memid=(\d+)/i)) {
      if (matched[1] == 'hk') t = 'hk'; else t = '';
      return embedflash('http://'+t+'myvlog.im.tv/?id='+matched[2]+'&mid='+matched[3], size, id);
   }
   if (matched=url.match(/^http:\/\/(www.)?im.tv\/vlog\/Personal\/(\d+)\/(\d+)/i))
      return embedflash('http://myvlog.im.tv/?id='+matched[3]+'&mid='+matched[2], size, id);
   // feed: http://myvlog.im.tv/?id=959323&mid=525915&album=0
   if (matched=url.match(/^http:\/\/myvlog.im.tv\/\?id=(\d+)&mid=(\d+)&album=(\d+)/i))
      return embedflash(matched[0], size, id);
   /* Google Video */
   if (matched=url.match(/^http:\/\/video.google.com\/.*?docid=([-\d]+)/i))
      return embedflash('http://video.google.com/googleplayer.swf?docId='+matched[1], size, id);
   /* Yahoo Video */
   if (matched=url.match(/^http:\/\/video.yahoo.com\/video\/play\?vid=(\w+).(\d+)/i)) {
      return '<div class="video"><embed wmode="transparent"  style="width:'+(size.width)+'px; height:'+(size.height)+'px;" id="target_'+id+'" type="application/x-shockwave-flash" src="http://us.i1.yimg.com/cosmos.bcst.yahoo.com/player/media/swf/FLVVideoSolo.swf" flashvars="id='+matched[2]+'&emailUrl=http%3A%2F%2Fvideo.yahoo.com%2f&vid='+matched[1]+'.'+matched[2]+'"></embed></div>';
   }
   /* Metacafe */
   if (matched=url.match(/^http:\/\/www.metacafe.com\/watch\/(\d+)\/([\w_]+)/i))
      return embedflash('http://www.metacafe.com/fplayer/'+matched[1]+'/'+matched[2]+'.swf', size, id);
   return null;
}

function preview(){
	if(videoFrom == 'H') {
		var so = new SWFObject('Video/flvplayer.swf','player','520','390','7');
		so.addParam("allowfullscreen","true");
		so.addParam("allowscriptaccess","always");

		//so.addVariable('height','390');
		//so.addVariable('width','520');
		//so.addVariable('lightcolor','0x335500');
		so.addVariable('file', flashurl);
		so.addVariable('linkfromdisplay','true');
		so.addVariable("image","videoimg/"+previewimg+".jpg");
		//so.write('previewContent');
                $('previewContent').innerHTML='<img alt="" src="/images/pic_hion.gif" />';
	}
	else if (videoFrom == 'W'){
		videoHTML=null;
		var previewSize={width:250,height:185};
		videoHTML=previewBox(flashurl,previewSize);
		/*
		if(!noVideo) videoHTML=previewBox(url,size);
		iframeHTML='<iframe style="border:none;width:'+(size.width)+'px; height:'+(size.height)+'px;" id="target_quickView" src="'+url+'" border="0"></iframe>';

		alert(videoHTML);
		*/

		if(videoHTML){
			$('previewContent').innerHTML=videoHTML;
		}
		/*
		else
		{
			$('previewContent').innerHTML=iframeHTML;
		}
		*/
	}
}

function getDocumentSize(){
	return {width:document.body.offsetWidth,height:document.body.offsetHeight};
}

